diff options
author | Dan Finlay <dan@danfinlay.com> | 2016-07-08 04:21:45 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2016-07-08 04:21:45 +0800 |
commit | e8efe84320ea791535b40e69a64525f7fdb3ea8a (patch) | |
tree | e5ac81f816c18871bbe4b14b546d15a924f904f2 /ui/lib | |
parent | 306035f57508cafd07c27407896a5ac32dc1b435 (diff) | |
download | tangerine-wallet-browser-e8efe84320ea791535b40e69a64525f7fdb3ea8a.tar tangerine-wallet-browser-e8efe84320ea791535b40e69a64525f7fdb3ea8a.tar.gz tangerine-wallet-browser-e8efe84320ea791535b40e69a64525f7fdb3ea8a.tar.bz2 tangerine-wallet-browser-e8efe84320ea791535b40e69a64525f7fdb3ea8a.tar.lz tangerine-wallet-browser-e8efe84320ea791535b40e69a64525f7fdb3ea8a.tar.xz tangerine-wallet-browser-e8efe84320ea791535b40e69a64525f7fdb3ea8a.tar.zst tangerine-wallet-browser-e8efe84320ea791535b40e69a64525f7fdb3ea8a.zip |
Add nickname rendering for recipient address
Diffstat (limited to 'ui/lib')
-rw-r--r-- | ui/lib/contract-namer.js | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/ui/lib/contract-namer.js b/ui/lib/contract-namer.js index eae066ad5..62c7933e8 100644 --- a/ui/lib/contract-namer.js +++ b/ui/lib/contract-namer.js @@ -5,13 +5,27 @@ * otherwise returns null. */ +// Nickname keys must be stored in lower case. const nicknames = {} -module.exports = function(address) { +module.exports = function(addr, identities = {}) { - if (address in nicknames) { - return nicknames[address] + const address = addr.toLowerCase() + const ids = hashFromIdentities(identities) + + console.dir({ addr, ids }) + return addrFromHash(address, ids) || addrFromHash(address, nicknames) +} + +function hashFromIdentities(identities) { + const result = {} + for (let key in identities) { + result[key] = identities[key].name } + return result +} - return null +function addrFromHash(addr, hash) { + const address = addr.toLowerCase() + return hash[address] || null } |