From 9839e92584d2211a144191348e882f15b37bc9ab Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Mon, 9 Dec 2019 15:30:54 +0100 Subject: [PATCH] fix(@cockpit/ens): ensure default account is set when registering subdomains Prior to this commit, registering ENS subdomains would fail due to `defaultAccount` being null. This is because the underlying API was still relying on `blockchain:defaultAccount:get`. However since the bigger refactor, every plugin/module is in charge of creating its own blockchain connector instance and ensuring it has a default account. This commit makes use of ENS' module's `webDefaultAccount` async getter to ensure a valid default account is set when registering an ENS subdomain. --- packages/plugins/ens/src/index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/plugins/ens/src/index.js b/packages/plugins/ens/src/index.js index 88bdad880..fe4ed58cd 100644 --- a/packages/plugins/ens/src/index.js +++ b/packages/plugins/ens/src/index.js @@ -469,10 +469,9 @@ class ENS { ENSFunctions.lookupAddress(address, this.ensContract, namehash, this.createResolverContract.bind(this), cb); } - ensRegisterSubdomain(subdomain, address, cb) { - this.events.request("blockchain:defaultAccount:get", (_err, defaultAccount) => { - this.safeRegisterSubDomain(subdomain, address, defaultAccount, cb); - }); + async ensRegisterSubdomain(subdomain, address, cb) { + const defaultAccount = await this.web3DefaultAccount; + this.safeRegisterSubDomain(subdomain, address, defaultAccount, cb); } isENSName(name) {