diff --git a/components/Transaction/index.tsx b/components/Transaction/index.tsx index 33e86d3..ae09717 100644 --- a/components/Transaction/index.tsx +++ b/components/Transaction/index.tsx @@ -1,5 +1,5 @@ import { Play } from "phosphor-react"; -import { FC, useCallback, useEffect, useMemo } from "react"; +import { FC, useCallback, useEffect } from "react"; import { useSnapshot } from "valtio"; import state from "../../state"; import { @@ -15,7 +15,7 @@ import Flex from "../Flex"; import { TxJson } from "./json"; import { TxUI } from "./ui"; import { default as _estimateFee } from "../../utils/estimateFee"; -import toast from 'react-hot-toast'; +import toast from "react-hot-toast"; export interface TransactionProps { header: string; @@ -34,7 +34,6 @@ const Transaction: FC = ({ txIsDisabled, txIsLoading, viewType, - editorSavedValue, editorValue, } = txState; @@ -46,7 +45,7 @@ const Transaction: FC = ({ ); const prepareOptions = useCallback( - (state: TransactionState = txState) => { + (state: Partial = txState) => { const { selectedTransaction, selectedDestAccount, @@ -57,7 +56,7 @@ const Transaction: FC = ({ const TransactionType = selectedTransaction?.value || null; const Destination = selectedDestAccount?.value || - ("Destination" in txFields ? null : undefined); + (txFields && "Destination" in txFields ? null : undefined); const Account = selectedAccount?.value || null; return prepareTransaction({ @@ -140,11 +139,14 @@ const Transaction: FC = ({ modifyTransaction(header, { viewType }, { replaceState: true }); }, [header, viewType]); - const jsonValue = useMemo( - () => - editorSavedValue || - JSON.stringify(prepareOptions?.() || {}, null, editorSettings.tabSize), - [editorSavedValue, editorSettings.tabSize, prepareOptions] + const getJsonString = useCallback( + (state?: Partial) => + JSON.stringify( + prepareOptions?.(state) || {}, + null, + editorSettings.tabSize + ), + [editorSettings.tabSize, prepareOptions] ); const estimateFee = useCallback( @@ -156,10 +158,10 @@ const Transaction: FC = ({ ); if (!account) { if (!opts?.silent) { - toast.error("Please select account from the list.") + toast.error("Please select account from the list."); } - return - }; + return; + } ptx.Account = account.address; ptx.Sequence = account.sequence; @@ -176,7 +178,7 @@ const Transaction: FC = ({ {viewType === "json" ? ( = ({