From 04acabedc377b53e325bbbf1b18f544e2e65c3fa Mon Sep 17 00:00:00 2001 From: Pedro Rezende Date: Wed, 15 Nov 2023 09:35:53 -0300 Subject: [PATCH] fix(extension, setup): removing return button from last step and deleting seed phrase from the state (#443) --- .../ContainerHeader/ContainerHeader.tsx | 17 +++++++------ apps/extension/src/Setup/Setup.tsx | 25 +++++++++++++++++-- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/apps/extension/src/Setup/Common/ContainerHeader/ContainerHeader.tsx b/apps/extension/src/Setup/Common/ContainerHeader/ContainerHeader.tsx index 1f2d48732a..c21ddf6711 100644 --- a/apps/extension/src/Setup/Common/ContainerHeader/ContainerHeader.tsx +++ b/apps/extension/src/Setup/Common/ContainerHeader/ContainerHeader.tsx @@ -27,13 +27,16 @@ export const ContainerHeader = ({ )} {totalSteps > 0 && ( <> - navigate(-1)}> - - + {/* Don't show return button in the last step */} + {currentStep < totalSteps && ( + navigate(-1)}> + + + )} { alias: "", }); const [seedPhrase, setSeedPhrase] = useState(); + const [selectedSeedPhrase, setSelectedSeedPhrase] = useState([]); const [currentStep, setCurrentStep] = useState(0); const [totalSteps, setTotalSteps] = useState(0); @@ -145,7 +146,16 @@ export const Setup: React.FC = () => { seedPhrase={seedPhrase || []} passwordRequired={!passwordInitialized} onConfirm={(accountCreationDetails: AccountDetails) => { + if (!seedPhrase?.length) { + formatRouterPath([ + TopLevelRoute.AccountCreation, + AccountCreationRoute.SeedPhraseConfirmation, + ]); + return; + } setAccountCreationDetails(accountCreationDetails); + setSelectedSeedPhrase(Array.from(seedPhrase)); + setSeedPhrase(undefined); navigate( formatRouterPath([ TopLevelRoute.AccountCreation, @@ -166,7 +176,7 @@ export const Setup: React.FC = () => { pageTitle="Namada Keys Created" pageSubtitle="Here are the accounts generated from your keys" alias={accountCreationDetails.alias || ""} - mnemonic={seedPhrase || []} + mnemonic={selectedSeedPhrase || []} password={accountCreationDetails.password || ""} scanAccounts={false} /> @@ -211,6 +221,17 @@ export const Setup: React.FC = () => { accountCreationDetails={accountCreationDetails} seedPhrase={seedPhrase} onConfirm={(accountCreationDetails: AccountDetails) => { + if (!seedPhrase) { + navigate( + formatRouterPath([ + TopLevelRoute.ImportAccount, + AccountImportRoute.SeedPhrase, + ]) + ); + return; + } + + setSelectedSeedPhrase(Array.from(seedPhrase)); setAccountCreationDetails(accountCreationDetails); navigate( formatRouterPath([ @@ -232,7 +253,7 @@ export const Setup: React.FC = () => { pageTitle="Namada Keys Imported" pageSubtitle="Here are the accounts generated from your keys" alias={accountCreationDetails.alias || ""} - mnemonic={seedPhrase || []} + mnemonic={selectedSeedPhrase || []} password={accountCreationDetails.password || ""} scanAccounts={false} />