2021-10-27 01:10:37 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import AddressHighlighter from "../components/AddressHighlighter";
|
|
|
|
|
import DecoratedAddressLink from "../components/DecoratedAddressLink";
|
2021-10-27 08:14:46 +00:00
|
|
|
import FormattedBalance from "../components/FormattedBalance";
|
2021-10-28 05:54:36 +00:00
|
|
|
import FunctionSignature from "./FunctionSignature";
|
2021-10-27 01:10:37 +00:00
|
|
|
import { TransactionData } from "../types";
|
2021-10-28 20:39:10 +00:00
|
|
|
import { extract4Bytes, FourBytesEntry } from "../use4Bytes";
|
2021-10-27 01:10:37 +00:00
|
|
|
import { TraceGroup } from "../useErigonHooks";
|
|
|
|
|
|
|
|
|
|
type TraceItemProps = {
|
|
|
|
|
t: TraceGroup;
|
|
|
|
|
txData: TransactionData;
|
|
|
|
|
last: boolean;
|
2021-10-28 20:21:01 +00:00
|
|
|
fourBytesMap: Record<string, FourBytesEntry | null | undefined>;
|
2021-10-27 01:10:37 +00:00
|
|
|
};
|
|
|
|
|
|
2021-10-28 20:21:01 +00:00
|
|
|
const TraceItem: React.FC<TraceItemProps> = ({
|
|
|
|
|
t,
|
|
|
|
|
txData,
|
|
|
|
|
last,
|
|
|
|
|
fourBytesMap,
|
|
|
|
|
}) => {
|
2021-10-28 20:39:10 +00:00
|
|
|
const raw4Bytes = extract4Bytes(t.input);
|
|
|
|
|
const sigText =
|
|
|
|
|
raw4Bytes === null
|
|
|
|
|
? "<fallback>"
|
|
|
|
|
: fourBytesMap[raw4Bytes]?.name ?? raw4Bytes;
|
2021-10-27 04:08:26 +00:00
|
|
|
|
2021-10-27 01:10:37 +00:00
|
|
|
return (
|
|
|
|
|
<>
|
2021-10-30 01:31:16 +00:00
|
|
|
<div className="flex relative">
|
|
|
|
|
<div className="absolute border-l border-b w-5 h-full transform -translate-y-1/2"></div>
|
|
|
|
|
{!last && (
|
|
|
|
|
<div className="absolute left-0 border-l w-5 h-full transform translate-y-1/2"></div>
|
|
|
|
|
)}
|
|
|
|
|
<div className="ml-5 flex items-baseline border rounded px-1 py-px">
|
2021-10-27 01:10:37 +00:00
|
|
|
<span className="text-xs text-gray-400 lowercase">{t.type}</span>
|
|
|
|
|
<span>
|
|
|
|
|
<AddressHighlighter address={t.to}>
|
|
|
|
|
<DecoratedAddressLink
|
|
|
|
|
address={t.to}
|
|
|
|
|
miner={t.to === txData.confirmedData?.miner}
|
|
|
|
|
txFrom={t.to === txData.from}
|
|
|
|
|
txTo={t.to === txData.to}
|
|
|
|
|
/>
|
|
|
|
|
</AddressHighlighter>
|
|
|
|
|
</span>
|
|
|
|
|
<span>.</span>
|
2021-10-28 20:39:10 +00:00
|
|
|
<FunctionSignature callType={t.type} sig={sigText} />
|
2021-10-27 08:14:46 +00:00
|
|
|
{t.value && !t.value.isZero() && (
|
|
|
|
|
<span className="text-red-700 whitespace-nowrap">
|
|
|
|
|
{"{"}value: <FormattedBalance value={t.value} /> ETH{"}"}
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
2021-10-30 01:31:16 +00:00
|
|
|
<span className="whitespace-nowrap">
|
|
|
|
|
({t.input.length > 10 && <>input=[0x{t.input.slice(10)}]</>})
|
|
|
|
|
</span>
|
2021-10-27 01:10:37 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{t.children && (
|
2021-10-30 01:31:16 +00:00
|
|
|
<div className={`pl-10 ${last ? "" : "border-l"} space-y-3`}>
|
|
|
|
|
{t.children.map((tc, i, a) => (
|
|
|
|
|
<TraceItem
|
|
|
|
|
key={i}
|
|
|
|
|
t={tc}
|
|
|
|
|
txData={txData}
|
|
|
|
|
last={i === a.length - 1}
|
|
|
|
|
fourBytesMap={fourBytesMap}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
2021-10-27 01:10:37 +00:00
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-27 20:19:20 +00:00
|
|
|
export default TraceItem;
|