aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/scripts/keyring-controller.js13
-rw-r--r--app/scripts/keyrings/hd.js4
-rw-r--r--app/scripts/lib/idStore-migrator.js22
3 files changed, 8 insertions, 31 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index d0ce16cbb..6a087c918 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -623,16 +623,17 @@ module.exports = class KeyringController extends EventEmitter {
// may be completed without interruption.
migrateOldVaultIfAny (password) {
const shouldMigrate = !!this.configManager.getWallet() && !this.configManager.getVault()
+ if (!shouldMigrate) {
+ return Promise.resolve()
+ }
+
return this.idStoreMigrator.migratedVaultForPassword(password)
.then((result) => {
- console.log('migrator called back with')
- console.dir(result)
- const { serialized, lostAccounts } = result
- console.dir({ serialized, lostAccounts })
- this.configManager.setLostAccounts(lostAccounts)
this.password = password
- if (serialized && shouldMigrate) {
+ if (result && shouldMigrate) {
+ const { serialized, lostAccounts } = result
+ this.configManager.setLostAccounts(lostAccounts)
return this.restoreKeyring(serialized)
.then(keyring => keyring.getAccounts())
.then((accounts) => {
diff --git a/app/scripts/keyrings/hd.js b/app/scripts/keyrings/hd.js
index 55c008601..097d995a7 100644
--- a/app/scripts/keyrings/hd.js
+++ b/app/scripts/keyrings/hd.js
@@ -38,7 +38,6 @@ class HdKeyring extends EventEmitter {
}
if ('numberOfAccounts' in opts) {
- console.log('number of accounts detected, adding accounts.')
return this.addAccounts(opts.numberOfAccounts)
}
@@ -49,7 +48,6 @@ class HdKeyring extends EventEmitter {
if (!this.root) {
this._initFromMnemonic(bip39.generateMnemonic())
}
- console.log('attempting to add %s accounts', numberOfAccounts)
const oldLen = this.wallets.length
const newWallets = []
@@ -59,9 +57,7 @@ class HdKeyring extends EventEmitter {
newWallets.push(wallet)
this.wallets.push(wallet)
}
- console.log('hd has %s wallets', this.wallets.length)
const hexWallets = newWallets.map(w => w.getAddress().toString('hex'))
- console.log('hd calling back w promise of hex wallets ' + hexWallets)
return Promise.resolve(hexWallets)
}
diff --git a/app/scripts/lib/idStore-migrator.js b/app/scripts/lib/idStore-migrator.js
index c13015b96..14bd0d8b8 100644
--- a/app/scripts/lib/idStore-migrator.js
+++ b/app/scripts/lib/idStore-migrator.js
@@ -14,31 +14,21 @@ module.exports = class IdentityStoreMigrator {
}
migratedVaultForPassword (password) {
- console.log('migrating vault for password')
const hasOldVault = this.hasOldVault()
const configManager = this.configManager
if (!this.idStore) {
- console.log('initializing id store')
this.idStore = new IdentityStore({ configManager })
- console.log('initialized')
}
if (!hasOldVault) {
- console.log('no old vault recognized')
return Promise.resolve(null)
}
- console.log('returning new promise')
return new Promise((resolve, reject) => {
- console.log('submitting password to idStore')
this.idStore.submitPassword(password, (err) => {
- console.log('returned ' + err)
if (err) return reject(err)
- console.log('serializing vault')
const serialized = this.serializeVault()
- console.log('migrated and serialized into')
- console.dir(serialized)
this.checkForErrors(serialized)
.then(resolve)
.catch(reject)
@@ -57,16 +47,9 @@ module.exports = class IdentityStoreMigrator {
}
checkForErrors (serialized) {
- console.log('checking for errors, first making hd wallet')
const hd = new HdKeyring()
- return hd.deserialize(serialized)
- .then(() => {
- console.log('deserialized, now getting accounts')
- console.dir(arguments)
- return hd.getAccounts()
- })
+ return hd.deserialize(serialized.data)
.then((hexAccounts) => {
- console.log('hd returned accounts', hexAccounts)
const newAccounts = hexAccounts.map(normalize)
const oldAccounts = this.idStore._getAddresses().map(normalize)
const lostAccounts = oldAccounts.reduce((result, account) => {
@@ -78,9 +61,6 @@ module.exports = class IdentityStoreMigrator {
}
}, [])
- console.log('migrator has')
- console.dir({ newAccounts, oldAccounts, lostAccounts, hexAccounts })
-
return {
serialized,
lostAccounts,