feat: require messenger and Blockaid bulk scan in TokenDataSource#8329
Open
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?
| "@metamask/network-controller": "^30.0.1", | ||
| "@metamask/network-enablement-controller": "^5.0.1", | ||
| "@metamask/permission-controller": "^12.3.0", | ||
| "@metamask/phishing-controller": "^17.1.0", |
Contributor
There was a problem hiding this comment.
Nit: Should we also update tsconfig.json and tsconfig.build.json
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
Introduces a new dependency on
PhishingController:bulkScanTokensand changesTokenDataSourceconstruction/signature, which can break consumers and affects which tokens are persisted in balances/metadata if the scan or chain-mapping is incorrect.Overview
Token metadata enrichment now performs a Blockaid malicious-token screen.
TokenDataSourcebatches detected token addresses and callsPhishingController:bulkScanTokens, removing assets flagged malicious (and pruning them fromassetsInfo,assetsBalance, anddetectedAssets) before merging Tokens API v3 metadata; the previous minimum-occurrencesspam heuristic was removed.Breaking wiring changes:
TokenDataSourcenow requires the sharedAssetsControllerMessengervia a(messenger, options)constructor,AssetsControlleraddsPhishingControllerBulkScanTokensActionto its allowed actions and passes its messenger through, and@metamask/phishing-controlleris added as a dependency. Public root exports were also trimmed to stop re-exporting various*AllowedActions/*AllowedEventstypes (includingTokenDataSourceAllowedActions), and tests were updated accordingly.Written by Cursor Bugbot for commit 5231be9. This will update automatically on new commits. Configure here.