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-27 01:10:37 +00:00
|
|
|
import { TransactionData } from "../types";
|
2021-10-27 04:08:26 +00:00
|
|
|
import { rawInputTo4Bytes, use4Bytes } from "../use4Bytes";
|
2021-10-27 01:10:37 +00:00
|
|
|
import { TraceGroup } from "../useErigonHooks";
|
|
|
|
|
|
|
|
|
|
type TraceItemProps = {
|
|
|
|
|
t: TraceGroup;
|
|
|
|
|
txData: TransactionData;
|
|
|
|
|
last: boolean;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TraceItem: React.FC<TraceItemProps> = ({ t, txData, last }) => {
|
|
|
|
|
const raw4Bytes = rawInputTo4Bytes(t.input);
|
2021-10-27 04:08:26 +00:00
|
|
|
const fourBytesEntry = use4Bytes(raw4Bytes);
|
|
|
|
|
|
2021-10-27 01:10:37 +00:00
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<div className="flex">
|
|
|
|
|
<div className="relative w-5">
|
|
|
|
|
<div className="absolute border-l border-b w-full h-full transform -translate-y-1/2"></div>
|
|
|
|
|
{!last && (
|
|
|
|
|
<div className="absolute left-0 border-l w-full h-full transform translate-y-1/2"></div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex items-baseline border rounded px-1 py-px">
|
|
|
|
|
<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-27 04:18:18 +00:00
|
|
|
<span
|
|
|
|
|
className={`font-bold ${
|
2021-10-27 04:33:14 +00:00
|
|
|
t.type === "STATICCALL"
|
|
|
|
|
? "text-red-700"
|
2021-10-27 17:57:38 +00:00
|
|
|
: t.type === "DELEGATECALL" || t.type === "CALLCODE"
|
2021-10-27 04:33:14 +00:00
|
|
|
? "text-gray-400"
|
|
|
|
|
: "text-blue-900"
|
2021-10-27 04:18:18 +00:00
|
|
|
}`}
|
|
|
|
|
>
|
2021-10-27 04:08:26 +00:00
|
|
|
{fourBytesEntry ? fourBytesEntry.name : raw4Bytes}
|
|
|
|
|
</span>
|
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-27 01:10:37 +00:00
|
|
|
<span>(</span>
|
|
|
|
|
{t.input.length > 10 && (
|
|
|
|
|
<span className="whitespace-nowrap">
|
2021-10-27 04:20:01 +00:00
|
|
|
input=[0x{t.input.slice(10)}]
|
2021-10-27 01:10:37 +00:00
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
<span>)</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{t.children && (
|
|
|
|
|
<div className="flex">
|
|
|
|
|
<div className={`w-10 ${last ? "" : "border-l"}`}></div>
|
|
|
|
|
<div className="space-y-3">
|
|
|
|
|
{t.children.map((tc, i, a) => (
|
|
|
|
|
<TraceItem
|
|
|
|
|
key={i}
|
|
|
|
|
t={tc}
|
|
|
|
|
txData={txData}
|
|
|
|
|
last={i === a.length - 1}
|
|
|
|
|
/>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default React.memo(TraceItem);
|