Skip to content

perf: Avoid full token catalog for non-withdraw flows#27728

Merged
dan437 merged 1 commit into
mainfrom
withdraw-perf-update
Mar 20, 2026
Merged

perf: Avoid full token catalog for non-withdraw flows#27728
dan437 merged 1 commit into
mainfrom
withdraw-perf-update

Conversation

@dan437

@dan437 dan437 commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Description

Avoids full token catalog for non-withdraw flows.

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/CONF-1067

Manual testing steps

  1. Predict and Perps deposit pages load faster now

Note

Low Risk
Low risk: this only changes when useSendTokens loads the full token catalog, and is gated to withdraw flows with an allowlist; main risk is missing allowlisted tokens if the gating condition is wrong.

Overview
Improves token list performance for non-withdraw flows by avoiding loading the full token catalog via useSendTokens unless the current transaction is a pay-withdraw and a withdraw allowlist (config.tokens) is configured.

Updates useWithdrawTokenFilter to conditionally enable includeNoBalance/includeAllTokens, and extends tests to assert the new useSendTokens call behavior (including clearing mocks between cases).

Written by Cursor Bugbot for commit 82a19fc. This will update automatically on new commits. Configure here.

Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
@dan437 dan437 requested a review from a team as a code owner March 20, 2026 10:37
@github-actions

Copy link
Copy Markdown
Contributor

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.

@metamaskbot metamaskbot added team-confirmations Push issues to confirmations team INVALID-PR-TEMPLATE PR's body doesn't match template labels Mar 20, 2026
@github-actions github-actions Bot added size-S risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePredictions, SmokeConfirmations, SmokeWalletPlatform
  • Selected Performance tags: @PerformancePredict
  • Risk Level: medium
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are in useWithdrawTokenFilter.ts and its test file, located in app/components/Views/confirmations/hooks/pay/.

What changed: The hook now conditionally loads the full token catalog (includeNoBalance/includeAllTokens) only when: (1) it's a withdraw transaction AND (2) an allowlist is present. Previously it always loaded the full catalog. This is both a performance optimization and a correctness fix.

Impact analysis:

  • The hook is used in pay-with-modal and useAutomaticTransactionPayToken, which are part of the Predictions withdraw flow (predictWithdraw transaction type).
  • SmokePredictions: Directly affected - this hook handles the predictWithdraw transaction type. The token filtering logic for prediction withdrawals has changed, and the withdraw flow needs validation.
  • SmokeConfirmations: Required per SmokePredictions tag description ("also select SmokeConfirmations - opening/closing positions are on-chain transactions"). The hook lives in the confirmations directory and affects the pay-with-modal used during confirmation flows.
  • SmokeWalletPlatform: Required per SmokePredictions tag description ("also select SmokeWalletPlatform - Trending section"). Predictions is embedded in the Trending tab.

Risk: Medium - the logic change could affect which tokens appear in the withdraw token selector. If shouldLoadFullTokenCatalog is incorrectly false, users might not see allowlisted tokens with zero balance during withdrawals. The unit tests cover the new cases, but E2E validation of the actual withdraw flow is warranted.

Performance Test Selection:
The change modifies token loading behavior in the predict withdraw flow - it now avoids loading the full token catalog when not needed (optimization). The @PerformancePredict tag covers prediction market flows including deposit/withdraw flows and balance display. While the change is an optimization that should improve performance, it's worth validating that the predict flow performance is not negatively impacted by the conditional logic change.

View GitHub Actions results

@dan437 dan437 enabled auto-merge March 20, 2026 10:41
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.35%. Comparing base (eb832ce) to head (82a19fc).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #27728    +/-   ##
========================================
  Coverage   82.34%   82.35%            
========================================
  Files        4787     4796     +9     
  Lines      123646   123803   +157     
  Branches    27511    27550    +39     
========================================
+ Hits       101822   101962   +140     
- Misses      14779    14785     +6     
- Partials     7045     7056    +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
16 value mismatches detected (expected — fixture represents an existing user).
View details

@dan437 dan437 added this pull request to the merge queue Mar 20, 2026
Merged via the queue into main with commit 5cb34da Mar 20, 2026
125 checks passed
@dan437 dan437 deleted the withdraw-perf-update branch March 20, 2026 11:41
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 20, 2026
@metamaskbot metamaskbot added the release-7.72.0 Issue or pull request that will be included in release 7.72.0 label Mar 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template release-7.72.0 Issue or pull request that will be included in release 7.72.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-S team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants