diff --git a/src/Transaction.tsx b/src/Transaction.tsx index e18a163..3f450e9 100644 --- a/src/Transaction.tsx +++ b/src/Transaction.tsx @@ -7,27 +7,11 @@ import React, { } from "react"; import { Route, Switch, useParams } from "react-router-dom"; import { BigNumber, ethers } from "ethers"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { - faCheckCircle, - faTimesCircle, -} from "@fortawesome/free-solid-svg-icons"; import StandardFrame from "./StandardFrame"; import StandardSubtitle from "./StandardSubtitle"; import Tab from "./components/Tab"; -import ContentFrame from "./ContentFrame"; -import InfoRow from "./components/InfoRow"; -import BlockLink from "./components/BlockLink"; -import AddressHighlighter from "./components/AddressHighlighter"; -import AddressOrENSName from "./components/AddressOrENSName"; -import AddressLink from "./components/AddressLink"; -import Copy from "./components/Copy"; -import Timestamp from "./components/Timestamp"; -import InternalTransfer from "./components/InternalTransfer"; -import MethodName from "./components/MethodName"; -import GasValue from "./components/GasValue"; -import FormattedBalance from "./components/FormattedBalance"; -import TokenTransferItem from "./TokenTransferItem"; +import Details from "./transaction/Details"; +import Logs from "./transaction/Logs"; import erc20 from "./erc20.json"; import { TokenMetas, TokenTransfer, TransactionData, Transfer } from "./types"; import { RuntimeContext } from "./useRuntime"; @@ -140,7 +124,7 @@ const Transaction: React.FC = () => { return false; }, [txData, transfers]); - const traceTransfersUsingOtsTrace = useCallback(async () => { + const traceTransfers = useCallback(async () => { if (!provider || !txData) { return; } @@ -160,8 +144,8 @@ const Transaction: React.FC = () => { setTransfers(_transfers); }, [provider, txData]); useEffect(() => { - traceTransfersUsingOtsTrace(); - }, [traceTransfersUsingOtsTrace]); + traceTransfers(); + }, [traceTransfers]); const selectionCtx = useSelection(); @@ -178,185 +162,14 @@ const Transaction: React.FC = () => { - - - - {txData.transactionHash} - - - - - {txData.status ? ( - - - Success - - ) : ( - - - Fail - - )} - - - - - - {txData.confirmations} Block Confirmations - - - - - - - - - - - - - - - - - - - - - - {transfers && ( - - {transfers.map((t, i) => ( - - ))} - - )} - - - - - {txData.tokenTransfers.length > 0 && ( - - - {txData.tokenTransfers.map((t, i) => ( - - ))} - - - )} - - - {ethers.utils.formatEther(txData.value)} Ether - - - - Ether - - - - - Ether ( - {" "} - Gwei) - - {sendsEthToMiner && ( - - Flashbots - - )} - - - N/A - - - - - ( - {(txData.gasUsedPerc * 100).toFixed(2)}%) - - {txData.nonce} - - - {txData.transactionIndex} - - - - - - + - - - Transaction Receipt Event Logs - - {txData && - txData.logs.map((l, i) => ( - - - - {l.logIndex} - - - - - Address - - - - - {l.topics.map((t, i) => ( - - - {i === 0 && "Topics"} - - - - {i} - - {t} - - - ))} - - Data - - - - - - - ))} - + diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx new file mode 100644 index 0000000..f5022da --- /dev/null +++ b/src/transaction/Details.tsx @@ -0,0 +1,144 @@ +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"; +import AddressOrENSName from "../components/AddressOrENSName"; +import Copy from "../components/Copy"; +import Timestamp from "../components/Timestamp"; +import InternalTransfer from "../components/InternalTransfer"; +import MethodName from "../components/MethodName"; +import GasValue from "../components/GasValue"; +import FormattedBalance from "../components/FormattedBalance"; +import TokenTransferItem from "../TokenTransferItem"; +import { TransactionData, Transfer } from "../types"; + +type DetailsProps = { + txData: TransactionData; + transfers?: Transfer[]; + sendsEthToMiner: boolean; +}; + +const Details: React.FC = ({ + txData, + transfers, + sendsEthToMiner, +}) => ( + + + + {txData.transactionHash} + + + + + {txData.status ? ( + + + Success + + ) : ( + + + Fail + + )} + + + + + + {txData.confirmations} Block Confirmations + + + + + + + + + + + + + + + + + + + + + + {transfers && ( + + {transfers.map((t, i) => ( + + ))} + + )} + + + + + {txData.tokenTransfers.length > 0 && ( + + + {txData.tokenTransfers.map((t, i) => ( + + ))} + + + )} + + + {ethers.utils.formatEther(txData.value)} Ether + + + + Ether + + + + + Ether ( + Gwei) + + {sendsEthToMiner && ( + + Flashbots + + )} + + + N/A + + + + + ( + {(txData.gasUsedPerc * 100).toFixed(2)}%) + + {txData.nonce} + + + {txData.transactionIndex} + + + + + + +); + +export default React.memo(Details); diff --git a/src/transaction/Logs.tsx b/src/transaction/Logs.tsx new file mode 100644 index 0000000..eda12be --- /dev/null +++ b/src/transaction/Logs.tsx @@ -0,0 +1,57 @@ +import React from "react"; +import ContentFrame from "../ContentFrame"; +import AddressLink from "../components/AddressLink"; +import { TransactionData } from "../types"; + +type LogsProps = { + txData: TransactionData; +}; + +const Logs: React.FC = ({ txData }) => ( + + Transaction Receipt Event Logs + {txData && + txData.logs.map((l, i) => ( + + + + {l.logIndex} + + + + + Address + + + + + {l.topics.map((t, i) => ( + + {i === 0 && "Topics"} + + + {i} + + {t} + + + ))} + + Data + + + + + + + ))} + +); + +export default React.memo(Logs);