import React, { useState } from "react"; import { Switch } from "@headlessui/react"; import AddressHighlighter from "../components/AddressHighlighter"; import DecoratedAddressLink from "../components/DecoratedAddressLink"; import FormattedBalance from "../components/FormattedBalance"; import FunctionSignature from "./FunctionSignature"; import DecodedParamsTable from "./decoder/DecodedParamsTable"; import { TraceEntry } from "../useErigonHooks"; import { TransactionData } from "../types"; import { ResolvedAddresses } from "../api/address-resolver"; import { extract4Bytes, FourBytesEntry, useTransactionDescription, } from "../use4Bytes"; type TraceInputProps = { t: TraceEntry; txData: TransactionData; fourBytesMap: Record; resolvedAddresses: ResolvedAddresses | undefined; }; const TraceInput: React.FC = ({ t, txData, fourBytesMap, resolvedAddresses, }) => { const raw4Bytes = extract4Bytes(t.input); const fourBytes = raw4Bytes !== null ? fourBytesMap[raw4Bytes] : null; const sigText = raw4Bytes === null ? "" : fourBytes?.name ?? raw4Bytes; const hasParams = t.input.length > 10; const fourBytesTxDesc = useTransactionDescription( fourBytes, t.input, t.value ); const [expanded, setExpanded] = useState(false); return (
{t.type} . {t.value && !t.value.isZero() && ( {"{"}value: ETH{"}"} )} ( {hasParams && ( {expanded ? ( [-] ) : ( <>[...] )} )} {(!hasParams || !expanded) && <>)}
{hasParams && expanded && fourBytesTxDesc && ( <>
)
)}
); }; export default TraceInput;