Dont display the contract tab if we know the address is an EOA
This commit is contained in:
parent
f61b48742c
commit
3a6f050061
|
@ -1,4 +1,4 @@
|
||||||
import React, { useEffect, useContext, useCallback } from "react";
|
import React, { useEffect, useContext, useCallback, useMemo } from "react";
|
||||||
import {
|
import {
|
||||||
useParams,
|
useParams,
|
||||||
useNavigate,
|
useNavigate,
|
||||||
|
@ -21,8 +21,9 @@ import Contracts from "./address/Contracts";
|
||||||
import { RuntimeContext } from "./useRuntime";
|
import { RuntimeContext } from "./useRuntime";
|
||||||
import { useAppConfigContext } from "./useAppConfig";
|
import { useAppConfigContext } from "./useAppConfig";
|
||||||
import { useAddressOrENSFromURL } from "./useResolvedAddresses";
|
import { useAddressOrENSFromURL } from "./useResolvedAddresses";
|
||||||
import { useSingleMetadata } from "./sourcify/useSourcify";
|
import { useMultipleMetadata } from "./sourcify/useSourcify";
|
||||||
import { ChecksummedAddress } from "./types";
|
import { ChecksummedAddress } from "./types";
|
||||||
|
import { useAddressesWithCode } from "./useErigonHooks";
|
||||||
|
|
||||||
const AddressTransactions: React.FC = () => {
|
const AddressTransactions: React.FC = () => {
|
||||||
const { provider } = useContext(RuntimeContext);
|
const { provider } = useContext(RuntimeContext);
|
||||||
|
@ -58,11 +59,24 @@ const AddressTransactions: React.FC = () => {
|
||||||
}, [addressOrName, checksummedAddress, isENS]);
|
}, [addressOrName, checksummedAddress, isENS]);
|
||||||
|
|
||||||
const { sourcifySource } = useAppConfigContext();
|
const { sourcifySource } = useAppConfigContext();
|
||||||
const addressMetadata = useSingleMetadata(
|
const checksummedAddressAsArray = useMemo(
|
||||||
checksummedAddress,
|
() => (checksummedAddress !== undefined ? [checksummedAddress] : []),
|
||||||
|
[checksummedAddress]
|
||||||
|
);
|
||||||
|
const contractAddresses = useAddressesWithCode(
|
||||||
|
provider,
|
||||||
|
checksummedAddressAsArray
|
||||||
|
);
|
||||||
|
const metadatas = useMultipleMetadata(
|
||||||
|
undefined,
|
||||||
|
contractAddresses,
|
||||||
provider?.network.chainId,
|
provider?.network.chainId,
|
||||||
sourcifySource
|
sourcifySource
|
||||||
);
|
);
|
||||||
|
const addressMetadata =
|
||||||
|
checksummedAddress !== undefined
|
||||||
|
? metadatas[checksummedAddress]
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StandardFrame>
|
<StandardFrame>
|
||||||
|
@ -97,31 +111,33 @@ const AddressTransactions: React.FC = () => {
|
||||||
<NavTab href={`/address/${checksummedAddress}`}>
|
<NavTab href={`/address/${checksummedAddress}`}>
|
||||||
Overview
|
Overview
|
||||||
</NavTab>
|
</NavTab>
|
||||||
<NavTab href={`/address/${checksummedAddress}/contract`}>
|
{(contractAddresses?.length ?? 0) > 0 && (
|
||||||
<span
|
<NavTab href={`/address/${checksummedAddress}/contract`}>
|
||||||
className={`flex items-baseline space-x-2 ${
|
<span
|
||||||
addressMetadata === undefined ? "italic opacity-50" : ""
|
className={`flex items-baseline space-x-2 ${
|
||||||
}`}
|
addressMetadata === undefined ? "italic opacity-50" : ""
|
||||||
>
|
}`}
|
||||||
<span>Contract</span>
|
>
|
||||||
{addressMetadata === undefined ? (
|
<span>Contract</span>
|
||||||
<span className="self-center">
|
{addressMetadata === undefined ? (
|
||||||
<FontAwesomeIcon
|
<span className="self-center">
|
||||||
className="animate-spin"
|
<FontAwesomeIcon
|
||||||
icon={faCircleNotch}
|
className="animate-spin"
|
||||||
/>
|
icon={faCircleNotch}
|
||||||
</span>
|
/>
|
||||||
) : addressMetadata === null ? (
|
</span>
|
||||||
<span className="self-center text-red-500">
|
) : addressMetadata === null ? (
|
||||||
<FontAwesomeIcon icon={faQuestionCircle} />
|
<span className="self-center text-red-500">
|
||||||
</span>
|
<FontAwesomeIcon icon={faQuestionCircle} />
|
||||||
) : (
|
</span>
|
||||||
<span className="self-center">
|
) : (
|
||||||
<SourcifyLogo />
|
<span className="self-center">
|
||||||
</span>
|
<SourcifyLogo />
|
||||||
)}
|
</span>
|
||||||
</span>
|
)}
|
||||||
</NavTab>
|
</span>
|
||||||
|
</NavTab>
|
||||||
|
)}
|
||||||
</Tab.List>
|
</Tab.List>
|
||||||
<Tab.Panels>
|
<Tab.Panels>
|
||||||
<Routes>
|
<Routes>
|
||||||
|
@ -142,7 +158,12 @@ const AddressTransactions: React.FC = () => {
|
||||||
element={
|
element={
|
||||||
<Contracts
|
<Contracts
|
||||||
checksummedAddress={checksummedAddress}
|
checksummedAddress={checksummedAddress}
|
||||||
rawMetadata={addressMetadata}
|
rawMetadata={
|
||||||
|
contractAddresses !== undefined &&
|
||||||
|
contractAddresses.length === 0
|
||||||
|
? null
|
||||||
|
: addressMetadata
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue