Skip to content

chore: deprecate TokenBalancesController - #9327

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

chore: deprecate TokenBalancesController#9327
Prithpal-Sooriya wants to merge 5 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?

@salimtb salimtb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

tested and works as expected

@salimtb
salimtb added this pull request to the merge queue Jul 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 11, 2026
@Prithpal-Sooriya

Copy link
Copy Markdown
Contributor Author

@cursor get latest and resolve conflicts

@cursor

cursor Bot commented Jul 20, 2026

Copy link
Copy Markdown

Merged latest main into cursor/deprecate-token-balances-controller-e12b and pushed.

Merge: Clean auto-merge on packages/assets-controllers/CHANGELOG.md; no manual conflict resolution needed.

Post-merge fix: The changelog entry had landed under [109.3.0] instead of [Unreleased] after the merge. Moved it back to [Unreleased] so changelog validation passes.

Verified locally:

  • changelog:validate passes
  • lint:misc:check passes
  • All 15 isDeprecated tests pass

Branch is up to date at d1b59abad.

Open in Web Open in Cursor 

…n-balances-controller-e12b

Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1de2b32. Configure here.

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.

4 participants