diff options
author | Dan Finlay <dan@danfinlay.com> | 2016-11-23 16:23:41 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2016-11-23 16:23:41 +0800 |
commit | 600f5c31db47a06c0c9bb9a97c01476d77b0a0df (patch) | |
tree | 5bfd1ce4ebaa634509cd099d1ce981309b5914e8 /app/scripts | |
parent | c77d355e98d3c61699a3a85dfc2ed1f320a9eb03 (diff) | |
download | tangerine-wallet-browser-600f5c31db47a06c0c9bb9a97c01476d77b0a0df.tar tangerine-wallet-browser-600f5c31db47a06c0c9bb9a97c01476d77b0a0df.tar.gz tangerine-wallet-browser-600f5c31db47a06c0c9bb9a97c01476d77b0a0df.tar.bz2 tangerine-wallet-browser-600f5c31db47a06c0c9bb9a97c01476d77b0a0df.tar.lz tangerine-wallet-browser-600f5c31db47a06c0c9bb9a97c01476d77b0a0df.tar.xz tangerine-wallet-browser-600f5c31db47a06c0c9bb9a97c01476d77b0a0df.tar.zst tangerine-wallet-browser-600f5c31db47a06c0c9bb9a97c01476d77b0a0df.zip |
Mostly got async keyringController tests passing
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/keyring-controller.js | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js index 4cfe84b6b..a36f5b752 100644 --- a/app/scripts/keyring-controller.js +++ b/app/scripts/keyring-controller.js @@ -99,16 +99,17 @@ module.exports = class KeyringController extends EventEmitter { mnemonic: seed, numberOfAccounts: 1, }, (err) => { - if (err) return cb(err) const firstKeyring = this.keyrings[0] const accounts = firstKeyring.getAccounts() const firstAccount = accounts[0] const hexAccount = normalize(firstAccount) this.configManager.setSelectedAccount(hexAccount) this.setupAccounts(accounts) - - this.emit('update') - cb() + this.persistAllKeyrings() + .then(() => { + this.emit('update') + cb(err) + }) }) }) } @@ -152,6 +153,7 @@ module.exports = class KeyringController extends EventEmitter { createFirstKeyTree (password, cb) { this.clearKeyrings() this.addNewKeyring('HD Key Tree', {numberOfAccounts: 1}, (err) => { + if (err) return cb(err) const accounts = this.keyrings[0].getAccounts() const firstAccount = accounts[0] const hexAccount = normalize(firstAccount) @@ -162,7 +164,7 @@ module.exports = class KeyringController extends EventEmitter { this.setupAccounts(accounts) this.persistAllKeyrings() .then(() => { - cb(err) + cb() }) .catch((reason) => { cb(reason) @@ -335,10 +337,10 @@ module.exports = class KeyringController extends EventEmitter { getAccounts () { const keyrings = this.keyrings || [] - return keyrings.map(kr => kr.getAccounts()) + return Promise.all(keyrings.map(kr => kr.getAccounts()) .reduce((res, arr) => { return res.concat(arr) - }, []) + }, [])) } setSelectedAccount (address, cb) { |