Skip to content

chore(predict): opt in useNavigation to AppNavigationProp (Phase 4)#33458

Open
weitingsun wants to merge 4 commits into
mainfrom
chore/navigation-typing-phase-4-predict
Open

chore(predict): opt in useNavigation to AppNavigationProp (Phase 4)#33458
weitingsun wants to merge 4 commits into
mainfrom
chore/navigation-typing-phase-4-predict

Conversation

@weitingsun

@weitingsun weitingsun commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Description

Phase 4 of the incremental React Navigation typing migration — Predict feature.

Predict production call sites still used untyped useNavigation() (or the feature-local NavigationProp<PredictNavigationParamList> / NativeStackNavigationProp<PredictNavigationParamList>), so they were checked only against the Predict param list (or the loose global ReactNavigation.RootParamList) and could not enforce route names / params against the app-wide RootStackParamList. This PR opts Predict into the strict path via useNavigation<AppNavigationProp>() (and AppStackNavigationProp where stack-only APIs are needed).

This is effectively types-only

What changed

  1. Opt-in across Predict (~51 production files)

    • useNavigation() / useNavigation<NavigationProp<PredictNavigationParamList>>()useNavigation<AppNavigationProp>()
    • Added import type { AppNavigationProp } from app/core/NavigationService/types
    • Covers feed / home sections, market cards, market details, positions, transactions, buy/sell previews, buy-with-any-token, add-funds, world-cup modules, GTM modal, and hooks
  2. Guard prop retype (app/components/UI/Predict/hooks/usePredictActionGuard.ts)

    • navigation: NavigationProp<PredictNavigationParamList>navigation: AppNavigationProp, so callers passing the root-typed navigation no longer clash with the guard
  3. Stack-only APIs use AppStackNavigationProp (app/components/UI/Predict/views/PredictBuyWithAnyToken/hooks/usePredictBuyActions.ts)

    • useNavigation<NativeStackNavigationProp<PredictNavigationParamList>>()useNavigation<AppStackNavigationProp>() (needs native-stack transitionEnd event + StackActions.pop())
    • Dropped the now-unused NativeStackNavigationProp import
  4. Removed a redundant cast (app/components/UI/Predict/views/PredictMarketDetails/PredictMarketDetails.tsx)

    • The Polymarket-resolution Webview navigation previously did (navigation as unknown as AppNavigationProp).navigate(...) because navigation was typed to the Predict stack. Now that navigation is AppNavigationProp, the cast (and its TODO) are gone
  5. PredictEntryPoint widened (app/components/UI/Predict/types/navigation.ts)

    • Added REWARDS, GTM_MODAL, BUY_PREVIEW entry points that were already used at runtime but not part of the type union
  6. AppStackNavigationProp JSDoc clarified (app/core/NavigationService/types.ts)

    • Documents that it is for stack-only APIs (incl. native-stack events like transitionEnd) and remains keyed to the loose global RootParamList during Phase 4; prefer AppNavigationProp for strict route/param checking

Changelog

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)

  • 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

Low Risk
Types-only refactor across Predict navigation; no logic changes beyond removing an unsafe cast that should now type-check correctly.

Overview
Phase 4 of the React Navigation typing migration: Predict production code now uses app-wide navigation types instead of untyped useNavigation() or NavigationProp<PredictNavigationParamList>.

Across ~50+ Predict files (components, views, hooks, contexts), call sites switch to useNavigation<AppNavigationProp>() with imports from core/NavigationService/types. usePredictActionGuard now expects AppNavigationProp, so guarded flows align with root stack typing. usePredictBuyActions uses AppStackNavigationProp for stack-only APIs (e.g. transitionEnd, StackActions).

In PredictMarketDetails, Polymarket resolution Webview navigation drops the (navigation as unknown as AppNavigationProp) cast now that navigation is already root-typed.

PredictEntryPoint adds REWARDS, GTM_MODAL, and BUY_PREVIEW to match runtime analytics usage. AppStackNavigationProp JSDoc notes when to prefer it vs AppNavigationProp during Phase 4.

