From e795ce44728f40e68da04f86ddc77d57ab263b92 Mon Sep 17 00:00:00 2001 From: Valtteri Karesto Date: Wed, 6 Apr 2022 14:15:53 +0300 Subject: [PATCH] Fixes issue #68 --- state/actions/importAccount.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/state/actions/importAccount.ts b/state/actions/importAccount.ts index 9cae7c8..4fa5fec 100644 --- a/state/actions/importAccount.ts +++ b/state/actions/importAccount.ts @@ -1,5 +1,5 @@ import toast from "react-hot-toast"; -import { derive } from "xrpl-accountlib"; +import { derive, XRPL_Account } from "xrpl-accountlib"; import state from '../index'; import { names } from './addFaucetAccount'; @@ -12,8 +12,14 @@ export const importAccount = (secret: string) => { if (state.accounts.find((acc) => acc.secret === secret)) { return toast.error("Account already added!"); } - const account = derive.familySeed(secret); - if (!account.secret.familySeed) { + let account: XRPL_Account | null = null; + try { + account = derive.familySeed(secret); + } catch (err: any) { + toast.error(err.message) + return; + } + if (!account || !account.secret.familySeed) { return toast.error(`Couldn't create account!`); } state.accounts.push({