fix: implicit tokens add
Explanation
This PR includes improvements to both the TokenDetectionController and the CurrencyRateController:
✅ Fix for token detection triggering when toggle is off: Token detection should not run when the detection toggle is disabled. However, it was still triggered on user refresh even when the toggle was off. This PR fixes that issue.
✅ Improved handling of detected tokens:
Previously, detected tokens were added to allDetectedTokens and then imported manually through the UI, which was messy and led to performance issues. Now, detected tokens are implicitly added directly to allTokens, simplifying the flow and improving performance.
✅ Behavior adjusted based on basic functionality status:
- When basic functionality is disabled, token detection now uses direct RPC calls.
- When basic functionality is disabled, requests to CryptoCompare are also disabled to avoid unnecessary calls.
References
Changelog
@metamask/assets-controllers
UPDATE: Improve TokenDetectionController and CurrencyRateController behavior to respect feature toggles and reduce unnecessary operations.
- Prevent
TokenDetectionControllerfrom running when the detection toggle is off, including during user refresh. - Automatically add detected tokens to
allTokensinstead of routing them throughallDetectedTokensand UI import, streamlining the flow and improving performance. - Fall back to direct RPC-based token detection when basic functionality is disabled.
- Skip CryptoCompare requests entirely when basic functionality is turned off to reduce external dependencies.
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, highlighting breaking changes as necessary
- [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes