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 { extract4Bytes, use4Bytes, useTransactionDescription, } from "../use4Bytes"; import { useChainInfo } from "../useChainInfo"; import { TransactionData } from "../types"; type TraceInputProps = { t: TraceEntry; txData: TransactionData; }; const TraceInput: React.FC = ({ t, txData }) => { const { nativeSymbol } = useChainInfo(); const raw4Bytes = extract4Bytes(t.input); const fourBytes = use4Bytes(raw4Bytes); 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: {" "} {nativeSymbol} {"}"} )} ( {hasParams && ( )} {(!hasParams || !expanded) && <>)} )} )}
{hasParams && expanded && ( <>
)
)}
); }; export default TraceInput;