Skip to content

Conversation

@runway-github
Copy link
Contributor

@runway-github runway-github bot commented Dec 5, 2025

Description

This PR adds slip44 wildcard matching support to the Deposit
useCryptoCurrencies hook, aligning it with the existing behavior in
the Aggregator flow.

Reason for change:
When navigating to the Deposit flow from the Asset Details page with a
native asset (e.g., ETH), the intent contains a wildcard asset ID like
eip155:1/slip44:.. However, the Deposit SDK returns native tokens with
specific slip44 coin types (e.g., eip155:1/slip44:60). The direct
string comparison was failing to match these, causing the native token
not to be pre-selected.

Solution:
Added fallback logic that parses the CAIP-19 asset ID and matches any
token with the same chainId and slip44 namespace when the direct
match fails. This mirrors the existing behavior in the Aggregator
useCryptoCurrencies hook.

Changelog

CHANGELOG entry: null

Related issues

Fixes: #23441

Manual testing steps

Feature: Native token selection in Deposit flow

  Scenario: user navigates to Deposit from Asset Details with native token
    Given the user is on the Asset Details page for ETH (or any native token)
    And the Deposit flow is enabled for the user's region

    When user taps the "Buy" button
    Then the Deposit flow opens with ETH pre-selected as the cryptocurrency

Screenshots/Recordings

Before

before_intent.mp4

After

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

Adds slip44 wildcard matching in useCryptoCurrencies to pre-select native tokens, with comprehensive tests.

  • Deposit:
    • Update useCryptoCurrencies to parse CAIP-19 and support slip44 wildcard matching for native assets when intent has slip44:., falling back to direct match and then first token.
    • Import parseCAIP19AssetId and use it to match native tokens by chainId and slip44 namespace.
  • Tests:
    • Add cases covering slip44 wildcard selection (same/different chain), fallback when no native match, and preference of direct match over wildcard.

Written by Cursor Bugbot for commit c15c639. This will update automatically on new commits. Configure here.

f053689

…sset cp-7.61.0 (#23689)

## **Description**

This PR adds slip44 wildcard matching support to the Deposit
`useCryptoCurrencies` hook, aligning it with the existing behavior in
the Aggregator flow.

**Reason for change:**
When navigating to the Deposit flow from the Asset Details page with a
native asset (e.g., ETH), the intent contains a wildcard asset ID like
`eip155:1/slip44:.`. However, the Deposit SDK returns native tokens with
specific slip44 coin types (e.g., `eip155:1/slip44:60`). The direct
string comparison was failing to match these, causing the native token
not to be pre-selected.

**Solution:**
Added fallback logic that parses the CAIP-19 asset ID and matches any
token with the same `chainId` and `slip44` namespace when the direct
match fails. This mirrors the existing behavior in the Aggregator
`useCryptoCurrencies` hook.

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Fixes: #23441

## **Manual testing steps**

```gherkin
Feature: Native token selection in Deposit flow

  Scenario: user navigates to Deposit from Asset Details with native token
    Given the user is on the Asset Details page for ETH (or any native token)
    And the Deposit flow is enabled for the user's region

    When user taps the "Buy" button
    Then the Deposit flow opens with ETH pre-selected as the cryptocurrency
```

## **Screenshots/Recordings**

### **Before**



https://github.com/user-attachments/assets/5a7b1ca1-3939-4ab1-a693-bf8579814e98



### **After**



https://github.com/user-attachments/assets/293d0de4-a430-43d3-b0bd-c97315baecd4



## **Pre-merge author checklist**

- [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
- [x] 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.

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


<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Adds slip44 wildcard CAIP-19 intent matching to pre-select native
tokens in the Deposit flow and introduces focused tests for this
behavior.
> 
> - **Hook**
(`app/components/UI/Ramp/Deposit/hooks/useCryptoCurrencies.ts`):
> - Add slip44 wildcard handling by parsing CAIP-19
(`parseCAIP19AssetId`) when direct `assetId` match fails, selecting a
native token with the same `chainId` and `slip44` namespace.
>   - Preserve direct `assetId` match precedence over wildcard matching.
>   - Minor refactor to use a mutable `intentCrypto` before selection.
> - **Tests**
(`app/components/UI/Ramp/Deposit/hooks/useCryptoCurrencies.test.ts`):
> - Add cases for slip44 wildcard selecting native token (same/different
`chainId`).
>   - Add fallback to first token when no native match found.
>   - Confirm direct match is preferred over wildcard.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
7d6606a. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@runway-github runway-github bot requested a review from a team as a code owner December 5, 2025 02:30
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

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.

@metamaskbot metamaskbot added the team-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Dec 5, 2025
@github-actions github-actions bot added the size-M label Dec 5, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 5, 2025

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeRamps
  • Risk Level: medium
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

Analysis Summary

The changes are focused on the Ramp Deposit functionality, specifically the useCryptoCurrencies hook. This is a well-contained change with clear scope.

Changes Made

1. useCryptoCurrencies.ts (Implementation)

  • Added case-insensitive comparison for asset IDs using toLowerCaseEquals
  • Implemented slip44 wildcard matching logic for native assets (e.g., eip155:1/slip44:.)
  • The slip44 wildcard allows matching any native asset on a chain when the specific asset reference is a wildcard
  • Enhanced the token selection logic with fallback matching for intent-based asset selection

2. useCryptoCurrencies.test.ts (Tests)

  • Added 4 comprehensive unit tests covering:
    • slip44 wildcard matching for native tokens
    • Different chain ID handling with slip44 wildcards
    • Fallback behavior when no match found
    • Preference of direct matches over wildcard matching

Impact Assessment

Affected Area: Ramps (On/Off-ramp features) - specifically the Deposit flow

  • This hook is used in BuildQuote views for both Deposit and Aggregator flows
  • The changes affect how crypto currencies are selected based on intent parameters
  • 6 files import this hook (confirmed by related files analysis)

Risk Level: Medium because:

  • Changes modify selection logic for crypto currencies in ramps flows
  • While well-tested at unit level, E2E verification is prudent
  • The slip44 wildcard matching is new functionality that affects native asset selection
  • Could impact user experience when selecting tokens for deposits

Why SmokeRamps?

  1. Changes are directly in the Ramps feature area (app/components/UI/Ramp/Deposit/)
  2. E2E tests exist in e2e/specs/ramps/ that use the SmokeRamps tag
  3. The tag description matches: "On/off ramp features, buy/sell"
  4. The changes affect the deposit/buy flow specifically

Why not other tags?

  • SmokeAssets: While this touches asset selection, it's specific to ramps context, not general asset management
  • SmokeWalletPlatform: Not core wallet functionality
  • SmokeCore: Not core wallet framework changes
  • SmokeNetworkAbstractions: Uses CAIP19 but doesn't change network layer itself

Test Coverage Recommendation

The SmokeRamps tests should cover:

  • Token selection flows in deposit/buy scenarios
  • Native token handling
  • Different network/chain scenarios
  • Intent-based token pre-selection

The changes include comprehensive unit tests, so E2E verification through SmokeRamps should provide adequate confidence that the feature works end-to-end in real user scenarios.

View GitHub Actions results

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 5, 2025

@joaoloureirop joaoloureirop merged commit 691b757 into release/7.61.0 Dec 5, 2025
126 of 131 checks passed
@joaoloureirop joaoloureirop deleted the runway-cherry-pick-7.61.0-1764901825 branch December 5, 2025 12:43
@github-actions github-actions bot locked and limited conversation to collaborators Dec 5, 2025
@metamaskbot metamaskbot added the release-7.61.0 Issue or pull request that will be included in release 7.61.0 label Dec 5, 2025
@metamaskbot
Copy link
Collaborator

No release label on PR. Adding release label release-7.61.0 on PR, as PR was cherry-picked in branch 7.61.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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

4 participants