-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
chore(runway): cherry-pick fix(ramp): parse slip44 intent as native asset cp-7.61.0 #23705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(runway): cherry-pick fix(ramp): parse slip44 intent as native asset cp-7.61.0 #23705
Conversation
…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 -->
|
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsAnalysis SummaryThe changes are focused on the Ramp Deposit functionality, specifically the Changes Made1. useCryptoCurrencies.ts (Implementation)
2. useCryptoCurrencies.test.ts (Tests)
Impact AssessmentAffected Area: Ramps (On/Off-ramp features) - specifically the Deposit flow
Risk Level: Medium because:
Why SmokeRamps?
Why not other tags?
Test Coverage RecommendationThe SmokeRamps tests should cover:
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. |
|
|
No release label on PR. Adding release label release-7.61.0 on PR, as PR was cherry-picked in branch 7.61.0. |



Description
This PR adds slip44 wildcard matching support to the Deposit
useCryptoCurrencieshook, aligning it with the existing behavior inthe 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 withspecific slip44 coin types (e.g.,
eip155:1/slip44:60). The directstring 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
chainIdandslip44namespace when the directmatch fails. This mirrors the existing behavior in the Aggregator
useCryptoCurrencieshook.Changelog
CHANGELOG entry: null
Related issues
Fixes: #23441
Manual testing steps
Screenshots/Recordings
Before
before_intent.mp4
After
after_intent.mp4
Pre-merge author checklist
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
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
Adds slip44 wildcard matching in
useCryptoCurrenciesto pre-select native tokens, with comprehensive tests.useCryptoCurrenciesto parse CAIP-19 and support slip44 wildcard matching for native assets when intent hasslip44:., falling back to direct match and then first token.parseCAIP19AssetIdand use it to match native tokens bychainIdandslip44namespace.Written by Cursor Bugbot for commit c15c639. This will update automatically on new commits. Configure here.
f053689