feat: require messenger and Blockaid bulk scan in TokenDataSource#8329
Merged
feat: require messenger and Blockaid bulk scan in TokenDataSource#8329
Conversation
Contributor
Author
|
@metamaskbot publish-preview |
1 similar comment
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
Contributor
cryptodev-2s
left a comment
There was a problem hiding this comment.
Some minimal suggestions: @metamask/assets-controller now depends on @metamask/phishing-controller.
Could you also update the root dependency graph in the README by running yarn update-readme-content?
Contributor
Author
|
@metamaskbot publish-preview |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
bergarces
approved these changes
Apr 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
Current state and why it changed
TokenDataSourceused a minimum occurrence count (Tokens APIoccurrences) to drop likely spam before merging metadata. That heuristic is coarse: it can hide legitimate low-occurrence tokens and still allow tokens that security scanning flags as malicious.Solution
TokenDataSourcecallsPhishingController:bulkScanTokenson the sharedAssetsControllerMessenger, batches addresses (EVM by hex chain id; non-EVMtokennamespace by chain name, aligned with the multichain pattern), and drops assets whose scan result is malicious. Where scanning doesn’t apply or fails, behavior stays fail-open (keep the asset) as implemented.TokenDataSourcenow takes(messenger, options)with a requiredAssetsControllerMessenger, consistent with other data sources and ensuring the phishing action is wired in production.Non-obvious details
numberToHexfor EVM chain ids must come from@metamask/utils(not@metamask/controller-utils) so the Blockaid path does not throw and accidentally fail open.index—AssetsControllerMethodActionsand data-source*AllowedActions/*AllowedEventswere removed from the root export per repo ESLint/controller guidelines.TokenDataSourceAllowedActionsremains exported fromTokenDataSourceas an explicit alias for messenger wiring.References
Checklist
Note
Medium Risk
Changes token enrichment/filtering behavior and introduces a new cross-controller dependency; incorrect scanning or chain/address mapping could hide legitimate tokens or keep malicious ones (fail-open mitigates availability).
Overview
TokenDataSourcenow requires anAssetsControllerMessengerin its constructor and uses it to callPhishingController:bulkScanTokens(Blockaid) before merging token metadata.The previous spam heuristic (dropping non-native tokens with low
occurrences) is removed; instead, assets reported as malicious are filtered out ofassetsInfo,assetsBalance, anddetectedAssets, while scan failures/non-applicable assets fail open.This PR wires the new action into
AssetsControllerallowed actions, adds@metamask/phishing-controlleras a dependency/TS project reference, updates tests accordingly, and trims root exports to stop re-exporting various*AllowedActions/*AllowedEventstypes.Written by Cursor Bugbot for commit ce9be8b. This will update automatically on new commits. Configure here.