mirror of https://github.com/embarklabs/embark.git
fix(ens/embarkjs): fix using await with embarkjs functions
This commit is contained in:
parent
ca212e3ffb
commit
c64c093a48
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
let __embarkENS = {};
|
let __embarkENS = {};
|
||||||
|
|
||||||
|
const NOT_REGISTERED_ERROR = 'Name not yet registered';
|
||||||
// resolver interface
|
// resolver interface
|
||||||
__embarkENS.resolverInterface = [
|
__embarkENS.resolverInterface = [
|
||||||
{
|
{
|
||||||
|
@ -189,15 +190,20 @@ __embarkENS.resolve = function (name, callback) {
|
||||||
callback(err, addr);
|
callback(err, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.ens.methods.resolver(node).call((err, resolverAddress) => {
|
return this.ens.methods.resolver(node).call()
|
||||||
if (err) {
|
.then(resolverAddress => {
|
||||||
return cb(err);
|
|
||||||
}
|
|
||||||
if (resolverAddress === voidAddress) {
|
if (resolverAddress === voidAddress) {
|
||||||
return cb('Name not yet registered');
|
return cb(NOT_REGISTERED_ERROR);
|
||||||
}
|
}
|
||||||
let resolverContract = new EmbarkJS.Blockchain.Contract({abi: this.resolverInterface, address: resolverAddress, web3: web3});
|
let resolverContract = new EmbarkJS.Blockchain.Contract({
|
||||||
resolverContract.methods.addr(node).call(cb);
|
abi: this.resolverInterface,
|
||||||
|
address: resolverAddress,
|
||||||
|
web3: web3
|
||||||
|
});
|
||||||
|
return resolverContract.methods.addr(node).call(cb);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
cb(err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -221,15 +227,20 @@ __embarkENS.lookup = function (address, callback) {
|
||||||
return callback(err, name);
|
return callback(err, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.ens.methods.resolver(node).call((err, resolverAddress) => {
|
return this.ens.methods.resolver(node).call()
|
||||||
if (err) {
|
.then(resolverAddress => {
|
||||||
return cb(err);
|
|
||||||
}
|
|
||||||
if (resolverAddress === voidAddress) {
|
if (resolverAddress === voidAddress) {
|
||||||
return cb('Address not associated to a resolver');
|
return cb('Address not associated to a resolver');
|
||||||
}
|
}
|
||||||
let resolverContract = new EmbarkJS.Blockchain.Contract({abi: this.resolverInterface, address: resolverAddress, web3: web3});
|
const resolverContract = new EmbarkJS.Blockchain.Contract({
|
||||||
resolverContract.methods.name(node).call(cb);
|
abi: this.resolverInterface,
|
||||||
|
address: resolverAddress,
|
||||||
|
web3: web3
|
||||||
|
});
|
||||||
|
return resolverContract.methods.name(node).call(cb);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
cb(err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue