fix: prevent false token unavailable errors with RampsController status tracking#27241
fix: prevent false token unavailable errors with RampsController status tracking#27241georgeweiler wants to merge 1 commit intomainfrom
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: No other core controllers (e.g., NetworkController, AccountController), navigation, confirmations system, or shared wallet platform components were modified. The changes appear scoped to ramp flows (amount input, provider/payment method selection, quote building, region selection) and ramps controller state handling. Given this scope, running SmokeRamps is necessary to validate:
No evidence of changes to wallet home entry points, account management, confirmations, multi-chain permissions, or other platform-wide components, so additional tags (e.g., SmokeWalletPlatform, SmokeConfirmations, SmokeAccounts) are not required. The migration introduces some additional risk related to state shape changes, but still within the ramps domain, keeping overall risk medium and scoped to SmokeRamps. Performance Test Selection: |
|
✅ E2E Fixture Validation — Schema is up to date |
Description
Rehosting #26962
This PR fixes false positive "Token Not Available" errors in the Buy flow by leveraging the new status field from RampsController ResourceState. Previously, the component used refs to track loading cycles because the controller's default state ({ data: [], isLoading: false }) was indistinguishable from a completed fetch returning no data.
With the controller now exposing explicit status ('idle' | 'loading' | 'success' | 'error'), we can directly check paymentMethodsStatus === 'success' && paymentMethods.length === 0 to accurately determine token unavailability.
Changelog
CHANGELOG entry: Fixed false "Token Not Available" errors during Buy flow when payment methods are still loading
Related issues
Fixes: (original issue reference)
Depends on:
MetaMask/core#8158
Manual testing steps
Screenshots/Recordings
Before
False positive "Token Not Available" error appeared immediately when payment methods were still loading.
After
"Token Not Available" only appears after payment methods fetch completes with empty results.
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2026-03-05.at.10.41.16.mov
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Modifies Buy flow navigation conditions and adds a persisted-state migration for
RampsControllerresources, so mistakes could cause incorrect modals or migration edge-case regressions on upgrade.Overview
Prevents premature navigation to
RampTokenNotAvailableModalinBuildQuoteby introducingtokenStateIsSettledgating and checkingpaymentMethodsStatus === RequestStatus.SUCCESS && paymentMethods.length === 0(in addition to the provider’ssupportedCryptoCurrenciesmetadata).Plumbs a new
statusfield through ramps hooks (useRampsPaymentMethods/useRampsController) and updates ramps selectors to default/tolerate missingstatuswhile preserving referential equality whenstatusis present.Adds migration
125to backfill missingstatus: 'idle'on persistedRampsControllerResourceStates (including Transak sub-states), updates initial background state fixtures, and expands/adjusts unit tests to cover the new status-based behavior.Written by Cursor Bugbot for commit 0b31108. This will update automatically on new commits. Configure here.