Skip to content

refactor(earn): migrate Earn routes to native stack and HeaderStandard#30478

Merged
weitingsun merged 4 commits into
mainfrom
wsun/change-earn-routes-to-native-stack
May 25, 2026
Merged

refactor(earn): migrate Earn routes to native stack and HeaderStandard#30478
weitingsun merged 4 commits into
mainfrom
wsun/change-earn-routes-to-native-stack

Conversation

@weitingsun

@weitingsun weitingsun commented May 20, 2026

Copy link
Copy Markdown
Contributor

Description

Migrates Earn navigation stacks from @react-navigation/stack to @react-navigation/native-stack, and replaces imperative getStakingNavbar headers on stablecoin lending deposit/withdrawal confirmation screens with declarative HeaderStandard from the design system.

Why

  • Align Earn with other recently converted stacks (native stack for performance and consistency).

  • Remove legacy navigation.setOptions(getStakingNavbar(...)) in favor of in-view HeaderStandard, matching patterns from refactor/unstake (refactor(unstake): use HeaderStandard instead of getStakingNavbar #30281) and refactor/headerstandard-titles-bridge (accessibility-label–based header interactions in tests).

What changed

app/components/UI/Earn/routes/index.tsx

  • createStackNavigator → createNativeStackNavigator for EarnScreenStack and EarnModalStack.
  • EarnScreenStack uses transparentModalScreenOptions.
  • EarnModalStack uses clearNativeStackNavigatorOptions + transparentModalScreenOptions.
  • headerShown: false on lending deposit and withdrawal confirmation screens (headers owned by the view).

EarnLendingDepositConfirmationView

  • Renders with dynamic title (Supply ).
  • Back via onBack + backButtonProps.accessibilityLabel: strings('navigation.back').
  • Removed dead getStakingNavbar(...) call and navbar useEffect.

EarnLendingWithdrawalConfirmationView

  • Same HeaderStandard pattern with title (Withdraw ).
  • Back press preserves EARN_LENDING_WITHDRAW_CONFIRMATION_BACK_CLICKED analytics (moved from getStakingNavbar backButtonEvent into handleHeaderBackPress).

Tests

  • Added HeaderStandard coverage (title rendering, back navigation, withdrawal back analytics).
  • Back button queried via getByLabelText(strings('navigation.back')) (bridge header pattern), not button-icon testID.
  • Removed getStakingNavbar spy/import from withdrawal tests.

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Earn - Deposit Earn - Withdraw earn - confirmation Earn - conversion education earn - learn more modal earn - confirm modal

Android EarnLendingDepositConfirmationView and EarnLendingWithdrawalConfirmationView screens after nav header changes

EarnLendingDepositConfirmationView EarnLendingWithdrawalConfirmationView
Screenshot_20260521_071052_MetaMask Screenshot_20260521_070956_MetaMask

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
Touches user-facing Earn confirmation navigation and header/back behavior; withdrawal back analytics are explicitly preserved, but stack presentation changes warrant manual regression on deposit/withdraw flows.

Overview
Earn navigation moves from the legacy JS stack to native stack, with shared transparentModalScreenOptions / clearNativeStackNavigatorOptions and headerShown: false on stablecoin lending deposit and withdrawal confirmation routes so headers live in the screen.

Deposit and withdrawal confirmation drop getStakingNavbar / navigation.setOptions and render in-view HeaderStandard with titles built from the routed token (ticker → symbol → name). Back uses onBack and the navigation.back accessibility label; tests query the back control via that label.

On withdrawal, EARN_LENDING_WITHDRAW_CONFIRMATION_BACK_CLICKED analytics move from the old navbar backButtonEvent into handleHeaderBackPress before goBack(). Deposit back only navigates back (no new back analytics in this change).

Reviewed by Cursor Bugbot for commit c8a60d9. 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.

@metamaskbotv2 metamaskbotv2 Bot added the team-mobile-platform Mobile Platform team label May 20, 2026
@weitingsun weitingsun self-assigned this May 20, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.13%. Comparing base (4adf4d4) to head (1481e3b).

Files with missing lines Patch % Lines
...ws/EarnLendingWithdrawalConfirmationView/index.tsx 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #30478   +/-   ##
=======================================
  Coverage   82.12%   82.13%           
=======================================
  Files        5477     5477           
  Lines      147205   147208    +3     
  Branches    33847    33847           
=======================================
+ Hits       120897   120906    +9     
+ Misses      18031    18025    -6     
  Partials     8277     8277           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@weitingsun weitingsun marked this pull request as ready for review May 20, 2026 22:16
@weitingsun weitingsun requested a review from a team as a code owner May 20, 2026 22:16
@weitingsun weitingsun enabled auto-merge May 21, 2026 19:10
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeStake, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR makes targeted changes to the Earn lending deposit and withdrawal confirmation views:

  1. Header component replacement: Both EarnLendingDepositConfirmationView and EarnLendingWithdrawalConfirmationView replace the getStakingNavbar pattern (which used navigation.setOptions()) with an inline HeaderStandard component from @metamask/design-system-react-native. This changes how the header is rendered and how back navigation works.

  2. Navigator migration: Earn/routes/index.tsx migrates from createStackNavigator (JS stack) to createNativeStackNavigator (native stack), with headerShown: false on both confirmation screens. This is a meaningful architectural change that affects screen transitions and modal presentation behavior.

  3. Analytics preservation: The withdrawal back button now fires EARN_LENDING_WITHDRAW_CONFIRMATION_BACK_CLICKED analytics event directly in the handleHeaderBackPress callback (previously done via getStakingNavbar options).

Tag selection rationale:

  • SmokeStake: Directly covers lending deposit (lending-deposit-smoke.spec.ts) and lending withdrawal (lending-withdrawal-smoke.spec.ts) E2E tests, which exercise the exact views modified in this PR. The navigation stack change and header component change need to be validated end-to-end.
  • SmokeConfirmations: Per the SmokeStake tag description, stake/lending flows involve on-chain transaction confirmations, so SmokeConfirmations should also be selected. The confirmation footer actions are part of both lending flows.

No other tags are warranted — changes are scoped to the Earn lending confirmation views and their navigation stack, with no impact on accounts, identity, browser, swaps, network management, or other areas.

Performance Test Selection:
The changes are UI component replacements (header component swap) and a navigator type migration. There are no changes to list rendering, data loading, state management, app startup, or other performance-sensitive areas. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@weitingsun weitingsun added this pull request to the merge queue May 25, 2026
Merged via the queue into main with commit 8b4cc93 May 25, 2026
271 of 273 checks passed
@weitingsun weitingsun deleted the wsun/change-earn-routes-to-native-stack branch May 25, 2026 21:25
@github-actions github-actions Bot locked and limited conversation to collaborators May 25, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.80.0 Issue or pull request that will be included in release 7.80.0 label May 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.80.0 Issue or pull request that will be included in release 7.80.0 size-M team-mobile-platform Mobile Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants