Skip to content

fix(ramps): Refresh providers on app unlock and separate provider list by token support#27958

Merged
imyugioh merged 8 commits into
mainfrom
fix/ramps-3383-payment-methods-query-disabled-for-unknown-tokens
Mar 27, 2026
Merged

fix(ramps): Refresh providers on app unlock and separate provider list by token support#27958
imyugioh merged 8 commits into
mainfrom
fix/ramps-3383-payment-methods-query-disabled-for-unknown-tokens

Conversation

@imyugioh

@imyugioh imyugioh commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Description

Fixed a bug where selecting a provider for some token (e.g. MUSD on Linea) would instantly show "No payment methods are available" because the provider's cached supportedCryptoCurrencies map was stale and didn't include the token.

Root cause: The providers data (supportedCryptoCurrencies) was persisted across sessions and only refreshed on region change or fresh install. For tokens added to the backend after the user's last provider cache update, the map wouldn't include the token, causing the payment methods query to be disabled and the "Token Not Available" modal to show — even though the API supports it.

Evidence from reporter's state logs (v7.71.0 build 4173):

  • MUSD Linea (eip155:59144/erc20:0xaca92e438df0b2401ff60da7e4337b687a2435da) was NOT IN MAP for all 11 providers
  • Fresh /providers endpoint already includes MUSD Linea for Transak and Mercuryo
  • Providers data was served from stale Redux persist cache

Fix:

  1. queries/providers.ts + useRampsProviders: added a react-query wrapper for getProviders with staleTime: 15min and refetchOnMount: true. Providers (including supportedCryptoCurrencies) are refreshed when data is stale (>15min) and a component using useRampsProviders mounts (e.g. after password unlock or entering the buy flow). On app restart, react-query cache is empty so the first mount always fetches fresh data. The query calls getProviders(regionCode, { forceRefresh: true }) to bypass the controller's internal cache.
  2. ProviderSelectionModal: skip quotes fetch when selectedPaymentMethod is null (prevents API error "Payment methods are required"), and set showQuotes=false so no "No providers available" error is shown
  3. ProviderSelection: when quotes are not available, fall back to separating providers by supportedCryptoCurrencies — supported tokens on top, others under "Other options"

Companion fix in core: George's feat: removes provider and token persistence in ramps controller (#8307) sets persist: false for providers and tokens so stale data won't survive across app restarts. The react-query refresh complements this by also catching stale data within long-running sessions.

Changelog

CHANGELOG entry: Fixed payment methods and provider availability for newly added tokens by refreshing providers via react-query (15min TTL) on mount and separating the provider list by token support

Related issues

Fixes: TRAM-3383

Manual testing steps

Feature: Payment methods load for tokens missing from supportedCryptoCurrencies

  Scenario: providers are refreshed when stale on mount
    Given the app has provider data older than 15 minutes
    When the user enters the buy flow or unlocks the app (component mounts)
    Then providers data should be refetched from the API via react-query
    And supportedCryptoCurrencies should be up to date

  Scenario: providers are always fresh after app restart
    Given the user restarts the app (react-query cache is empty)
    When the user enters the password and the app loads
    Then providers data should be fetched fresh from the API
    And supportedCryptoCurrencies should include newly added tokens

  Scenario: user opens change provider when no payment method is selected
    Given user is on the Buy screen with a provider that does not support the selected token
    And no payment method is selected (selectedPaymentMethod is null)

    When user taps "Change provider"
    Then the provider list should show supported providers at the top
    And unsupported providers should appear under "Other options" separator
    And no "No providers available" error should be shown

Screenshots/Recordings

Before

ScreenRecording_03-25-2026.08-46-14_1.1.MP4

After

Payment methods query fires and returns results from the API.

Screen.Recording.2026-03-26.mp4
Screen.Recording.2026-03-26.063000.mp4

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.

Note

Medium Risk
Medium risk due to new react-query-driven provider refetching and conditional quote fetching logic that can change network request patterns and provider ordering in the buy flow.

Overview
Prevents stale supportedCryptoCurrencies from breaking buy flows by adding a react-query providers query (15min staleTime, refetchOnMount, forceRefresh) and wiring it into useRampsProviders (triggered when regionCode is available).

Tightens “token unavailable” and provider selection behavior: BuildQuote now treats missing entries in supportedCryptoCurrencies as unsupported, ProviderSelectionModal skips quote fetching and disables quote UI when selectedPaymentMethod is null, and ProviderSelection groups providers into supported vs unsupported (with an “Other options” separator) when quotes aren’t shown/available.

Adds/updates unit tests for the new query options, provider grouping, quote-fetch gating, and the token-unavailable edge case.

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

@imyugioh imyugioh self-assigned this Mar 26, 2026
@imyugioh imyugioh added the team-money-movement issues related to Money Movement features label Mar 26, 2026
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk size-S labels Mar 26, 2026
Comment thread app/components/UI/Ramp/hooks/useRampsPaymentMethods.ts Outdated
@imyugioh imyugioh requested a review from a team as a code owner March 26, 2026 05:19
@github-actions github-actions Bot added size-M and removed size-S labels Mar 26, 2026
@imyugioh imyugioh changed the title fix(ramps): Allow payment methods query for tokens missing from supportedCryptoCurrencies fix(ramps): Allow payment methods query for tokens missing from supportedCryptoCurrencies -> cp-7.71.0 Mar 26, 2026
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 26, 2026
pkowalski
pkowalski previously approved these changes Mar 26, 2026
@pkowalski

Copy link
Copy Markdown
Contributor

I approved as it looks to make sense and the videos look good though I lack 100% context. Would be good to have a sanity check by George or Pedro

Comment thread app/components/UI/Ramp/Views/Modals/ProviderSelectionModal/ProviderSelection.tsx Outdated
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 26, 2026
@imyugioh imyugioh requested review from pkowalski and wachunei March 26, 2026 13:19
@wachunei

Copy link
Copy Markdown
Member

BuildQuote component: changed !supportedCryptoCurrencies[assetId] to === false so the "Token Not Available" modal only triggers for explicitly unsupported tokens, not missing/unknown ones

isn't this a weird check to make, what is the API convention here? In my opinion the only case for the asset to be supported is when supportedCryptoCurrencies[assetId] is true, al other cases (false, undefined) mean it is not true, why would we not show the unsupported modal for missing or unknown, those are meant to be falsy.

@wachunei wachunei changed the title fix(ramps): Allow payment methods query for tokens missing from supportedCryptoCurrencies -> cp-7.71.0 fix(ramps): Allow payment methods query for tokens missing from supportedCryptoCurrencies Mar 26, 2026
@imyugioh

Copy link
Copy Markdown
Contributor Author

BuildQuote component: changed !supportedCryptoCurrencies[assetId] to === false so the "Token Not Available" modal only triggers for explicitly unsupported tokens, not missing/unknown ones

isn't this a weird check to make, what is the API convention here? In my opinion the only case for the asset to be supported is when supportedCryptoCurrencies[assetId] is true, al other cases (false, undefined) mean it is not true, why would we not show the unsupported modal for missing or unknown, those are meant to be falsy.

good @wachunei the reason we can not treat undefined the same as false here is that supportedCryptoCurrencies is a cached map, not a live API response. It comes from the /providers endpoint that was cached and persisted across sessions.

mobile can have the old cached providers, that missed tokens, then /payments, and /quotes endpoints return valid data for it - then that shows immediate "No payment methods" without call the endpoint.

