From e88720327e649450a59132a75cce2fc7c5eacd6b Mon Sep 17 00:00:00 2001 From: muzam1l Date: Thu, 28 Apr 2022 18:51:50 +0530 Subject: [PATCH] Allow using only imported accounts --- components/Transaction/index.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/components/Transaction/index.tsx b/components/Transaction/index.tsx index 1aacd5e..913d0ad 100644 --- a/components/Transaction/index.tsx +++ b/components/Transaction/index.tsx @@ -89,19 +89,24 @@ const Transaction: FC = ({ const account = accounts.find( acc => acc.address === selectedAccount?.value ); - const TransactionType = selectedTransaction?.value; - if (!account || !TransactionType || txIsDisabled) return; + if (txIsDisabled) return; setState({ txIsLoading: true }); + const logPrefix = header ? `${header.split(".")[0]}: ` : undefined; try { + if (!account) { + throw Error("Account must be selected from imported accounts!"); + } const options = prepareOptions(st); - const logPrefix = header ? `${header.split(".")[0]}: ` : undefined; await sendTransaction(account, options, { logPrefix }); } catch (error) { console.error(error); if (error instanceof Error) { - state.transactionLogs.push({ type: "error", message: error.message }); + state.transactionLogs.push({ + type: "error", + message: `${logPrefix}${error.message}`, + }); } } setState({ txIsLoading: false }); @@ -109,7 +114,6 @@ const Transaction: FC = ({ viewType, editorValue, accounts, - selectedTransaction?.value, txIsDisabled, setState, selectedAccount?.value,