fix: filter low-occurrence websocket tokens before detection - #9803
Merged
Conversation
Enrich AccountActivity (websocket) updates with Token API occurrence counts before DetectionMiddleware so spam airdrops never reach detection, metadata enrichment, or state. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 0e1e41a. Configure here.
Checksum AccountActivity ERC-20 IDs and compare occurrence-filter known-asset lookups case-insensitively so existing holdings are not misclassified as new spam and deleted before they reach state.
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. |
Prithpal-Sooriya
approved these changes
Aug 10, 2026
4 tasks
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.

Enrich AccountActivity (websocket) updates with Token API occurrence counts before DetectionMiddleware so spam airdrops never reach detection, metadata enrichment, or state.
Explanation
References
https://consensyssoftware.atlassian.net/browse/ASSETS-3844
Checklist
Note
Medium Risk
Changes real-time balance ingestion and spam filtering in the assets pipeline; regressions could hide legitimate new tokens or drop balance updates for existing ERC-20 holdings.
Overview
Account-activity (websocket) updates now run occurrence-floor spam filtering before
DetectionMiddlewarewhen basic functionality is on, so low-occurrence airdrops are dropped (balances and stubassetsInfo) before detection, enrichment, pricing, or persistence.TokenDataSource.assetsMiddlewarealso strips stub metadata for assets removed by spam filtering so leftovers cannot “heal” spam on the next update.AccountActivityDataSourcechecksums lower-case ERC-20 CAIP-19 IDs via sharedsafeNormalizeAssetId(also used by custom-asset graduation), fixing mismatches with checksummed state keys that could re-detect known tokens or lose balance updates.occurrenceFilterMiddlewarecompares asset IDs case-insensitively against balances, metadata, and custom assets.Tests and changelog entries cover checksum normalization, pre-detection filtering, metadata stripping, and case-insensitive “known asset” exemptions.
Reviewed by Cursor Bugbot for commit 6131327. Bugbot is set up for automated code reviews on this repo. Configure here.