should work to create the reverse lookup

Signed-off-by: VoR0220 <catalanor0220@gmail.com>
This commit is contained in:
VoR0220 2018-05-23 16:53:39 -05:00
parent fe84cc8de4
commit 8b07039907

View File

@ -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);
}