diff --git a/src/PriceBox.tsx b/src/PriceBox.tsx index ad73d06..2ebb5d7 100644 --- a/src/PriceBox.tsx +++ b/src/PriceBox.tsx @@ -10,6 +10,7 @@ import { useLatestBlock } from "./useLatestBlock"; const ETH_FEED_DECIMALS = 8; +// TODO: reduce duplication with useETHUSDOracle const PriceBox: React.FC = () => { const { provider } = useContext(RuntimeContext); const latestBlock = useLatestBlock(provider); diff --git a/src/address/AddressTransactionResults.tsx b/src/address/AddressTransactionResults.tsx index cc8665e..1a95535 100644 --- a/src/address/AddressTransactionResults.tsx +++ b/src/address/AddressTransactionResults.tsx @@ -1,6 +1,12 @@ import React, { useContext, useEffect, useMemo, useState } from "react"; import { BlockTag } from "@ethersproject/providers"; import ContentFrame from "../ContentFrame"; +import InfoRow from "../components/InfoRow"; +import TransactionValue from "../components/TransactionValue"; +import ETH2USDValue from "../components/ETH2USDValue"; +import TransactionAddress from "../components/TransactionAddress"; +import Copy from "../components/Copy"; +import TransactionLink from "../components/TransactionLink"; import PendingResults from "../search/PendingResults"; import ResultHeader from "../search/ResultHeader"; import { SearchController } from "../search/search"; @@ -11,8 +17,9 @@ import { SelectionContext, useSelection } from "../useSelection"; import { useMultipleETHUSDOracle } from "../usePriceOracle"; import { RuntimeContext } from "../useRuntime"; import { useParams, useSearchParams } from "react-router-dom"; -import { ChecksummedAddress } from "../types"; +import { ChecksummedAddress, ProcessedTransaction } from "../types"; import { useContractsMetadata } from "../hooks"; +import { useAddressBalance, useContractCreator } from "../useErigonHooks"; type AddressTransactionResultsProps = { address: ChecksummedAddress; @@ -95,9 +102,12 @@ const AddressTransactionResults: React.FC = ({ // TODO: dedup blockTags const blockTags: BlockTag[] = useMemo(() => { if (!page) { - return []; + return ["latest"]; } - return page.map((t) => t.blockNumber); + + const blockTags: BlockTag[] = page.map((t) => t.blockNumber); + blockTags.push("latest"); + return blockTags; }, [page]); const priceMap = useMultipleETHUSDOracle(provider, blockTags); @@ -117,65 +127,91 @@ const AddressTransactionResults: React.FC = ({ return _addresses; }, [address, page]); const metadatas = useContractsMetadata(addresses, provider); + const balance = useAddressBalance(provider, address); + const creator = useContractCreator(provider, address); return ( -
-
- {page === undefined ? ( - <>Waiting for search results... - ) : ( - <>{page.length} transactions on this page - )} -
- -
- - {page ? ( - - {page.map((tx) => ( - - ))} -
-
- {page === undefined ? ( - <>Waiting for search results... - ) : ( - <>{page.length} transactions on this page + + {balance && ( + +
+ + {!balance.isZero() && priceMap["latest"] !== undefined && ( + + + )}
- -
- - ) : ( - - )} + + )} + {creator && ( + +
+
+ + +
+
+ +
+
+
+ )} + + + {page ? ( + <> + {page.map((tx) => ( + + ))} + + + ) : ( + + )} + ); }; +type NavBarProps = { + address: ChecksummedAddress; + page: ProcessedTransaction[] | undefined; + controller: SearchController | undefined; +}; + +const NavBar: React.FC = ({ address, page, controller }) => ( +
+
+ {page === undefined ? ( + <>Waiting for search results... + ) : ( + <>{page.length} transactions on this page + )} +
+ +
+); + export default AddressTransactionResults; diff --git a/src/components/Copy.tsx b/src/components/Copy.tsx index 86e902d..41d048e 100644 --- a/src/components/Copy.tsx +++ b/src/components/Copy.tsx @@ -22,7 +22,7 @@ const Copy: React.FC = ({ value, rounded }) => { return (