Skip to content

chore: deprecate TokenBalancesController#9327

Open
Prithpal-Sooriya wants to merge 3 commits into
mainfrom
cursor/deprecate-token-balances-controller-e12b
Open

chore: deprecate TokenBalancesController#9327
Prithpal-Sooriya wants to merge 3 commits into
mainfrom
cursor/deprecate-token-balances-controller-e12b

Conversation

@Prithpal-Sooriya

@Prithpal-Sooriya Prithpal-Sooriya commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Explanation

TokenBalancesController already supports an optional isDeprecated constructor callback (added in #9033) so hosts can disable it when AssetsController supersedes legacy balance state under the assets-unify-state feature flag.

This PR completes deprecation coverage on the remaining entry points that could still start polling or schedule balance fetches after the flag toggles at runtime:

  • startPolling / _startPolling
  • updateChainPollingConfigs
  • TransactionController:transactionConfirmed

When isDeprecated() returns true, these paths now call #enforceDisabledState() and return early, matching the behavior of updateBalances, _executePoll, and the other messenger-driven handlers.

References

Manual testing steps

N/A — behavior-preserving unless isDeprecated() returns true.

Screenshots/Recordings

N/A

Changed files

File Change Verification
packages/assets-controllers/src/TokenBalancesController.ts Guard _startPolling, updateChainPollingConfigs, and #onTransactionConfirmed with isDeprecated ESLint
packages/assets-controllers/src/TokenBalancesController.test.ts Add 3 runtime-toggle tests for the new entry points yarn workspace @metamask/assets-controllers run jest --no-coverage src/TokenBalancesController.test.ts -t "isDeprecated"
packages/assets-controllers/CHANGELOG.md Document extended isDeprecated entry points yarn validate:changelog

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them
Open in Web Open in Cursor 

…oints

When isDeprecated() returns true, skip startPolling,
updateChainPollingConfigs, and TransactionController:transactionConfirmed
handlers while clearing stale tokenBalances. Adds unit tests for the
runtime-toggle behavior on these entry points.

Ticket: ASSETS-3335

Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
cursoragent and others added 2 commits July 1, 2026 08:08
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
@Prithpal-Sooriya Prithpal-Sooriya marked this pull request as ready for review July 1, 2026 08:54
@Prithpal-Sooriya Prithpal-Sooriya requested review from a team as code owners July 1, 2026 08:54
});
};

readonly #onTransactionConfirmed = (transactionMeta: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we move this to a separate function instead of keeping it inline as it was?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants