From 1d7851e2ff1e23113467a03dafeab168e8f15051 Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Mon, 25 Jun 2018 12:25:22 -0500 Subject: [PATCH 1/3] catch errors and handle gracefully in ENS --- lib/modules/ens/embarkjs.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/modules/ens/embarkjs.js b/lib/modules/ens/embarkjs.js index d2b82b67..bc52bc9f 100644 --- a/lib/modules/ens/embarkjs.js +++ b/lib/modules/ens/embarkjs.js @@ -14,6 +14,7 @@ __embarkENS.resolverInterface = [ } ], "name": "addr", + "outputs": [ { "name": "", @@ -172,7 +173,14 @@ __embarkENS.resolve = function (name) { return resolverContract.methods.addr(node).call(); }).then((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) { @@ -189,5 +197,12 @@ __embarkENS.lookup = function (address) { return self.ens.methods.resolver(node).call().then((resolverAddress) => { let resolverContract = new EmbarkJS.Contract({abi: self.resolverInterface, address: resolverAddress}); 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; + } + }); }; From 8bf79e704da6813ef8af23c60680084147f282d8 Mon Sep 17 00:00:00 2001 From: RJ Catalano Date: Mon, 25 Jun 2018 15:41:26 -0500 Subject: [PATCH 2/3] fix line --- lib/modules/ens/embarkjs.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/modules/ens/embarkjs.js b/lib/modules/ens/embarkjs.js index bc52bc9f..905af112 100644 --- a/lib/modules/ens/embarkjs.js +++ b/lib/modules/ens/embarkjs.js @@ -14,7 +14,6 @@ __embarkENS.resolverInterface = [ } ], "name": "addr", - "outputs": [ { "name": "", From 5e7cd6a88b98281ab81c15f71e17bf3302191eba Mon Sep 17 00:00:00 2001 From: VoR0220 Date: Tue, 26 Jun 2018 13:28:28 -0500 Subject: [PATCH 3/3] get rid of else Signed-off-by: VoR0220 --- lib/modules/ens/embarkjs.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/modules/ens/embarkjs.js b/lib/modules/ens/embarkjs.js index 905af112..40bc99e6 100644 --- a/lib/modules/ens/embarkjs.js +++ b/lib/modules/ens/embarkjs.js @@ -176,9 +176,8 @@ __embarkENS.resolve = function (name) { if (err == 'Couldn\'t decode addr from ABI: 0x') { console.log(name + " is not registered"); return "0x"; - } else { - return err; } + return err; }); }; @@ -200,8 +199,7 @@ __embarkENS.lookup = function (address) { 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; } + return err; }); };