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
|
// Calls the `addAccounts` method on the Keyring
|
||||||
// in the kryings array at index `keyringNum`,
|
// in the kryings array at index `keyringNum`,
|
||||||
// and then saves those changes.
|
// and then saves those changes.
|
||||||
addNewAccount (keyRingNum = 0) {
|
addNewAccount (selectedKeyring) {
|
||||||
const ring = this.keyrings[keyRingNum]
|
return selectedKeyring.addAccounts(1)
|
||||||
return ring.addAccounts(1)
|
|
||||||
.then(this.setupAccounts.bind(this))
|
.then(this.setupAccounts.bind(this))
|
||||||
.then(this.persistAllKeyrings.bind(this))
|
.then(this.persistAllKeyrings.bind(this))
|
||||||
.then(this.fullUpdate.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)
|
return this.keyringTypes.find(kr => kr.type === type)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getKeyringsByType (type) {
|
||||||
|
return this.keyrings.filter((keyring) => keyring.type === type)
|
||||||
|
}
|
||||||
|
|
||||||
// Get Accounts
|
// Get Accounts
|
||||||
// returns Promise( @Array[ @string accounts ] )
|
// returns Promise( @Array[ @string accounts ] )
|
||||||
//
|
//
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const EventEmitter = require('events')
|
const EventEmitter = require('events')
|
||||||
const extend = require('xtend')
|
const extend = require('xtend')
|
||||||
|
const promiseToCallback = require('promise-to-callback')
|
||||||
const EthStore = require('./lib/eth-store')
|
const EthStore = require('./lib/eth-store')
|
||||||
const MetaMaskProvider = require('web3-provider-engine/zero.js')
|
const MetaMaskProvider = require('web3-provider-engine/zero.js')
|
||||||
const KeyringController = require('./keyring-controller')
|
const KeyringController = require('./keyring-controller')
|
||||||
@ -121,7 +122,11 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
.then((newState) => { cb(null, newState) })
|
.then((newState) => { cb(null, newState) })
|
||||||
.catch((reason) => { cb(reason) })
|
.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),
|
setSelectedAccount: nodeify(keyringController.setSelectedAccount).bind(keyringController),
|
||||||
saveAccountLabel: nodeify(keyringController.saveAccountLabel).bind(keyringController),
|
saveAccountLabel: nodeify(keyringController.saveAccountLabel).bind(keyringController),
|
||||||
exportAccount: nodeify(keyringController.exportAccount).bind(keyringController),
|
exportAccount: nodeify(keyringController.exportAccount).bind(keyringController),
|
||||||
|
@ -75,6 +75,7 @@
|
|||||||
"polyfill-crypto.getrandomvalues": "^1.0.0",
|
"polyfill-crypto.getrandomvalues": "^1.0.0",
|
||||||
"post-message-stream": "^1.0.0",
|
"post-message-stream": "^1.0.0",
|
||||||
"promise-filter": "^1.1.0",
|
"promise-filter": "^1.1.0",
|
||||||
|
"promise-to-callback": "^1.0.0",
|
||||||
"pumpify": "^1.3.4",
|
"pumpify": "^1.3.4",
|
||||||
"qrcode-npm": "0.0.3",
|
"qrcode-npm": "0.0.3",
|
||||||
"react": "^15.0.2",
|
"react": "^15.0.2",
|
||||||
|
@ -270,8 +270,8 @@ function navigateToNewAccountScreen() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function addNewAccount (ringNumber = 0) {
|
function addNewAccount () {
|
||||||
return callBackgroundThenUpdate(background.addNewAccount, ringNumber)
|
return callBackgroundThenUpdate(background.addNewAccount)
|
||||||
}
|
}
|
||||||
|
|
||||||
function showInfoPage () {
|
function showInfoPage () {
|
||||||
|
Loading…
Reference in New Issue
Block a user