-
-
Notifications
You must be signed in to change notification settings - Fork 271
feat: Integrate bulk token screening into transaction simulation flow within runAfterSimulateHook #6617
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
…se resultType instead of isMalicious and metadata
…g in PhishingController
…handling in PhishingController
…se more descriptive field names
…o extend TTL and increase max size
…rmat and simplify lookup logic
…ns method signature in PhishingController
…hishingController
…taMask/core into feat/add-token-screening-tx-controller
…d TransactionController
…_ENDPOINT and update related comments for clarity
AugmentedMode
added a commit
that referenced
this pull request
Sep 22, 2025
#6483) ## Explanation This PR extends the **PhishingController** to support bulk token screening with caching, similar to the existing URL scanning functionality. This PR also replaces the `urlScanCache` with a reusable `cacheManager` class that is shared between both `urlScanCache` and now `tokenScanCache` **Changes introduced** - Added a new `bulkScanTokens` method that can screen up to 100 tokens per batch - Implemented a new `cacheManager` class that handles caching logic with a 15-minute TTL. - Replaced `urlScanCache` with `cacheManager`. - Introduced `tokenScanCache` using the same `cacheManager` for consistency and reuse. - Defined cache key format as `${chainId}:${tokenAddress}` for token scans. - Registered `bulkScanTokens` as a controller action under `PhishingControllerBulkScanTokensAction`. - Exported new types for extension consumption and exposed the scanning functionality via the messenger. Screenshot showcasing the `tokenScanCache` is implemented as expected This is grabbed via the extension console using await stateHooks.getPersistedState() after triggering a swap in uniswap. You will notice i was doing a swap for USDC which is the only token address stored in the cache. <img width="548" height="250" alt="Screenshot 2025-09-15 at 10 28 15 AM" src="https://github.com/user-attachments/assets/8b465d07-b4a4-4d55-890e-543d5600931b" /> <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## 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](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
…oller using Immer patches
…plify transaction patch check
cryptotavares
approved these changes
Sep 24, 2025
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
This PR integrates the bulk token screening functionality from the
PhishingControllerinto the TransactionController's transaction simulation workflow. When a transaction simulation completes with received tokens, those tokens are scanned in a fire and forget method.Changes introduced
#bulkScanReceivedTokensmethod that scans tokens received during transaction simulationPhishingController:bulkScanTokensto the TransactionController's allowed actions#afterSimulateworkflow as a fire and forgetScreenshot showcasing the
tokenScanCacheis implemented as expectedThis is grabbed via the extension console using await stateHooks.getPersistedState() after triggering a swap in uniswap. You will notice i was doing a swap for USDC which is the only token address stored in the cache.
References
Checklist