diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-10-18 04:19:57 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-10-18 04:19:57 +0800 |
commit | d7f384485d2af15ec694208b9ef068c18c7dc91d (patch) | |
tree | 5428bc604bcb65323b74605e4f120d95804a1d10 | |
parent | ab31eb6a17f5ab230fe47df66344cbce59223306 (diff) | |
download | tangerine-wallet-browser-d7f384485d2af15ec694208b9ef068c18c7dc91d.tar tangerine-wallet-browser-d7f384485d2af15ec694208b9ef068c18c7dc91d.tar.gz tangerine-wallet-browser-d7f384485d2af15ec694208b9ef068c18c7dc91d.tar.bz2 tangerine-wallet-browser-d7f384485d2af15ec694208b9ef068c18c7dc91d.tar.lz tangerine-wallet-browser-d7f384485d2af15ec694208b9ef068c18c7dc91d.tar.xz tangerine-wallet-browser-d7f384485d2af15ec694208b9ef068c18c7dc91d.tar.zst tangerine-wallet-browser-d7f384485d2af15ec694208b9ef068c18c7dc91d.zip |
Select first account when restoring seed
Fixes #2348
-rw-r--r-- | app/scripts/metamask-controller.js | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 2a45e413b..8a51fdd8d 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -337,7 +337,7 @@ module.exports = class MetamaskController extends EventEmitter { // KeyringController setLocked: nodeify(keyringController.setLocked, keyringController), createNewVaultAndKeychain: this.createNewVaultAndKeychain.bind(this), - createNewVaultAndRestore: nodeify(keyringController.createNewVaultAndRestore, keyringController), + createNewVaultAndRestore: this.createNewVaultAndRestore.bind(this), addNewKeyring: nodeify(keyringController.addNewKeyring, keyringController), saveAccountLabel: nodeify(keyringController.saveAccountLabel, keyringController), exportAccount: nodeify(keyringController.exportAccount, keyringController), @@ -461,14 +461,28 @@ module.exports = class MetamaskController extends EventEmitter { createNewVaultAndKeychain (password, cb) { this.keyringController.createNewVaultAndKeychain(password) .then((vault) => { - const { identities } = vault - const address = Object.keys(identities)[0] + this.selectFirstIdentity(vault) this.preferencesController.setSelectedAddress(address) cb(null, vault) }) .catch(reason => cb(reason)) } + createNewVaultAndRestore (password, seed, cb) { + this.keyringController.createNewVaultAndRestore(password, seed) + .then((vault) => { + this.selectFirstIdentity(vault) + cb(null, vault) + }) + .catch(reason => cb(reason)) + } + + selectFirstIdentity (vault) { + const { identities } = vault + const address = Object.keys(identities)[0] + this.preferencesController.setSelectedAddress(address) + } + submitPassword (password, cb) { return this.keyringController.submitPassword(password) .then((newState) => { cb(null, newState) }) |