From b699d0215e0b9eaec565df5dffaedb9d1b715b4c Mon Sep 17 00:00:00 2001 From: jinoosss Date: Thu, 26 Sep 2024 12:02:24 +0900 Subject: [PATCH] feat: add validation logic when adding seed phrases --- .../src/hooks/web/use-account-import-screen.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/adena-extension/src/hooks/web/use-account-import-screen.ts b/packages/adena-extension/src/hooks/web/use-account-import-screen.ts index 54783e3a..7cfba1c0 100644 --- a/packages/adena-extension/src/hooks/web/use-account-import-screen.ts +++ b/packages/adena-extension/src/hooks/web/use-account-import-screen.ts @@ -166,6 +166,7 @@ const useAccountImportScreen = ({ wallet }: { wallet: Wallet }): UseAccountImpor const onClickNext = useCallback(async () => { if (step === 'INIT') { + setErrMsg(''); if (ableToSkipQuestionnaire) { setStep('SET_MNEMONIC'); } else { @@ -190,11 +191,14 @@ const useAccountImportScreen = ({ wallet }: { wallet: Wallet }): UseAccountImpor }).then(() => navigate(RoutePath.WebAccountAddedComplete)); return; } else { - setStep('LOADING'); + const keyring = await HDWalletKeyring.fromMnemonic(inputValue).catch(() => null); + if (!keyring) { + setErrMsg('Invalid seed phrase'); + return; + } + setStep('LOADING'); await waitForRun(async () => { - const keyring = await HDWalletKeyring.fromMnemonic(inputValue); - setGeneratedKeyring(keyring); await loadAccountsByKeyring(keyring); }).then(() => {