From f06ad954b900aa94a36fbb3e4765d0a9222e0920 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 26 May 2017 09:58:33 -0700 Subject: [PATCH 1/6] Move to eth-contract-metadata --- package.json | 2 +- ui/lib/icon-factory.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 9f47d76cb..9efba3866 100644 --- a/package.json +++ b/package.json @@ -62,11 +62,11 @@ "end-of-stream": "^1.1.0", "ensnare": "^1.0.0", "eth-bin-to-ops": "^1.0.1", + "eth-contract-metadata": "^1.0.0", "eth-hd-keyring": "^1.1.1", "eth-query": "^2.1.1", "eth-sig-util": "^1.1.1", "eth-simple-keyring": "^1.1.1", - "ethereum-contract-icons": "^1.0.0", "ethereumjs-tx": "^1.3.0", "ethereumjs-util": "ethereumjs/ethereumjs-util#ac5d0908536b447083ea422b435da27f26615de9", "ethereumjs-wallet": "^0.6.0", diff --git a/ui/lib/icon-factory.js b/ui/lib/icon-factory.js index 4aed9109b..c16507527 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 (address in contractMap) && isValidAddress(address) && ('logo' in contractMap[address]) } 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 From 1203bd15c2861332b62e4a39a3d961f61daed6dc Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 26 May 2017 10:25:00 -0700 Subject: [PATCH 2/6] Add names to contract map & conf view --- CHANGELOG.md | 1 + 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) { From 5e6b23082147f530adbf52cacf61202d7edf1111 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 26 May 2017 10:54:16 -0700 Subject: [PATCH 3/6] Move off in operator --- ui/lib/contract-namer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/lib/contract-namer.js b/ui/lib/contract-namer.js index 0800ee7df..2400fa576 100644 --- a/ui/lib/contract-namer.js +++ b/ui/lib/contract-namer.js @@ -11,7 +11,7 @@ const ethUtil = require('ethereumjs-util') module.exports = function (addr, identities = {}) { const checksummed = ethUtil.toChecksumAddress(addr) - if (checksummed in contractMap && 'name' in contractMap[checksummed]) { + if (contractMap.checksummed && contractMap[checksummed].name) { return contractMap[checksummed].name } From fd42d7bfd5cede30f14e232b6d93ba4205dbcf1d Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 26 May 2017 11:05:51 -0700 Subject: [PATCH 4/6] Fix contract map reference --- ui/lib/contract-namer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/lib/contract-namer.js b/ui/lib/contract-namer.js index 2400fa576..86bba1edc 100644 --- a/ui/lib/contract-namer.js +++ b/ui/lib/contract-namer.js @@ -11,7 +11,7 @@ const ethUtil = require('ethereumjs-util') module.exports = function (addr, identities = {}) { const checksummed = ethUtil.toChecksumAddress(addr) - if (contractMap.checksummed && contractMap[checksummed].name) { + if (contractMap[checksummed] && contractMap[checksummed].name) { return contractMap[checksummed].name } From fb2565c9d1f6c3cc6601c0f317fe10651ad21097 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 26 May 2017 11:13:39 -0700 Subject: [PATCH 5/6] Remove comment --- ui/lib/contract-namer.js | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/lib/contract-namer.js b/ui/lib/contract-namer.js index 86bba1edc..f05e770cc 100644 --- a/ui/lib/contract-namer.js +++ b/ui/lib/contract-namer.js @@ -5,7 +5,6 @@ * otherwise returns null. */ -// Nickname keys must be stored in lower case. const contractMap = require('eth-contract-metadata') const ethUtil = require('ethereumjs-util') From 9d2844c7128c79314529e163b473353d42200e9c Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Fri, 26 May 2017 11:16:58 -0700 Subject: [PATCH 6/6] remove more in operators --- ui/lib/icon-factory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/lib/icon-factory.js b/ui/lib/icon-factory.js index c16507527..45be47b7a 100644 --- a/ui/lib/icon-factory.js +++ b/ui/lib/icon-factory.js @@ -43,7 +43,7 @@ IconFactory.prototype.generateNewIdenticon = function (address, diameter) { // util function iconExistsFor (address) { - return (address in contractMap) && isValidAddress(address) && ('logo' in contractMap[address]) + return (contractMap.address) && isValidAddress(address) && (contractMap[address].logo) } function imageElFor (address) {