Skip to content

Commit 5c8766b

Browse files
committed
1 parent 04f8269 commit 5c8766b

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({
145145

146146
const customFactoryAbi = useCustomFactoryAbi(
147147
customFactoryAddress,
148-
Number(customFactoryNetwork),
148+
customFactoryNetwork ? Number(customFactoryNetwork) : undefined,
149149
);
150150

151151
const isTWPublisher = checkTwPublisher(metadata?.publisher);

apps/dashboard/src/components/contract-components/hooks.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,19 +212,32 @@ export function useContractEvents(abi: Abi) {
212212
return abi.filter((a) => a.type === "event");
213213
}
214214

215-
export function useCustomFactoryAbi(contractAddress: string, chainId: number) {
215+
export function useCustomFactoryAbi(
216+
contractAddress: string,
217+
chainId: number | undefined,
218+
) {
216219
const chain = useV5DashboardChain(chainId);
217220
const client = useThirdwebClient();
218221
const contract = useMemo(() => {
222+
if (!chain) {
223+
return undefined;
224+
}
225+
219226
return getContract({
220227
client,
221228
address: contractAddress,
222229
chain,
223230
});
224231
}, [contractAddress, chain, client]);
232+
225233
return useQuery({
226234
queryKey: ["custom-factory-abi", contract],
227-
queryFn: () => resolveContractAbi<Abi>(contract),
235+
queryFn: () => {
236+
if (!contract) {
237+
throw new Error("Contract not found");
238+
}
239+
return resolveContractAbi<Abi>(contract);
240+
},
228241
enabled: !!contract,
229242
});
230243
}

0 commit comments

Comments
 (0)