diff --git a/src/transaction/TraceInput.tsx b/src/transaction/TraceInput.tsx new file mode 100644 index 0000000..e656d6e --- /dev/null +++ b/src/transaction/TraceInput.tsx @@ -0,0 +1,58 @@ +import React from "react"; +import AddressHighlighter from "../components/AddressHighlighter"; +import DecoratedAddressLink from "../components/DecoratedAddressLink"; +import FormattedBalance from "../components/FormattedBalance"; +import FunctionSignature from "./FunctionSignature"; +import { TraceEntry } from "../useErigonHooks"; +import { TransactionData } from "../types"; +import { ResolvedAddresses } from "../api/address-resolver"; +import { extract4Bytes, FourBytesEntry } 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 sigText = + raw4Bytes === null + ? "" + : fourBytesMap[raw4Bytes]?.name ?? raw4Bytes; + + return ( +
+ {t.type} + + + + + + . + + {t.value && !t.value.isZero() && ( + + {"{"}value: ETH{"}"} + + )} + + ({t.input.length > 10 && <>input=[0x{t.input.slice(10)}]}) + +
+ ); +}; + +export default TraceInput; diff --git a/src/transaction/TraceItem.tsx b/src/transaction/TraceItem.tsx index 9f7510c..b1e2be3 100644 --- a/src/transaction/TraceItem.tsx +++ b/src/transaction/TraceItem.tsx @@ -3,14 +3,11 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faPlusSquare } from "@fortawesome/free-regular-svg-icons/faPlusSquare"; import { faMinusSquare } from "@fortawesome/free-regular-svg-icons/faMinusSquare"; 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 { TransactionData } from "../types"; -import { extract4Bytes, FourBytesEntry } from "../use4Bytes"; +import { FourBytesEntry } from "../use4Bytes"; import { TraceGroup } from "../useErigonHooks"; import { ResolvedAddresses } from "../api/address-resolver"; +import TraceInput from "./TraceInput"; type TraceItemProps = { t: TraceGroup; @@ -28,11 +25,6 @@ const TraceItem: React.FC = ({ resolvedAddresses, }) => { const [expanded, setExpanded] = useState(true); - const raw4Bytes = extract4Bytes(t.input); - const sigText = - raw4Bytes === null - ? "" - : fourBytesMap[raw4Bytes]?.name ?? raw4Bytes; return ( <> @@ -53,30 +45,12 @@ const TraceItem: React.FC = ({ /> )} -
- {t.type} - - - - - - . - - {t.value && !t.value.isZero() && ( - - {"{"}value: ETH{"}"} - - )} - - ({t.input.length > 10 && <>input=[0x{t.input.slice(10)}]}) - -
+ {t.children && (