Fix invalid nonce handling

This commit is contained in:
Willian Mitsuda 2022-01-31 16:26:27 -03:00
parent 17194c089a
commit 5abf171be9
2 changed files with 9 additions and 17 deletions

View File

@ -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 (
<AddressTransactionByNonce
checksummedAddress={checksummedAddress}
nonce={nonce}
rawNonce={rawNonce}
/>
);
}

View File

@ -9,36 +9,34 @@ import { RuntimeContext } from "./useRuntime";
type AddressTransactionByNonceProps = {
checksummedAddress: ChecksummedAddress | undefined;
nonce: number | undefined;
rawNonce: string;
};
const AddressTransactionByNonce: React.FC<AddressTransactionByNonceProps> = ({
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 (
<StandardFrame>
<AddressOrENSNameInvalidNonce
addressOrENSName={checksummedAddress}
nonce={"undefined"}
nonce={rawNonce}
/>
</StandardFrame>
);
}
if (
checksummedAddress !== undefined &&
nonce !== undefined &&
txHash === null
) {
if (checksummedAddress !== undefined && !isNaN(nonce) && txHash === null) {
return (
<StandardFrame>
<AddressOrENSNameInvalidNonce