otterscan/src/components/InternalSelfDestruct.tsx

70 lines
2.4 KiB
TypeScript
Raw Normal View History

import React from "react";
import { formatEther } from "@ethersproject/units";
2021-07-17 18:58:33 +00:00
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faAngleRight } from "@fortawesome/free-solid-svg-icons/faAngleRight";
2021-07-17 18:58:33 +00:00
import AddressHighlighter from "./AddressHighlighter";
import DecoratedAddressLink from "./DecoratedAddressLink";
import TransactionAddress from "./TransactionAddress";
import { useChainInfo } from "../useChainInfo";
import { TransactionData, InternalOperation } from "../types";
2021-07-17 18:58:33 +00:00
type InternalSelfDestructProps = {
txData: TransactionData;
2021-07-21 19:06:51 +00:00
internalOp: InternalOperation;
2021-07-17 18:58:33 +00:00
};
const InternalSelfDestruct: React.FC<InternalSelfDestructProps> = ({
txData,
2021-07-21 19:06:51 +00:00
internalOp,
2021-07-17 18:58:33 +00:00
}) => {
const { nativeSymbol } = useChainInfo();
const toMiner =
txData.confirmedData?.miner !== undefined &&
internalOp.to === txData.confirmedData.miner;
2021-07-17 18:58:33 +00:00
return (
<>
<div className="flex items-baseline space-x-1 whitespace-nowrap">
2021-07-17 18:58:33 +00:00
<span className="text-gray-500">
<FontAwesomeIcon icon={faAngleRight} size="1x" /> SELF DESTRUCT
2021-07-17 18:58:33 +00:00
</span>
<span>Contract</span>
<div className="flex items-baseline">
2021-07-21 19:06:51 +00:00
<AddressHighlighter address={internalOp.from}>
<DecoratedAddressLink address={internalOp.from} selfDestruct />
2021-07-17 18:58:33 +00:00
</AddressHighlighter>
</div>
{internalOp.value.isZero() && (
<div className="flex items-baseline text-gray-400">
(To: <TransactionAddress address={internalOp.to} />)
</div>
)}
2021-07-17 18:58:33 +00:00
</div>
2021-07-21 19:06:51 +00:00
{!internalOp.value.isZero() && (
<div className="ml-5 flex items-baseline space-x-1">
2021-07-17 18:58:33 +00:00
<span className="text-gray-500">
<FontAwesomeIcon icon={faAngleRight} size="1x" /> TRANSFER
</span>
<span>
{formatEther(internalOp.value)} {nativeSymbol}
</span>
2021-07-17 18:58:33 +00:00
<div className="flex items-baseline">
<span className="text-gray-500">To</span>
2021-07-21 19:06:51 +00:00
<AddressHighlighter address={internalOp.to}>
2021-07-17 18:58:33 +00:00
<div
className={`flex items-baseline space-x-1 ${
toMiner ? "rounded px-2 py-1 bg-yellow-100" : ""
}`}
>
<DecoratedAddressLink address={internalOp.to} miner={toMiner} />
2021-07-17 18:58:33 +00:00
</div>
</AddressHighlighter>
</div>
</div>
)}
</>
);
};
2021-11-18 18:51:08 +00:00
export default InternalSelfDestruct;