1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Merge pull request #1507 from MetaMask/AddContractIconMap

Add contract name map
This commit is contained in:
kumavis 2017-05-26 12:19:51 -07:00 committed by GitHub
commit 5e9274d4d5
4 changed files with 14 additions and 8 deletions

View File

@ -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

View File

@ -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",

View File

@ -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) {

View File

@ -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