diff options
Diffstat (limited to 'ui/lib')
-rw-r--r-- | ui/lib/contract-namer.js | 12 | ||||
-rw-r--r-- | ui/lib/icon-factory.js | 7 |
2 files changed, 12 insertions, 7 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) { diff --git a/ui/lib/icon-factory.js b/ui/lib/icon-factory.js index 4aed9109b..45be47b7a 100644 --- a/ui/lib/icon-factory.js +++ b/ui/lib/icon-factory.js @@ -1,7 +1,7 @@ var iconFactory const isValidAddress = require('ethereumjs-util').isValidAddress const toChecksumAddress = require('ethereumjs-util').toChecksumAddress -const iconMap = require('ethereum-contract-icons') +const contractMap = require('eth-contract-metadata') module.exports = function (jazzicon) { if (!iconFactory) { @@ -43,11 +43,12 @@ IconFactory.prototype.generateNewIdenticon = function (address, diameter) { // util function iconExistsFor (address) { - return (address in iconMap) && isValidAddress(address) + return (contractMap.address) && isValidAddress(address) && (contractMap[address].logo) } function imageElFor (address) { - const fileName = iconMap[address] + const contract = contractMap[address] + const fileName = contract.logo const path = `images/contract/${fileName}` const img = document.createElement('img') img.src = path |