diff --git a/src/transaction/NavButton.tsx b/src/transaction/NavButton.tsx index 04d421c..cad49d2 100644 --- a/src/transaction/NavButton.tsx +++ b/src/transaction/NavButton.tsx @@ -1,18 +1,21 @@ import { NavLink } from "react-router-dom"; -import { transactionURL } from "../url"; +import { ChecksummedAddress } from "../types"; +import { addressByNonceURL } from "../url"; // TODO: extract common component with block/NavButton type NavButtonProps = { - txHash: string | null | undefined; + sender: ChecksummedAddress; + nonce: number; disabled?: boolean; }; const NavButton: React.FC = ({ - txHash, + sender, + nonce, disabled, children, }) => { - if (disabled || txHash === null || txHash === undefined) { + if (disabled) { return ( {children} @@ -23,7 +26,7 @@ const NavButton: React.FC = ({ return ( {children} diff --git a/src/transaction/NavNonce.tsx b/src/transaction/NavNonce.tsx index ee30a4b..fb94b66 100644 --- a/src/transaction/NavNonce.tsx +++ b/src/transaction/NavNonce.tsx @@ -7,7 +7,6 @@ import { ChecksummedAddress } from "../types"; import { RuntimeContext } from "../useRuntime"; import { prefetchTransactionBySenderAndNonce, - useTransactionBySenderAndNonce, useTransactionCount, } from "../useErigonHooks"; import { useSWRConfig } from "swr"; @@ -19,22 +18,7 @@ type NavNonceProps = { const NavNonce: React.FC = ({ sender, nonce }) => { const { provider } = useContext(RuntimeContext); - const prevTxHash = useTransactionBySenderAndNonce( - provider, - sender, - nonce - 1 - ); - const nextTxHash = useTransactionBySenderAndNonce( - provider, - sender, - nonce + 1 - ); const count = useTransactionCount(provider, sender); - const lastTxHash = useTransactionBySenderAndNonce( - provider, - sender, - count !== undefined ? count - 1 : undefined - ); // Prefetch const swrConfig = useSWRConfig(); @@ -60,17 +44,19 @@ const NavNonce: React.FC = ({ sender, nonce }) => { return (
- + = count - 1} > = count - 1} > diff --git a/src/url.ts b/src/url.ts index 2216bf6..cf44ab6 100644 --- a/src/url.ts +++ b/src/url.ts @@ -20,6 +20,9 @@ export const blockTxsURL = (blockNum: BlockTag) => `/block/${blockNum}/txs`; export const transactionURL = (txHash: string) => `/tx/${txHash}`; +export const addressByNonceURL = (address: ChecksummedAddress, nonce: number) => + `/address/${address}?nonce=${nonce}`; + export enum SourcifySource { // Resolve trusted IPNS for root IPFS IPFS_IPNS,