mirror of https://github.com/embarklabs/embark.git
use EmbarkJS to initialize ens contracts and set ens contract only when embark is ready
This commit is contained in:
parent
6a5020402f
commit
0ba9990073
|
@ -258,7 +258,9 @@ __embarkENS.setProvider = function () {
|
||||||
this.ens = null;
|
this.ens = null;
|
||||||
web3.eth.net.getId().then(id => {
|
web3.eth.net.getId().then(id => {
|
||||||
if (registryAddresses[id] !== undefined) {
|
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
|
// todo: deploy at this point
|
||||||
}).catch(e => {
|
}).catch(e => {
|
||||||
|
@ -278,7 +280,7 @@ __embarkENS.resolve = function(name) {
|
||||||
let node = namehash.hash(name);
|
let node = namehash.hash(name);
|
||||||
|
|
||||||
return self.ens.methods.resolver(node).call().then((resolverAddress) => {
|
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();
|
return resolverContract.methods.addr(node).call();
|
||||||
}).then((addr) => {
|
}).then((addr) => {
|
||||||
return addr;
|
return addr;
|
||||||
|
@ -295,7 +297,7 @@ __embarkENS.lookup = function(address) {
|
||||||
let node = namehash.hash(address.toLowerCase() + ".addr.reverse");
|
let node = namehash.hash(address.toLowerCase() + ".addr.reverse");
|
||||||
|
|
||||||
return self.ens.methods.resolver(node).call().then((resolverAddress) => {
|
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();
|
return resolverContract.methods.name(node).call();
|
||||||
}).then((name) => {
|
}).then((name) => {
|
||||||
if (name === "" || name === undefined) throw Error("ENS name not found");
|
if (name === "" || name === undefined) throw Error("ENS name not found");
|
||||||
|
|
Loading…
Reference in New Issue