diff --git a/src/AddressTransactions.tsx b/src/AddressTransactions.tsx index e671087..4727f7c 100644 --- a/src/AddressTransactions.tsx +++ b/src/AddressTransactions.tsx @@ -15,6 +15,7 @@ import { SearchController } from "./search/search"; import { RuntimeContext } from "./useRuntime"; import { useENSCache } from "./useReverseCache"; import { useFeeToggler } from "./search/useFeeToggler"; +import { SelectionContext, useSelection } from "./useSelection"; type BlockParams = { addressOrName: string; @@ -153,6 +154,8 @@ const AddressTransactions: React.FC = () => { const [feeDisplay, feeDisplayToggler] = useFeeToggler(); + const selectionCtx = useSelection(); + return ( {error ? ( @@ -204,7 +207,7 @@ const AddressTransactions: React.FC = () => { feeDisplayToggler={feeDisplayToggler} /> {controller ? ( - <> + {controller.getPage().map((tx) => ( { nextHash={page ? page[page.length - 1].hash : ""} /> - + ) : ( )} diff --git a/src/BlockTransactionHeader.tsx b/src/BlockTransactionHeader.tsx new file mode 100644 index 0000000..65a8288 --- /dev/null +++ b/src/BlockTransactionHeader.tsx @@ -0,0 +1,21 @@ +import React from "react"; +import { ethers } from "ethers"; +import StandardSubtitle from "./StandardSubtitle"; +import BlockLink from "./components/BlockLink"; + +type BlockTransactionHeaderProps = { + blockTag: ethers.providers.BlockTag; +}; + +const BlockTransactionHeader: React.FC = ({ + blockTag, +}) => ( + <> + Transactions +
+ For Block +
+ +); + +export default React.memo(BlockTransactionHeader); diff --git a/src/BlockTransactionResults.tsx b/src/BlockTransactionResults.tsx new file mode 100644 index 0000000..74e2783 --- /dev/null +++ b/src/BlockTransactionResults.tsx @@ -0,0 +1,78 @@ +import React, { useContext } from "react"; +import ContentFrame from "./ContentFrame"; +import PageControl from "./search/PageControl"; +import ResultHeader from "./search/ResultHeader"; +import PendingResults from "./search/PendingResults"; +import TransactionItem from "./search/TransactionItem"; +import { useFeeToggler } from "./search/useFeeToggler"; +import { RuntimeContext } from "./useRuntime"; +import { SelectionContext, useSelection } from "./useSelection"; +import { useENSCache } from "./useReverseCache"; +import { ProcessedTransaction } from "./types"; +import { PAGE_SIZE } from "./params"; + +type BlockTransactionResultsProps = { + page?: ProcessedTransaction[]; + total: number; + pageNumber: number; +}; + +const BlockTransactionResults: React.FC = ({ + page, + total, + pageNumber, +}) => { + const selectionCtx = useSelection(); + const [feeDisplay, feeDisplayToggler] = useFeeToggler(); + const { provider } = useContext(RuntimeContext); + const reverseCache = useENSCache(provider, page); + + return ( + +
+
+ {page === undefined ? ( + <>Waiting for search results... + ) : ( + <>A total of {total} transactions found + )} +
+ +
+ + {page ? ( + + {page.map((tx) => ( + + ))} +
+
+ A total of {total} transactions found +
+ +
+
+ ) : ( + + )} +
+ ); +}; + +export default React.memo(BlockTransactionResults); diff --git a/src/BlockTransactions.tsx b/src/BlockTransactions.tsx index 8f8f474..8ded619 100644 --- a/src/BlockTransactions.tsx +++ b/src/BlockTransactions.tsx @@ -3,18 +3,11 @@ import { useParams, useLocation } from "react-router"; import { ethers } from "ethers"; import queryString from "query-string"; import StandardFrame from "./StandardFrame"; -import StandardSubtitle from "./StandardSubtitle"; -import ContentFrame from "./ContentFrame"; -import PageControl from "./search/PageControl"; -import ResultHeader from "./search/ResultHeader"; -import PendingResults from "./search/PendingResults"; -import TransactionItem from "./search/TransactionItem"; -import BlockLink from "./components/BlockLink"; +import BlockTransactionHeader from "./BlockTransactionHeader"; +import BlockTransactionResults from "./BlockTransactionResults"; import { ProcessedTransaction } from "./types"; import { PAGE_SIZE } from "./params"; -import { useFeeToggler } from "./search/useFeeToggler"; import { RuntimeContext } from "./useRuntime"; -import { useENSCache } from "./useReverseCache"; type BlockParams = { blockNumber: string; @@ -110,62 +103,16 @@ const BlockTransactions: React.FC = () => { }, [txs, pageNumber]); const total = useMemo(() => txs?.length ?? 0, [txs]); - const reverseCache = useENSCache(provider, page); - document.title = `Block #${blockNumber} Txns | Otterscan`; - const [feeDisplay, feeDisplayToggler] = useFeeToggler(); - return ( - Transactions -
- For Block -
- -
-
- {page === undefined ? ( - <>Waiting for search results... - ) : ( - <>A total of {total} transactions found - )} -
- -
- - {page ? ( - <> - {page.map((tx) => ( - - ))} -
-
- A total of {total} transactions found -
- -
- - ) : ( - - )} -
+ +
); }; diff --git a/src/TokenTransferItem.tsx b/src/TokenTransferItem.tsx index 64a42f6..4b1fc62 100644 --- a/src/TokenTransferItem.tsx +++ b/src/TokenTransferItem.tsx @@ -1,8 +1,9 @@ import React from "react"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faCaretRight } from "@fortawesome/free-solid-svg-icons"; -import AddressLink from "./components/AddressLink"; +import AddressHighlighter from "./components/AddressHighlighter"; import AddressOrENSName from "./components/AddressOrENSName"; +import AddressLink from "./components/AddressLink"; import TokenLogo from "./components/TokenLogo"; import FormattedBalance from "./components/FormattedBalance"; import { TokenMetas, TokenTransfer } from "./types"; @@ -20,16 +21,20 @@ const TokenTransferItem: React.FC = ({ -
-
+
+
From - + + +
-
+
To - + + +
-
+
For { return false; }, [txData, transfers]); - const traceTransfersUsingOtsTrace = useCallback(async () => { + const traceTransfers = useCallback(async () => { if (!provider || !txData) { return; } @@ -157,14 +144,16 @@ const Transaction: React.FC = () => { setTransfers(_transfers); }, [provider, txData]); useEffect(() => { - traceTransfersUsingOtsTrace(); - }, [traceTransfersUsingOtsTrace]); + traceTransfers(); + }, [traceTransfers]); + + const selectionCtx = useSelection(); return ( Transaction Details {txData && ( - <> +
Overview @@ -173,198 +162,20 @@ 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} - - - -