chore: deprecate TokenBalancesController - #9327
Conversation
…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>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
| }); | ||
| }; | ||
|
|
||
| readonly #onTransactionConfirmed = (transactionMeta: { |
There was a problem hiding this comment.
Why did we move this to a separate function instead of keeping it inline as it was?
salimtb
left a comment
There was a problem hiding this comment.
tested and works as expected
|
@cursor get latest and resolve conflicts |
|
Merged latest Merge: Clean auto-merge on Post-merge fix: The changelog entry had landed under Verified locally:
Branch is up to date at |
…n-balances-controller-e12b Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1de2b32. Configure here.
| if (this.#isDeprecated()) { | ||
| this.#enforceDisabledState(); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Polling never resumes after deprecation
Medium Severity
When startPolling runs while isDeprecated() is true, the mixin still registers a polling token but _startPolling returns before starting intervals. A later startPolling with the same input leaves the token set size above one, so _startPolling is never invoked again and polling cannot resume after deprecation ends.
Reviewed by Cursor Bugbot for commit 1de2b32. Configure here.




Explanation
TokenBalancesControlleralready supports an optionalisDeprecatedconstructor callback (added in #9033) so hosts can disable it whenAssetsControllersupersedes legacy balance state under theassets-unify-statefeature 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/_startPollingupdateChainPollingConfigsTransactionController:transactionConfirmedWhen
isDeprecated()returnstrue, these paths now call#enforceDisabledState()and return early, matching the behavior ofupdateBalances,_executePoll, and the other messenger-driven handlers.References
Manual testing steps
N/A — behavior-preserving unless
isDeprecated()returnstrue.Screenshots/Recordings
N/A
Changed files
packages/assets-controllers/src/TokenBalancesController.ts_startPolling,updateChainPollingConfigs, and#onTransactionConfirmedwithisDeprecatedpackages/assets-controllers/src/TokenBalancesController.test.tsyarn workspace @metamask/assets-controllers run jest --no-coverage src/TokenBalancesController.test.ts -t "isDeprecated"packages/assets-controllers/CHANGELOG.mdisDeprecatedentry pointsyarn validate:changelogChecklist