Fix error handling

This commit is contained in:
Willian Mitsuda 2021-07-02 16:20:50 -03:00
parent 62df32b82f
commit 0c7cc1fc64
1 changed files with 79 additions and 69 deletions

View File

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