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 // Search address by nonce === transaction @ nonce
const rawNonce = searchParams.get("nonce"); const rawNonce = searchParams.get("nonce");
if (rawNonce !== null) { if (rawNonce !== null) {
let nonce: number | undefined = undefined;
try {
nonce = parseInt(rawNonce);
} catch (err) {
// ignore
}
return ( return (
<AddressTransactionByNonce <AddressTransactionByNonce
checksummedAddress={checksummedAddress} checksummedAddress={checksummedAddress}
nonce={nonce} rawNonce={rawNonce}
/> />
); );
} }

View File

@ -9,36 +9,34 @@ import { RuntimeContext } from "./useRuntime";
type AddressTransactionByNonceProps = { type AddressTransactionByNonceProps = {
checksummedAddress: ChecksummedAddress | undefined; checksummedAddress: ChecksummedAddress | undefined;
nonce: number | undefined; rawNonce: string;
}; };
const AddressTransactionByNonce: React.FC<AddressTransactionByNonceProps> = ({ const AddressTransactionByNonce: React.FC<AddressTransactionByNonceProps> = ({
checksummedAddress, checksummedAddress,
nonce, rawNonce,
}) => { }) => {
const { provider } = useContext(RuntimeContext); const { provider } = useContext(RuntimeContext);
const nonce = parseInt(rawNonce, 10);
const txHash = useTransactionBySenderAndNonce( const txHash = useTransactionBySenderAndNonce(
provider, provider,
checksummedAddress, checksummedAddress,
nonce isNaN(nonce) ? undefined : nonce
); );
const navigate = useNavigate(); const navigate = useNavigate();
if (checksummedAddress !== undefined && nonce === undefined) { if (checksummedAddress !== undefined && isNaN(nonce)) {
return ( return (
<StandardFrame> <StandardFrame>
<AddressOrENSNameInvalidNonce <AddressOrENSNameInvalidNonce
addressOrENSName={checksummedAddress} addressOrENSName={checksummedAddress}
nonce={"undefined"} nonce={rawNonce}
/> />
</StandardFrame> </StandardFrame>
); );
} }
if ( if (checksummedAddress !== undefined && !isNaN(nonce) && txHash === null) {
checksummedAddress !== undefined &&
nonce !== undefined &&
txHash === null
) {
return ( return (
<StandardFrame> <StandardFrame>
<AddressOrENSNameInvalidNonce <AddressOrENSNameInvalidNonce