@imyugioh imyugioh requested a review from georgeweiler March 26, 2026 16:29
@github-actions github-actions Bot added risk-high Extensive testing required · High bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 26, 2026
Comment thread app/components/UI/Ramp/Views/BuildQuote/BuildQuote.tsx
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 27, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread app/components/UI/Ramp/queries/providers.test.ts Outdated
@imyugioh imyugioh force-pushed the fix/ramps-3383-payment-methods-query-disabled-for-unknown-tokens branch from c95dee4 to 6b8594c Compare March 27, 2026 05:11
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 27, 2026
@imyugioh imyugioh force-pushed the fix/ramps-3383-payment-methods-query-disabled-for-unknown-tokens branch from 6b8594c to 0118ed1 Compare March 27, 2026 12:03
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 27, 2026
@imyugioh imyugioh requested a review from wachunei March 27, 2026 15:00
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 27, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.45455% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.63%. Comparing base (241087f) to head (c8bef12).
⚠️ Report is 81 commits behind head on main.

Files with missing lines Patch % Lines
app/components/UI/Ramp/hooks/useRampsProviders.ts 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #27958      +/-   ##
==========================================
+ Coverage   82.59%   82.63%   +0.03%     
==========================================
  Files        4843     4855      +12     
  Lines      124595   125081     +486     
  Branches    27777    27921     +144     
==========================================
+ Hits       102914   103361     +447     
- Misses      14598    14603       +5     
- Partials     7083     7117      +34     

☔ 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.

@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.

@github-actions github-actions Bot removed the risk-medium Moderate testing recommended · Possible bug introduction risk label Mar 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeRamps
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 92%
click to see 🤖 AI reasoning details

E2E Test Selection:
All 13 changed files are exclusively within the Ramp feature (app/components/UI/Ramp/). The changes include:

  1. New providers query (queries/providers.ts): Introduces a react-query-based provider fetching mechanism via RampsController.getProviders() with 15-minute stale time and refetchOnMount: true.
  2. Query index update (queries/index.ts): Exports the new providers query.
  3. useRampsProviders hook update: Now triggers a background provider refresh using react-query when a user region is available, ensuring supportedCryptoCurrencies data is fresh.
  4. BuildQuote.tsx: Minor optional chaining refactor for supportedCryptoCurrencies check - functionally equivalent but cleaner.
  5. ProviderSelectionModal.tsx: Fixed quote fetching to require selectedPaymentMethod before fetching quotes (prevents unnecessary API calls), and updated showQuotes condition to also require selectedPaymentMethod.
  6. ProviderSelection.tsx: Added provider list sorting logic to separate supported vs unsupported providers by supportedCryptoCurrencies when quotes aren't available, with a separator between groups.

These changes directly affect the on-ramp/off-ramp (buy/sell crypto) flows - specifically provider selection, quote fetching conditions, and provider list display. The SmokeRamps tag covers exactly these flows: off-ramp token amount input, region-aware on-ramp flows, payment method availability, and deep link navigation into buy flows.

No other feature areas are affected - there are no changes to shared navigation, Engine, controllers, confirmations, or other wallet features. The changes are self-contained within the Ramp UI components and hooks.

Performance Test Selection:
The changes are confined to the Ramp feature's UI components and data fetching hooks. While react-query is introduced for provider fetching, this is a background data refresh mechanism with a 15-minute stale time and does not affect rendering performance of critical paths like account lists, login, app launch, or swap flows. No performance test tags cover Ramp-specific flows, and the changes don't impact any of the measured performance areas (account list rendering, onboarding, login, swaps, app launch, asset loading, predict markets, or perps).

View GitHub Actions results

@github-actions github-actions Bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Mar 27, 2026

@wachunei wachunei left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. @georgeweiler please review as well so you are aware of this top level request

@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

@imyugioh imyugioh added this pull request to the merge queue Mar 27, 2026
Merged via the queue into main with commit 41350a4 Mar 27, 2026
88 of 90 checks passed
@imyugioh imyugioh deleted the fix/ramps-3383-payment-methods-query-disabled-for-unknown-tokens branch March 27, 2026 16:42
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2026
@metamaskbot metamaskbot added the release-7.73.0 Issue or pull request that will be included in release 7.73.0 label Mar 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.73.0 Issue or pull request that will be included in release 7.73.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-M team-money-movement issues related to Money Movement features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants