From 23d6b0746730ec925a7b9bdae6864c307513ffc9 Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Tue, 25 Sep 2018 15:30:46 +0100 Subject: [PATCH] Warning if no default account for ens --- lib/modules/ens/embarkjs.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/modules/ens/embarkjs.js b/lib/modules/ens/embarkjs.js index 526bbded6..6663f023a 100644 --- a/lib/modules/ens/embarkjs.js +++ b/lib/modules/ens/embarkjs.js @@ -131,6 +131,7 @@ __embarkENS.resolverInterface = [ } ]; +const defaultAccountNotSetError = 'web3.eth.defaultAccount not set'; const providerNotSetError = 'ENS provider not set'; const NoDecodeAddrError = 'Error: Couldn\'t decode address from ABI: 0x'; const NoDecodeStringError = 'ERROR: The returned value is not a convertible string: 0x0'; @@ -151,7 +152,6 @@ __embarkENS.setProvider = function (config) { const ERROR_MESSAGE = 'ENS is not available in this chain'; self.registration = config.registration; self.env = config.env; - EmbarkJS.onReady(() => { web3.eth.net.getId() .then((id) => { @@ -176,6 +176,10 @@ __embarkENS.resolve = function (name, callback) { if (!this.ens) { return callback(providerNotSetError); } + if (!web3.eth.defaultAccount) { + return callback(defaultAccountNotSetError); + } + let node = namehash.hash(name); function cb(err, addr) { @@ -202,6 +206,9 @@ __embarkENS.lookup = function (address, callback) { if (!this.ens) { return callback(providerNotSetError); } + if (!web3.eth.defaultAccount) { + return callback(defaultAccountNotSetError); + } if (address.startsWith("0x")) { address = address.slice(2); } @@ -229,6 +236,10 @@ __embarkENS.lookup = function (address, callback) { __embarkENS.registerSubDomain = function (name, address, callback) { callback = callback || function () {}; + if (!web3.eth.defaultAccount) { + return callback(defaultAccountNotSetError); + } + if (this.env !== 'development' && this.env !== 'privatenet') { return callback('Sub-domain registration is only available in development or privatenet mode'); }