Skip to content

Commit

Permalink
fix: fix bugs during multiple mnemonics processing (#587)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinoosss authored Sep 26, 2024
1 parent eeb5a43 commit 5ab7148
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { formatAddress } from '@common/utils/client-utils';
import { Row, WebCheckBox, WebText } from '@components/atoms';
import React from 'react';
import { useTheme } from 'styled-components';
Expand All @@ -15,7 +14,7 @@ const SelectAccountBoxItem: React.FC<{
return (
<StyledSelectAccountBoxItem key={index}>
<Row style={{ columnGap: 8 }}>
<WebText type='body5'>{formatAddress(address)}</WebText>
<WebText type='body5'>{address}</WebText>
<WebText type='body5' color={theme.webNeutral._700}>{`m/44'/118'/0'/0/${hdPath}`}</WebText>
</Row>
{stored ? (
Expand Down
26 changes: 18 additions & 8 deletions packages/adena-extension/src/hooks/web/use-account-add-screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type UseAccountAddScreenReturn = {
export type AccountAddStateType = 'INIT' | 'SELECT_SEED_PHRASE' | 'CREATE_ACCOUNT';

const useAccountAddScreen = (): UseAccountAddScreenReturn => {
const { navigate, params } = useAppNavigate<RoutePath.WebAccountAdd>();
const { navigate } = useAppNavigate<RoutePath.WebAccountAdd>();
const { ableToSkipQuestionnaire } = useQuestionnaire();
const { wallet, updateWallet } = useWalletContext();
const { changeCurrentAccount } = useCurrentAccount();
Expand All @@ -42,13 +42,19 @@ const useAccountAddScreen = (): UseAccountAddScreenReturn => {
return wallet.keyrings.filter(isHDWalletKeyring).length > 1;
}, [wallet]);

const [step, setStep] = useState<AccountAddStateType>(
params?.doneQuestionnaire
? hasMultiSeedPhrase
? 'CREATE_ACCOUNT'
: 'SELECT_SEED_PHRASE'
: 'INIT',
);
const getInitializeStep = (): AccountAddStateType => {
if (!wallet) {
return 'INIT';
}

if (hasMultiSeedPhrase) {
return 'SELECT_SEED_PHRASE';
}

return 'CREATE_ACCOUNT';
};

const [step, setStep] = useState<AccountAddStateType>(getInitializeStep());

const accountAddStepNo = hasMultiSeedPhrase
? {
Expand Down Expand Up @@ -87,6 +93,10 @@ const useAccountAddScreen = (): UseAccountAddScreenReturn => {
break;
case 'SELECT_SEED_PHRASE':
case 'CREATE_ACCOUNT':
if (wallet) {
navigate(RoutePath.WebAdvancedOption);
break;
}
setStep('INIT');
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,11 @@ const useAccountImportScreen = ({ wallet }: { wallet: Wallet }): UseAccountImpor
}
}, [
step,
wallet,
inputType,
inputValue,
selectedAddresses,
loadedAccounts,
ableToSkipQuestionnaire,
makePrivateKeyAccountAndKeyring,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { WebMainHeader } from '@components/pages/web/main-header';
import useAccountAddScreen from '@hooks/web/use-account-add-screen';

import { ADENA_DOCS_PAGE } from '@common/constants/resource.constant';
import { WEB_TOP_SPACING, WEB_TOP_SPACING_RESPONSIVE } from '@common/constants/ui.constant';
import { WEB_TOP_SPACING } from '@common/constants/ui.constant';
import SensitiveInfoStep from '@components/pages/web/sensitive-info-step';
import CreateAccountStep from './create-account-step';
import SelectSeedPhraseStep from './select-seed-phrase-step';
Expand All @@ -20,7 +20,7 @@ const AccountAddScreen = (): ReactElement => {
if (step === 'INIT') {
return {
default: WEB_TOP_SPACING,
responsive: WEB_TOP_SPACING_RESPONSIVE,
responsive: WEB_TOP_SPACING,
};
}
return null;
Expand Down

0 comments on commit 5ab7148

Please sign in to comment.