Files
js/@3rdweb-sdk/react/hooks/useContractMetadata.ts
T
Jonas Daniels 53e92add39 move over the last prebuilt pages and use @nightly (#481)
* move over the last prebuilt pages and use nightly

* fix lint

* update to latest dev

* remove log

* fix various more things

* upgrade to @nightly

* fix lister for creating listings

* update dependencies to solve token metadata issue
2022-09-13 21:15:37 +00:00

23 lines
650 B
TypeScript

import { contractKeys, networkKeys } from "../cache-keys";
import { useQuery } from "@tanstack/react-query";
import {
PrebuiltContractType,
SUPPORTED_CHAIN_ID,
SchemaForPrebuiltContractType,
} from "@thirdweb-dev/sdk";
import { z } from "zod";
export function useContractMetadataWithAddress(
address: string,
queryFn: () => Promise<
z.infer<SchemaForPrebuiltContractType<PrebuiltContractType>["output"]>
>,
chainId: SUPPORTED_CHAIN_ID,
) {
return useQuery(
[...networkKeys.chain(chainId), ...contractKeys.detail(address)],
() => queryFn(),
{ enabled: !!address && typeof queryFn === "function" && !!chainId },
);
}