diff options
author | kumavis <kumavis@users.noreply.github.com> | 2018-05-29 14:51:59 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-29 14:51:59 +0800 |
commit | 76c5851df135e1636f58545d2856cd74b8d5ef25 (patch) | |
tree | a9f593350475aec4cdc13f8614dd5389198bb976 | |
parent | 12492aae60b96bc439d8a7e0272b1a41924cbf1e (diff) | |
parent | 7e87600042805727a9e99e62c8bf23819f6d0b0f (diff) | |
download | tangerine-wallet-browser-76c5851df135e1636f58545d2856cd74b8d5ef25.tar tangerine-wallet-browser-76c5851df135e1636f58545d2856cd74b8d5ef25.tar.gz tangerine-wallet-browser-76c5851df135e1636f58545d2856cd74b8d5ef25.tar.bz2 tangerine-wallet-browser-76c5851df135e1636f58545d2856cd74b8d5ef25.tar.lz tangerine-wallet-browser-76c5851df135e1636f58545d2856cd74b8d5ef25.tar.xz tangerine-wallet-browser-76c5851df135e1636f58545d2856cd74b8d5ef25.tar.zst tangerine-wallet-browser-76c5851df135e1636f58545d2856cd74b8d5ef25.zip |
Merge pull request #4391 from MetaMask/newui-imported-accounts-select-fix
metamask-controller - update preferences controller addresses after import account
-rw-r--r-- | app/scripts/metamask-controller.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 1b1d26886..0457b4476 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -350,7 +350,7 @@ module.exports = class MetamaskController extends EventEmitter { verifySeedPhrase: nodeify(this.verifySeedPhrase, this), clearSeedWordCache: this.clearSeedWordCache.bind(this), resetAccount: nodeify(this.resetAccount, this), - importAccountWithStrategy: this.importAccountWithStrategy.bind(this), + importAccountWithStrategy: nodeify(this.importAccountWithStrategy, this), // vault management submitPassword: nodeify(keyringController.submitPassword, keyringController), @@ -608,15 +608,15 @@ module.exports = class MetamaskController extends EventEmitter { * @param {any} args - The data required by that strategy to import an account. * @param {Function} cb - A callback function called with a state update on success. */ - importAccountWithStrategy (strategy, args, cb) { - accountImporter.importAccount(strategy, args) - .then((privateKey) => { - return this.keyringController.addNewKeyring('Simple Key Pair', [ privateKey ]) - }) - .then(keyring => keyring.getAccounts()) - .then((accounts) => this.preferencesController.setSelectedAddress(accounts[0])) - .then(() => { cb(null, this.keyringController.fullUpdate()) }) - .catch((reason) => { cb(reason) }) + async importAccountWithStrategy (strategy, args) { + const privateKey = await accountImporter.importAccount(strategy, args) + const keyring = await this.keyringController.addNewKeyring('Simple Key Pair', [ privateKey ]) + const accounts = await keyring.getAccounts() + // update accounts in preferences controller + const allAccounts = await this.keyringController.getAccounts() + this.preferencesController.setAddresses(allAccounts) + // set new account as selected + await this.preferencesController.setSelectedAddress(accounts[0]) } // --------------------------------------------------------------------------- |