From 5abf171be96bb39d0690884e41a890be85931fb8 Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Mon, 31 Jan 2022 16:26:27 -0300 Subject: [PATCH] Fix invalid nonce handling --- src/Address.tsx | 8 +------- src/AddressTransactionByNonce.tsx | 18 ++++++++---------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/Address.tsx b/src/Address.tsx index da1f959..3b9b62d 100644 --- a/src/Address.tsx +++ b/src/Address.tsx @@ -89,16 +89,10 @@ const Address: React.FC = () => { // Search address by nonce === transaction @ nonce const rawNonce = searchParams.get("nonce"); if (rawNonce !== null) { - let nonce: number | undefined = undefined; - try { - nonce = parseInt(rawNonce); - } catch (err) { - // ignore - } return ( ); } diff --git a/src/AddressTransactionByNonce.tsx b/src/AddressTransactionByNonce.tsx index c720bd9..1478092 100644 --- a/src/AddressTransactionByNonce.tsx +++ b/src/AddressTransactionByNonce.tsx @@ -9,36 +9,34 @@ import { RuntimeContext } from "./useRuntime"; type AddressTransactionByNonceProps = { checksummedAddress: ChecksummedAddress | undefined; - nonce: number | undefined; + rawNonce: string; }; const AddressTransactionByNonce: React.FC = ({ checksummedAddress, - nonce, + rawNonce, }) => { const { provider } = useContext(RuntimeContext); + + const nonce = parseInt(rawNonce, 10); const txHash = useTransactionBySenderAndNonce( provider, checksummedAddress, - nonce + isNaN(nonce) ? undefined : nonce ); const navigate = useNavigate(); - if (checksummedAddress !== undefined && nonce === undefined) { + if (checksummedAddress !== undefined && isNaN(nonce)) { return ( ); } - if ( - checksummedAddress !== undefined && - nonce !== undefined && - txHash === null - ) { + if (checksummedAddress !== undefined && !isNaN(nonce) && txHash === null) { return (