Skip to content

refactor: remove ScreenComponent any cast from staking routes#28108

Merged
asalsys merged 5 commits into
mainfrom
refactor/remove-screen-component-any-staking
Mar 31, 2026
Merged

refactor: remove ScreenComponent any cast from staking routes#28108
asalsys merged 5 commits into
mainfrom
refactor/remove-screen-component-any-staking

Conversation

@asalsys

@asalsys asalsys commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Description

The staking routes used type ScreenComponent = React.ComponentType<any> with // eslint-disable-next-line @typescript-eslint/no-explicit-any to work around React Navigation type mismatches when screen components accepted route props directly. This PR removes that escape hatch by migrating the affected components to use the useRoute() hook with properly typed generics instead of receiving route as a prop.

Changes:

  • routes/index.tsx: Removed the ScreenComponent type alias and all as ScreenComponent casts
  • StakeConfirmationView: Switched from ({ route }: StakeConfirmationViewProps) to useRoute<RouteProp<...>>() hook
  • UnstakeConfirmationView: Same migration to useRoute() hook
  • GasImpactModal: Same migration to useRoute() hook
  • Type files: Exported RouteParams interfaces for use by useRoute() callers; removed dead StakeConfirmationViewProps and GasImpactModalProps interfaces (kept UnstakeConfirmationViewProps as it's still used by the confirmations module)
  • Tests: Updated to mock useRoute() instead of passing route as a component prop

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

N/A — this is a pure refactoring with no user-facing behavior change. Existing unit tests (3 suites, 11 tests) cover the affected components.

Screenshots/Recordings

Before

N/A

After

N/A

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.

Made with Cursor


Note

Low Risk
Low risk refactor limited to React Navigation wiring and TypeScript types; main risk is runtime issues if any of these components are rendered without the expected route params.

Overview
Refactors StakeConfirmationView, UnstakeConfirmationView, and GasImpactModal to stop accepting route props and instead fetch strongly-typed route params via useRoute<RouteProp<...>>(), reducing the need for any-style screen component casts.

Updates associated *.types.ts to export RouteParams types (and removes now-unused props types where applicable), and adjusts unit tests to mock useRoute() rather than passing route props into the components.

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

@asalsys asalsys self-assigned this Mar 30, 2026
@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.

@metamaskbot metamaskbot added the team-mobile-platform Mobile Platform team label Mar 30, 2026
@asalsys asalsys marked this pull request as ready for review March 31, 2026 14:12
@asalsys asalsys requested a review from a team as a code owner March 31, 2026 14:12
Base automatically changed from feat/react-navigation-v6-migration to main March 31, 2026 15:02
@andrepimenta andrepimenta requested review from a team as code owners March 31, 2026 15:02
@github-actions github-actions Bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Mar 31, 2026
The staking routes used `type ScreenComponent = React.ComponentType<any>`
with eslint-disable to work around React Navigation type mismatches.
Migrates affected components to use the useRoute() hook with properly
typed generics instead of receiving route as a prop.

Changes:
- StakeConfirmationView: switched to useRoute() hook
- UnstakeConfirmationView: switched to useRoute() hook
- GasImpactModal: switched to useRoute() hook
- Type files: exported RouteParams interfaces, removed dead Props types
- Tests: updated to mock useRoute() instead of passing route as prop

Made-with: Cursor
@asalsys asalsys force-pushed the refactor/remove-screen-component-any-staking branch from 520ef13 to 5677adb Compare March 31, 2026 15:14
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 31, 2026
@asalsys asalsys removed request for a team March 31, 2026 15:29
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-low Low testing needed · Low bug introduction risk labels Mar 31, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 31, 2026
@asalsys asalsys reopened this Mar 31, 2026
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 31, 2026
@asalsys asalsys removed risk-low Low testing needed · Low bug introduction risk labels Mar 31, 2026
@github-actions github-actions Bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Mar 31, 2026
@MetaMask MetaMask unlocked this conversation Mar 31, 2026
@github-actions github-actions Bot added risk-low Low testing needed · Low bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 31, 2026
@asalsys asalsys enabled auto-merge March 31, 2026 17:11
@nickewansmith

Copy link
Copy Markdown
Contributor

Thank you!

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

lgtm

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The changes are a pure internal refactoring of three Stake-related components (StakeConfirmationView, UnstakeConfirmationView, GasImpactModal). The refactoring replaces the pattern of receiving route as a component prop with using the useRoute() hook from React Navigation directly inside the component. The types files are updated accordingly to export route params interfaces instead of component props interfaces.

This is a low-risk change since:

  1. No functional logic was changed - only how route params are accessed
  2. The useRoute() hook is the standard React Navigation pattern
  3. The route params structure (amountWei, amountFiat, etc.) remains identical

The existing E2E stake test (tests/smoke/stake/stake-action-smoke.spec.ts) is tagged with SmokeTrade and exercises the full stake flow including the StakeConfirmationView. This test should be run to verify the refactoring didn't break the stake confirmation flow.

SmokeConfirmations is not selected because the staking confirmation views are specialized stake-specific screens, not the general transaction confirmation system tested by SmokeConfirmations. The stake flow is specifically covered under SmokeTrade.

Performance Test Selection:
These changes are pure refactoring of how route params are accessed (prop vs hook) in stake confirmation views. There is no change to rendering logic, data fetching, state management, or UI structure that would impact performance metrics.

View GitHub Actions results

@github-actions

Copy link
Copy Markdown
Contributor

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

@sonarqubecloud

Copy link
Copy Markdown

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

Labels

release-7.73.0 Issue or pull request that will be included in release 7.73.0 risk-low Low testing needed · Low bug introduction risk size-M team-mobile-platform Mobile Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants