mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Made changes according to feedback.
This commit is contained in:
parent
7b9749e30c
commit
20d2204ce6
@ -33,11 +33,11 @@ class HdKeyring extends EventEmitter {
|
||||
this.mnemonic = null
|
||||
this.root = null
|
||||
|
||||
if ('mnemonic' in opts) {
|
||||
if (opts.mnemonic) {
|
||||
this._initFromMnemonic(opts.mnemonic)
|
||||
}
|
||||
|
||||
if ('numberOfAccounts' in opts) {
|
||||
if (opts.numberOfAccounts) {
|
||||
return this.addAccounts(opts.numberOfAccounts)
|
||||
}
|
||||
|
||||
|
@ -441,6 +441,5 @@ ConfigManager.prototype.setLostAccounts = function (lostAccounts) {
|
||||
|
||||
ConfigManager.prototype.getLostAccounts = function () {
|
||||
var data = this.getData()
|
||||
return ('lostAccounts' in data) && data.lostAccounts || []
|
||||
return data.lostAccounts || []
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ const IdentityStore = require('./idStore')
|
||||
const HdKeyring = require('../keyrings/hd')
|
||||
const sigUtil = require('./sig-util')
|
||||
const normalize = sigUtil.normalize
|
||||
const denodeify = require('denodeify')
|
||||
|
||||
module.exports = class IdentityStoreMigrator {
|
||||
|
||||
@ -25,14 +26,13 @@ module.exports = class IdentityStoreMigrator {
|
||||
return Promise.resolve(null)
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
this.idStore.submitPassword(password, (err) => {
|
||||
if (err) return reject(err)
|
||||
const serialized = this.serializeVault()
|
||||
this.checkForErrors(serialized)
|
||||
.then(resolve)
|
||||
.catch(reject)
|
||||
})
|
||||
const idStore = this.idStore
|
||||
const submitPassword = denodeify(idStore.submitPassword.bind(idStore))
|
||||
|
||||
return submitPassword(password)
|
||||
.then(() => {
|
||||
const serialized = this.serializeVault()
|
||||
return this.checkForLostAccounts(serialized)
|
||||
})
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ module.exports = class IdentityStoreMigrator {
|
||||
}
|
||||
}
|
||||
|
||||
checkForErrors (serialized) {
|
||||
checkForLostAccounts (serialized) {
|
||||
const hd = new HdKeyring()
|
||||
return hd.deserialize(serialized.data)
|
||||
.then((hexAccounts) => {
|
||||
|
@ -39,6 +39,7 @@
|
||||
"clone": "^1.0.2",
|
||||
"copy-to-clipboard": "^2.0.0",
|
||||
"debounce": "^1.0.0",
|
||||
"denodeify": "^1.2.1",
|
||||
"dnode": "^1.2.2",
|
||||
"end-of-stream": "^1.1.0",
|
||||
"ensnare": "^1.0.0",
|
||||
|
@ -83,7 +83,6 @@ describe('IdentityStore to KeyringController migration', function() {
|
||||
keyringController.configManager.setWallet('something')
|
||||
const state = keyringController.getState()
|
||||
assert(state.isInitialized, 'old vault counted as initialized.')
|
||||
console.dir(state)
|
||||
assert.equal(state.lostAccounts.length, 0, 'no lost accounts')
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user