diff options
author | Dan Finlay <dan@danfinlay.com> | 2016-11-04 02:34:57 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2016-11-04 02:34:57 +0800 |
commit | 9ca3c57339571c43106306a6b4fadcfad40d3c19 (patch) | |
tree | 0ceb65d3107fdf56e24ba2e02dcb3a3e8f4d4985 /app | |
parent | d8a9ae0f079a602ced40e424389eb05317cc276d (diff) | |
download | tangerine-wallet-browser-9ca3c57339571c43106306a6b4fadcfad40d3c19.tar tangerine-wallet-browser-9ca3c57339571c43106306a6b4fadcfad40d3c19.tar.gz tangerine-wallet-browser-9ca3c57339571c43106306a6b4fadcfad40d3c19.tar.bz2 tangerine-wallet-browser-9ca3c57339571c43106306a6b4fadcfad40d3c19.tar.lz tangerine-wallet-browser-9ca3c57339571c43106306a6b4fadcfad40d3c19.tar.xz tangerine-wallet-browser-9ca3c57339571c43106306a6b4fadcfad40d3c19.tar.zst tangerine-wallet-browser-9ca3c57339571c43106306a6b4fadcfad40d3c19.zip |
Fix vault creation bug
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/keyring-controller.js | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js index 3b59c7890..3bc9561e2 100644 --- a/app/scripts/keyring-controller.js +++ b/app/scripts/keyring-controller.js @@ -78,7 +78,7 @@ module.exports = class KeyringController extends EventEmitter { } createNewVaultAndKeychain(password, entropy, cb) { - this.createNewVault(password, entropy, (err, serialized) => { + this.createNewVault(password, entropy, (err) => { if (err) return cb(err) this.createFirstKeyTree(password, cb) }) @@ -107,8 +107,8 @@ module.exports = class KeyringController extends EventEmitter { const firstAccount = accounts[0] const hexAccount = ethUtil.addHexPrefix(firstAccount) this.configManager.setSelectedAccount(hexAccount) - this.setupAccounts(accounts) + this.emit('update') cb(null, this.getState()) }) @@ -127,8 +127,7 @@ module.exports = class KeyringController extends EventEmitter { }) .then((serialized) => { if (serialized && shouldMigrate) { - const accountLength = this.getAccounts().length - const keyring = this.restoreKeyring(accountLength, serialized) + const keyring = this.restoreKeyring(serialized) this.keyrings.push(keyring) this.configManager.setSelectedAccount(keyring.getAccounts()[0]) } @@ -144,12 +143,8 @@ module.exports = class KeyringController extends EventEmitter { configManager.setSalt(salt) return this.migrateAndGetKey(password) - .then((key) => { - cb(null, configManager.getVault()) - }) - .then((encryptedString) => { - const serialized = this.keyrings[0].serialize() - cb(null, serialized) + .then(() => { + cb(null) }) .catch((err) => { cb(err) @@ -160,12 +155,14 @@ module.exports = class KeyringController extends EventEmitter { this.clearKeyrings() this.addNewKeyring('HD Key Tree', {n: 1}, (err) => { const firstKeyring = this.keyrings[0] - const firstAccount = firstKeyring.getAccounts()[0] + const accounts = firstKeyring.getAccounts() + const firstAccount = accounts[0] const hexAccount = ethUtil.addHexPrefix(firstAccount) const seedWords = firstKeyring.serialize().mnemonic - this.configManager.setSelectedAccount(hexAccount) + this.configManager.setSelectedAccount(firstAccount) this.configManager.setSeedWords(seedWords) autoFaucet(hexAccount) + this.setupAccounts(accounts) this.persistAllKeyrings() cb(err, this.getState()) }) @@ -284,7 +281,7 @@ module.exports = class KeyringController extends EventEmitter { const encryptedVault = this.configManager.getVault() return this.encryptor.decryptWithKey(key, encryptedVault) .then((vault) => { - this.keyrings = vault.map(this.restoreKeyring.bind(this, 0)) + this.keyrings = vault.map(this.restoreKeyring.bind(this)) return this.persistAllKeyrings() }) .then(() => { @@ -292,15 +289,14 @@ module.exports = class KeyringController extends EventEmitter { }) } - restoreKeyring(i, serialized) { + restoreKeyring(serialized) { const { type, data } = serialized const Keyring = this.getKeyringClassForType(type) const keyring = new Keyring() keyring.deserialize(data) - keyring.getAccounts().forEach((account) => { - this.loadBalanceAndNickname(account, i) - }) + const accounts = keyring.getAccounts() + this.setupAccounts(accounts) this.keyrings.push(keyring) return keyring |