aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/metamask-controller.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-05-29 13:58:14 +0800
committerkumavis <aaron@kumavis.me>2018-05-29 14:00:22 +0800
commit09601439e38e2681c434f23bc77c3b7665f8c98a (patch)
tree38211eb3e44dfe7282bb0d95a7cfa90fcfbe64ed /app/scripts/metamask-controller.js
parent12492aae60b96bc439d8a7e0272b1a41924cbf1e (diff)
downloadtangerine-wallet-browser-09601439e38e2681c434f23bc77c3b7665f8c98a.tar
tangerine-wallet-browser-09601439e38e2681c434f23bc77c3b7665f8c98a.tar.gz
tangerine-wallet-browser-09601439e38e2681c434f23bc77c3b7665f8c98a.tar.bz2
tangerine-wallet-browser-09601439e38e2681c434f23bc77c3b7665f8c98a.tar.lz
tangerine-wallet-browser-09601439e38e2681c434f23bc77c3b7665f8c98a.tar.xz
tangerine-wallet-browser-09601439e38e2681c434f23bc77c3b7665f8c98a.tar.zst
tangerine-wallet-browser-09601439e38e2681c434f23bc77c3b7665f8c98a.zip
metamask-controller - update preferences controller addresses after import account
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r--app/scripts/metamask-controller.js20
1 files changed, 10 insertions, 10 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 1b1d26886..01adc3596 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 keyringController.getAccounts()
+ this.preferencesController.setAddresses(allAccounts)
+ // set new account as selected
+ await this.preferencesController.setSelectedAddress(accounts[0])
}
// ---------------------------------------------------------------------------