diff --git a/src/Address.tsx b/src/Address.tsx index 583966f..07883a5 100644 --- a/src/Address.tsx +++ b/src/Address.tsx @@ -21,7 +21,6 @@ import SourcifyLogo from "./sourcify/SourcifyLogo"; import AddressTransactionResults from "./address/AddressTransactionResults"; import Contracts from "./address/Contracts"; import { RuntimeContext } from "./useRuntime"; -import { useAppConfigContext } from "./useAppConfig"; import { useAddressOrENS } from "./useResolvedAddresses"; import { useSourcifyMetadata } from "./sourcify/useSourcify"; import { ChecksummedAddress } from "./types"; @@ -66,11 +65,9 @@ const Address: React.FC = () => { }, [addressOrName, checksummedAddress, isENS]); const hasCode = useHasCode(provider, checksummedAddress, "latest"); - const { sourcifySource } = useAppConfigContext(); const addressMetadata = useSourcifyMetadata( hasCode ? checksummedAddress : undefined, - provider?.network.chainId, - sourcifySource + provider?.network.chainId ); const { network, faucets } = useChainInfo(); diff --git a/src/components/DecoratedAddressLink.tsx b/src/components/DecoratedAddressLink.tsx index 62ccd3a..4659e68 100644 --- a/src/components/DecoratedAddressLink.tsx +++ b/src/components/DecoratedAddressLink.tsx @@ -9,7 +9,6 @@ import { faCoins } from "@fortawesome/free-solid-svg-icons/faCoins"; import SourcifyLogo from "../sourcify/SourcifyLogo"; import PlainAddress from "./PlainAddress"; import { RuntimeContext } from "../useRuntime"; -import { useAppConfigContext } from "../useAppConfig"; import { useSourcifyMetadata } from "../sourcify/useSourcify"; import { useResolvedAddress } from "../useResolvedAddresses"; import { AddressContext, ChecksummedAddress, ZERO_ADDRESS } from "../types"; @@ -39,12 +38,7 @@ const DecoratedAddressLink: React.FC = ({ eoa, }) => { const { provider } = useContext(RuntimeContext); - const { sourcifySource } = useAppConfigContext(); - const metadata = useSourcifyMetadata( - address, - provider?.network.chainId, - sourcifySource - ); + const metadata = useSourcifyMetadata(address, provider?.network.chainId); const mint = addressCtx === AddressContext.FROM && address === ZERO_ADDRESS; const burn = addressCtx === AddressContext.TO && address === ZERO_ADDRESS; diff --git a/src/sourcify/useSourcify.ts b/src/sourcify/useSourcify.ts index 0ae3958..1ef4150 100644 --- a/src/sourcify/useSourcify.ts +++ b/src/sourcify/useSourcify.ts @@ -4,6 +4,7 @@ import { ErrorDescription } from "@ethersproject/abi/lib/interface"; import useSWRImmutable from "swr/immutable"; import { ChecksummedAddress, TransactionData } from "../types"; import { sourcifyMetadata, SourcifySource, sourcifySourceFile } from "../url"; +import { useAppConfigContext } from "../useAppConfig"; export type UserMethod = { notice?: string | undefined; @@ -98,13 +99,13 @@ const sourcifyFetcher = async (url: string) => { export const useSourcifyMetadata = ( address: ChecksummedAddress | undefined, - chainId: number | undefined, - source: SourcifySource + chainId: number | undefined ): Metadata | null | undefined => { + const { sourcifySource } = useAppConfigContext(); const metadataURL = () => address === undefined || chainId === undefined ? null - : sourcifyMetadata(address, chainId, source); + : sourcifyMetadata(address, chainId, sourcifySource); const { data, error } = useSWRImmutable( metadataURL, sourcifyFetcher diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 5db70f2..62844ff 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -37,7 +37,6 @@ import { use4Bytes, useTransactionDescription, } from "../use4Bytes"; -import { useAppConfigContext } from "../useAppConfig"; import { useError, useSourcifyMetadata, @@ -82,12 +81,7 @@ const Details: React.FC = ({ txData }) => { return false; }, [txData, internalOps]); - const { sourcifySource } = useAppConfigContext(); - const metadata = useSourcifyMetadata( - txData?.to, - provider?.network.chainId, - sourcifySource - ); + const metadata = useSourcifyMetadata(txData?.to, provider?.network.chainId); const txDesc = useSourcifyTransactionDescription(metadata, txData); const userDoc = metadata?.output.userdoc; diff --git a/src/transaction/LogEntry.tsx b/src/transaction/LogEntry.tsx index d67d30e..9f8d691 100644 --- a/src/transaction/LogEntry.tsx +++ b/src/transaction/LogEntry.tsx @@ -9,7 +9,6 @@ import DecodedParamsTable from "./decoder/DecodedParamsTable"; import DecodedLogSignature from "./decoder/DecodedLogSignature"; import { useTopic0 } from "../useTopic0"; import { RuntimeContext } from "../useRuntime"; -import { useAppConfigContext } from "../useAppConfig"; import { useSourcifyMetadata } from "../sourcify/useSourcify"; type LogEntryProps = { @@ -18,12 +17,7 @@ type LogEntryProps = { const LogEntry: React.FC = ({ log }) => { const { provider } = useContext(RuntimeContext); - const { sourcifySource } = useAppConfigContext(); - const metadata = useSourcifyMetadata( - log.address, - provider?.network.chainId, - sourcifySource - ); + const metadata = useSourcifyMetadata(log.address, provider?.network.chainId); const logDesc = useMemo(() => { if (!metadata) {