import React, { useMemo, useContext } from "react"; import { Route, Switch, useParams } 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 Details from "./transaction/Details"; import Logs from "./transaction/Logs"; import { RuntimeContext } from "./useRuntime"; import { SelectionContext, useSelection } from "./useSelection"; import { useInternalOperations, useTxData } from "./useErigonHooks"; import { useETHUSDOracle } from "./usePriceOracle"; import { useSourcify, useTransactionDescription } from "./useSourcify"; import { SourcifySource } from "./url"; type TransactionParams = { txhash: string; }; const Transaction: React.FC = () => { const { provider } = useContext(RuntimeContext); const params = useParams(); const { txhash } = params; 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 metadata = useSourcify( txData?.to, provider?.network.chainId, SourcifySource.CENTRAL_SERVER // TODO: use dynamic selector ); 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})`} )}
)} ); }; export default React.memo(Transaction);