From 8b070399070a95eb05d3ed7aec788486647c21a1 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Wed, 23 May 2018 16:53:39 -0500 Subject: [PATCH] should work to create the reverse lookup Signed-off-by: VoR0220 --- lib/modules/ens/embarkjs.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/modules/ens/embarkjs.js b/lib/modules/ens/embarkjs.js index 90aaa910f..b6444c967 100644 --- a/lib/modules/ens/embarkjs.js +++ b/lib/modules/ens/embarkjs.js @@ -277,3 +277,23 @@ __embarkENS.resolve = function(name) { return addr; }).catch(err => err); }; + +__embarkENS.NameNotFound = Error("ENS name not found"); + +__embarkENS.lookup = function(address) { + const self = this; + + if (self.ens === undefined) return undefined; + + if(address.startsWith("0x")) + address = address.slice(2); + + let node = namehash(address.toLowerCase() + ".addr.reverse") + + self.ens.methods.resolver(node).call().then((resolverAddress) => { + let resolverContract = new web3.eth.Contract(resolverInterface, resolverAddress); + return resolverContract.methods.name(node).call(); + }).then((name) => { + return name; + }).catch(err => err); +}