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

Promisify metamask-controller vault creating methods

This commit is contained in:
Dan Finlay 2017-10-17 13:25:27 -07:00
parent d7f384485d
commit 50e8599988

View File

@ -336,8 +336,8 @@ module.exports = class MetamaskController extends EventEmitter {
// KeyringController // KeyringController
setLocked: nodeify(keyringController.setLocked, keyringController), setLocked: nodeify(keyringController.setLocked, keyringController),
createNewVaultAndKeychain: this.createNewVaultAndKeychain.bind(this), createNewVaultAndKeychain: nodeify(this.createNewVaultAndKeychain, this),
createNewVaultAndRestore: this.createNewVaultAndRestore.bind(this), createNewVaultAndRestore: nodeify(this.createNewVaultAndRestore, this),
addNewKeyring: nodeify(keyringController.addNewKeyring, keyringController), addNewKeyring: nodeify(keyringController.addNewKeyring, keyringController),
saveAccountLabel: nodeify(keyringController.saveAccountLabel, keyringController), saveAccountLabel: nodeify(keyringController.saveAccountLabel, keyringController),
exportAccount: nodeify(keyringController.exportAccount, keyringController), exportAccount: nodeify(keyringController.exportAccount, keyringController),
@ -458,23 +458,16 @@ module.exports = class MetamaskController extends EventEmitter {
// Vault Management // Vault Management
// //
createNewVaultAndKeychain (password, cb) { async createNewVaultAndKeychain (password, cb) {
this.keyringController.createNewVaultAndKeychain(password) const vault = await this.keyringController.createNewVaultAndKeychain(password)
.then((vault) => { this.selectFirstIdentity(vault)
this.selectFirstIdentity(vault) return vault
this.preferencesController.setSelectedAddress(address)
cb(null, vault)
})
.catch(reason => cb(reason))
} }
createNewVaultAndRestore (password, seed, cb) { async createNewVaultAndRestore (password, seed, cb) {
this.keyringController.createNewVaultAndRestore(password, seed) const vault = await this.keyringController.createNewVaultAndRestore(password, seed)
.then((vault) => { this.selectFirstIdentity(vault)
this.selectFirstIdentity(vault) return vault
cb(null, vault)
})
.catch(reason => cb(reason))
} }
selectFirstIdentity (vault) { selectFirstIdentity (vault) {