Skip to content

chore(runway): cherry-pick feat: normalize assetId for Ramps API & aut provider switch gate fix#29073

Merged
chloeYue merged 1 commit into
release/7.74.00from
cherry-pick-7-74-0-e17efc9
Apr 21, 2026
Merged

chore(runway): cherry-pick feat: normalize assetId for Ramps API & aut provider switch gate fix#29073
chloeYue merged 1 commit into
release/7.74.00from
cherry-pick-7-74-0-e17efc9

Conversation

@runway-github

@runway-github runway-github Bot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

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

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.

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 — 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

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

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

Screenshots/Recordings

Before

ScreenRecording_04-17-2026.10-29-25_1.1.MP4

After

provider-selection.mp4

Pre-merge author checklist

Performance checks (if applicable)

  • 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

    to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production
    performance metrics
  • See trace() for usage and
    addToken
    for an example

For performance guidelines and tooling, see the Performance
Guide
.

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

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

…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
@runway-github runway-github Bot requested a review from a team as a code owner April 20, 2026 21:26
@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.

@metamaskbotv2 metamaskbotv2 Bot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Apr 20, 2026
@github-actions github-actions Bot added the risk-high Extensive testing required · High bug introduction risk label Apr 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - PR targets a release branch (release/*)

All E2E tests pre-selected.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

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

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

LGTM

@chloeYue chloeYue merged commit bbac67b into release/7.74.00 Apr 21, 2026
113 checks passed
@chloeYue chloeYue deleted the cherry-pick-7-74-0-e17efc9 branch April 21, 2026 06:46
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

risk-high Extensive testing required · High bug introduction risk size-M team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants