import React, { useState } from "react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faBomb } from "@fortawesome/free-solid-svg-icons/faBomb"; import TransactionAddress from "../components/TransactionAddress"; import FormattedBalance from "../components/FormattedBalance"; import FunctionSignature from "./FunctionSignature"; import InputDecoder from "./decoder/InputDecoder"; import ExpanderSwitch from "../components/ExpanderSwitch"; import { TraceEntry } from "../useErigonHooks"; import { ResolvedAddresses } from "../api/address-resolver"; import { extract4Bytes, FourBytesEntry, useTransactionDescription, } from "../use4Bytes"; type TraceInputProps = { t: TraceEntry; fourBytesMap: Record; resolvedAddresses: ResolvedAddresses | undefined; }; const TraceInput: React.FC = ({ t, 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.type === "SELFDESTRUCT" ? ( ) : ( <> {t.type !== "CREATE" && t.type !== "CREATE2" && ( <> . {t.value && !t.value.isZero() && ( {"{"}value: ETH{"}"} )} ( {hasParams && ( )} {(!hasParams || !expanded) && <>)} )} )}
{hasParams && expanded && ( <>
)
)}
); }; export default TraceInput;