From 7032edf32b43e94a7f58c7bcb068da63fa6bda1b Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 18 Oct 2017 11:13:14 -0700 Subject: Stop tracking old account balances after restore vault Per @kgserrano note --- app/scripts/metamask-controller.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'app') 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] -- cgit v1.2.3