Skip to content

fix(ramps): Case sensitive mismatch between token assetIds and provider keys#28399

Merged
amitabh94 merged 4 commits into
mainfrom
fix/ramps-case-sensitive-assetid
Apr 5, 2026
Merged

fix(ramps): Case sensitive mismatch between token assetIds and provider keys#28399
amitabh94 merged 4 commits into
mainfrom
fix/ramps-case-sensitive-assetid

Conversation

@imyugioh

@imyugioh imyugioh commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Description

Token assetIds from the controller use checksummed (mixed-case) addresses (e.g. eip155:1/erc20:0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48), but the on-ramp API and provider supportedCryptoCurrencies keys use lowercase. This case mismatch caused two bugs:

  1. "Token Not Available" modal shown incorrectlyBuildQuote checked supportedCryptoCurrencies[assetId] with a checksummed key against lowercase map keys. The lookup returned undefined, so every ERC-20 token appeared unsupported.

  2. Payment methods endpoint returned emptyuseRampsPaymentMethods passed the checksummed assetId to the API as the crypto query param. The API is case-sensitive and returned no results for the uppercase variant.

Changes:

  1. providerSupportsAsset.ts (new utility) — Case-insensitive lookup against supportedCryptoCurrencies. Tries the original key first, falls back to toLowerCase().

  2. BuildQuote.tsx — 3 locations replaced supportedCryptoCurrencies?.[assetId] with providerSupportsAsset(): the isTokenUnavailable check, first-time provider selection, and auto-switch on soft selection.

  3. ProviderSelectionModal.tsxdisplayProviders filter uses providerSupportsAsset() instead of direct bracket lookup.

  4. ProviderSelection.tsx — Supported/unsupported provider separation uses providerSupportsAsset().

  5. useRampsPaymentMethods.ts — Lowercases assetId before passing to the payment methods API call.

Changelog

CHANGELOG entry: Fixed case-sensitive assetId mismatch that caused false "Token Not Available" modal and empty payment methods for ERC-20 tokens

Related issues

Manual testing steps

Feature: Case-insensitive token support checks

  Scenario: ERC-20 token shows as available when provider supports it
    Given user is in region us-tx with Transak selected
    When user selects USDC on Ethereum
    Then the "Not available" modal does NOT appear
    And payment methods load correctly (e.g. Apple Pay, Debit/Credit)

  Scenario: Provider selection modal shows supporting providers
    Given user is on BuildQuote with USDC selected
    When user taps "Change provider"
    Then all providers that support USDC are listed
    And "No providers available" does NOT appear

  Scenario: Native tokens still work (no hex address)
    Given user selects ETH (native, slip44:60)
    Then token is recognized as supported
    And payment methods load normally

Screenshots/Recordings

Before

ScreenRecording_04-04-2026.08-18-44_1.MP4

After

Screen.Recording.2026-04-04.145248.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

Low Risk
Low risk: small, localized changes that normalize assetId casing and centralize the provider support check; behavior changes are limited to provider filtering/selection and payment-methods fetch parameters.

Overview
Fixes a case-sensitivity mismatch between checksummed token assetIds and lowercase provider/API identifiers.

Adds providerSupportsAsset() for case-insensitive supportedCryptoCurrencies lookups and switches Build Quote + provider selection modals to use it for token availability checks and provider filtering/auto-selection. Also lowercases assetId before calling the payment methods endpoint, with new unit tests covering both behaviors.

Reviewed by Cursor Bugbot for commit 086e404. Bugbot is set up for automated code reviews on this repo. Configure here.

@imyugioh imyugioh self-assigned this Apr 4, 2026
@imyugioh imyugioh added the team-money-movement issues related to Money Movement features label Apr 4, 2026
@github-actions github-actions Bot added the size-S label Apr 4, 2026
@github-actions github-actions Bot added size-M and removed size-S labels Apr 4, 2026
@imyugioh imyugioh marked this pull request as ready for review April 4, 2026 21:17
@imyugioh imyugioh requested a review from a team as a code owner April 4, 2026 21:17

@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 ff1e4c5. Configure here.

Comment thread app/components/UI/Ramp/utils/providerSupportsAsset.test.ts
@github-actions github-actions Bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Apr 4, 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 4, 2026
@github-actions

github-actions Bot commented Apr 4, 2026

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: 95%
click to see 🤖 AI reasoning details

E2E Test Selection:
All 7 changed files are scoped entirely to the Ramp feature (app/components/UI/Ramp/). The changes fix a case-sensitivity bug where checksummed ERC-20 assetIds (mixed-case, e.g. 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48) were not matching lowercase API keys in supportedCryptoCurrencies. The fix introduces a new providerSupportsAsset utility and normalizes the assetId to lowercase before API calls. This affects: (1) provider auto-selection in BuildQuote, (2) provider filtering in ProviderSelectionModal, (3) provider list categorization in ProviderSelection, and (4) payment methods fetching. These are all core Ramp flows (on-ramp/off-ramp quote building, provider selection). SmokeRamps directly covers these flows. No shared components (TabBar, navigation, modals outside Ramp), no controllers, no Engine changes — so no other tags are warranted.

Performance Test Selection:
The changes are purely logic fixes (case normalization for string matching) with no UI rendering changes, no new data fetching patterns, no list rendering changes, and no impact on app startup or critical performance paths. No performance tests are warranted.

View GitHub Actions results

@github-actions

github-actions Bot commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

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

@sonarqubecloud

sonarqubecloud Bot commented Apr 4, 2026

Copy link
Copy Markdown

@imyugioh imyugioh requested review from amitabh94 and pkowalski April 4, 2026 23:46
@amitabh94 amitabh94 added this pull request to the merge queue Apr 5, 2026
Merged via the queue into main with commit 62ea975 Apr 5, 2026
146 of 147 checks passed
@amitabh94 amitabh94 deleted the fix/ramps-case-sensitive-assetid branch April 5, 2026 03:23
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 5, 2026
@metamaskbot metamaskbot added the release-7.74.0 Issue or pull request that will be included in release 7.74.0 label Apr 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

3 participants