chore(perps): opt in useNavigation to AppNavigationProp (Phase 4)#33385
chore(perps): opt in useNavigation to AppNavigationProp (Phase 4)#33385weitingsun wants to merge 5 commits into
Conversation
|
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. |
PR template — items to address before "Ready for review"Warnings — informational, address before merging:
See docs/readme/ready-for-review.md for the full Definition of Ready for Review. |
…taMask/metamask-mobile into chore/navigation-typing-phase-4-perps
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Tag selection rationale:
The changes are primarily TypeScript type improvements with some functional null-safety fixes. Risk is medium because the navigation type changes and null-safety fixes could affect runtime behavior in Perps flows and confirmation navigation. Performance Test Selection: |
|
⚡ Performance Test Results
✅ All tests passed · 2 tests · 1 device 📱 Devices tested (1)Android: Google Pixel 8 Pro (v14.0) ✅ Passed Tests (2)
Branch: |



Description
Phase 4 of the incremental React Navigation typing migration — Perps feature.
Perps production call sites still used untyped
useNavigation(), so they received the loose globalReactNavigation.RootParamListand did not enforce route names / params againstRootStackParamList. This PR opts Perps into the strict path viauseNavigation<AppNavigationProp>().This is effectively types-only. No navigation destinations, route names, or user-facing flows were intentionally changed. A small number of call-site / param-list adjustments were required so TypeScript’s stricter overloads accept the existing (already-correct) navigate shapes.
What changed
Opt-in across Perps (~53 files)
useNavigation()→useNavigation<AppNavigationProp>()PerpsPillItem:NavigationProp<PerpsNavigationParamList>→AppNavigationPropimport type { AppNavigationProp }fromapp/core/NavigationService/typesParam-list alignment (
app/components/UI/Perps/types/navigation.ts) so real call sites type-check underAppNavigationProp:PerpsOrderRouteParamsPerpsMarketListView,PerpsTutorial,PerpsTrendingView→… | undefinedPerpsMarketDetails.marketwidened toPerpsMarketData | Partial<PerpsMarketData>(trade-details deep entries)PerpsPnlHeroCardaccepts optionalsourceRedesignedConfirmations(Perps stack) →Partial<PerpsOrderRouteParams> | undefinedRoot stack shared confirmation route (
app/core/NavigationService/types.ts)RedesignedConfirmationswidened toConfirmationParams | Partial<PerpsOrderRouteParams> | undefinedso both confirmations and the Perps order flow can open it under the same root keyMinimal call-site / helper typing fixes (no intended behavior change)
PerpsOrderView:szDecimals ?? undefined(null → undefined); market navigate fallback whennavigationMarketDatais missinggetRedesignedConfirmationsHeaderOptions: take optionalparamsobject instead of destructuring a possibly-undefinedparam listChangelog
CHANGELOG entry:null
Related issues
Fixes:https://consensyssoftware.atlassian.net/browse/MCWP-675
Manual testing steps
N/A
Screenshots/Recordings
N/A
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Low Risk
Compile-time navigation typing and param-list widening only; runtime flows are unchanged aside from defensive fallbacks for already-handled edge cases.
Overview
Phase 4 of the React Navigation typing migration for Perps. Production Perps screens, components, and hooks switch from untyped
useNavigation()touseNavigation<AppNavigationProp>()sonavigate/goBackare checked againstRootStackParamList.Param lists in
navigation.tsare adjusted so existing call sites compile: sharedPerpsOrderRouteParams, optionalundefinedfor screens opened without params,PerpsMarketDetails.marketaccepts partial market data, and Perps-stackRedesignedConfirmationsaligns with order-flow params. RootRedesignedConfirmationsinNavigationService/types.tsis widened toConfirmationParams | Partial<PerpsOrderRouteParams> | undefined.Small typing-only fixes in
PerpsOrderView(e.g.szDecimals ?? undefined, market param fallback) andgetRedesignedConfirmationsHeaderOptions(safe handling of optional params). No intentional navigation or UX behavior changes.Reviewed by Cursor Bugbot for commit 229acc8. Bugbot is set up for automated code reviews on this repo. Configure here.