mirror of https://github.com/embarklabs/embark.git
catch errors and handle gracefully in ENS
This commit is contained in:
parent
63a85d5af1
commit
a05fff3cfe
|
@ -14,6 +14,7 @@ __embarkENS.resolverInterface = [
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"name": "addr",
|
"name": "addr",
|
||||||
|
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"name": "",
|
"name": "",
|
||||||
|
@ -195,7 +196,14 @@ __embarkENS.resolve = function (name) {
|
||||||
return resolverContract.methods.addr(node).call();
|
return resolverContract.methods.addr(node).call();
|
||||||
}).then((addr) => {
|
}).then((addr) => {
|
||||||
return addr;
|
return addr;
|
||||||
}).catch(err => err);
|
}).catch((err) => {
|
||||||
|
if (err == 'Couldn\'t decode addr from ABI: 0x') {
|
||||||
|
console.log(name + " is not registered");
|
||||||
|
return "0x";
|
||||||
|
} else {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
__embarkENS.lookup = function (address) {
|
__embarkENS.lookup = function (address) {
|
||||||
|
@ -212,5 +220,12 @@ __embarkENS.lookup = function (address) {
|
||||||
return self.ens.methods.resolver(node).call().then((resolverAddress) => {
|
return self.ens.methods.resolver(node).call().then((resolverAddress) => {
|
||||||
let resolverContract = new EmbarkJS.Contract({abi: self.resolverInterface, address: 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) => {
|
||||||
|
if (err == 'ERROR: The returned value is not a convertible string: 0x0') {
|
||||||
|
console.log('Address does not resolve to name. Try syncing chain.');
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue