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
2 changes: 2 additions & 0 deletions docs/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import { useMetamask } from "@thirdweb-dev/react"
```
|
| [useMintNFT(contract)](./react.usemintnft.md) | <b><i>(BETA)</i></b> Use this to mint a new NFT on your [NFTContract](./react.nftcontract.md) |
| [useMintNFTSupply(contract)](./react.usemintnftsupply.md) | <b><i>(BETA)</i></b> Use this to mint a new NFT on your [NFTContract](./react.nftcontract.md) |
| [useMintToken(contract)](./react.useminttoken.md) | <b><i>(BETA)</i></b> Use this to mint new tokens on your contract |
| [useMultiwrap(contractAddress)](./react.usemultiwrap.md) | Hook for getting an instance of an <code>Multiwrap</code> contract. This contract is an ERC721 in which you can wrap ERC721, ERC1155 and ERC20 tokens. |
| [useNetwork()](./react.usenetwork.md) | Hook for getting metadata about the network the current wallet is connected to and switching networks |
Expand Down Expand Up @@ -165,6 +166,7 @@ import { useWalletConnect } from "@thirdweb-dev/react"
| [MakeBidParams](./react.makebidparams.md) | |
| [MintNFTParams](./react.mintnftparams.md) | <b><i>(BETA)</i></b> The params for the [useMintNFT()](./react.usemintnft.md) hook mutation. |
| [MintNFTReturnType](./react.mintnftreturntype.md) | <b><i>(BETA)</i></b> The return type of the [useMintNFT()](./react.usemintnft.md) hook. |
| [MintNFTSupplyParams](./react.mintnftsupplyparams.md) | <b><i>(BETA)</i></b> The params to pass to <code>useMintNFTSupply</code>. |
| [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. |
Expand Down
22 changes: 22 additions & 0 deletions docs/react.mintnftsupplyparams.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

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

## MintNFTSupplyParams 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 to pass to `useMintNFTSupply`<!-- -->.

<b>Signature:</b>

```typescript
export declare type MintNFTSupplyParams = {
tokenId: BigNumberish;
additionalSupply: Amount;
to: WalletAddress;
};
```
<b>References:</b> [WalletAddress](./react.walletaddress.md)

2 changes: 1 addition & 1 deletion docs/react.useburnnft.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const Component = () => {
disabled={isLoading}
onClick={() => burnNft({ tokenId: 0 })}
>
Mint!
Burn!
</button>
);
};
Expand Down
95 changes: 95 additions & 0 deletions docs/react.usemintnftsupply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

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

## useMintNFTSupply() 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 mint a new NFT on your [NFTContract](./react.nftcontract.md)

<b>Signature:</b>

```typescript
export declare function useMintNFTSupply(contract: Erc1155): 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, unknown>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| contract | Erc1155 | an instance of a |

<b>Returns:</b>

import("@tanstack/react-query").UseMutationResult&lt;import("@thirdweb-dev/sdk/dist/browser").TransactionResultWithId&lt;{ 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; }&gt;, unknown, [MintNFTSupplyParams](./react.mintnftsupplyparams.md)<!-- -->, unknown&gt;

a mutation object that can be used to mint a more supply of a token id to the provided wallet

## Example 1


```jsx
const Component = () => {
const nftDrop = useNFTDrop(<ContractAddress>);
const {
mutate: mintNftSupply,
isLoading,
error,
} = useMintNFTSupply(nftDrop);

if (error) {
console.error("failed to mint additional supply", error);
}

return (
<button
disabled={isLoading}
onClick={() => mintNftSupply({ tokenId: 0, additionalSupply: 100, to: "0x..."})}
>
Mint Additional Supply!
</button>
);
};
```

## Example 2


```jsx
const Component = () => {
const { contract } = useContract(<ContractAddress>);
const {
mutate: mintNftSupply,
isLoading,
error,
} = useMintNFTSupply(contract?.nft);

if (error) {
console.error("failed to mint additional supply", error);
}

return (
<button
disabled={isLoading}
onClick={() => mintNftSupply({ tokenId: 0, additionalSupply: 100, to: "0x..."})}
>
Mint Additional Supply!
</button>
);
};
```

26 changes: 24 additions & 2 deletions etc/react.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ export type MintNFTParams<TContract extends NFTContract> = TContract extends Erc
// @beta
export type MintNFTReturnType<TContract> = TContract extends Erc721 ? Awaited<ReturnType<Erc721Mintable["to"]>> : TContract extends Erc1155 ? Awaited<ReturnType<Erc1155Mintable["to"]>> : never;

// @beta
export type MintNFTSupplyParams = {
tokenId: BigNumberish;
additionalSupply: Amount;
to: WalletAddress;
};

