1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Clear AccountTracker accounts and CachedBalances on createNewVaultAndRestore (#9023)

This commit is contained in:
Thomas Huang 2020-07-16 19:09:38 -07:00 committed by GitHub
parent 7b2218ac6e
commit f02478e026
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View File

@ -65,6 +65,14 @@ export default class CachedBalancesController {
return balancesToCache
}
/**
* Removes cachedBalances
*/
clearCachedBalances () {
this.store.updateState({ cachedBalances: {} })
}
/**
* Sets up listeners and subscriptions which should trigger an update of cached balances. These updates will
* happen when the current account changes. Which happens on block updates, as well as on network and account

View File

@ -151,6 +151,14 @@ export default class AccountTracker {
this.store.updateState({ accounts })
}
/**
* Removes all addresses and associated balances
*/
clearAccounts () {
this.store.updateState({ accounts: {} })
}
/**
* Given a block, updates this AccountTracker's currentBlockGasLimit, and then updates each local account's balance
* via EthQuery

View File

@ -631,6 +631,12 @@ export default class MetamaskController extends EventEmitter {
// clear permissions
this.permissionsController.clearPermissions()
// clear accounts in accountTracker
this.accountTracker.clearAccounts()
// clear cachedBalances
this.cachedBalancesController.clearCachedBalances()
// clear unapproved transactions
this.txController.txStateManager.clearUnapprovedTxs()