diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-05-27 01:25:00 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-05-27 01:31:42 +0800 |
commit | 1203bd15c2861332b62e4a39a3d961f61daed6dc (patch) | |
tree | 7c441207e1af1d692b532b8362e9eb8dc267001a | |
parent | f06ad954b900aa94a36fbb3e4765d0a9222e0920 (diff) | |
download | tangerine-wallet-browser-1203bd15c2861332b62e4a39a3d961f61daed6dc.tar tangerine-wallet-browser-1203bd15c2861332b62e4a39a3d961f61daed6dc.tar.gz tangerine-wallet-browser-1203bd15c2861332b62e4a39a3d961f61daed6dc.tar.bz2 tangerine-wallet-browser-1203bd15c2861332b62e4a39a3d961f61daed6dc.tar.lz tangerine-wallet-browser-1203bd15c2861332b62e4a39a3d961f61daed6dc.tar.xz tangerine-wallet-browser-1203bd15c2861332b62e4a39a3d961f61daed6dc.tar.zst tangerine-wallet-browser-1203bd15c2861332b62e4a39a3d961f61daed6dc.zip |
Add names to contract map & conf view
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | ui/lib/contract-namer.js | 11 |
2 files changed, 9 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index ca9cc6f5a..e050a7509 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Now enforce 95% of block's gasLimit to protect users. - Removing provider-engine from the inpage provider. This fixes some error handling inconsistencies introduced in 3.7.0. - Some contracts will now display logos instead of jazzicons. +- Some contracts will now have names displayed in the confirmation view. ## 3.7.0 2017-5-23 diff --git a/ui/lib/contract-namer.js b/ui/lib/contract-namer.js index a94c62b62..0800ee7df 100644 --- a/ui/lib/contract-namer.js +++ b/ui/lib/contract-namer.js @@ -6,13 +6,18 @@ */ // Nickname keys must be stored in lower case. -const nicknames = {} +const contractMap = require('eth-contract-metadata') +const ethUtil = require('ethereumjs-util') module.exports = function (addr, identities = {}) { + const checksummed = ethUtil.toChecksumAddress(addr) + if (checksummed in contractMap && 'name' in contractMap[checksummed]) { + return contractMap[checksummed].name + } + const address = addr.toLowerCase() const ids = hashFromIdentities(identities) - - return addrFromHash(address, ids) || addrFromHash(address, nicknames) + return addrFromHash(address, ids) } function hashFromIdentities (identities) { |