Skip to content

feat: normalize assetId for Ramps API & aut provider switch gate fix cp-7.74.0#29037

Merged
amitabh94 merged 4 commits into
mainfrom
fix/TRAM-3463
Apr 20, 2026
Merged

feat: normalize assetId for Ramps API & aut provider switch gate fix cp-7.74.0#29037
amitabh94 merged 4 commits into
mainfrom
fix/TRAM-3463

Conversation

@meltingice1337

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

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.

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

@meltingice1337 meltingice1337 added the team-money-movement issues related to Money Movement features label Apr 20, 2026
@meltingice1337 meltingice1337 marked this pull request as ready for review April 20, 2026 12:12
@meltingice1337 meltingice1337 requested a review from a team as a code owner April 20, 2026 12:12

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

Reviewed by Cursor Bugbot for commit dd6bd6e. Configure here.

Comment thread app/components/UI/Ramp/Views/BuildQuote/BuildQuote.tsx
@github-actions github-actions Bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Apr 20, 2026
@wachunei

Copy link
Copy Markdown
Member

I see this PR fixes 2 bugs, are they required to be delivered in the same piece of code? I left a question about Nº1 in the dev channel https://consensys.slack.com/archives/C09J8LBSR9Q/p1776691101815109

@meltingice1337

Copy link
Copy Markdown
Contributor Author

I see this PR fixes 2 bugs, are they required to be delivered in the same piece of code? I left a question about Nº1 in the dev channel https://consensys.slack.com/archives/C09J8LBSR9Q/p1776691101815109

They are not required as part of the same code, but they do solve the same underlying issue.

@wachunei

Copy link
Copy Markdown
Member

I will approve this after you add cp-7.74.0 in the PR title please. Let's keep the discussion on slack about the EVM cases.

@meltingice1337 meltingice1337 changed the title feat: normalize assetId for Ramps API & aut provider switch gate fix feat: normalize assetId for Ramps API & aut provider switch gate fix cp-7.74.0 Apr 20, 2026
@meltingice1337

Copy link
Copy Markdown
Contributor Author

I will approve this after you add cp-7.74.0 in the PR title please. Let's keep the discussion on slack about the EVM cases.

I've added this.

amitabh94
amitabh94 previously approved these changes Apr 20, 2026
@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 Apr 20, 2026
@wachunei

Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request

Co-authored-by: wachunei <1024246+wachunei@users.noreply.github.com>

Copilot AI commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved in 57e89fc. There was one conflict in BuildQuote.tsx — the merge brought in hasAgreedTransakNativePolicy from main's Transak native policy feature (#28952) while preserving this PR's intentional removal of the providerAutoSelected gate.

Copilot AI requested a review from wachunei April 20, 2026 16:56
@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 Apr 20, 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:
The changes are entirely within the Ramps (on-ramp/off-ramp) feature area:

  1. normalizeAssetIdForApi.ts (new utility): Normalizes CAIP-19 asset IDs for the Ramps API - lowercases EVM (eip155:) asset IDs while preserving case for non-EVM (Solana, etc.) asset IDs. This fixes a bug where EIP-55 checksummed hex addresses were being sent to the API instead of lowercase.

  2. BuildQuote.tsx:

    • Uses normalizeAssetIdForApi when passing assetId to the polling query (fixes asset ID case normalization)
    • Removes providerAutoSelected selector dependency
    • Changes provider auto-switch behavior: now silently switches to any supporting provider regardless of whether it was auto-selected, only showing the "Token Not Available" modal when NO provider supports the token at all
  3. useRampsPaymentMethods.ts: Uses normalizeAssetIdForApi instead of manual .toLowerCase() for proper non-EVM asset ID handling

These changes affect the core ramp quote-building flow and payment methods fetching. The functional behavior change (auto-switch now always active) and the asset ID normalization fix both need E2E validation via SmokeRamps tests. No other feature areas are impacted - no shared navigation, modals, or controllers are touched.

Performance Test Selection:
The changes are limited to Ramps feature logic (asset ID normalization, provider auto-switch behavior, payment methods fetching). These are not performance-sensitive code paths - no UI rendering changes, no list components, no state management changes that would affect render performance. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@amitabh94 amitabh94 enabled auto-merge April 20, 2026 17:19
@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

@amitabh94 amitabh94 added this pull request to the merge queue Apr 20, 2026
Merged via the queue into main with commit e17efc9 Apr 20, 2026
97 checks passed
@amitabh94 amitabh94 deleted the fix/TRAM-3463 branch April 20, 2026 17:43
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 20, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.75.0 Issue or pull request that will be included in release 7.75.0 label Apr 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.75.0 Issue or pull request that will be included in release 7.75.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.

4 participants