2021-07-14 19:30:28 +00:00
|
|
|
import React from "react";
|
|
|
|
import { ethers } from "ethers";
|
|
|
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
|
|
import {
|
|
|
|
faCheckCircle,
|
|
|
|
faTimesCircle,
|
|
|
|
} from "@fortawesome/free-solid-svg-icons";
|
|
|
|
import ContentFrame from "../ContentFrame";
|
|
|
|
import InfoRow from "../components/InfoRow";
|
|
|
|
import BlockLink from "../components/BlockLink";
|
|
|
|
import AddressHighlighter from "../components/AddressHighlighter";
|
2021-07-19 03:38:38 +00:00
|
|
|
import DecoratedAddressLink from "../components/DecoratedAddressLink";
|
2021-07-14 19:30:28 +00:00
|
|
|
import Copy from "../components/Copy";
|
|
|
|
import Timestamp from "../components/Timestamp";
|
2021-07-19 23:49:54 +00:00
|
|
|
import InternalOperation from "../components/InternalOperation";
|
2021-07-14 19:30:28 +00:00
|
|
|
import MethodName from "../components/MethodName";
|
|
|
|
import GasValue from "../components/GasValue";
|
|
|
|
import FormattedBalance from "../components/FormattedBalance";
|
|
|
|
import TokenTransferItem from "../TokenTransferItem";
|
2021-07-19 23:49:54 +00:00
|
|
|
import { TransactionData, Transfer } from "../types";
|
2021-07-14 19:30:28 +00:00
|
|
|
|
|
|
|
type DetailsProps = {
|
|
|
|
txData: TransactionData;
|
2021-07-19 23:49:54 +00:00
|
|
|
internalTransfers?: Transfer[];
|
2021-07-14 19:30:28 +00:00
|
|
|
sendsEthToMiner: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
const Details: React.FC<DetailsProps> = ({
|
|
|
|
txData,
|
2021-07-17 18:58:33 +00:00
|
|
|
internalTransfers,
|
2021-07-14 19:30:28 +00:00
|
|
|
sendsEthToMiner,
|
|
|
|
}) => (
|
|
|
|
<ContentFrame tabs>
|
|
|
|
<InfoRow title="Transaction Hash">
|
|
|
|
<div className="flex items-baseline space-x-2">
|
|
|
|
<span className="font-hash">{txData.transactionHash}</span>
|
|
|
|
<Copy value={txData.transactionHash} />
|
|
|
|
</div>
|
|
|
|
</InfoRow>
|
|
|
|
<InfoRow title="Status">
|
|
|
|
{txData.status ? (
|
|
|
|
<span className="flex items-center w-min rounded-lg space-x-1 px-3 py-1 bg-green-50 text-green-500 text-xs">
|
|
|
|
<FontAwesomeIcon icon={faCheckCircle} size="1x" />
|
|
|
|
<span>Success</span>
|
|
|
|
</span>
|
|
|
|
) : (
|
|
|
|
<span className="flex items-center w-min rounded-lg space-x-1 px-3 py-1 bg-red-50 text-red-500 text-xs">
|
|
|
|
<FontAwesomeIcon icon={faTimesCircle} size="1x" />
|
|
|
|
<span>Fail</span>
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
</InfoRow>
|
|
|
|
<InfoRow title="Block">
|
|
|
|
<div className="flex items-baseline space-x-2">
|
|
|
|
<BlockLink blockTag={txData.blockNumber} />
|
|
|
|
<span className="rounded text-xs bg-gray-100 text-gray-500 px-2 py-1">
|
|
|
|
{txData.confirmations} Block Confirmations
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</InfoRow>
|
|
|
|
<InfoRow title="Timestamp">
|
|
|
|
<Timestamp value={txData.timestamp} />
|
|
|
|
</InfoRow>
|
|
|
|
<InfoRow title="From">
|
|
|
|
<div className="flex items-baseline space-x-2 -ml-1">
|
|
|
|
<AddressHighlighter address={txData.from}>
|
2021-07-19 03:38:38 +00:00
|
|
|
<DecoratedAddressLink
|
|
|
|
address={txData.from}
|
|
|
|
miner={txData.from === txData.miner}
|
2021-07-19 16:29:49 +00:00
|
|
|
txFrom
|
2021-07-19 03:38:38 +00:00
|
|
|
/>
|
2021-07-14 19:30:28 +00:00
|
|
|
</AddressHighlighter>
|
|
|
|
<Copy value={txData.from} />
|
|
|
|
</div>
|
|
|
|
</InfoRow>
|
|
|
|
<InfoRow title="Interacted With (To)">
|
|
|
|
<div className="flex items-baseline space-x-2 -ml-1">
|
|
|
|
<AddressHighlighter address={txData.to}>
|
2021-07-19 03:38:38 +00:00
|
|
|
<DecoratedAddressLink
|
|
|
|
address={txData.to}
|
|
|
|
miner={txData.to === txData.miner}
|
2021-07-19 16:29:49 +00:00
|
|
|
txTo
|
2021-07-19 03:38:38 +00:00
|
|
|
/>
|
2021-07-14 19:30:28 +00:00
|
|
|
</AddressHighlighter>
|
|
|
|
<Copy value={txData.to} />
|
|
|
|
</div>
|
2021-07-17 18:58:33 +00:00
|
|
|
{internalTransfers && (
|
2021-07-19 07:14:56 +00:00
|
|
|
<div className="mt-2 space-y-1">
|
2021-07-19 23:49:54 +00:00
|
|
|
{internalTransfers.map((t, i) => (
|
|
|
|
<InternalOperation key={i} txData={txData} transfer={t} />
|
2021-07-19 07:14:56 +00:00
|
|
|
))}
|
|
|
|
</div>
|
2021-07-14 19:30:28 +00:00
|
|
|
)}
|
|
|
|
</InfoRow>
|
|
|
|
<InfoRow title="Transaction Action">
|
|
|
|
<MethodName data={txData.data} />
|
|
|
|
</InfoRow>
|
|
|
|
{txData.tokenTransfers.length > 0 && (
|
|
|
|
<InfoRow title={`Tokens Transferred (${txData.tokenTransfers.length})`}>
|
2021-07-19 03:55:21 +00:00
|
|
|
<div>
|
2021-07-14 19:30:28 +00:00
|
|
|
{txData.tokenTransfers.map((t, i) => (
|
2021-07-19 16:29:49 +00:00
|
|
|
<TokenTransferItem
|
|
|
|
key={i}
|
|
|
|
t={t}
|
|
|
|
txData={txData}
|
|
|
|
tokenMetas={txData.tokenMetas}
|
|
|
|
/>
|
2021-07-14 19:30:28 +00:00
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</InfoRow>
|
|
|
|
)}
|
|
|
|
<InfoRow title="Value">
|
|
|
|
<span className="rounded bg-gray-100 px-2 py-1 text-xs">
|
|
|
|
{ethers.utils.formatEther(txData.value)} Ether
|
|
|
|
</span>
|
|
|
|
</InfoRow>
|
|
|
|
<InfoRow title="Transaction Fee">
|
|
|
|
<FormattedBalance value={txData.fee} /> Ether
|
|
|
|
</InfoRow>
|
|
|
|
<InfoRow title="Gas Price">
|
|
|
|
<div className="flex items-baseline space-x-1">
|
|
|
|
<span>
|
|
|
|
<FormattedBalance value={txData.gasPrice} /> Ether (
|
|
|
|
<FormattedBalance value={txData.gasPrice} decimals={9} /> Gwei)
|
|
|
|
</span>
|
|
|
|
{sendsEthToMiner && (
|
|
|
|
<span className="rounded text-yellow-500 bg-yellow-100 text-xs px-2 py-1">
|
|
|
|
Flashbots
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</InfoRow>
|
|
|
|
<InfoRow title="Ether Price">N/A</InfoRow>
|
|
|
|
<InfoRow title="Gas Limit">
|
|
|
|
<GasValue value={txData.gasLimit} />
|
|
|
|
</InfoRow>
|
|
|
|
<InfoRow title="Gas Used by Transaction">
|
|
|
|
<GasValue value={txData.gasUsed} /> (
|
|
|
|
{(txData.gasUsedPerc * 100).toFixed(2)}%)
|
|
|
|
</InfoRow>
|
|
|
|
<InfoRow title="Nonce">{txData.nonce}</InfoRow>
|
|
|
|
<InfoRow title="Position in Block">
|
|
|
|
<span className="rounded px-2 py-1 bg-gray-100 text-gray-500 text-xs">
|
|
|
|
{txData.transactionIndex}
|
|
|
|
</span>
|
|
|
|
</InfoRow>
|
|
|
|
<InfoRow title="Input Data">
|
|
|
|
<textarea
|
|
|
|
className="w-full h-40 bg-gray-50 text-gray-500 font-mono focus:outline-none border rounded p-2"
|
|
|
|
value={txData.data}
|
|
|
|
readOnly
|
|
|
|
/>
|
|
|
|
</InfoRow>
|
|
|
|
</ContentFrame>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default React.memo(Details);
|