Made changes according to feedback.

feature/default_network_editable
Dan Finlay 8 years ago
parent 7b9749e30c
commit 20d2204ce6
No known key found for this signature in database
GPG Key ID: 931102F24B36007A
  1. 4
      app/scripts/keyrings/hd.js
  2. 3
      app/scripts/lib/config-manager.js
  3. 16
      app/scripts/lib/idStore-migrator.js
  4. 1
      package.json
  5. 1
      test/unit/idStore-migration-test.js

@ -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 idStore = this.idStore
const submitPassword = denodeify(idStore.submitPassword.bind(idStore))
return submitPassword(password)
.then(() => {
const serialized = this.serializeVault()
this.checkForErrors(serialized)
.then(resolve)
.catch(reject)
})
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…
Cancel
Save