Fix error handling

This commit is contained in:
Willian Mitsuda 2021-07-02 16:20:50 -03:00
parent 62df32b82f
commit 0c7cc1fc64

View File

@ -36,6 +36,7 @@ const AddressTransactions: React.FC = () => {
const [checksummedAddress, setChecksummedAddress] = useState<string>();
const [isENS, setENS] = useState<boolean>();
const [error, setError] = useState<boolean>();
// If it looks like it is an ENS name, try to resolve it
useEffect(() => {
@ -50,6 +51,9 @@ const AddressTransactions: React.FC = () => {
if (resolvedAddress !== null) {
setENS(true);
setChecksummedAddress(resolvedAddress);
setError(false);
} else {
setError(true);
}
};
resolveName();
@ -129,12 +133,15 @@ const AddressTransactions: React.FC = () => {
const [feeDisplay, feeDisplayToggler] = useFeeToggler();
if (!checksummedAddress) {
return <></>;
}
return (
<StandardFrame>
{error ? (
<span className="text-base">
"{params.addressOrName}" is not an ETH address or ENS name.
</span>
) : (
checksummedAddress && (
<>
<StandardSubtitle>
<div className="flex space-x-2 items-baseline">
<Blockies
@ -182,7 +189,7 @@ const AddressTransactions: React.FC = () => {
<TransactionItem
key={tx.hash}
tx={tx}
selectedAddress={params.addressOrName}
selectedAddress={checksummedAddress}
feeDisplay={feeDisplay}
/>
))}
@ -205,6 +212,9 @@ const AddressTransactions: React.FC = () => {
<PendingResults />
)}
</ContentFrame>
</>
)
)}
</StandardFrame>
);
};