1
0
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:
Dan Finlay 2016-12-19 16:29:44 -08:00
parent 7b9749e30c
commit 20d2204ce6
No known key found for this signature in database
GPG Key ID: 931102F24B36007A
5 changed files with 13 additions and 14 deletions

View File

@ -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)
} }

View File

@ -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 || []
} }

View File

@ -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)
return submitPassword(password)
.then(() => {
const serialized = this.serializeVault() const serialized = this.serializeVault()
this.checkForErrors(serialized) return this.checkForLostAccounts(serialized)
.then(resolve)
.catch(reject)
})
}) })
} }
@ -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) => {

View File

@ -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",

View File

@ -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')
}) })
}) })