From 84f43eb6926c312b30002cb8ce2b8ffd86c1f862 Mon Sep 17 00:00:00 2001 From: jinoosss <112360739+jinoosss@users.noreply.github.com> Date: Thu, 26 Sep 2024 12:20:45 +0900 Subject: [PATCH] feat: add validation logic when adding seed phrases (#589) --- .../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(() => {