mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 17:33:23 +01:00
Fix issue where generating a new account would put it in loose keys
This commit is contained in:
parent
85b34e3f2b
commit
8642ced310
@ -259,9 +259,8 @@ module.exports = class KeyringController extends EventEmitter {
|
||||
// Calls the `addAccounts` method on the Keyring
|
||||
// in the kryings array at index `keyringNum`,
|
||||
// and then saves those changes.
|
||||
addNewAccount (keyRingNum = 0) {
|
||||
const ring = this.keyrings[keyRingNum]
|
||||
return ring.addAccounts(1)
|
||||
addNewAccount (selectedKeyring) {
|
||||
return selectedKeyring.addAccounts(1)
|
||||
.then(this.setupAccounts.bind(this))
|
||||
.then(this.persistAllKeyrings.bind(this))
|
||||
.then(this.fullUpdate.bind(this))
|
||||
@ -587,6 +586,10 @@ module.exports = class KeyringController extends EventEmitter {
|
||||
return this.keyringTypes.find(kr => kr.type === type)
|
||||
}
|
||||
|
||||
getKeyringsByType (type) {
|
||||
return this.keyrings.filter((keyring) => keyring.type === type)
|
||||
}
|
||||
|
||||
// Get Accounts
|
||||
// returns Promise( @Array[ @string accounts ] )
|
||||
//
|
||||
|
@ -1,5 +1,6 @@
|
||||
const EventEmitter = require('events')
|
||||
const extend = require('xtend')
|
||||
const promiseToCallback = require('promise-to-callback')
|
||||
const EthStore = require('./lib/eth-store')
|
||||
const MetaMaskProvider = require('web3-provider-engine/zero.js')
|
||||
const KeyringController = require('./keyring-controller')
|
||||
@ -121,7 +122,11 @@ module.exports = class MetamaskController extends EventEmitter {
|
||||
.then((newState) => { cb(null, newState) })
|
||||
.catch((reason) => { cb(reason) })
|
||||
},
|
||||
addNewAccount: nodeify(keyringController.addNewAccount).bind(keyringController),
|
||||
addNewAccount: (cb) => {
|
||||
const primaryKeyring = keyringController.getKeyringsByType('HD Key Tree')[0]
|
||||
if (!primaryKeyring) return cb(new Error('MetamaskController - No HD Key Tree found'))
|
||||
promiseToCallback(keyringController.addNewAccount(primaryKeyring))(cb)
|
||||
},
|
||||
setSelectedAccount: nodeify(keyringController.setSelectedAccount).bind(keyringController),
|
||||
saveAccountLabel: nodeify(keyringController.saveAccountLabel).bind(keyringController),
|
||||
exportAccount: nodeify(keyringController.exportAccount).bind(keyringController),
|
||||
|
@ -75,6 +75,7 @@
|
||||
"polyfill-crypto.getrandomvalues": "^1.0.0",
|
||||
"post-message-stream": "^1.0.0",
|
||||
"promise-filter": "^1.1.0",
|
||||
"promise-to-callback": "^1.0.0",
|
||||
"pumpify": "^1.3.4",
|
||||
"qrcode-npm": "0.0.3",
|
||||
"react": "^15.0.2",
|
||||
|
@ -270,8 +270,8 @@ function navigateToNewAccountScreen() {
|
||||
}
|
||||
}
|
||||
|
||||
function addNewAccount (ringNumber = 0) {
|
||||
return callBackgroundThenUpdate(background.addNewAccount, ringNumber)
|
||||
function addNewAccount () {
|
||||
return callBackgroundThenUpdate(background.addNewAccount)
|
||||
}
|
||||
|
||||
function showInfoPage () {
|
||||
|
Loading…
Reference in New Issue
Block a user