diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index b6246b2..ef6a5fa 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -5,7 +5,6 @@ import { Interface, } from "@ethersproject/abi"; import { BigNumber } from "@ethersproject/bignumber"; -import { toUtf8String } from "@ethersproject/strings"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faCheckCircle } from "@fortawesome/free-solid-svg-icons/faCheckCircle"; import { faCube } from "@fortawesome/free-solid-svg-icons/faCube"; @@ -62,16 +61,6 @@ const Details: React.FC = ({ txData.confirmedData?.blockBaseFeePerGas !== undefined && txData.confirmedData?.blockBaseFeePerGas !== null; - const utfInput = useMemo(() => { - try { - return txData && toUtf8String(txData.data); - } catch (err) { - console.warn("Error while converting input data to string"); - console.warn(err); - return ""; - } - }, [txData]); - const fourBytes = txData.to !== null ? rawInputTo4Bytes(txData.data) : "0x"; const fourBytesEntry = use4Bytes(fourBytes); const fourBytesTxDesc = useMemo(() => { @@ -339,11 +328,10 @@ const Details: React.FC = ({ diff --git a/src/transaction/LogEntry.tsx b/src/transaction/LogEntry.tsx index d8bf1ea..de34971 100644 --- a/src/transaction/LogEntry.tsx +++ b/src/transaction/LogEntry.tsx @@ -7,19 +7,16 @@ import Copy from "../components/Copy"; import ModeTab from "../components/ModeTab"; import DecodedParamsTable from "./decoder/DecodedParamsTable"; import DecodedLogSignature from "./decoder/DecodedLogSignature"; -import { TransactionData } from "../types"; import { useTopic0 } from "../useTopic0"; import { ResolvedAddresses } from "../api/address-resolver"; type LogEntryProps = { - txData: TransactionData; log: Log; logDesc: LogDescription | null | undefined; resolvedAddresses: ResolvedAddresses | undefined; }; const LogEntry: React.FC = ({ - txData, log, logDesc, resolvedAddresses, @@ -106,7 +103,6 @@ const LogEntry: React.FC = ({ diff --git a/src/transaction/Logs.tsx b/src/transaction/Logs.tsx index 1fd4207..85104f7 100644 --- a/src/transaction/Logs.tsx +++ b/src/transaction/Logs.tsx @@ -69,7 +69,6 @@ const Logs: React.FC = ({ txData, metadata, resolvedAddresses }) => { {txData.confirmedData.logs.map((l, i) => ( = ({ i, r, paramType, - txData, arrayElem, help, resolvedAddresses, @@ -102,7 +99,6 @@ const DecodedParamRow: React.FC = ({ i={idx} r={e} paramType={paramType.components[idx]} - txData={txData} /> ))} {paramType.baseType === "array" && @@ -112,7 +108,6 @@ const DecodedParamRow: React.FC = ({ prefix={paramType.name ?? param_{i}} r={e} paramType={paramType.arrayChildren} - txData={txData} arrayElem={idx} /> ))} diff --git a/src/transaction/decoder/DecodedParamsTable.tsx b/src/transaction/decoder/DecodedParamsTable.tsx index 8f4a562..376eee2 100644 --- a/src/transaction/decoder/DecodedParamsTable.tsx +++ b/src/transaction/decoder/DecodedParamsTable.tsx @@ -1,14 +1,12 @@ import React from "react"; import { ParamType, Result } from "@ethersproject/abi"; import DecodedParamRow from "./DecodedParamRow"; -import { TransactionData } from "../../types"; import { DevMethod, UserMethod } from "../../useSourcify"; import { ResolvedAddresses } from "../../api/address-resolver"; type DecodedParamsTableProps = { args: Result; paramTypes: ParamType[]; - txData: TransactionData; hasParamNames?: boolean; userMethod?: UserMethod | undefined; devMethod?: DevMethod | undefined; @@ -18,7 +16,6 @@ type DecodedParamsTableProps = { const DecodedParamsTable: React.FC = ({ args, paramTypes, - txData, hasParamNames = true, devMethod, resolvedAddresses, @@ -49,7 +46,6 @@ const DecodedParamsTable: React.FC = ({ i={i} r={r} paramType={paramTypes[i]} - txData={txData} help={devMethod?.params?.[paramTypes[i].name]} resolvedAddresses={resolvedAddresses} /> diff --git a/src/transaction/decoder/InputDecoder.tsx b/src/transaction/decoder/InputDecoder.tsx index 69820fd..d516539 100644 --- a/src/transaction/decoder/InputDecoder.tsx +++ b/src/transaction/decoder/InputDecoder.tsx @@ -1,75 +1,84 @@ -import React from "react"; +import React, { useMemo } from "react"; import { TransactionDescription } from "@ethersproject/abi"; +import { toUtf8String } from "@ethersproject/strings"; import { Tab } from "@headlessui/react"; import ModeTab from "../../components/ModeTab"; import DecodedParamsTable from "./DecodedParamsTable"; -import { TransactionData } from "../../types"; import { DevMethod, UserMethod } from "../../useSourcify"; import { ResolvedAddresses } from "../../api/address-resolver"; type InputDecoderProps = { fourBytes: string; resolvedTxDesc: TransactionDescription | null | undefined; - txDesc: TransactionDescription | null | undefined; - txData: TransactionData; + hasParamNames: boolean; + data: string; userMethod: UserMethod | undefined; devMethod: DevMethod | undefined; - utfInput: string; resolvedAddresses: ResolvedAddresses | undefined; }; const InputDecoder: React.FC = ({ fourBytes, resolvedTxDesc, - txDesc, - txData, + hasParamNames, + data, userMethod, devMethod, - utfInput, resolvedAddresses, -}) => ( - - - Decoded - Raw - UTF-8 - - - - {fourBytes === "0x" ? ( - <>No parameters - ) : resolvedTxDesc === undefined ? ( - <>Waiting for data... - ) : resolvedTxDesc === null ? ( - <>Can't decode data - ) : ( - { + const utfInput = useMemo(() => { + try { + return toUtf8String(data); + } catch (err) { + console.warn("Error while converting input data to string"); + console.warn(err); + return ""; + } + }, [data]); + + return ( + + + Decoded + Raw + UTF-8 + + + + {fourBytes === "0x" ? ( + <>No parameters + ) : resolvedTxDesc === undefined ? ( + <>Waiting for data... + ) : resolvedTxDesc === null ? ( + <>Can't decode data + ) : ( + + )} + + +