Skip to content

Commit 129c314

Browse files
authored
feat: convert manualBackupStep1 code to typescript (#24346)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** * Convert manualBackupStep1 component code from javascript to typescript * Jira: https://consensyssoftware.atlassian.net/browse/SL-438 <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: ## **Manual testing steps** ```gherkin 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** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** https://github.com/user-attachments/assets/334fb01d-3650-4f2b-9740-d12541e75eb9 <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Migrates the `ManualBackupStep1` view to TypeScript and hooks, simplifying props and improving type safety. > > - Rewrites `index.tsx` to use `useNavigation`, `useRoute`, and `useDispatch` (removes `connect`/`PropTypes`), adds `ManualBackupStep1.types.ts` for route/navigation typing > - Tightens state/function types (e.g., `password`, `words`), adds `useRef` guard to prevent double init, and improves error handling when unlocking/exporting SRP > - Switches image `require` calls to static imports and refactors navbar setup (explicit `headerRight: undefined`, conditional header hiding) > - Updates tests to mock `useRoute`/`useNavigation`, render component without passing props, and expand coverage for theme variants and “Remind me later” behavior > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 73da284. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent bd0fc32 commit 129c314

4 files changed

Lines changed: 436 additions & 127 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { RouteProp } from '@react-navigation/native';
2+
import { StackNavigationProp } from '@react-navigation/stack';
3+
4+
/**
5+
* Route params for ManualBackupStep1
6+
*/
7+
export interface ManualBackupStep1Params {
8+
backupFlow?: boolean;
9+
settingsBackup?: boolean;
10+
/**
11+
* Seed phrase words passed directly from previous screen.
12+
* Takes precedence over fetching from keyring.
13+
*/
14+
seedPhrase?: string[];
15+
/**
16+
* @deprecated Use seedPhrase instead. Kept for backwards compatibility.
17+
* Words passed from previous screen as fallback.
18+
*/
19+
words?: string[];
20+
}
21+
22+
/**
23+
* Route params for ManualBackupStep2
24+
*/
25+
export interface ManualBackupStep2Params {
26+
words: string[];
27+
steps: string[];
28+
backupFlow: boolean;
29+
settingsBackup: boolean;
30+
}
31+
32+
/**
33+
* Param list for backup flow navigation
34+
*/
35+
export interface BackupFlowParamList {
36+
[key: string]: object | undefined;
37+
ManualBackupStep1: ManualBackupStep1Params;
38+
ManualBackupStep2: ManualBackupStep2Params;
39+
RootModalFlow: { screen: string };
40+
OptinMetrics: { onContinue?: () => void };
41+
OnboardingSuccessFlow: undefined;
42+
}
43+
44+
/**
45+
* Navigation prop type with proper typing for navigate() calls
46+
*/
47+
export type ManualBackupStep1NavigationProp = StackNavigationProp<
48+
BackupFlowParamList,
49+
'ManualBackupStep1'
50+
>;
51+
52+
/**
53+
* Route prop type
54+
*/
55+
export type ManualBackupStep1RouteProp = RouteProp<
56+
BackupFlowParamList,
57+
'ManualBackupStep1'
58+
>;

0 commit comments

Comments
 (0)