// @beta
export type NFT<TContract extends NFTContract> = {
metadata: NFTMetadata;
Expand Down Expand Up @@ -1454,6 +1461,21 @@ export function useMetamask(): () => Promise<{
// @beta
export function useMintNFT<TContract extends NFTContract>(contract: RequiredParam<TContract>): UseMutationResult<MintNFTReturnType<TContract>, unknown, MintNFTParams<TContract>, unknown>;

// @beta
export function useMintNFTSupply(contract: Erc1155): UseMutationResult<TransactionResultWithId< {
metadata: {
[x: string]: 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, unknown>;

// @beta
export function useMintToken(contract: RequiredParam<Erc20>): UseMutationResult<Omit<{
receipt: TransactionReceipt;
Expand Down Expand Up @@ -1747,8 +1769,8 @@ export type WalletLinkConnectorType = "walletLink" | "coinbase" | {
// dist/hooks/async/roles.d.ts:126:5 - (ae-incompatible-release-tags) The symbol "role" is marked as @beta, but its signature references "RolesForContract" which is marked as @internal
// 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/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:187: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:193: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: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

// (No @packageDocumentation comment for this package)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@thirdweb-dev/react",
"version": "2.6.3-3",
"version": "2.6.3-4",
"repository": {
"type": "git",
"url": "git+https://github.com:thirdweb-dev/react.git"
Expand Down
92 changes: 91 additions & 1 deletion src/hooks/async/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
BurnNFTParams,
MintNFTParams,
MintNFTReturnType,
MintNFTSupplyParams,
NFT,
NFTContract,
RequiredParam,
Expand Down Expand Up @@ -437,6 +438,95 @@ export function useMintNFT<TContract extends NFTContract>(
);
}

/**
* Use this to mint a new NFT on your {@link NFTContract}
*
* @example
* ```jsx
* const Component = () => {
* const nftDrop = useNFTDrop(<ContractAddress>);
* const {
* mutate: mintNftSupply,
* isLoading,
* error,
* } = useMintNFTSupply(nftDrop);
*
* if (error) {
* console.error("failed to mint additional supply", error);
* }
*
* return (
* <button
* disabled={isLoading}
* onClick={() => mintNftSupply({ tokenId: 0, additionalSupply: 100, to: "0x..."})}
* >
* Mint Additional Supply!
* </button>
* );
* };
* ```
* @example
* ```jsx
* const Component = () => {
* const { contract } = useContract(<ContractAddress>);
* const {
* mutate: mintNftSupply,
* isLoading,
* error,
* } = useMintNFTSupply(contract?.nft);
*
* if (error) {
* console.error("failed to mint additional supply", error);
* }
*
* return (
* <button
* disabled={isLoading}
* onClick={() => mintNftSupply({ tokenId: 0, additionalSupply: 100, to: "0x..."})}
* >
* Mint Additional Supply!
* </button>
* );
* };
* ```
*
* @param contract - an instance of a {@link Erc1155}
* @returns a mutation object that can be used to mint a more supply of a token id to the provided wallet
* @beta
*/
export function useMintNFTSupply(contract: Erc1155) {
const activeChainId = useActiveChainId();
const contractAddress = contract?.getAddress();
const queryClient = useQueryClient();

return useMutation(
async (data: MintNFTSupplyParams) => {
invariant(data.to, 'No "to" address provided');
invariant(
contract?.mint?.additionalSupplyTo,
"contract does not support mint.additionalSupplyTo",
);

invariant("tokenId" in data, "tokenId not provided");
invariant("additionalSupply" in data, "additionalSupply not provided");
const { to, tokenId, additionalSupply } = data;
return await contract.mint.additionalSupplyTo(
to,
tokenId,
additionalSupply,
);
},
{
onSettled: () =>
invalidateContractAndBalances(
queryClient,
contractAddress,
activeChainId,
),
},
);
}

/**
* Use this to transfer tokens on your {@link NFTContract}
*
Expand Down Expand Up @@ -630,7 +720,7 @@ export function useAirdropNFT(contract: Erc1155) {
* disabled={isLoading}
* onClick={() => burnNft({ tokenId: 0 })}
* >
* Mint!
* Burn!
* </button>
* );
* };
Expand Down
10 changes: 10 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,16 @@ export type AirdropNFTParams = {
addresses: AirdropInput;
};

/**
* The params to pass to `useMintNFTSupply`.
* @beta
*/
export type MintNFTSupplyParams = {
tokenId: BigNumberish;
additionalSupply: Amount;
to: WalletAddress;
};

/**
* The params for the {@link useMintNFT} hook mutation.
*
Expand Down