Skip to content

Commit

Permalink
feat: add validation logic when adding seed phrases (#589)
Browse files Browse the repository at this point in the history
  • Loading branch information
jinoosss authored Sep 26, 2024
1 parent 5ab7148 commit 84f43eb
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ const useAccountImportScreen = ({ wallet }: { wallet: Wallet }): UseAccountImpor

const onClickNext = useCallback(async () => {
if (step === 'INIT') {
setErrMsg('');
if (ableToSkipQuestionnaire) {
setStep('SET_MNEMONIC');
} else {
Expand All @@ -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(() => {
Expand Down

0 comments on commit 84f43eb

Please sign in to comment.