aboutsummaryrefslogtreecommitdiffstats
path: root/ui/lib/contract-namer.js
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2017-05-27 03:19:51 +0800
committerGitHub <noreply@github.com>2017-05-27 03:19:51 +0800
commit5e9274d4d507a555020765954e05cbf7c6ed8aa2 (patch)
tree4a684ff7245d75d008f417fb2bbd836497c42206 /ui/lib/contract-namer.js
parent3b253649a433f1f38fd86e0478f0b12592006776 (diff)
parent9d2844c7128c79314529e163b473353d42200e9c (diff)
downloadtangerine-wallet-browser-5e9274d4d507a555020765954e05cbf7c6ed8aa2.tar
tangerine-wallet-browser-5e9274d4d507a555020765954e05cbf7c6ed8aa2.tar.gz
tangerine-wallet-browser-5e9274d4d507a555020765954e05cbf7c6ed8aa2.tar.bz2
tangerine-wallet-browser-5e9274d4d507a555020765954e05cbf7c6ed8aa2.tar.lz
tangerine-wallet-browser-5e9274d4d507a555020765954e05cbf7c6ed8aa2.tar.xz
tangerine-wallet-browser-5e9274d4d507a555020765954e05cbf7c6ed8aa2.tar.zst
tangerine-wallet-browser-5e9274d4d507a555020765954e05cbf7c6ed8aa2.zip
Merge pull request #1507 from MetaMask/AddContractIconMap
Add contract name map
Diffstat (limited to 'ui/lib/contract-namer.js')
-rw-r--r--ui/lib/contract-namer.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/ui/lib/contract-namer.js b/ui/lib/contract-namer.js
index a94c62b62..f05e770cc 100644
--- a/ui/lib/contract-namer.js
+++ b/ui/lib/contract-namer.js
@@ -5,14 +5,18 @@
* otherwise returns null.
*/
-// 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 (contractMap[checksummed] && contractMap[checksummed].name) {
+ 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) {