perf: Speed up the creation of the token list for Predict withdraw#27735
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
3abe8c1 to
1cc14e8
Compare
1cc14e8 to
c146b59
Compare
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
c146b59 to
b8e1cc7
Compare
|
✅ E2E Fixture Validation — Schema is up to date |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
SmokeConfirmations: Directly required - SmokePredictions: The SmokeWalletPlatform: Required per SmokePredictions tag description - Predictions is a section inside the Trending tab (SmokeWalletPlatform), so changes to Predictions flows affect Trending. The changes are a refactor with the same intended behavior but different implementation. Risk is medium because incorrect token filtering could silently show wrong tokens or no tokens in send/withdraw flows. Performance Test Selection: |
|



Description
This speeds up the withdraw token-selection path by moving the allowlist filter earlier in the pipeline.
Before this change, withdraw flows loaded the full token catalog, built
AssetTypes for all matching catalog entries, sorted the full result, and only then filtered down to the small allowlisted set we actually care about. This change adds atokenFilterhook parameter souseAccountTokenscan skip irrelevant catalog entries before building them, anduseWithdrawTokenFilterpasses the withdraw allowlist down to that lower-level loop.It also keeps the existing post-filter in place for correctness, so allowlisted tokens already owned by the user and native-token address mapping still work as before.
Local dev measurements while opening Predict Withdraw:
useAccountTokensThis brings the measured token-loading path from roughly
~1.05sdown to~44ms(~24xfaster).Changelog
CHANGELOG entry: Improved performance when loading Predict withdraw token selection
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/CONF-1054
Manual testing steps
Note
Medium Risk
Medium risk because it changes how withdraw token lists are constructed and filtered, which could inadvertently hide valid tokens if chainId/address normalization or
assetIdhandling is wrong. Scope is limited to token-selection hooks and is covered by updated/added unit tests.Overview
Speeds up Predict Withdraw token selection by pushing the withdraw allowlist filter down into token collection, avoiding building/sorting the full token catalog before narrowing to allowlisted entries.
This introduces an optional
tokenFilter(chainId, address)plumbed fromuseWithdrawTokenFilter→useSendTokens→useAccountTokens, and replaces the previous post-filtering inuseWithdrawTokenFilterwith a precomputed allowlist lookup that also maps zero-address entries to chain-specific native token addresses.Tests are updated to assert
useSendTokensis called with the new filtering options and to validatetokenFilterbehavior (case-insensitive matching, chain gating, and native-token mapping), plus newuseAccountTokenscoverage ensuring both owned assets and catalog token building respecttokenFilter.Written by Cursor Bugbot for commit b8e1cc7. This will update automatically on new commits. Configure here.