Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions docs/react.delayedreveallazymintinput.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/react](./react.md) &gt; [DelayedRevealLazyMintInput](./react.delayedreveallazymintinput.md)

## DelayedRevealLazyMintInput type

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

The params for the [useDelayedRevealLazyMint()](./react.usedelayedreveallazymint.md) hook mutation.

<b>Signature:</b>

```typescript
export declare type DelayedRevealLazyMintInput = {
placeholder: NFTMetadataInput;
metadatas: NFTMetadataInput[];
password: string;
};
```
5 changes: 5 additions & 0 deletions docs/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { useAddress } from "@thirdweb-dev/react"
| [useAllRoleMembers(contract)](./react.useallrolemembers.md) | <b><i>(BETA)</i></b> Use this to get the roles of a |
| [useAuctionWinner(contract, listingId)](./react.useauctionwinner.md) | <b><i>(BETA)</i></b> Use this to get the winner of an auction listing from your marketplace contract. |
| [useBalance(tokenAddress)](./react.usebalance.md) | <b><i>(BETA)</i></b> A hook to get the native or (optional) ERC20 token balance of the connected wallet. |
| [useBatchesToReveal(contract)](./react.usebatchestoreveal.md) | |
| [useBidBuffer(contract)](./react.usebidbuffer.md) | <b><i>(BETA)</i></b> Use this to get the buffer in basis points between offers from your marketplace contract. |
| [useBurnNFT(contract)](./react.useburnnft.md) | <b><i>(BETA)</i></b> Use this to burn an NFT on your [NFTContract](./react.nftcontract.md) |
| [useBurnToken(contract)](./react.useburntoken.md) | <b><i>(BETA)</i></b> Use this to burn tokens on your contract |
Expand Down Expand Up @@ -49,6 +50,7 @@ import { useCoinbaseWallet } from "@thirdweb-dev/react"
| [useContractType(contractAddress)](./react.usecontracttype.md) | <b><i>(BETA)</i></b> Use this to get the contract type for a (built-in or custom) contract. |
| [useCreateAuctionListing(contract)](./react.usecreateauctionlisting.md) | <b><i>(BETA)</i></b> Use this to create a new Auction Listing on your marketplace contract. |
| [useCreateDirectListing(contract)](./react.usecreatedirectlisting.md) | <b><i>(BETA)</i></b> Use this to create a new Direct Listing on your marketplace contract. |
| [useDelayedRevealLazyMint(contract, onProgress)](./react.usedelayedreveallazymint.md) | <b><i>(BETA)</i></b> Use this to lazy mint a batch of delayed reveal NFTs on your [DropContract](./react.dropcontract.md) |
| [useDisconnect(options)](./react.usedisconnect.md) | <p>Hook for disconnecting the currently connected wallet</p>
```javascript
import { useDisconnect } from "@thirdweb-dev/react"
Expand Down Expand Up @@ -102,6 +104,7 @@ import { useNetworkMistmatch } from "@thirdweb-dev/react"
| [usePrimarySaleRecipient(contract)](./react.useprimarysalerecipient.md) | <b><i>(BETA)</i></b> |
| [useResetClaimConditions(\[contract, tokenId\])](./react.useresetclaimconditions.md) | <b><i>(BETA)</i></b> Use this to reset claim conditions on your [NFTContract](./react.nftcontract.md) |
| [useResolvedMediaType(uri)](./react.useresolvedmediatype.md) | |
| [useRevealLazyMint(contract)](./react.usereveallazymint.md) | <b><i>(BETA)</i></b> Use this to reveal a batch of delayed reveal NFTs on your [DropContract](./react.dropcontract.md) |
| [useRevokeRole(contract)](./react.userevokerole.md) | <b><i>(BETA)</i></b> Use this to revoke a [WalletAddress](./react.walletaddress.md) a specific role on a |
| [useRoleMembers(contract, role)](./react.userolemembers.md) | <b><i>(BETA)</i></b> Use this to get the members of a role on a |
| [useRoyaltySettings(contract)](./react.useroyaltysettings.md) | <b><i>(BETA)</i></b> Use this to get the royalty settings of your |
Expand Down Expand Up @@ -169,6 +172,7 @@ import { useWalletConnect } from "@thirdweb-dev/react"
| [ClaimNFTReturnType](./react.claimnftreturntype.md) | <b><i>(BETA)</i></b> The return type of the [useClaimNFT()](./react.useclaimnft.md) hook. |
| [ClaimTokenParams](./react.claimtokenparams.md) | |
| [ContractAddress](./react.contractaddress.md) | <b><i>(BETA)</i></b> A contract address. |
| [DelayedRevealLazyMintInput](./react.delayedreveallazymintinput.md) | <b><i>(BETA)</i></b> The params for the [useDelayedRevealLazyMint()](./react.usedelayedreveallazymint.md) hook mutation. |
| [DropContract](./react.dropcontract.md) | <b><i>(BETA)</i></b> The possible DROP contract types. |
| [MakeBidParams](./react.makebidparams.md) | |
| [MintNFTParams](./react.mintnftparams.md) | <b><i>(BETA)</i></b> The params for the [useMintNFT()](./react.usemintnft.md) hook mutation. |
Expand All @@ -177,6 +181,7 @@ import { useWalletConnect } from "@thirdweb-dev/react"
| [NFT](./react.nft.md) | <b><i>(BETA)</i></b> A single NFT token |
| [NFTContract](./react.nftcontract.md) | <b><i>(BETA)</i></b> The possible NFT contract types. |
| [RequiredParam](./react.requiredparam.md) | <b><i>(BETA)</i></b> Makes a parameter required to be passed, but still allowes it to be undefined. |
| [RevealLazyMintInput](./react.reveallazymintinput.md) | <b><i>(BETA)</i></b> The params for the [useRevealLazyMint()](./react.usereveallazymint.md) hook mutation. |
| [SetClaimConditionsParams](./react.setclaimconditionsparams.md) | <b><i>(BETA)</i></b> The params for the [useSetClaimConditions()](./react.usesetclaimconditions.md) hook mutation. |
| [TokenBurnParams](./react.tokenburnparams.md) | <b><i>(BETA)</i></b> The parameters to pass to the burn function. |
| [TokenParams](./react.tokenparams.md) | <b><i>(BETA)</i></b> The parameters to pass to the mint and transfer functions. |
Expand Down
19 changes: 19 additions & 0 deletions docs/react.reveallazymintinput.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/react](./react.md) &gt; [RevealLazyMintInput](./react.reveallazymintinput.md)

## RevealLazyMintInput type

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

The params for the [useRevealLazyMint()](./react.usereveallazymint.md) hook mutation.

<b>Signature:</b>

```typescript
export declare type RevealLazyMintInput = {
batchId: BigNumberish;
password: string;
};
```
24 changes: 24 additions & 0 deletions docs/react.usebatchestoreveal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/react](./react.md) &gt; [useBatchesToReveal](./react.usebatchestoreveal.md)

## useBatchesToReveal() function

<b>Signature:</b>

```typescript
export declare function useBatchesToReveal<TContract extends NFTContract>(contract: RequiredParam<TContract>): import("@tanstack/react-query").UseQueryResult<import("@thirdweb-dev/sdk/dist/browser").BatchToReveal[], unknown>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| contract | [RequiredParam](./react.requiredparam.md)<!-- -->&lt;TContract&gt; | an instance of a [NFTContract](./react.nftcontract.md) |

<b>Returns:</b>

import("@tanstack/react-query").UseQueryResult&lt;import("@thirdweb-dev/sdk/dist/browser").BatchToReveal\[\], unknown&gt;

a response object that gets the batches to still be revealed

30 changes: 30 additions & 0 deletions docs/react.usedelayedreveallazymint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/react](./react.md) &gt; [useDelayedRevealLazyMint](./react.usedelayedreveallazymint.md)

## useDelayedRevealLazyMint() function

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

Use this to lazy mint a batch of delayed reveal NFTs on your [DropContract](./react.dropcontract.md)

<b>Signature:</b>

```typescript
export declare function useDelayedRevealLazyMint<TContract extends NFTContract>(contract: RequiredParam<TContract>, onProgress?: (progress: UploadProgressEvent) => void): import("@tanstack/react-query").UseMutationResult<import("@thirdweb-dev/sdk/dist/browser").TransactionResultWithId<never>[], unknown, DelayedRevealLazyMintInput, unknown>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| contract | [RequiredParam](./react.requiredparam.md)<!-- -->&lt;TContract&gt; | an instance of a [NFTContract](./react.nftcontract.md) with the drop extension |
| onProgress | (progress: UploadProgressEvent) =&gt; void | <i>(Optional)</i> an optional callback that will be called with the progress of the upload |

<b>Returns:</b>

import("@tanstack/react-query").UseMutationResult&lt;import("@thirdweb-dev/sdk/dist/browser").TransactionResultWithId&lt;never&gt;\[\], unknown, [DelayedRevealLazyMintInput](./react.delayedreveallazymintinput.md)<!-- -->, unknown&gt;

a mutation object that can be used to lazy mint a batch of NFTs

32 changes: 32 additions & 0 deletions docs/react.usereveallazymint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/react](./react.md) &gt; [useRevealLazyMint](./react.usereveallazymint.md)

## useRevealLazyMint() function

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>

Use this to reveal a batch of delayed reveal NFTs on your [DropContract](./react.dropcontract.md)

<b>Signature:</b>

```typescript
export declare function useRevealLazyMint<TContract extends NFTContract>(contract: RequiredParam<TContract>): import("@tanstack/react-query").UseMutationResult<Omit<{
receipt: import("@ethersproject/abstract-provider").TransactionReceipt;
data: () => Promise<unknown>;
}, "data">, unknown, RevealLazyMintInput, unknown>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| contract | [RequiredParam](./react.requiredparam.md)<!-- -->&lt;TContract&gt; | an instance of a [NFTContract](./react.nftcontract.md) with the drop extension |

<b>Returns:</b>

import("@tanstack/react-query").UseMutationResult&lt;Omit&lt;{ receipt: import("@ethersproject/abstract-provider").TransactionReceipt; data: () =&gt; Promise&lt;unknown&gt;; }, "data"&gt;, unknown, [RevealLazyMintInput](./react.reveallazymintinput.md)<!-- -->, unknown&gt;

a mutation object that can be used to reveal a batch of delayed reveal NFTs

34 changes: 32 additions & 2 deletions etc/react.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { AirdropInput } from '@thirdweb-dev/sdk/dist/browser';
import type { Amount } from '@thirdweb-dev/sdk/dist/browser';
import { AuctionListing } from '@thirdweb-dev/sdk/dist/browser';
import { BaseContract } from 'ethers';
import { BatchToReveal } from '@thirdweb-dev/sdk/dist/browser';
import { BigNumber } from 'ethers';
import { BigNumberish } from 'ethers';
import { CallOverrides } from 'ethers';
Expand Down Expand Up @@ -52,6 +53,7 @@ import { NFTCollection } from '@thirdweb-dev/sdk/dist/browser';
import { NFTDrop } from '@thirdweb-dev/sdk/dist/browser';
import { NFTMetadata } from '@thirdweb-dev/sdk/dist/browser';
import { NFTMetadataInput } from '@thirdweb-dev/sdk/dist/browser';
import type { NFTMetadataInput as NFTMetadataInput_2 } from '@thirdweb-dev/sdk/dist/src/schema';
import type { NFTMetadataOrUri } from '@thirdweb-dev/sdk/dist/src/schema';
import { Offer } from '@thirdweb-dev/sdk/dist/browser';
import { Pack } from '@thirdweb-dev/sdk/dist/browser';
Expand Down Expand Up @@ -167,6 +169,13 @@ export { defaultChains }

