aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-10-19 02:13:14 +0800
committerDan Finlay <dan@danfinlay.com>2017-10-19 02:13:14 +0800
commit7032edf32b43e94a7f58c7bcb068da63fa6bda1b (patch)
treec90ea91a193ee731ac4fea16efd6c1874feeaf73 /app/scripts
parentcafabf914fe813d54b6eed78554b4f81f555f5ca (diff)
downloadtangerine-wallet-browser-7032edf32b43e94a7f58c7bcb068da63fa6bda1b.tar
tangerine-wallet-browser-7032edf32b43e94a7f58c7bcb068da63fa6bda1b.tar.gz
tangerine-wallet-browser-7032edf32b43e94a7f58c7bcb068da63fa6bda1b.tar.bz2
tangerine-wallet-browser-7032edf32b43e94a7f58c7bcb068da63fa6bda1b.tar.lz
tangerine-wallet-browser-7032edf32b43e94a7f58c7bcb068da63fa6bda1b.tar.xz
tangerine-wallet-browser-7032edf32b43e94a7f58c7bcb068da63fa6bda1b.tar.zst
tangerine-wallet-browser-7032edf32b43e94a7f58c7bcb068da63fa6bda1b.zip
Stop tracking old account balances after restore vault
Per @kgserrano note
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/metamask-controller.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 4b11f6024..b6a3749e4 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -459,17 +459,30 @@ module.exports = class MetamaskController extends EventEmitter {
//
async createNewVaultAndKeychain (password, cb) {
+ this.forgetOldAccounts()
const vault = await this.keyringController.createNewVaultAndKeychain(password)
this.selectFirstIdentity(vault)
return vault
}
async createNewVaultAndRestore (password, seed, cb) {
+ this.forgetOldAccounts()
const vault = await this.keyringController.createNewVaultAndRestore(password, seed)
this.selectFirstIdentity(vault)
return vault
}
+ forgetOldAccounts () {
+ const { accountTracker } = this
+ let oldAccounts = []
+ try {
+ oldAccounts = Object.keys(accountTracker.store.getState().accounts)
+ } catch (e) {
+ log.warn('Could not load old accounts to forget', e)
+ }
+ oldAccounts.forEach(addr => accountTracker.removeAccount(addr))
+ }
+
selectFirstIdentity (vault) {
const { identities } = vault
const address = Object.keys(identities)[0]