aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-05-29 13:58:14 +0800
committerkumavis <aaron@kumavis.me>2018-05-29 13:58:14 +0800
commitfe42de46422c89156e91fb08ee06f50511c8601f (patch)
tree75638f7a79b6d876e039026ffb48921998d7ba20 /app/scripts
parente2a9b9e2aed514d935c48cfbdbc274771b4ee671 (diff)
downloadtangerine-wallet-browser-fe42de46422c89156e91fb08ee06f50511c8601f.tar
tangerine-wallet-browser-fe42de46422c89156e91fb08ee06f50511c8601f.tar.gz
tangerine-wallet-browser-fe42de46422c89156e91fb08ee06f50511c8601f.tar.bz2
tangerine-wallet-browser-fe42de46422c89156e91fb08ee06f50511c8601f.tar.lz
tangerine-wallet-browser-fe42de46422c89156e91fb08ee06f50511c8601f.tar.xz
tangerine-wallet-browser-fe42de46422c89156e91fb08ee06f50511c8601f.tar.zst
tangerine-wallet-browser-fe42de46422c89156e91fb08ee06f50511c8601f.zip
metamask-controller - update preferences controller addresses after import account
Diffstat (limited to 'app/scripts')
-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 796c9385a..ed606d4ab 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -345,7 +345,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),
@@ -603,15 +603,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])
}
// ---------------------------------------------------------------------------