export { defaultL2Chains }

// @beta
export type DelayedRevealLazyMintInput = {
placeholder: NFTMetadataInput_2;
metadatas: NFTMetadataInput_2[];
password: string;
};

// @beta
export type DropContract = NFTDrop | EditionDrop | SignatureDrop;

Expand Down Expand Up @@ -263,6 +272,12 @@ export type NFTContract = Erc721 | Erc1155;
// @beta
export type RequiredParam<T> = T | undefined;

// @beta
export type RevealLazyMintInput = {
batchId: BigNumberish;
password: string;
};

// Warning: (ae-internal-missing-underscore) The name "RolesForContract" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
Expand Down Expand Up @@ -433,6 +448,12 @@ decimals: number;
displayValue: string;
} | undefined, unknown>;

// Warning: (ae-incompatible-release-tags) The symbol "useBatchesToReveal" is marked as @public, but its signature references "NFTContract" which is marked as @beta
// Warning: (ae-incompatible-release-tags) The symbol "useBatchesToReveal" is marked as @public, but its signature references "RequiredParam" which is marked as @beta
//
// @public (undocumented)
export function useBatchesToReveal<TContract extends NFTContract>(contract: RequiredParam<TContract>): UseQueryResult<BatchToReveal[], unknown>;

// @beta
export function useBidBuffer(contract: RequiredParam<Marketplace>): UseQueryResult<BigNumber, unknown>;

Expand Down Expand Up @@ -1390,6 +1411,9 @@ export function useCreateAuctionListing(contract: RequiredParam<Marketplace>): U
// @beta
export function useCreateDirectListing(contract: RequiredParam<Marketplace>): UseMutationResult<TransactionResultWithId<never>, unknown, NewDirectListing, unknown>;

// @beta
export function useDelayedRevealLazyMint<TContract extends NFTContract>(contract: RequiredParam<TContract>, onProgress?: (progress: UploadProgressEvent) => void): UseMutationResult<TransactionResultWithId<never>[], unknown, DelayedRevealLazyMintInput, unknown>;

// Warning: (ae-internal-missing-underscore) The name "useDesiredChainId" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
Expand Down Expand Up @@ -1607,6 +1631,12 @@ export function useResolvedMediaType(uri?: string): {
mimeType: string | undefined;
};

// @beta
export function useRevealLazyMint<TContract extends NFTContract>(contract: RequiredParam<TContract>): UseMutationResult<Omit<{
receipt: TransactionReceipt;
data: () => Promise<unknown>;
}, "data">, unknown, RevealLazyMintInput, unknown>;

