fix reference to ens object

This commit is contained in:
Iuri Matias 2018-05-28 11:21:52 -04:00
parent e988bd6b4a
commit 32a9b25fe3
1 changed files with 6 additions and 4 deletions

View File

@ -252,11 +252,13 @@ __embarkENS.registryAddresses = {
}; };
__embarkENS.setProvider = function () { __embarkENS.setProvider = function () {
const self = this;
// get network id and then assign ENS contract based on that // get network id and then assign ENS contract based on that
let registryAddresses = this.registryAddresses; let registryAddresses = this.registryAddresses;
this.ens = web3.eth.net.getId().then(id => { this.ens = null
web3.eth.net.getId().then(id => {
if (registryAddresses[id] !== undefined) { if (registryAddresses[id] !== undefined) {
return new web3.eth.Contract(this.registryInterface, registryAddresses[id]); self.ens = new web3.eth.Contract(self.registryInterface, registryAddresses[id]);
} }
// todo: deploy at this point // todo: deploy at this point
return undefined; return undefined;
@ -268,7 +270,7 @@ __embarkENS.resolve = function(name) {
if (self.ens === undefined) return undefined; if (self.ens === undefined) return undefined;
let node = namehash(name); let node = namehash.hash(name);
self.ens.methods.resolver(node).call().then((resolverAddress) => { self.ens.methods.resolver(node).call().then((resolverAddress) => {
let resolverContract = new web3.eth.Contract(self.resolverInterface, resolverAddress); let resolverContract = new web3.eth.Contract(self.resolverInterface, resolverAddress);
@ -285,7 +287,7 @@ __embarkENS.lookup = function(address) {
if (address.startsWith("0x")) address = address.slice(2); if (address.startsWith("0x")) address = address.slice(2);
let node = namehash(address.toLowerCase() + ".addr.reverse"); let node = namehash.hash(address.toLowerCase() + ".addr.reverse");
self.ens.methods.resolver(node).call().then((resolverAddress) => { self.ens.methods.resolver(node).call().then((resolverAddress) => {
let resolverContract = new web3.eth.Contract(self.resolverInterface, resolverAddress); let resolverContract = new web3.eth.Contract(self.resolverInterface, resolverAddress);