diff --git a/apps/dashboard/src/components/contract-components/hooks.ts b/apps/dashboard/src/components/contract-components/hooks.ts index 56a83bf6f85..c3d8d1cb425 100644 --- a/apps/dashboard/src/components/contract-components/hooks.ts +++ b/apps/dashboard/src/components/contract-components/hooks.ts @@ -6,8 +6,8 @@ import type { Abi } from "abitype"; import { isEnsName, resolveEns } from "lib/ens"; import { useV5DashboardChain } from "lib/v5-adapter"; import { useMemo } from "react"; -import { type ThirdwebContract, getContract } from "thirdweb"; -import { resolveContractAbi } from "thirdweb/contract"; +import type { ThirdwebContract } from "thirdweb"; +import { getContract, resolveContractAbi } from "thirdweb/contract"; import { isAddress } from "thirdweb/utils"; import { type PublishedContractWithVersion, @@ -179,26 +179,24 @@ export function useCustomFactoryAbi( ) { const chain = useV5DashboardChain(chainId); const client = useThirdwebClient(); - const contract = useMemo(() => { - if (!chain) { - return undefined; - } - - return getContract({ - client, - address: contractAddress, - chain, - }); - }, [contractAddress, chain, client]); return useQuery({ - queryKey: ["custom-factory-abi", contract], + queryKey: ["custom-factory-abi", { contractAddress, chainId }], queryFn: () => { + const contract = chain + ? getContract({ + client, + address: contractAddress, + chain, + }) + : undefined; + if (!contract) { throw new Error("Contract not found"); } + return resolveContractAbi(contract); }, - enabled: !!contract, + enabled: !!contractAddress && !!chainId, }); }