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.
This commit is contained in:
Pascal Precht 2019-12-09 15:30:54 +01:00 committed by Iuri Matias
parent e72aeba892
commit 9839e92584

View File

@ -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) {