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,16 +190,21 @@ __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) {
|
||||||
}
|
return cb(NOT_REGISTERED_ERROR);
|
||||||
if (resolverAddress === voidAddress) {
|
}
|
||||||
return cb('Name not yet registered');
|
let resolverContract = new EmbarkJS.Blockchain.Contract({
|
||||||
}
|
abi: this.resolverInterface,
|
||||||
let resolverContract = new EmbarkJS.Blockchain.Contract({abi: this.resolverInterface, address: resolverAddress, web3: web3});
|
address: resolverAddress,
|
||||||
resolverContract.methods.addr(node).call(cb);
|
web3: web3
|
||||||
});
|
});
|
||||||
|
return resolverContract.methods.addr(node).call(cb);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
cb(err);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
__embarkENS.lookup = function (address, callback) {
|
__embarkENS.lookup = function (address, callback) {
|
||||||
|
@ -221,16 +227,21 @@ __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) {
|
||||||
}
|
return cb('Address not associated to a resolver');
|
||||||
if (resolverAddress === voidAddress) {
|
}
|
||||||
return cb('Address not associated to a resolver');
|
const resolverContract = new EmbarkJS.Blockchain.Contract({
|
||||||
}
|
abi: this.resolverInterface,
|
||||||
let resolverContract = new EmbarkJS.Blockchain.Contract({abi: this.resolverInterface, address: resolverAddress, web3: web3});
|
address: resolverAddress,
|
||||||
resolverContract.methods.name(node).call(cb);
|
web3: web3
|
||||||
});
|
});
|
||||||
|
return resolverContract.methods.name(node).call(cb);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
cb(err);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
__embarkENS.registerSubDomain = function (name, address, callback) {
|
__embarkENS.registerSubDomain = function (name, address, callback) {
|
||||||
|
|
Loading…
Reference in New Issue