Skip to content

chore(assets-controllers): add isDeprecated to TokenDetectionController#9362

Draft
Prithpal-Sooriya wants to merge 3 commits into
mainfrom
cursor/deprecate-token-detection-controller-553e
Draft

chore(assets-controllers): add isDeprecated to TokenDetectionController#9362
Prithpal-Sooriya wants to merge 3 commits into
mainfrom
cursor/deprecate-token-detection-controller-553e

Conversation

@Prithpal-Sooriya

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

Copy link
Copy Markdown
Contributor

Explanation

As part of the assets-unify-state rollout, AssetsController supersedes legacy per-chain controllers. TokenDetectionController needs the same opt-out mechanism already added to TokenListController, TokensController, TokenBalancesController, and related controllers.

This PR adds an optional isDeprecated constructor callback to TokenDetectionController. When it returns true, the controller stops polling, blocks network activity, and becomes a no-op at every entry point (start, detectTokens, _executePoll, addDetectedTokensViaWs, and addDetectedTokensViaPolling). The callback is re-evaluated on each entry point so hosts can toggle deprecation at runtime without reconstructing the controller.

References

Manual testing steps

N/A — behavior-preserving when isDeprecated is omitted (defaults to false).

Screenshots/Recordings

N/A

Changed files

File Change Verification
packages/assets-controllers/src/TokenDetectionController.ts Added isDeprecated option and #enforceDisabledState() guards on all detection entry points yarn eslint on changed files
packages/assets-controllers/src/TokenDetectionController.test.ts Added isDeprecated test suite (9 cases) yarn workspace @metamask/assets-controllers run jest --no-coverage packages/assets-controllers/src/TokenDetectionController.test.ts -t "isDeprecated"
packages/assets-controllers/CHANGELOG.md Documented new isDeprecated option under Unreleased Pending PR number for link

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 

cursoragent and others added 2 commits July 2, 2026 08:06
Add an optional isDeprecated constructor callback so hosts can disable
token detection when AssetsController supersedes this controller via the
assets-unify-state feature flag. When deprecated, polling is stopped and
all detection entry points become no-ops without tearing down the
controller.

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

Co-authored-by: Prithpal Sooriya <prithpal.sooriya@gmail.com>
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.

2 participants