From c728dd881d16c60724acfb67e7873218f8c9707f Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Mon, 31 Jan 2022 17:06:49 -0300 Subject: [PATCH] Handle search for latest nonce on uninitialized addresses --- src/AddressTransactionByNonce.tsx | 13 ++++++++++++- src/components/AddressOrENSNameNoTx.tsx | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/components/AddressOrENSNameNoTx.tsx diff --git a/src/AddressTransactionByNonce.tsx b/src/AddressTransactionByNonce.tsx index a5bb17e..f7e1a8a 100644 --- a/src/AddressTransactionByNonce.tsx +++ b/src/AddressTransactionByNonce.tsx @@ -2,6 +2,7 @@ import React, { useContext, useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import StandardFrame from "./StandardFrame"; import AddressOrENSNameInvalidNonce from "./components/AddressOrENSNameInvalidNonce"; +import AddressOrENSNameNoTx from "./components/AddressOrENSNameNoTx"; import { ChecksummedAddress } from "./types"; import { transactionURL } from "./url"; import { useTransactionBySenderAndNonce } from "./useErigonHooks"; @@ -37,7 +38,7 @@ const AddressTransactionByNonce: React.FC = ({ // in case of latest let nonce: number | undefined; if (rawNonce === "latest") { - if (txCount !== undefined && txCount > 0) { + if (txCount !== undefined) { nonce = txCount - 1; } } else { @@ -52,10 +53,20 @@ const AddressTransactionByNonce: React.FC = ({ ); const navigate = useNavigate(); + // Loading... if (checksummedAddress === undefined || nonce === undefined) { return ; } + // Address hasn't made the first outbound tx yet + if (nonce < 0) { + return ( + + + + ); + } + // Garbage nonce if (isNaN(nonce)) { return ( diff --git a/src/components/AddressOrENSNameNoTx.tsx b/src/components/AddressOrENSNameNoTx.tsx new file mode 100644 index 0000000..c4f6178 --- /dev/null +++ b/src/components/AddressOrENSNameNoTx.tsx @@ -0,0 +1,24 @@ +import React from "react"; +import StandardSubtitle from "../StandardSubtitle"; +import ContentFrame from "../ContentFrame"; +import AddressOrENSName from "./AddressOrENSName"; + +type AddressOrENSNameNoTxProps = { + addressOrENSName: string; +}; + +const AddressOrENSNameNoTx: React.FC = ({ + addressOrENSName, +}) => ( + <> + Transaction Details + +
+ + : no outbound transactions found. +
+
+ +); + +export default React.memo(AddressOrENSNameNoTx);