Skip to content

fix: cp-7.69.0 default to first convertible token regardless of selected network in deeplink flow#27202

Merged
nickewansmith merged 1 commit into
mainfrom
MUSD-496-mobile-education-screen-shows-continue-when-there-are-convertible-tokens-if-on-unsupported-chain
Mar 9, 2026
Merged

fix: cp-7.69.0 default to first convertible token regardless of selected network in deeplink flow#27202
nickewansmith merged 1 commit into
mainfrom
MUSD-496-mobile-education-screen-shows-continue-when-there-are-convertible-tokens-if-on-unsupported-chain

Conversation

@nickewansmith

@nickewansmith nickewansmith commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Description

When a user opens the mUSD conversion education screen via deeplink, the component calls getPaymentTokenForSelectedNetwork() to determine which token to convert. If the user hasn't selected a specific network (e.g., using the "Popular networks" filter), this function can return null — causing the flow to skip conversion entirely and fall through to the buy or navigate-home paths, even though the user has convertible tokens.

This fix adds a fallback: when getPaymentTokenForSelectedNetwork() returns null but conversionTokens is non-empty (guarded by the hasConvertibleTokens check), the component defaults to the first available conversion token. This ensures deeplink users are always routed to the conversion flow when they have eligible tokens.

Changelog

CHANGELOG entry: n/a

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/MUSD-496

Manual testing steps

Feature: mUSD Deeplink Conversion Fallback

  Background:
    Given the user has convertible stablecoin tokens in their wallet
    And the user goes through deeplink flow  `xcrun simctl openurl booted "metamask://earn-musd"`

  Scenario: Deeplink converts using first available token when no network-specific token exists
    Given the user has not selected a specific network filter
    And getPaymentTokenForSelectedNetwork returns null
    When the user opens the mUSD conversion deeplink
    And the education screen is displayed
    And the user presses the primary "Get Started" button
    Then the conversion flow initiates with the first convertible token
    And the education screen is marked as seen

  Scenario: Deeplink converts using network-specific token when available
    Given the user has selected a specific network
    And getPaymentTokenForSelectedNetwork returns a valid token
    When the user opens the mUSD conversion deeplink
    And the education screen is displayed
    And the user presses the primary "Get Started" button
    Then the conversion flow initiates with the network-specific token
    And the education screen is marked as seen

Screenshots/Recordings

Before

https://consensys.slack.com/files/U06EZC2Q81X/F0AKSVBC51P/screenrecording_03-09-2026_10-22-25_1.mp4

After

Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-03-09.at.09.57.01.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

Medium Risk
Changes deeplink routing to auto-select a fallback conversion token and alters conversion-token ordering, which can affect which asset is preselected/converted for users in edge cases. Scope is limited to mUSD conversion entry flow and covered by added tests, but impacts user-facing navigation/selection logic.

Overview
mUSD deeplink conversion now falls back to a wallet token instead of skipping conversion. When getPaymentTokenForSelectedNetwork() returns null, the education deeplink flow uses the first conversionTokens entry (validated/normalized via safeFormatChainIdToHex + toChecksumAddress) to proceed with convert rather than falling through to buy or home.

Conversion token ordering is updated. useMusdConversionTokens now sorts eligible conversion tokens by descending fiat balance so the fallback token is deterministically the highest-value option.

Tests updated/added to cover the fallback conversion behavior and the buy/home fall-through when the fallback token is invalid (e.g., missing chainId), plus token sorting by fiat balance.

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

@nickewansmith nickewansmith requested a review from a team as a code owner March 9, 2026 14:52
@github-actions

github-actions Bot commented Mar 9, 2026

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.

@nickewansmith nickewansmith changed the title fix: default to first convertible token regardless of selected networ… fix: default to first convertible token regardless of selected network Mar 9, 2026
@nickewansmith nickewansmith changed the title fix: default to first convertible token regardless of selected network fix: default to first convertible token regardless of selected network in deeplink flow Mar 9, 2026
@github-actions github-actions Bot added the size-S label Mar 9, 2026
Comment thread app/components/UI/Earn/Views/EarnMusdConversionEducationView/index.tsx Outdated
@nickewansmith nickewansmith force-pushed the MUSD-496-mobile-education-screen-shows-continue-when-there-are-convertible-tokens-if-on-unsupported-chain branch from 7e97ba6 to f545c05 Compare March 9, 2026 15:03

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

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@nickewansmith nickewansmith force-pushed the MUSD-496-mobile-education-screen-shows-continue-when-there-are-convertible-tokens-if-on-unsupported-chain branch from 6dfbbea to b179cd4 Compare March 9, 2026 16:10
Matt561
Matt561 previously approved these changes Mar 9, 2026
@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

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

@nickewansmith nickewansmith force-pushed the MUSD-496-mobile-education-screen-shows-continue-when-there-are-convertible-tokens-if-on-unsupported-chain branch from b179cd4 to 5a5c5da Compare March 9, 2026 17:46
@nickewansmith nickewansmith enabled auto-merge March 9, 2026 17:46
@github-actions github-actions Bot added size-M and removed size-S labels Mar 9, 2026
@nickewansmith nickewansmith requested a review from Matt561 March 9, 2026 17:47
@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 84%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes are limited to the Earn feature UI layer:

  • EarnMusdConversionEducationView component
  • useMusdConversionTokens hook
  • Associated unit tests

These are isolated to a specific Earn educational/conversion view and related hook logic. There are:

  • No changes to core controllers (no Engine/*, *Controller.ts, or state management changes)
  • No navigation, TabBar, or global modal changes
  • No changes to TradeWalletActions entry points
  • No changes to confirmations, transactions, network management, identity, multi-SRP, or Snaps

While Earn is accessible from the Trade wallet actions menu, SmokeTrade primarily validates swaps, bridges, staking, analytics, and transaction flows—not internal educational subviews. There is no indication that this PR modifies entry points, transaction flows, or shared components used by other E2E scenarios.

Given the scope (component + hook + unit tests only), the risk to existing Detox E2E flows is low and does not justify running any specific E2E tag suite.

Performance Test Selection:
The changes are limited to a small UI view and a local hook. There are no modifications to rendering-heavy lists, account selectors, network selectors, swaps, predictions, perps, onboarding, login, launch, or asset loading flows. No controllers or global state performance paths were touched. Therefore, performance tests are not required.

View GitHub Actions results

@nickewansmith nickewansmith changed the title fix: default to first convertible token regardless of selected network in deeplink flow fix: cp-7.68.0 default to first convertible token regardless of selected network in deeplink flow Mar 9, 2026
@nickewansmith nickewansmith changed the title fix: cp-7.68.0 default to first convertible token regardless of selected network in deeplink flow fix: cp-7.69.0 default to first convertible token regardless of selected network in deeplink flow Mar 9, 2026
@sonarqubecloud

sonarqubecloud Bot commented Mar 9, 2026

Copy link
Copy Markdown

@nickewansmith nickewansmith added this pull request to the merge queue Mar 9, 2026
Merged via the queue into main with commit da3d5ff Mar 9, 2026
69 checks passed
@nickewansmith nickewansmith deleted the MUSD-496-mobile-education-screen-shows-continue-when-there-are-convertible-tokens-if-on-unsupported-chain branch March 9, 2026 18:40
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 9, 2026
@metamaskbot metamaskbot added the release-7.70.0 Issue or pull request that will be included in release 7.70.0 label Mar 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.70.0 Issue or pull request that will be included in release 7.70.0 size-M team-earn

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants