Skip to content

fix: buy flow quote loading and provider selection#28373

Merged
imyugioh merged 6 commits into
mainfrom
fix/provider-selection-supporting-token
Apr 4, 2026
Merged

fix: buy flow quote loading and provider selection#28373
imyugioh merged 6 commits into
mainfrom
fix/provider-selection-supporting-token

Conversation

@amitabh94

@amitabh94 amitabh94 commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

Description

Quotes felt slow to load on Buy (Continue / amount screen loading, modals sluggish) partly because every quote path passed forceRefresh: true and React Query used staleTime: 0, so getQuotes almost always bypassed the ramps controller cache (15s TTL) even when token, amount, provider, and payment method were unchanged.

This PR sets RAMPS_QUOTES_STALE_TIME_MS (15s) on the quotes query—aligned with RampsController DEFAULT_QUOTES_TTL—and stops passing forceRefresh from Build Quote, provider selection, and payment selection so controller + React Query can reuse responses within that window.

Provider list correctness: The provider selection modal filtered the visible list using only the route assetId. When that param was absent but selectedToken was set, the UI could still show every provider while getQuotes used the token from selectedToken, inflating quote work and mismatching the list vs quotes.

This change uses the same effective asset id as quote fetching (paramAssetId ?? selectedToken?.assetId) to derive displayProviders from supportedCryptoCurrencies, so only providers that support the current asset appear and are included in quote params.

Changelog

CHANGELOG entry: Fixed buy flow provider selection so only providers that support the selected asset are shown; improved quote responsiveness by aligning React Query cache with the ramps quotes TTL (15s) and avoiding unnecessary forceRefresh on each fetch.

Related issues

Fixes: TRAM-3425

Manual testing steps

Feature: Ramp buy flow quotes and provider selection

  Scenario: Provider list matches token support without route asset id
    Given user is in the MetaMask buy flow with a token selected
    When user opens the provider selection screen
    Then only providers that declare support for that token asset id are listed

  Scenario: Quotes reuse cache within a short window when inputs unchanged
    Given user is on Build Quote with token, provider, payment method, and amount set
    When user navigates away and back to the same screen without changing those inputs
    Then quote loading should not repeatedly pay full cold-fetch latency where the 15s cache applies

Screenshots/Recordings

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@amitabh94 amitabh94 self-assigned this Apr 3, 2026
@github-actions

github-actions Bot commented Apr 3, 2026

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 the team-money-movement issues related to Money Movement features label Apr 3, 2026
@github-actions github-actions Bot added the size-S label Apr 3, 2026
@amitabh94 amitabh94 marked this pull request as ready for review April 3, 2026 04:17
@amitabh94 amitabh94 marked this pull request as draft April 3, 2026 04:17
@amitabh94 amitabh94 changed the title fix: filter provider selection modal by supported token fix: buy flow quote loading and provider selection Apr 3, 2026
@github-actions github-actions Bot added size-M and removed size-S labels Apr 3, 2026
- Use effective asset id (route param or selectedToken) for displayProviders
- Aligns listed providers with getQuotes providerIds when route omits assetId
- Add regression test and update snapshot

Made-with: Cursor
Ensure supportedCryptoCurrencies always includes defaultTestAssetId
boolean entries so jest mock matches inferred controller return type.

Made-with: Cursor
- Set React Query staleTime to 15s (RAMPS_QUOTES_STALE_TIME_MS), aligned with
  RampsController DEFAULT_QUOTES_TTL
- Stop passing forceRefresh on BuildQuote, provider, and payment quote fetches
  so controller + RQ can reuse responses within the window
- Update modal and quotes query tests

Made-with: Cursor
Compute executeRequest cache keys like RampsController and compare the
entry timestamp before vs after the sync prelude, instead of diffing the
entire state.requests map (which mislabeled getQuotes when other fetches
updated unrelated keys).

Made-with: Cursor
@amitabh94 amitabh94 force-pushed the fix/provider-selection-supporting-token branch from 2a3088c to 3a11f9b Compare April 3, 2026 16:54
@github-actions github-actions Bot added size-S and removed size-M labels Apr 3, 2026
@amitabh94 amitabh94 marked this pull request as ready for review April 3, 2026 21:15
@amitabh94 amitabh94 requested a review from a team as a code owner April 3, 2026 21:15
@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - draft PR

All E2E tests pre-selected.

View GitHub Actions results

@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

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

@sonarqubecloud

sonarqubecloud Bot commented Apr 3, 2026

Copy link
Copy Markdown

@MetaMask MetaMask deleted a comment from codecov-commenter Apr 3, 2026
@imyugioh imyugioh added this pull request to the merge queue Apr 4, 2026
Merged via the queue into main with commit bcdaa5c Apr 4, 2026
110 checks passed
@imyugioh imyugioh deleted the fix/provider-selection-supporting-token branch April 4, 2026 04:29
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 4, 2026
@metamaskbot metamaskbot added the release-7.74.0 Issue or pull request that will be included in release 7.74.0 label Apr 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.74.0 Issue or pull request that will be included in release 7.74.0 size-S team-money-movement issues related to Money Movement features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants