From 46d331a501811a6e142d88cc70d1e63b53486622 Mon Sep 17 00:00:00 2001 From: Nacho Iacovino Date: Wed, 24 Aug 2022 22:45:13 +0200 Subject: [PATCH] Add Erc20 to claim conditions --- .../docs/react.useactiveclaimcondition.md | 2 +- .../docs/react.useclaimconditions.md | 2 +- .../react.useclaimineligibilityreasons.md | 2 +- .../thirdweb-react/docs/react.uselazymint.md | 4 +- .../docs/react.usemintnftsupply.md | 4 +- .../docs/react.useresetclaimconditions.md | 2 +- .../docs/react.usesetclaimconditions.md | 2 +- .../docs/react.useunclaimednfts.md | 4 +- packages/thirdweb-react/etc/react.api.md | 21 +++---- packages/thirdweb-react/package.json | 2 +- .../src/hooks/async/claim-conditions.ts | 15 ++--- packages/thirdweb-react/src/index.ts | 2 +- yarn.lock | 58 +++++++++++-------- 13 files changed, 63 insertions(+), 57 deletions(-) diff --git a/packages/thirdweb-react/docs/react.useactiveclaimcondition.md b/packages/thirdweb-react/docs/react.useactiveclaimcondition.md index 5d06055..b4a7e99 100644 --- a/packages/thirdweb-react/docs/react.useactiveclaimcondition.md +++ b/packages/thirdweb-react/docs/react.useactiveclaimcondition.md @@ -12,7 +12,7 @@ Use this to get the active claim conditon for ERC20, ERC721 or ERC1155 based con Signature: ```typescript -export declare function useActiveClaimCondition(...[contract, tokenId]: ClaimConditionsInputParams): import("@tanstack/react-query").UseQueryResult<{ +export declare function useActiveClaimCondition(...[contract, tokenId]: ClaimConditionsInputParams): import("@tanstack/react-query").UseQueryResult<{ snapshot?: { address: string; maxClaimable: string; diff --git a/packages/thirdweb-react/docs/react.useclaimconditions.md b/packages/thirdweb-react/docs/react.useclaimconditions.md index fabf6a8..1a26ea3 100644 --- a/packages/thirdweb-react/docs/react.useclaimconditions.md +++ b/packages/thirdweb-react/docs/react.useclaimconditions.md @@ -12,7 +12,7 @@ Use this to get all claim conditons for ERC20, ERC721 or ERC1155 based contracts Signature: ```typescript -export declare function useClaimConditions(...[contract, tokenId]: ClaimConditionsInputParams): import("@tanstack/react-query").UseQueryResult<{ +export declare function useClaimConditions(...[contract, tokenId]: ClaimConditionsInputParams): import("@tanstack/react-query").UseQueryResult<{ snapshot?: { address: string; maxClaimable: string; diff --git a/packages/thirdweb-react/docs/react.useclaimineligibilityreasons.md b/packages/thirdweb-react/docs/react.useclaimineligibilityreasons.md index 96d7ec3..2af9957 100644 --- a/packages/thirdweb-react/docs/react.useclaimineligibilityreasons.md +++ b/packages/thirdweb-react/docs/react.useclaimineligibilityreasons.md @@ -12,7 +12,7 @@ Use this to check for reasons that prevent claiming for either ERC20, ERC721 or Signature: ```typescript -export declare function useClaimIneligibilityReasons(...[contract, params, tokenId]: ClaimIneligibilityInputParams): import("@tanstack/react-query").UseQueryResult; +export declare function useClaimIneligibilityReasons(...[contract, params, tokenId]: ClaimIneligibilityInputParams): import("@tanstack/react-query").UseQueryResult; ``` ## Parameters diff --git a/packages/thirdweb-react/docs/react.uselazymint.md b/packages/thirdweb-react/docs/react.uselazymint.md index 403765a..d9ecc9d 100644 --- a/packages/thirdweb-react/docs/react.uselazymint.md +++ b/packages/thirdweb-react/docs/react.uselazymint.md @@ -14,7 +14,7 @@ Use this to lazy mint a batch of NFTs on your [DropContract](./react.dropcontrac ```typescript export declare function useLazyMint(contract: RequiredParam, onProgress?: (progress: UploadProgressEvent) => void): import("@tanstack/react-query").UseMutationResult(contract: Req Returns: -import("@tanstack/react-query").UseMutationResult<import("@thirdweb-dev/sdk/dist/browser").TransactionResultWithId<{ \[x: string\]: import("@thirdweb-dev/sdk/dist/browser").Json; name?: string \| undefined; description?: string \| null \| undefined; image?: string \| null \| undefined; external\_url?: string \| null \| undefined; animation\_url?: string \| null \| undefined; uri: string; id: import("ethers").BigNumber; }>\[\], unknown, { metadatas: NFTMetadataInput\[\]; }, unknown> +import("@tanstack/react-query").UseMutationResult<import("@thirdweb-dev/sdk/dist/browser").TransactionResultWithId<{ \[x: string\]: import("@thirdweb-dev/sdk/dist/browser").Json; name?: string \| number \| undefined; description?: string \| null \| undefined; image?: string \| null \| undefined; external\_url?: string \| null \| undefined; animation\_url?: string \| null \| undefined; uri: string; id: import("ethers").BigNumber; }>\[\], unknown, { metadatas: NFTMetadataInput\[\]; }, unknown> a mutation object that can be used to lazy mint a batch of NFTs diff --git a/packages/thirdweb-react/docs/react.usemintnftsupply.md b/packages/thirdweb-react/docs/react.usemintnftsupply.md index 196da65..7c80ec4 100644 --- a/packages/thirdweb-react/docs/react.usemintnftsupply.md +++ b/packages/thirdweb-react/docs/react.usemintnftsupply.md @@ -15,7 +15,7 @@ Use this to mint a new NFT on your [NFTContract](./react.nftcontract.md) export declare function useMintNFTSupply(contract: Erc1155): import("@tanstack/react-query").UseMutationResultReturns: -import("@tanstack/react-query").UseMutationResult<import("@thirdweb-dev/sdk/dist/browser").TransactionResultWithId<{ metadata: { \[x: string\]: import("@thirdweb-dev/sdk/dist/browser").Json; name?: string \| undefined; description?: string \| null \| undefined; image?: string \| null \| undefined; external\_url?: string \| null \| undefined; animation\_url?: string \| null \| undefined; uri: string; id: BigNumber; }; supply: BigNumber; }>, unknown, [MintNFTSupplyParams](./react.mintnftsupplyparams.md), unknown> +import("@tanstack/react-query").UseMutationResult<import("@thirdweb-dev/sdk/dist/browser").TransactionResultWithId<{ metadata: { \[x: string\]: import("@thirdweb-dev/sdk/dist/browser").Json; name?: string \| number \| undefined; description?: string \| null \| undefined; image?: string \| null \| undefined; external\_url?: string \| null \| undefined; animation\_url?: string \| null \| undefined; uri: string; id: BigNumber; }; supply: BigNumber; }>, unknown, [MintNFTSupplyParams](./react.mintnftsupplyparams.md), unknown> a mutation object that can be used to mint a more supply of a token id to the provided wallet diff --git a/packages/thirdweb-react/docs/react.useresetclaimconditions.md b/packages/thirdweb-react/docs/react.useresetclaimconditions.md index b744b8d..cd353d1 100644 --- a/packages/thirdweb-react/docs/react.useresetclaimconditions.md +++ b/packages/thirdweb-react/docs/react.useresetclaimconditions.md @@ -12,7 +12,7 @@ Use this to reset claim conditions on your [NFTContract](./react.nftcontract.md) Signature: ```typescript -export declare function useResetClaimConditions(...[contract, tokenId]: ClaimConditionsInputParams): import("@tanstack/react-query").UseMutationResult(...[contract, tokenId]: ClaimConditionsInputParams): import("@tanstack/react-query").UseMutationResult Promise; }, "data"> | undefined, unknown, void, unknown>; diff --git a/packages/thirdweb-react/docs/react.usesetclaimconditions.md b/packages/thirdweb-react/docs/react.usesetclaimconditions.md index dd62ba2..c3398bf 100644 --- a/packages/thirdweb-react/docs/react.usesetclaimconditions.md +++ b/packages/thirdweb-react/docs/react.usesetclaimconditions.md @@ -12,7 +12,7 @@ Use this to set claim conditions on your [NFTContract](./react.nftcontract.md) Signature: ```typescript -export declare function useSetClaimConditions(...[contract, tokenId]: ClaimConditionsInputParams): import("@tanstack/react-query").UseMutationResult(...[contract, tokenId]: ClaimConditionsInputParams): import("@tanstack/react-query").UseMutationResult Promise; }, "data"> | undefined, unknown, SetClaimConditionsParams, unknown>; diff --git a/packages/thirdweb-react/docs/react.useunclaimednfts.md b/packages/thirdweb-react/docs/react.useunclaimednfts.md index b392823..abff316 100644 --- a/packages/thirdweb-react/docs/react.useunclaimednfts.md +++ b/packages/thirdweb-react/docs/react.useunclaimednfts.md @@ -14,7 +14,7 @@ Use this to get a list of \*unclaimed\* NFT tokens of your ERC721 Drop contract. ```typescript export declare function useUnclaimedNFTs(contract: RequiredParam, queryParams?: QueryAllParams): import("@tanstack/react-query").UseQueryResult<{ [x: string]: import("@thirdweb-dev/sdk/dist/browser").Json; - name?: string | undefined; + name?: string | number | undefined; description?: string | null | undefined; image?: string | null | undefined; external_url?: string | null | undefined; @@ -33,7 +33,7 @@ export declare function useUnclaimedNFTs(contract: RequiredParam, query Returns: -import("@tanstack/react-query").UseQueryResult<{ \[x: string\]: import("@thirdweb-dev/sdk/dist/browser").Json; name?: string \| undefined; description?: string \| null \| undefined; image?: string \| null \| undefined; external\_url?: string \| null \| undefined; animation\_url?: string \| null \| undefined; uri: string; id: import("ethers").BigNumber; }\[\], unknown> +import("@tanstack/react-query").UseQueryResult<{ \[x: string\]: import("@thirdweb-dev/sdk/dist/browser").Json; name?: string \| number \| undefined; description?: string \| null \| undefined; image?: string \| null \| undefined; external\_url?: string \| null \| undefined; animation\_url?: string \| null \| undefined; uri: string; id: import("ethers").BigNumber; }\[\], unknown> a response object that includes an array of NFTs that are unclaimed diff --git a/packages/thirdweb-react/etc/react.api.md b/packages/thirdweb-react/etc/react.api.md index 850caa0..92056d3 100644 --- a/packages/thirdweb-react/etc/react.api.md +++ b/packages/thirdweb-react/etc/react.api.md @@ -31,13 +31,12 @@ import { Edition } from '@thirdweb-dev/sdk/dist/browser'; import { EditionDrop } from '@thirdweb-dev/sdk/dist/browser'; import { Erc1155 } from '@thirdweb-dev/sdk/dist/browser'; import type { Erc1155Mintable } from '@thirdweb-dev/sdk/dist/browser'; -import type { Erc20 } from '@thirdweb-dev/sdk/dist/browser'; +import { Erc20 } from '@thirdweb-dev/sdk/dist/browser'; import type { Erc721 } from '@thirdweb-dev/sdk/dist/browser'; import type { Erc721Mintable } from '@thirdweb-dev/sdk/dist/browser'; import type { EventQueryFilter } from '@thirdweb-dev/sdk/dist/browser'; import { FetchStatus } from '@tanstack/react-query'; import { InjectedConnector } from 'wagmi/connectors/injected'; -import { IpfsStorage } from '@thirdweb-dev/sdk/dist/browser'; import { IStorage } from '@thirdweb-dev/sdk/dist/browser'; import { Json } from '@thirdweb-dev/sdk/dist/browser'; import { ListingType } from '@thirdweb-dev/sdk/dist/browser'; @@ -204,8 +203,6 @@ export type InjectedConnectorType = "injected" | "metamask" | { options?: InjectedConnector["options"]; }; -export { IpfsStorage } - // @public (undocumented) export interface LoginConfig { onError?: (error: string) => void; @@ -404,7 +401,7 @@ export function useActiveChainId(): SUPPORTED_CHAIN_ID | undefined; // Warning: (ae-forgotten-export) The symbol "ClaimConditionsInputParams" needs to be exported by the entry point thirdweb-dev-react.cjs.d.ts // // @beta -export function useActiveClaimCondition(...[contract, tokenId]: ClaimConditionsInputParams): UseQueryResult< { +export function useActiveClaimCondition(...[contract, tokenId]: ClaimConditionsInputParams): UseQueryResult< { snapshot?: { address: string; maxClaimable: string; @@ -521,7 +518,7 @@ type: ListingType.Auction; export function useChainId(): number | undefined; // @beta -export function useClaimConditions(...[contract, tokenId]: ClaimConditionsInputParams): UseQueryResult< { +export function useClaimConditions(...[contract, tokenId]: ClaimConditionsInputParams): UseQueryResult< { snapshot?: { address: string; maxClaimable: string; @@ -556,7 +553,7 @@ export function useClaimedNFTSupply(contract: RequiredParam): UseQ // Warning: (ae-forgotten-export) The symbol "ClaimIneligibilityInputParams" needs to be exported by the entry point thirdweb-dev-react.cjs.d.ts // // @beta -export function useClaimIneligibilityReasons(...[contract, params, tokenId]: ClaimIneligibilityInputParams): UseQueryResult; +export function useClaimIneligibilityReasons(...[contract, params, tokenId]: ClaimIneligibilityInputParams): UseQueryResult; // @beta export function useClaimNFT(contract: RequiredParam): UseMutationResult, unknown, ClaimNFTParams, unknown>; @@ -1488,7 +1485,7 @@ export function useIsAddressRole(contract: // @beta export function useLazyMint(contract: RequiredParam, onProgress?: (progress: UploadProgressEvent) => void): UseMutationResult(contract: RequiredPara export function useMintNFTSupply(contract: Erc1155): UseMutationResult(...[contract, tokenId]: ClaimConditionsInputParams): UseMutationResult(...[contract, tokenId]: ClaimConditionsInputParams): UseMutationResult Promise; }, "data"> | undefined, unknown, void, unknown>; @@ -1699,7 +1696,7 @@ export function useSDK(): ThirdwebSDK | undefined; export function useSetAllRoleMembers(contract: RequiredParam): UseMutationResult]: string[]; }, unknown>; // @beta -export function useSetClaimConditions(...[contract, tokenId]: ClaimConditionsInputParams): UseMutationResult(...[contract, tokenId]: ClaimConditionsInputParams): UseMutationResult Promise; }, "data"> | undefined, unknown, SetClaimConditionsParams, unknown>; @@ -1766,7 +1763,7 @@ data: () => Promise; // @beta export function useUnclaimedNFTs(contract: RequiredParam, queryParams?: QueryAllParams): UseQueryResult< { [x: string]: Json; -name?: string | undefined; +name?: string | number | undefined; description?: string | null | undefined; image?: string | null | undefined; external_url?: string | null | undefined; diff --git a/packages/thirdweb-react/package.json b/packages/thirdweb-react/package.json index 53d12a7..5b9e91b 100644 --- a/packages/thirdweb-react/package.json +++ b/packages/thirdweb-react/package.json @@ -39,7 +39,7 @@ "@microsoft/api-extractor": "^7.19.4", "@microsoft/tsdoc": "^0.14.1", "@preconstruct/cli": "^2.2.1", - "@thirdweb-dev/sdk": "^2.3.35", + "@thirdweb-dev/sdk": "^2.3.39", "@trivago/prettier-plugin-sort-imports": "^3.2.0", "@types/color": "^3.0.3", "@types/mime": "^3.0.1", diff --git a/packages/thirdweb-react/src/hooks/async/claim-conditions.ts b/packages/thirdweb-react/src/hooks/async/claim-conditions.ts index 3bb82fb..967da9d 100644 --- a/packages/thirdweb-react/src/hooks/async/claim-conditions.ts +++ b/packages/thirdweb-react/src/hooks/async/claim-conditions.ts @@ -9,6 +9,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query"; import { ClaimCondition, ClaimConditionInput, + Erc20, Erc1155, } from "@thirdweb-dev/sdk/dist/browser"; import { BigNumberish } from "ethers"; @@ -77,7 +78,7 @@ export type SetClaimConditionsParams = { * * @beta */ -export function useActiveClaimCondition( +export function useActiveClaimCondition( ...[contract, tokenId]: ClaimConditionsInputParams ) { const contractAddress = contract?.getAddress(); @@ -127,7 +128,7 @@ export function useActiveClaimCondition( * * @beta */ -export function useClaimConditions( +export function useClaimConditions( ...[contract, tokenId]: ClaimConditionsInputParams ) { const contractAddress = contract?.getAddress(); @@ -177,9 +178,9 @@ export function useClaimConditions( * * @beta */ -export function useClaimIneligibilityReasons( - ...[contract, params, tokenId]: ClaimIneligibilityInputParams -) { +export function useClaimIneligibilityReasons< + TContract extends NFTContract | Erc20, +>(...[contract, params, tokenId]: ClaimIneligibilityInputParams) { const contractAddress = contract?.getAddress(); return useQueryWithNetwork( @@ -284,7 +285,7 @@ export function useClaimIneligibilityReasons( * @returns a mutation object that can be used to set claim conditions * @beta */ -export function useSetClaimConditions( +export function useSetClaimConditions( ...[contract, tokenId]: ClaimConditionsInputParams ) { const activeChainId = useActiveChainId(); @@ -370,7 +371,7 @@ export function useSetClaimConditions( * @returns a mutation object that can be used to reset claim conditions * @beta */ -export function useResetClaimConditions( +export function useResetClaimConditions( ...[contract, tokenId]: ClaimConditionsInputParams ) { const activeChainId = useActiveChainId(); diff --git a/packages/thirdweb-react/src/index.ts b/packages/thirdweb-react/src/index.ts index fbbafc5..7458dc1 100644 --- a/packages/thirdweb-react/src/index.ts +++ b/packages/thirdweb-react/src/index.ts @@ -18,7 +18,7 @@ export * from "./hooks/useNetwork"; // re-exports export { defaultChains, defaultL2Chains, useAccount, useProvider } from "wagmi"; -export { ChainId, IpfsStorage } from "@thirdweb-dev/sdk/dist/browser"; +export { ChainId } from "@thirdweb-dev/sdk/dist/browser"; // async hooks export * from "./hooks/async/contracts"; diff --git a/yarn.lock b/yarn.lock index a90e876..5a0d52a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2140,31 +2140,12 @@ resolved "https://registry.yarnpkg.com/@thirdweb-dev/contracts/-/contracts-3.1.0-1.tgz#8c4d068f0548f780a90cc723636bcc358cb946eb" integrity sha512-v19UtKKIpd6ol7fXcAL24F7Jwew1jIAmxstogTw9MdX2k9McwaI0Ebxu/3SSkQq2AhmruwOPp+E2xq1SWKsBUw== -"@thirdweb-dev/react@*": - version "2.7.1" - resolved "https://registry.yarnpkg.com/@thirdweb-dev/react/-/react-2.7.1.tgz#2c9a54689dddcf4c932ac255fd5208645f32a467" - integrity sha512-3Uf6MS18vqIN+8YxnBjvINwo66izfRvSC/6ftxyFQJu6VXI4KdYX0DgmYTWPC7JlIM7wsIYCKO6pmZaaodpT9w== - dependencies: - "@emotion/react" "^11.10.0" - "@emotion/styled" "^11.10.0" - "@gnosis.pm/safe-core-sdk" "2.1.0" - "@gnosis.pm/safe-ethers-adapters" "0.1.0-alpha.9" - "@gnosis.pm/safe-ethers-lib" "1.1.0" - "@reach/portal" "^0.17.0" - "@tanstack/react-query" "^4.0.10" - "@zag-js/menu" "^0.1.11" - "@zag-js/react" "^0.1.13" - color "^4.2.3" - copy-to-clipboard "^3.3.2" - detect-browser "^5.3.0" - magic-sdk "^8.1.1" - mime "^3.0.0" - react-cool-dimensions "^2.0.7" - react-icons "^4.4.0" - tiny-invariant "^1.2.0" - wagmi "^0.2.28" +"@thirdweb-dev/contracts@3.1.2": + version "3.1.2" + resolved "https://registry.yarnpkg.com/@thirdweb-dev/contracts/-/contracts-3.1.2.tgz#fde89c4b42f842f2504fe8f3d42b7535e8c1ddab" + integrity sha512-Ly3cEw5K8xfCwj0Fhgzr5olK3mG267TKacDeeufXM/YvU+/6qrpcCWd0JeSafK11+OrMDVXAK/5md93JeniNPQ== -"@thirdweb-dev/sdk@^2", "@thirdweb-dev/sdk@^2.3.35": +"@thirdweb-dev/sdk@^2": version "2.3.38" resolved "https://registry.yarnpkg.com/@thirdweb-dev/sdk/-/sdk-2.3.38.tgz#785ef14e6a03c3816dd71c7f377192e1edeb4177" integrity sha512-jVR1nUt0Q9VldRjT8/3DGGq3mmHflVg/PliQ70xPTEVZ+o0KqudlJwO4HHkNm/oddzapvCKq9scC4pRb/UgmGA== @@ -2181,6 +2162,33 @@ uuid "^8.3.2" zod "^3.11.6" +"@thirdweb-dev/sdk@^2.3.39": + version "2.3.39" + resolved "https://registry.yarnpkg.com/@thirdweb-dev/sdk/-/sdk-2.3.39.tgz#95af60acd8d02e61c2df6c1e024b514e4e8f4d3b" + integrity sha512-JVnX64+MdQiSIrn/CNhFsrBDhpbd1oVKe7bLGHnAJ/CjG5LRiUOLR1Xj754odotxDiUPW8umIiCKqZRF267pZQ== + dependencies: + "@thirdweb-dev/contracts" "3.1.2" + "@thirdweb-dev/storage" "^0.1.0" + "@web-std/file" "^3.0.0" + cbor "^8.1.0" + cross-fetch "^3.1.5" + eventemitter3 "^4.0.7" + fast-deep-equal "^3.1.3" + form-data "^4.0.0" + multihashes "^4.0.3" + tiny-invariant "^1.2.0" + uuid "^8.3.2" + zod "^3.11.6" + +"@thirdweb-dev/storage@^0.1.0": + version "0.1.0" + resolved "https://registry.yarnpkg.com/@thirdweb-dev/storage/-/storage-0.1.0.tgz#5bd38cb2abf174d50bca76576d9cbcc64c04ce18" + integrity sha512-/ss9vDBun2Ibkxzhjpw88q44/fzGmVwxKOBda9V7WS86cfxwP6mW3RaixaguYkQtMxPatQom/2nCoSxYWHUKhQ== + dependencies: + "@web-std/file" "^3.0.2" + cross-fetch "^3.1.5" + form-data "^4.0.0" + "@trivago/prettier-plugin-sort-imports@^3.2.0": version "3.3.0" resolved "https://registry.yarnpkg.com/@trivago/prettier-plugin-sort-imports/-/prettier-plugin-sort-imports-3.3.0.tgz#ee4e9ec1d8e3076b95fcb94311f42f7a61eecd37" @@ -2625,7 +2633,7 @@ "@web-std/stream" "1.0.0" web-encoding "1.1.5" -"@web-std/file@^3.0.0": +"@web-std/file@^3.0.0", "@web-std/file@^3.0.2": version "3.0.2" resolved "https://registry.yarnpkg.com/@web-std/file/-/file-3.0.2.tgz#b84cc9ed754608b18dcf78ac62c40dbcc6a94692" integrity sha512-pIH0uuZsmY8YFvSHP1NsBIiMT/1ce0suPrX74fEeO3Wbr1+rW0fUGEe4d0R99iLwXtyCwyserqCFI4BJkJlkRA==