From 0ba9990073ac61cbe51e9d5cec1a1dacbd29400a Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 21 Jun 2018 21:03:23 -0400 Subject: [PATCH 1/2] use EmbarkJS to initialize ens contracts and set ens contract only when embark is ready --- lib/modules/ens/embarkjs.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/modules/ens/embarkjs.js b/lib/modules/ens/embarkjs.js index 1f37856c..e6c984c5 100644 --- a/lib/modules/ens/embarkjs.js +++ b/lib/modules/ens/embarkjs.js @@ -258,7 +258,9 @@ __embarkENS.setProvider = function () { this.ens = null; web3.eth.net.getId().then(id => { if (registryAddresses[id] !== undefined) { - self.ens = new web3.eth.Contract(self.registryInterface, registryAddresses[id]); + EmbarkJS.onReady(() => { + self.ens = new EmbarkJS.Contract({abi: self.registryInterface, address: registryAddresses[id]}); + }); } // todo: deploy at this point }).catch(e => { @@ -278,7 +280,7 @@ __embarkENS.resolve = function(name) { let node = namehash.hash(name); return self.ens.methods.resolver(node).call().then((resolverAddress) => { - let resolverContract = new web3.eth.Contract(self.resolverInterface, resolverAddress); + let resolverContract = new EmbarkJS.Contract({abi: self.resolverInterface, address: resolverAddress}); return resolverContract.methods.addr(node).call(); }).then((addr) => { return addr; @@ -295,7 +297,7 @@ __embarkENS.lookup = function(address) { let node = namehash.hash(address.toLowerCase() + ".addr.reverse"); return self.ens.methods.resolver(node).call().then((resolverAddress) => { - let resolverContract = new web3.eth.Contract(self.resolverInterface, resolverAddress); + let resolverContract = new EmbarkJS.Contract({abi: self.resolverInterface, address: resolverAddress}); return resolverContract.methods.name(node).call(); }).then((name) => { if (name === "" || name === undefined) throw Error("ENS name not found"); From 5a429d05748e49527b0f8fe57ce5118f3211d453 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 21 Jun 2018 21:07:27 -0400 Subject: [PATCH 2/2] make linter happy --- lib/modules/ens/embarkjs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/ens/embarkjs.js b/lib/modules/ens/embarkjs.js index e6c984c5..e50fb5b4 100644 --- a/lib/modules/ens/embarkjs.js +++ b/lib/modules/ens/embarkjs.js @@ -1,6 +1,6 @@ import namehash from 'eth-ens-namehash'; -/*global web3*/ +/*global web3, EmbarkJS*/ let __embarkENS = {}; // registry interface for later