chore(runway): cherry-pick feat: normalize assetId for Ramps API & aut provider switch gate fix#29073
Merged
Merged
Conversation
…cp-7.74.0 (#29037) <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> Fixes two issues that prevented non-EVM (Solana) tokens from working in the Buy flow and caused unnecessary friction when switching between tokens: `useRampsPaymentMethods` was blanket-lowercasing `selectedToken.assetId` before passing it to `/payments`, and `BuildQuote` was forwarding the raw controller-state `assetId` into `/quotes`. The blanket lowercase was originally added in #28399 to normalize EVM EIP-55 checksummed hex addresses (which the server stores lowercase), but it mangles CAIP-19 references from namespaces where case is significant — notably Solana (base58 mint addresses). With a lowercased mint, the server's strict-equality crypto filter in `RegionsV2Service` returned zero matches and short-circuited to `payments: []`, so every Solana token appeared to have no payment methods. This PR introduces `normalizeAssetIdForApi` which only lowercases when the CAIP-19 namespace is `eip155:`, preserving case for non-EVM namespaces (`solana`, `bip122`, …). It's wired into both `useRampsPaymentMethods` and BuildQuote's `quoteFetchParams`, so the EVM normalization from #28399 still applies while non-EVM asset IDs pass through verbatim. Wiring `/quotes` symmetrically also closes a latent version of the same EVM bug on the quotes endpoint that #28399 only patched for `/payments`. switching tokens When the selected token wasn't supported by the current provider, the BuildQuote auto-switch effect was gated on `providerAutoSelected` — it only silently switched to a supporting provider if the current provider had been system-picked. A user who had manually chosen (e.g.) Transak and then navigated back to token selection and picked a Solana token got the "Token Not Available" modal even when another provider (e.g. Coinbase) supported the token. The gate is removed. The auto-switch effect now runs whenever `isTokenUnavailable` fires and the modal only appears when **no** provider supports the token. Manual provider picks remain sticky for any token the provider can actually serve, because the effect still early-returns when `!isTokenUnavailable`. CHANGELOG entry: Fixed empty payment methods and false "Token Not Available" modal for Solana and other non-EVM tokens in the Buy flow; a manually-selected provider now silently switches to a supporting provider when the selected token isn't supported, instead of blocking the user with the unavailability modal. Fixes: [TRAM-3463](https://consensyssoftware.atlassian.net/browse/TRAM-3463) ```gherkin Feature: Buy flow supports non-EVM tokens and auto-switches providers Scenario: User buys a Solana token whose mint has mixed-case base58 Given the user is in a region that supports Solana tokens (e.g. us-tx) And the user is on the BuildQuote screen When the user opens token selection and picks dogwifhat (WIF) Then the BuildQuote screen loads payment methods successfully And the "Token Not Available" modal does not appear Scenario: Manually-selected provider stays when it supports the token Given the user has manually selected Transak in the provider picker And the currently selected token is USDC on Ethereum When the user navigates away and comes back to BuildQuote Then Transak remains selected And payment methods load normally Scenario: Manually-selected provider silently switches when it cannot serve the token Given the user has manually selected Transak in the provider picker And Transak supports the current token And Coinbase is also available in the region and supports Solana WIF When the user opens token selection and picks Solana WIF Then the provider silently switches from Transak to Coinbase And payment methods for Coinbase load on the BuildQuote screen And the "Token Not Available" modal does not appear Scenario: Modal still appears when no provider supports the token Given the user is on BuildQuote with any provider selected And no available provider supports the chosen token When payment methods settle with an empty result Then the "Token Not Available" modal appears after the 600ms debounce And the user can tap "Change token" or "Change provider" Scenario: EVM checksummed assetId still resolves correctly (regression guard) Given the user is in us-tx with Transak selected And the controller emits USDC as an EIP-55 checksummed assetId When the user lands on BuildQuote with USDC selected Then payment methods load and the /payments request carries the assetId in lowercase hex And the "Token Not Available" modal does not appear ``` <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> <!-- Record: Buy flow → pick Solana token (e.g. WIF) → "Token Not Available" modal appears; payment methods list empty. --> <!-- Record: Manually select Transak → switch to a token Transak does not support → "Token Not Available" modal appears even though Coinbase is available. --> https://github.com/user-attachments/assets/97daaea8-3b59-4280-9f0a-2dd687a6c306 <!-- Record: Buy flow → pick Solana token (e.g. WIF) → BuildQuote loads with payment methods populated. --> <!-- Record: Manually select Transak → switch to a Solana token → provider silently switches to Coinbase, payment methods populate, no modal. --> <!-- Record: Token that no provider supports → modal still appears after debounce. --> https://github.com/user-attachments/assets/72fdf10a-d6a4-4e4a-bc0b-f75af3588f2f - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. - [x] I've tested on Android - Ideally on a mid-range device; emulator is acceptable - [ ] I've tested with a power user scenario - Use these [power-user SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93) to import wallets with many accounts and tokens - [ ] I've instrumented key operations with Sentry traces for production performance metrics - See [`trace()`](/app/util/trace.ts) for usage and [`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274) for an example For performance guidelines and tooling, see the [Performance Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers). - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] 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. [TRAM-3463]: https://consensyssoftware.atlassian.net/browse/TRAM-3463?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Behavior changes in the Buy (Ramps) flow around provider selection and API request parameters could affect quote/payment-method fetching and navigation to the token-unavailable modal if edge cases weren’t covered. > > **Overview** > Fixes Buy-flow failures for non-EVM tokens by introducing `normalizeAssetIdForApi` and using it when calling the Ramps `/payments` and `/quotes` APIs, lowercasing only `eip155:` assetIds while preserving case for namespaces like Solana. > > Changes the token-unavailable handling on `BuildQuote` to **auto-switch to another supporting provider regardless of whether the current provider was auto- or manually-selected**, only showing the "Token Not Available" modal when no provider supports the token, and updates/extends tests to cover these scenarios. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 57e89fc. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Darius Costolas <10818970+meltingice1337@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: wachunei <1024246+wachunei@users.noreply.github.com> Made-with: Cursor
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. |
Contributor
🔍 Smart E2E Test Selection⏭️ Smart E2E selection skipped - PR targets a release branch (release/*) All E2E tests pre-selected. |
|
Contributor
|
✅ E2E Fixture Validation — Schema is up to date |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Fixes two issues that prevented non-EVM (Solana) tokens from working in
the Buy flow and caused unnecessary friction when switching between
tokens:
1. Case-sensitive assetId mismatch for non-EVM tokens
useRampsPaymentMethodswas blanket-lowercasingselectedToken.assetIdbefore passing it to
/payments, andBuildQuotewas forwarding theraw controller-state
assetIdinto/quotes. The blanket lowercase wasoriginally added in #28399 to normalize EVM EIP-55 checksummed hex
addresses (which the server stores lowercase), but it mangles CAIP-19
references from namespaces where case is significant — notably Solana
(base58 mint addresses). With a lowercased mint, the server's
strict-equality crypto filter in
RegionsV2Servicereturned zeromatches and short-circuited to
payments: [], so every Solana tokenappeared to have no payment methods.
This PR introduces
normalizeAssetIdForApiwhich only lowercases whenthe CAIP-19 namespace is
eip155:, preserving case for non-EVMnamespaces (
solana,bip122, …). It's wired into bothuseRampsPaymentMethodsand BuildQuote'squoteFetchParams, so the EVMnormalization from #28399 still applies while non-EVM asset IDs pass
through verbatim. Wiring
/quotessymmetrically also closes a latentversion of the same EVM bug on the quotes endpoint that #28399 only
patched for
/payments.2. "Token Not Available" modal blocked manual-provider users from
switching tokens
When the selected token wasn't supported by the current provider, the
BuildQuote auto-switch effect was gated on
providerAutoSelected— itonly silently switched to a supporting provider if the current provider
had been system-picked. A user who had manually chosen (e.g.) Transak
and then navigated back to token selection and picked a Solana token got
the "Token Not Available" modal even when another provider (e.g.
Coinbase) supported the token.
The gate is removed. The auto-switch effect now runs whenever
isTokenUnavailablefires and the modal only appears when noprovider supports the token. Manual provider picks remain sticky for any
token the provider can actually serve, because the effect still
early-returns when
!isTokenUnavailable.Changelog
CHANGELOG entry: Fixed empty payment methods and false "Token Not
Available" modal for Solana and other non-EVM tokens in the Buy flow; a
manually-selected provider now silently switches to a supporting
provider when the selected token isn't supported, instead of blocking
the user with the unavailability modal.
Related issues
Fixes:
TRAM-3463
Manual testing steps
Screenshots/Recordings
Before
ScreenRecording_04-17-2026.10-29-25_1.1.MP4
After
provider-selection.mp4
Pre-merge author checklist
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Performance checks (if applicable)
SRPs
to import wallets with many accounts and tokens
performance metrics
trace()for usage andaddTokenfor an example
For performance guidelines and tooling, see the Performance
Guide.
Pre-merge reviewer checklist
app, test code being changed).
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Note
Medium Risk
Behavior changes in the Buy (Ramps) flow around provider selection and
API request parameters could affect quote/payment-method fetching and
navigation to the token-unavailable modal if edge cases weren’t covered.
Overview
Fixes Buy-flow failures for non-EVM tokens by introducing
normalizeAssetIdForApiand using it when calling the Ramps/paymentsand
/quotesAPIs, lowercasing onlyeip155:assetIds while preservingcase for namespaces like Solana.
Changes the token-unavailable handling on
BuildQuotetoauto-switch to another supporting provider regardless of whether the
current provider was auto- or manually-selected, only showing the
"Token Not Available" modal when no provider supports the token, and
updates/extends tests to cover these scenarios.
Reviewed by Cursor Bugbot for commit
57e89fc. Bugbot is set up for automated
code reviews on this repo. Configure
here.
Co-authored-by: Darius Costolas 10818970+meltingice1337@users.noreply.github.com
Co-authored-by: copilot-swe-agent[bot] 198982749+Copilot@users.noreply.github.com
Co-authored-by: wachunei 1024246+wachunei@users.noreply.github.com e17efc9