Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear AccountTracker accounts and CachedBalances on createNewVaultAndRestore #9023

Merged
merged 2 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/scripts/controllers/cached-balances.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions app/scripts/lib/account-tracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down