Fix error handling
This commit is contained in:
parent
5e5dc6f20a
commit
7c0d06dd8f
|
@ -30,8 +30,6 @@ import { ChecksummedAddress } from "./types";
|
|||
type AddressMainPageProps = {};
|
||||
|
||||
const AddressMainPage: React.FC<AddressMainPageProps> = ({}) => {
|
||||
const { provider } = useContext(RuntimeContext);
|
||||
|
||||
const { addressOrName, direction } = useParams();
|
||||
if (addressOrName === undefined) {
|
||||
throw new Error("addressOrName couldn't be undefined here");
|
||||
|
@ -55,6 +53,7 @@ const AddressMainPage: React.FC<AddressMainPageProps> = ({}) => {
|
|||
urlFixer
|
||||
);
|
||||
|
||||
const { provider } = useContext(RuntimeContext);
|
||||
const hasCode = useHasCode(provider, checksummedAddress, "latest");
|
||||
const addressMetadata = useSourcifyMetadata(
|
||||
hasCode ? checksummedAddress : undefined,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import React, { useCallback, useContext, useEffect, useState } from "react";
|
||||
import { useNavigate, useParams, useSearchParams } from "react-router-dom";
|
||||
import StandardFrame from "./StandardFrame";
|
||||
import AddressOrENSNameNotFound from "./components/AddressOrENSNameNotFound";
|
||||
import AddressOrENSNameInvalidNonce from "./components/AddressOrENSNameInvalidNonce";
|
||||
import AddressOrENSNameNoTx from "./components/AddressOrENSNameNoTx";
|
||||
import { useTransactionBySenderAndNonce } from "./useErigonHooks";
|
||||
|
@ -36,7 +37,7 @@ const AddressTransactionByNonce: React.FC<AddressTransactionByNonceProps> = ({
|
|||
},
|
||||
[navigate, direction, searchParams]
|
||||
);
|
||||
const [checksummedAddress, isENS, error] = useAddressOrENS(
|
||||
const [checksummedAddress, , ensError] = useAddressOrENS(
|
||||
addressOrName,
|
||||
urlFixer
|
||||
);
|
||||
|
@ -77,12 +78,20 @@ const AddressTransactionByNonce: React.FC<AddressTransactionByNonceProps> = ({
|
|||
nonce !== undefined && isNaN(nonce) ? undefined : nonce
|
||||
);
|
||||
|
||||
// Invalid ENS
|
||||
if (ensError) {
|
||||
return (
|
||||
<StandardFrame>
|
||||
<AddressOrENSNameNotFound
|
||||
addressOrENSName={addressOrName}
|
||||
supportsENS={provider?.network.ensAddress !== undefined}
|
||||
/>
|
||||
</StandardFrame>
|
||||
);
|
||||
}
|
||||
|
||||
// Loading...
|
||||
if (
|
||||
checksummedAddress === undefined ||
|
||||
nonce === undefined ||
|
||||
txHash === undefined
|
||||
) {
|
||||
if (checksummedAddress === undefined || nonce === undefined) {
|
||||
return <StandardFrame />;
|
||||
}
|
||||
|
||||
|
@ -107,6 +116,11 @@ const AddressTransactionByNonce: React.FC<AddressTransactionByNonceProps> = ({
|
|||
);
|
||||
}
|
||||
|
||||
// Valid nonce, waiting tx load
|
||||
if (txHash === undefined) {
|
||||
return <StandardFrame />;
|
||||
}
|
||||
|
||||
// Valid nonce, but no tx found
|
||||
if (txHash === null) {
|
||||
return (
|
||||
|
|
Loading…
Reference in New Issue