diff options
author | Dan Finlay <dan@danfinlay.com> | 2016-09-11 03:08:27 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2016-09-11 03:08:27 +0800 |
commit | 59fd86383fbf379724c3bcca6da9d5a6192bbcf2 (patch) | |
tree | f85323ae03f1c5c7747e034b8ded08fd9c4d1c0b /app | |
parent | 6763871c416001e19c224b90a99ed7d9ece69158 (diff) | |
download | tangerine-wallet-browser-59fd86383fbf379724c3bcca6da9d5a6192bbcf2.tar tangerine-wallet-browser-59fd86383fbf379724c3bcca6da9d5a6192bbcf2.tar.gz tangerine-wallet-browser-59fd86383fbf379724c3bcca6da9d5a6192bbcf2.tar.bz2 tangerine-wallet-browser-59fd86383fbf379724c3bcca6da9d5a6192bbcf2.tar.lz tangerine-wallet-browser-59fd86383fbf379724c3bcca6da9d5a6192bbcf2.tar.xz tangerine-wallet-browser-59fd86383fbf379724c3bcca6da9d5a6192bbcf2.tar.zst tangerine-wallet-browser-59fd86383fbf379724c3bcca6da9d5a6192bbcf2.zip |
Correctly clear ethStore cache on new vault restore
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/lib/idStore.js | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index d2d37b0f4..69ffd3f72 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -451,7 +451,11 @@ IdentityStore.prototype.tryPassword = function (password, cb) { } IdentityStore.prototype._createIdmgmt = function (password, seedPhrase, entropy, cb) { - const opts = { password } + const opts = { + password, + hdPathString: this.hdPathString, + } + if (seedPhrase) { opts.seedPhrase = seedPhrase } @@ -464,10 +468,7 @@ IdentityStore.prototype._createIdmgmt = function (password, seedPhrase, entropy, keyStore.keyFromPassword(password, (err, derivedKey) => { if (err) return cb(err) - this._ethStore._currentState = { - accounts: {}, - transactions: {}, - } + this.purgeCache() keyStore.addHdDerivationPath(this.hdPathString, derivedKey, {curve: 'secp256k1', purpose: 'sign'}) @@ -486,10 +487,16 @@ IdentityStore.prototype._createIdmgmt = function (password, seedPhrase, entropy, }) } +IdentityStore.prototype.purgeCache = function () { + this._getAddresses().forEach((address) => { + this._ethStore.del(address) + }) +} + IdentityStore.prototype._createFirstWallet = function (derivedKey) { const keyStore = this._keyStore keyStore.setDefaultHdDerivationPath(this.hdPathString) - keyStore.generateNewAddress(derivedKey) + keyStore.generateNewAddress(derivedKey, 1) var addresses = keyStore.getAddresses() this._ethStore.addAccount(addresses[0]) this.configManager.setWallet(keyStore.serialize()) @@ -497,7 +504,9 @@ IdentityStore.prototype._createFirstWallet = function (derivedKey) { // get addresses and normalize address hexString IdentityStore.prototype._getAddresses = function () { - return this._keyStore.getAddresses(this.hdPathString).map((address) => { return '0x' + address }) + return this._keyStore.getAddresses(this.hdPathString).map((address) => { + return ethUtil.addHexPrefix(address) + }) } IdentityStore.prototype._autoFaucet = function () { |