Skip to content

Commit 7221699

Browse files
committed
chore: update forgot password flow also
1 parent a21b626 commit 7221699

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

src/app/pages/ForgotPassword/ForgotPassword.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import wordsList from 'bip39/src/wordlists/english.json';
66
import { formatMnemonic } from 'app/defaults';
77
import { useMidenContext } from 'lib/miden/front';
88
import { clearClientStorage } from 'lib/miden/reset';
9+
import type { WalletAccount } from 'lib/shared/types';
910
import { navigate } from 'lib/woozie';
1011
import { ForgotPasswordFlow } from 'screens/onboarding/forgot-password-navigator';
1112
import { ForgotPasswordAction, ForgotPasswordStep, OnboardingType } from 'screens/onboarding/types';
@@ -17,6 +18,7 @@ const ForgotPassword: FC = () => {
1718
const [password, setPassword] = useState<string | null>(null);
1819
const [importedWithFile, setImportedWithFile] = useState(false);
1920
const [isLoading, setIsLoading] = useState(false);
21+
const [importedWalletAccounts, setImportedWalletAccounts] = useState<WalletAccount[]>([]);
2022

2123
const { registerWallet, importWalletFromClient } = useMidenContext();
2224

@@ -38,13 +40,21 @@ const ForgotPassword: FC = () => {
3840
} else {
3941
try {
4042
console.log('importing wallet from client');
41-
await importWalletFromClient(password, seedPhraseFormatted);
43+
await importWalletFromClient(password, seedPhraseFormatted, importedWalletAccounts);
4244
} catch (e) {
4345
console.error(e);
4446
}
4547
}
4648
}
47-
}, [password, seedPhrase, importedWithFile, registerWallet, onboardingType, importWalletFromClient]);
49+
}, [
50+
password,
51+
seedPhrase,
52+
importedWithFile,
53+
registerWallet,
54+
onboardingType,
55+
importWalletFromClient,
56+
importedWalletAccounts
57+
]);
4858

4959
const onAction = useCallback(
5060
async (action: ForgotPasswordAction) => {
@@ -63,8 +73,8 @@ const ForgotPassword: FC = () => {
6373
break;
6474
case 'import-wallet-file-submit':
6575
const seedPhrase = action.payload.split(' ');
66-
console.log({ seedPhrase });
6776
setSeedPhrase(seedPhrase);
77+
setImportedWalletAccounts(action.walletAccounts);
6878
setImportedWithFile(true);
6979
setStep(ForgotPasswordStep.CreatePassword);
7080
break;

src/lib/store/index.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,13 @@ describe('useWalletStore', () => {
299299
mockRequest.mockResolvedValueOnce({ type: WalletMessageType.ImportFromClientResponse });
300300

301301
const { importWalletFromClient } = useWalletStore.getState();
302-
await importWalletFromClient('password123', 'mnemonic words');
302+
await importWalletFromClient('password123', 'mnemonic words', []);
303303

304304
expect(mockRequest).toHaveBeenCalledWith({
305305
type: WalletMessageType.ImportFromClientRequest,
306306
password: 'password123',
307-
mnemonic: 'mnemonic words'
307+
mnemonic: 'mnemonic words',
308+
walletAccounts: []
308309
});
309310
});
310311

src/screens/onboarding/forgot-password-navigator.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React, { FC, useCallback, useMemo, useState } from 'react';
22

3+
import { WalletAccount } from 'lib/shared/types';
4+
35
import { ConfirmationScreen } from './common/Confirmation';
46
import { CreatePasswordScreen } from './common/CreatePassword';
57
import OnboardingHeader from './common/OnboardingHeader';
@@ -144,8 +146,8 @@ export const ForgotPasswordFlow: FC<ForgotPasswordFlowProps> = ({
144146
onForwardAction?.({ id: 'confirmation' });
145147
};
146148

147-
const onImportFileSubmit = (seedPhrase: string) => {
148-
onForwardAction?.({ id: 'import-wallet-file-submit', payload: seedPhrase });
149+
const onImportFileSubmit = (seedPhrase: string, walletAccounts: WalletAccount[]) => {
150+
onForwardAction?.({ id: 'import-wallet-file-submit', payload: seedPhrase, walletAccounts });
149151
};
150152

151153
const onSelectTransactionTypeSubmit = () =>

0 commit comments

Comments
 (0)