From 728115171e12cb9953a6b1f8ed16a9f213e44ed1 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Sun, 10 Nov 2019 21:15:59 -0500 Subject: [PATCH] Catch reverse resolve ENS errors (#7377) The 'reverseResolveAddress' method is intended to return undefined if unable to reverse resolve the given address. Instead it was throwing an error, which surfaced in the UI console. This error is now caught. --- app/scripts/controllers/ens/index.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/scripts/controllers/ens/index.js b/app/scripts/controllers/ens/index.js index 8451ccb65..81ba5d81e 100644 --- a/app/scripts/controllers/ens/index.js +++ b/app/scripts/controllers/ens/index.js @@ -1,6 +1,7 @@ const ethUtil = require('ethereumjs-util') const ObservableStore = require('obs-store') const punycode = require('punycode') +const log = require('loglevel') const Ens = require('./ens') const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' @@ -51,8 +52,22 @@ class EnsController { return state.ensResolutionsByAddress[address] } - const domain = await this._ens.reverse(address) - const registeredAddress = await this._ens.lookup(domain) + let domain + try { + domain = await this._ens.reverse(address) + } catch (error) { + log.debug(error) + return undefined + } + + let registeredAddress + try { + registeredAddress = await this._ens.lookup(domain) + } catch (error) { + log.debug(error) + return undefined + } + if (registeredAddress === ZERO_ADDRESS || registeredAddress === ZERO_X_ERROR_ADDRESS) { return undefined }