Skip to content

Commit

Permalink
fix(extension, setup): removing return button from last step and dele…
Browse files Browse the repository at this point in the history
…ting seed phrase from the state (anoma#443)
  • Loading branch information
pedrorezende authored Nov 15, 2023
1 parent 6f0c28e commit 04acabe
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ export const ContainerHeader = ({
)}
{totalSteps > 0 && (
<>
<ReturnIcon onClick={() => navigate(-1)}>
<Icon
strokeColorOverride="currentColor"
fillColorOverride="currentColor"
iconName={IconName.ArrowLeft}
/>
</ReturnIcon>
{/* Don't show return button in the last step */}
{currentStep < totalSteps && (
<ReturnIcon onClick={() => navigate(-1)}>
<Icon
strokeColorOverride="currentColor"
fillColorOverride="currentColor"
iconName={IconName.ArrowLeft}
/>
</ReturnIcon>
)}
<ProgressIndicator
keyName="setup"
totalSteps={totalSteps}
Expand Down
25 changes: 23 additions & 2 deletions apps/extension/src/Setup/Setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const Setup: React.FC = () => {
alias: "",
});
const [seedPhrase, setSeedPhrase] = useState<string[]>();
const [selectedSeedPhrase, setSelectedSeedPhrase] = useState<string[]>([]);
const [currentStep, setCurrentStep] = useState(0);
const [totalSteps, setTotalSteps] = useState(0);

Expand Down Expand Up @@ -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,
Expand All @@ -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}
/>
Expand Down Expand Up @@ -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([
Expand All @@ -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}
/>
Expand Down

0 comments on commit 04acabe

Please sign in to comment.