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