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

Move the assumption of their only being one hd keyring when requesting seed words to metamaskController

This commit is contained in:
Frankie 2017-01-24 12:28:05 -08:00
parent 8642ced310
commit 48ffea0142
2 changed files with 8 additions and 7 deletions

View File

@ -171,11 +171,8 @@ module.exports = class KeyringController extends EventEmitter {
// //
// Used when creating a first vault, to allow confirmation. // Used when creating a first vault, to allow confirmation.
// Also used when revealing the seed words in the confirmation view. // Also used when revealing the seed words in the confirmation view.
placeSeedWords () { placeSeedWords (selectedKeyring) {
const hdKeyrings = this.keyrings.filter((keyring) => keyring.type === 'HD Key Tree') return selectedKeyring.serialize()
const firstKeyring = hdKeyrings[0]
if (!firstKeyring) throw new Error('KeyringController - No HD Key Tree found')
return firstKeyring.serialize()
.then((serialized) => { .then((serialized) => {
const seedWords = serialized.mnemonic const seedWords = serialized.mnemonic
this.configManager.setSeedWords(seedWords) this.configManager.setSeedWords(seedWords)
@ -436,7 +433,7 @@ module.exports = class KeyringController extends EventEmitter {
this.emit('newAccount', hexAccount) this.emit('newAccount', hexAccount)
return this.setupAccounts(accounts) return this.setupAccounts(accounts)
}).then(() => { }).then(() => {
return this.placeSeedWords() return this.placeSeedWords(this.getKeyringsByType('HD Key Tree')[0])
}) })
.then(this.persistAllKeyrings.bind(this)) .then(this.persistAllKeyrings.bind(this))
} }

View File

@ -107,7 +107,11 @@ module.exports = class MetamaskController extends EventEmitter {
// forward directly to keyringController // forward directly to keyringController
createNewVaultAndKeychain: nodeify(keyringController.createNewVaultAndKeychain).bind(keyringController), createNewVaultAndKeychain: nodeify(keyringController.createNewVaultAndKeychain).bind(keyringController),
createNewVaultAndRestore: nodeify(keyringController.createNewVaultAndRestore).bind(keyringController), createNewVaultAndRestore: nodeify(keyringController.createNewVaultAndRestore).bind(keyringController),
placeSeedWords: nodeify(keyringController.placeSeedWords).bind(keyringController), placeSeedWords: (cb) => {
const primaryKeyring = keyringController.getKeyringsByType('HD Key Tree')[0]
if (!primaryKeyring) return cb(new Error('MetamaskController - No HD Key Tree found'))
promiseToCallback(keyringController.placeSeedWords(primaryKeyring))(cb)
},
clearSeedWordCache: nodeify(keyringController.clearSeedWordCache).bind(keyringController), clearSeedWordCache: nodeify(keyringController.clearSeedWordCache).bind(keyringController),
setLocked: nodeify(keyringController.setLocked).bind(keyringController), setLocked: nodeify(keyringController.setLocked).bind(keyringController),
submitPassword: (password, cb) => { submitPassword: (password, cb) => {