mirror of https://github.com/embarklabs/embark.git
Merge pull request #583 from embark-framework/fix_ens_js
(re)add Fix to ens js
This commit is contained in:
commit
d12271e85d
|
@ -1,6 +1,6 @@
|
||||||
import namehash from 'eth-ens-namehash';
|
import namehash from 'eth-ens-namehash';
|
||||||
|
|
||||||
/*global web3*/
|
/*global EmbarkJS*/
|
||||||
let __embarkENS = {};
|
let __embarkENS = {};
|
||||||
|
|
||||||
// resolver interface
|
// resolver interface
|
||||||
|
@ -154,7 +154,10 @@ __embarkENS.resolverInterface = [
|
||||||
];
|
];
|
||||||
|
|
||||||
__embarkENS.setProvider = function (config) {
|
__embarkENS.setProvider = function (config) {
|
||||||
this.ens = new web3.eth.Contract(config.abi, config.address);
|
const self = this;
|
||||||
|
EmbarkJS.onReady(() => {
|
||||||
|
self.ens = new EmbarkJS.Contract({abi: config.abi, address: config.address});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
__embarkENS.resolve = function (name) {
|
__embarkENS.resolve = function (name) {
|
||||||
|
@ -165,7 +168,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;
|
||||||
|
@ -184,7 +187,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();
|
||||||
}).catch(err => err);
|
}).catch(err => err);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue