1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Select first account when restoring seed

Fixes #2348
This commit is contained in:
Dan Finlay 2017-10-17 13:19:57 -07:00
parent ab31eb6a17
commit d7f384485d

View File

@ -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) })