Skip to content

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

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

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

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, legacy asset controllers need an opt-in deprecation path so hosts can disable them when AssetsController supersedes their behavior — without removing the controllers yet.

This PR adds an optional isDeprecated constructor callback to TokenDetectionController, following the same pattern already used by TokensController, CurrencyRateController, TokenListController, and the multichain controllers. When isDeprecated() returns true:

  • Polling is stopped immediately
  • All detection entry points become no-ops (detectTokens, addDetectedTokensViaWs, addDetectedTokensViaPolling, start, _executePoll, and event-driven restarts)
  • The callback is re-evaluated on every entry point so it can be toggled at runtime

This is behavior-preserving when the callback is omitted or returns false (the default).

References

Manual testing steps

N/A — behavior-preserving when isDeprecated is not provided.

Screenshots/Recordings

N/A

Changed files

File Change Verification
packages/assets-controllers/src/TokenDetectionController.ts Added isDeprecated option and guards at all entry points ESLint pass
packages/assets-controllers/src/TokenDetectionController.test.ts Added isDeprecated test suite (9 tests) yarn workspace @metamask/assets-controllers run jest --no-coverage packages/assets-controllers/src/TokenDetectionController.test.ts -t "isDeprecated" — all pass
packages/assets-controllers/CHANGELOG.md Added Unreleased entry Reviewed against Keep a Changelog format

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 3 commits July 2, 2026 08:07
Add an optional isDeprecated constructor callback so hosts can disable
token detection when assets-unify-state supersedes this controller. When
true, polling stops and all detection entry points become no-ops.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants