diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-10-20 03:15:26 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-10-20 03:15:26 +0800 |
commit | 3b4c679ffcd76279221bb7cb6b83c53f0468ee65 (patch) | |
tree | ab1887ee29949f5429dd27e0269ddd3ac2420c48 | |
parent | 0ae406e489a635ea094913ee5c20d1e8f2165db5 (diff) | |
download | tangerine-wallet-browser-3b4c679ffcd76279221bb7cb6b83c53f0468ee65.tar tangerine-wallet-browser-3b4c679ffcd76279221bb7cb6b83c53f0468ee65.tar.gz tangerine-wallet-browser-3b4c679ffcd76279221bb7cb6b83c53f0468ee65.tar.bz2 tangerine-wallet-browser-3b4c679ffcd76279221bb7cb6b83c53f0468ee65.tar.lz tangerine-wallet-browser-3b4c679ffcd76279221bb7cb6b83c53f0468ee65.tar.xz tangerine-wallet-browser-3b4c679ffcd76279221bb7cb6b83c53f0468ee65.tar.zst tangerine-wallet-browser-3b4c679ffcd76279221bb7cb6b83c53f0468ee65.zip |
Fix bug where new account was not immediately selected
-rw-r--r-- | app/scripts/metamask-controller.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 366bb6d98..457d38e26 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -324,7 +324,7 @@ module.exports = class MetamaskController extends EventEmitter { createShapeShiftTx: this.createShapeShiftTx.bind(this), // primary HD keyring management - addNewAccount: this.addNewAccount.bind(this), + addNewAccount: nodeify(this.addNewAccount, this), placeSeedWords: this.placeSeedWords.bind(this), clearSeedWordCache: this.clearSeedWordCache.bind(this), importAccountWithStrategy: this.importAccountWithStrategy.bind(this), @@ -490,10 +490,21 @@ module.exports = class MetamaskController extends EventEmitter { // Opinionated Keyring Management // - addNewAccount (cb) { + async addNewAccount (cb) { const primaryKeyring = this.keyringController.getKeyringsByType('HD Key Tree')[0] if (!primaryKeyring) return cb(new Error('MetamaskController - No HD Key Tree found')) - promiseToCallback(this.keyringController.addNewAccount(primaryKeyring))(cb) + const keyringController = this.keyringController + const oldAccounts = await keyringController.getAccounts() + const keyState = await keyringController.addNewAccount(primaryKeyring) + const newAccounts = await keyringController.getAccounts() + + newAccounts.forEach((address) => { + if (!oldAccounts.includes(address)) { + this.preferencesController.setSelectedAddress(address) + } + }) + + return keyState } // Adds the current vault's seed words to the UI's state tree. |