// Warning: (ae-incompatible-release-tags) The symbol "useRevokeRole" is marked as @beta, but its signature references "ContractWithRoles" which is marked as @internal
//
// @beta
Expand Down Expand Up @@ -1817,8 +1847,8 @@ export type WalletLinkConnectorType = "walletLink" | "coinbase" | {
// dist/hooks/async/roles.d.ts:161:5 - (ae-incompatible-release-tags) The symbol "role" is marked as @beta, but its signature references "RolesForContract" which is marked as @internal
// dist/hooks/auth/useUser.d.ts:12:5 - (ae-forgotten-export) The symbol "ThirdwebAuthUser" needs to be exported by the entry point index.d.ts
// dist/hooks/useNetwork.d.ts:48:5 - (ae-forgotten-export) The symbol "SwitchChainError" needs to be exported by the entry point index.d.ts
// dist/types.d.ts:196:5 - (ae-incompatible-release-tags) The symbol "buyForWallet" is marked as @public, but its signature references "WalletAddress" which is marked as @beta
// dist/types.d.ts:202:5 - (ae-incompatible-release-tags) The symbol "to" is marked as @public, but its signature references "WalletAddress" which is marked as @beta
// dist/types.d.ts:215:5 - (ae-incompatible-release-tags) The symbol "buyForWallet" is marked as @public, but its signature references "WalletAddress" which is marked as @beta
// dist/types.d.ts:221:5 - (ae-incompatible-release-tags) The symbol "to" is marked as @public, but its signature references "WalletAddress" which is marked as @beta

// (No @packageDocumentation comment for this package)

Expand Down
104 changes: 104 additions & 0 deletions src/hooks/async/drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import { useActiveChainId } from "../../Provider";
import {
ClaimNFTParams,
ClaimNFTReturnType,
DelayedRevealLazyMintInput,
DropContract,
NFTContract,
RequiredParam,
RevealLazyMintInput,
} from "../../types";
import {
cacheKeys,
Expand Down Expand Up @@ -128,6 +130,29 @@ export function useClaimedNFTSupply(contract: RequiredParam<DropContract>) {
);
}

/**
*
* @param contract - an instance of a {@link NFTContract}
* @returns a response object that gets the batches to still be revealed
*/
export function useBatchesToReveal<TContract extends NFTContract>(
contract: RequiredParam<TContract>,
) {
const contractAddress = contract?.getAddress();
return useQueryWithNetwork(
cacheKeys.contract.nft.drop.revealer.getBatchesToReveal(contractAddress),
() => {
invariant(contract, "No Contract instance provided");
invariant(
contract.drop?.revealer?.getBatchesToReveal,
"Contract instance does not support drop.revealer.getBatchesToReveal",
);
return contract.drop.revealer.getBatchesToReveal();
},
{ enabled: !!contract },
);
}

/** **********************/
/** WRITE HOOKS **/
/** **********************/
Expand Down Expand Up @@ -240,3 +265,82 @@ export function useLazyMint<TContract extends NFTContract>(
},
);
}

/**
* Use this to lazy mint a batch of delayed reveal NFTs on your {@link DropContract}
*
* @param contract - an instance of a {@link NFTContract} with the drop extension
* @param onProgress - an optional callback that will be called with the progress of the upload
* @returns a mutation object that can be used to lazy mint a batch of NFTs
* @beta
*/
export function useDelayedRevealLazyMint<TContract extends NFTContract>(
contract: RequiredParam<TContract>,
onProgress?: (progress: UploadProgressEvent) => void,
) {
const activeChainId = useActiveChainId();
const contractAddress = contract?.getAddress();
const queryClient = useQueryClient();

return useMutation(
async (data: DelayedRevealLazyMintInput) => {
invariant(
contract?.drop?.revealer?.createDelayedRevealBatch,
"contract does not support drop.revealer.createDelayedRevealBatch",
);
let options;
if (onProgress) {
options = {
onProgress,
};
}
return await contract.drop.revealer.createDelayedRevealBatch(
data.placeholder,
data.metadatas,
data.password,
options,
);
},
{
onSettled: () =>
invalidateContractAndBalances(
queryClient,
contractAddress,
activeChainId,
),
},
);
}

/**
* Use this to reveal a batch of delayed reveal NFTs on your {@link DropContract}
*
* @param contract - an instance of a {@link NFTContract} with the drop extension
* @returns a mutation object that can be used to reveal a batch of delayed reveal NFTs
* @beta
*/
export function useRevealLazyMint<TContract extends NFTContract>(
contract: RequiredParam<TContract>,
) {
const activeChainId = useActiveChainId();
const contractAddress = contract?.getAddress();
const queryClient = useQueryClient();

return useMutation(
async (data: RevealLazyMintInput) => {
invariant(
contract?.drop?.revealer?.reveal,
"contract does not support drop.revealer.reveal",
);
return await contract.drop.revealer.reveal(data.batchId, data.password);
},
{
onSettled: () =>
invalidateContractAndBalances(
queryClient,
contractAddress,
activeChainId,
),
},
);
}
Loading