No intended runtime behavior change—compile-time route/param checking against RootStackParamList.

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

@metamask-ci metamask-ci Bot added the team-mobile-platform Mobile Platform team label Jul 17, 2026
@metamask-ci

metamask-ci Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

  • Pre-merge author checklist has unchecked items (e.g. "I've tested on Android"). Every box must be consciously checked — see docs/readme/ready-for-review.md.

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

@weitingsun
weitingsun marked this pull request as ready for review July 20, 2026 18:39
@weitingsun
weitingsun requested review from a team as code owners July 20, 2026 18:39
@github-actions github-actions Bot added the risk:low AI analysis: low risk label Jul 20, 2026
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePredictions, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: @PerformancePredict
  • Risk Level: medium
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR is a TypeScript navigation type refactoring across the entire Predict feature (53 files) plus a minor JSDoc update to NavigationService/types.ts.

Core change pattern: Every Predict component/hook/view replaces useNavigation<NavigationProp<PredictNavigationParamList>>() with useNavigation<AppNavigationProp>(), migrating from the Predict-stack-specific navigation type to the global app navigation type. This also removes the as unknown as AppNavigationProp cast in PredictMarketDetails for WebView navigation.

New entry points added: REWARDS, GTM_MODAL, and BUY_PREVIEW added to PredictEntryPoint union type.

Risk assessment: Medium risk - while these are TypeScript-only type changes (no runtime behavior change in most cases), the removal of the cast in PredictMarketDetails is a functional improvement that should be verified. Navigation flows across deposit, cash-out, claim, withdraw, market details, positions, and feed views all touched.

Tag selection rationale:

  1. SmokePredictions: Directly covers the Predict feature - all navigation hooks (usePredictDeposit, usePredictCashOut, usePredictClaim, usePredictWithdraw, usePredictNavigation, usePredictActionGuard) and views (PredictHome, PredictFeed, PredictFeedView, PredictMarketDetails, PredictBuyPreview, PredictBuyWithAnyToken, PredictSellPreview, PredictPositionsView, PredictTransactionsView, PredictGTMModal) were all modified.
  2. SmokeWalletPlatform: Per tag description, Predictions is a section inside the Trending tab - changes to Predictions views affect Trending. When selecting SmokePredictions, also select SmokeWalletPlatform.
  3. SmokeConfirmations: Per SmokePredictions tag description, opening/closing positions are on-chain transactions. When selecting SmokePredictions, also select SmokeConfirmations.

Performance Test Selection:
The PR modifies navigation hooks and views across the entire Predict feature, including PredictHome, PredictFeed, PredictFeedView, PredictMarketDetails, and PredictPositionsView. The @PerformancePredict tag covers prediction market list loading, market details, deposit flows, and balance display - all of which are touched by this navigation type refactoring. While the changes are TypeScript-only, the navigation type migration could theoretically affect render behavior, and the new entry points (REWARDS, GTM_MODAL, BUY_PREVIEW) may affect flow performance. Running @PerformancePredict ensures no performance regression was introduced.

View GitHub Actions results

@github-actions

Copy link
Copy Markdown
Contributor

⚡ Performance Test Results

ℹ️ Performance test results are currently non-blocking and will not block this PR.

All tests passed · 3 tests · 1 device

📱 Devices tested (1)

Android: Google Pixel 8 Pro (v14.0)

✅ Passed Tests (3)
Test Platform Device Duration Team Recording
Predict Available Balance - Complete Flow Performance Android Google Pixel 8 Pro (v14.0) 1.17s @team-predict 📹 Watch
Predict Deposit - Complete Flow Performance Android Google Pixel 8 Pro (v14.0) 11.26s @team-predict 📹 Watch
Predict Market Details - Complete Flow Performance Android Google Pixel 8 Pro (v14.0) 4.65s @team-predict 📹 Watch

Branch: chore/navigation-typing-phase-4-predict · Build: Normal · Commit: bcca35d · View full run

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

Labels

risk:low AI analysis: low risk size-M team-mobile-platform Mobile Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant