Skip to content

Commit

Permalink
Remove calls to 0.rpc on deploy page
Browse files Browse the repository at this point in the history
  • Loading branch information
MananTank committed Oct 4, 2024
1 parent 04f8269 commit 6175d6f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const CustomContractForm: React.FC<CustomContractFormProps> = ({

const customFactoryAbi = useCustomFactoryAbi(
customFactoryAddress,
Number(customFactoryNetwork),
customFactoryNetwork ? Number(customFactoryNetwork) : undefined,
);

const isTWPublisher = checkTwPublisher(metadata?.publisher);
Expand Down
17 changes: 15 additions & 2 deletions apps/dashboard/src/components/contract-components/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,32 @@ export function useContractEvents(abi: Abi) {
return abi.filter((a) => a.type === "event");
}

export function useCustomFactoryAbi(contractAddress: string, chainId: number) {
export function useCustomFactoryAbi(
contractAddress: string,
chainId: number | undefined,
) {
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],
queryFn: () => resolveContractAbi<Abi>(contract),
queryFn: () => {
if (!contract) {
throw new Error("Contract not found");
}
return resolveContractAbi<Abi>(contract);
},
enabled: !!contract,
});
}

0 comments on commit 6175d6f

Please sign in to comment.