diff options
Add names to contract map & conf view
Diffstat (limited to 'ui/lib/contract-namer.js')
-rw-r--r-- | ui/lib/contract-namer.js | 11 |
1 files changed, 8 insertions, 3 deletions
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) { |