import React, { useContext, useMemo } from "react"; import { Route, Routes } from "react-router-dom"; import { Tab } from "@headlessui/react"; import StandardFrame from "./StandardFrame"; import StandardSubtitle from "./StandardSubtitle"; import ContentFrame from "./ContentFrame"; import NavTab from "./components/NavTab"; import { RuntimeContext } from "./useRuntime"; import { useInternalOperations, useTxData } from "./useErigonHooks"; import { SelectionContext, useSelection } from "./useSelection"; import { SelectedTransactionContext } from "./useSelectedTransaction"; import { useETHUSDOracle } from "./usePriceOracle"; import { useAppConfigContext } from "./useAppConfig"; import { useSourcify, useTransactionDescription } from "./sourcify/useSourcify"; const Details = React.lazy( () => import( /* webpackChunkName: "txdetails", webpackPrefetch: true */ "./transaction/Details" ) ); const Logs = React.lazy( () => import( /* webpackChunkName: "txlogs", webpackPrefetch: true */ "./transaction/Logs" ) ); const Trace = React.lazy( () => import( /* webpackChunkName: "txtrace", webpackPrefetch: true */ "./transaction/Trace" ) ); type TransactionPageContentProps = { txHash: string; }; const TransactionPageContent: React.FC = ({ txHash, }) => { const { provider } = useContext(RuntimeContext); const txData = useTxData(provider, txHash); const internalOps = useInternalOperations(provider, txData); const sendsEthToMiner = useMemo(() => { if (!txData || !internalOps) { return false; } for (const t of internalOps) { if (t.to === txData.confirmedData?.miner) { return true; } } return false; }, [txData, internalOps]); const selectionCtx = useSelection(); const blockETHUSDPrice = useETHUSDOracle( provider, txData?.confirmedData?.blockNumber ); const { sourcifySource } = useAppConfigContext(); const metadata = useSourcify( txData?.to, provider?.network.chainId, sourcifySource ); const txDesc = useTransactionDescription(metadata, txData); return ( Transaction Details {txData === null && (
Transaction {txHash} not found.
)} {txData && ( Overview {txData.confirmedData?.blockNumber !== undefined && ( Logs {txData && ` (${txData.confirmedData?.logs?.length ?? 0})`} )} Trace } /> } /> } /> )}
); }; export default TransactionPageContent;