aboutsummaryrefslogtreecommitdiffstats
path: root/ui/lib/contract-namer.js
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2016-07-08 07:33:06 +0800
committerKevin Serrano <kevgagser@gmail.com>2016-07-08 07:33:06 +0800
commit86b7cc6637edefd2f628238a2abff540c82e1a78 (patch)
treea6126d8b83ec7b66cd2a138c670863beedbefba1 /ui/lib/contract-namer.js
parent9a9c1f2cd48235be47e65b42c84bd9bf55ecbec4 (diff)
parent44a45f38be5251eacd2c43ebbc55acf34f65084c (diff)
downloadtangerine-wallet-browser-86b7cc6637edefd2f628238a2abff540c82e1a78.tar
tangerine-wallet-browser-86b7cc6637edefd2f628238a2abff540c82e1a78.tar.gz
tangerine-wallet-browser-86b7cc6637edefd2f628238a2abff540c82e1a78.tar.bz2
tangerine-wallet-browser-86b7cc6637edefd2f628238a2abff540c82e1a78.tar.lz
tangerine-wallet-browser-86b7cc6637edefd2f628238a2abff540c82e1a78.tar.xz
tangerine-wallet-browser-86b7cc6637edefd2f628238a2abff540c82e1a78.tar.zst
tangerine-wallet-browser-86b7cc6637edefd2f628238a2abff540c82e1a78.zip
Resolve merge conflict.
Diffstat (limited to 'ui/lib/contract-namer.js')
-rw-r--r--ui/lib/contract-namer.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/ui/lib/contract-namer.js b/ui/lib/contract-namer.js
new file mode 100644
index 000000000..62c7933e8
--- /dev/null
+++ b/ui/lib/contract-namer.js
@@ -0,0 +1,31 @@
+/* CONTRACT NAMER
+ *
+ * Takes an address,
+ * Returns a nicname if we have one stored,
+ * otherwise returns null.
+ */
+
+// Nickname keys must be stored in lower case.
+const nicknames = {}
+
+module.exports = function(addr, identities = {}) {
+
+ 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
+}
+
+function addrFromHash(addr, hash) {
+ const address = addr.toLowerCase()
+ return hash[address] || null
+}