aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/scripts/keyrings/hd.js4
-rw-r--r--app/scripts/lib/config-manager.js3
-rw-r--r--app/scripts/lib/idStore-migrator.js18
-rw-r--r--package.json1
-rw-r--r--test/unit/idStore-migration-test.js1
5 files changed, 13 insertions, 14 deletions
diff --git a/app/scripts/keyrings/hd.js b/app/scripts/keyrings/hd.js
index 097d995a7..80b713b58 100644
--- a/app/scripts/keyrings/hd.js
+++ b/app/scripts/keyrings/hd.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)
}
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js
index efc0b4628..d36ccf0db 100644
--- a/app/scripts/lib/config-manager.js
+++ b/app/scripts/lib/config-manager.js
@@ -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 || []
}
-
diff --git a/app/scripts/lib/idStore-migrator.js b/app/scripts/lib/idStore-migrator.js
index 14bd0d8b8..2e9418376 100644
--- a/app/scripts/lib/idStore-migrator.js
+++ b/app/scripts/lib/idStore-migrator.js
@@ -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) => {
diff --git a/package.json b/package.json
index 683938aad..3a62ae59e 100644
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/test/unit/idStore-migration-test.js b/test/unit/idStore-migration-test.js
index 2ea5cc36f..66dd4683d 100644
--- a/test/unit/idStore-migration-test.js
+++ b/test/unit/idStore-migration-test.js
@@ -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')
})
})