Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

Commit 3d3e29b

Browse files
add additional contract hooks (#56)
* add additional contract hooks * v2.3.2-0 * Fix typo and some examples * v2.3.2-1 Co-authored-by: Nacho Iacovino <nacho.iacovino@gmail.com>
1 parent 69bd43c commit 3d3e29b

27 files changed

+1067
-128
lines changed

docs/react.claimnftparams.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@thirdweb-dev/react](./react.md) &gt; [ClaimNFTParams](./react.claimnftparams.md)
4+
5+
## ClaimNFTParams type
6+
7+
> 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.
8+
>
9+
10+
The params for the [useClaimNFT()](./react.useclaimnft.md) hook mutation.
11+
12+
<b>Signature:</b>
13+
14+
```typescript
15+
export declare type ClaimNFTParams<TContract extends DropContract> = TContract extends Erc1155 ? {
16+
to: WalletAddress;
17+
tokenId: BigNumberish;
18+
quantity: BigNumberish;
19+
proofs?: BytesLike[];
20+
} : {
21+
to: WalletAddress;
22+
quantity: BigNumberish;
23+
proofs?: BytesLike[];
24+
};
25+
```
26+
<b>References:</b> [DropContract](./react.dropcontract.md)<!-- -->, [WalletAddress](./react.walletaddress.md)
27+

docs/react.claimnftreturntype.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@thirdweb-dev/react](./react.md) &gt; [ClaimNFTReturnType](./react.claimnftreturntype.md)
4+
5+
## ClaimNFTReturnType type
6+
7+
> 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.
8+
>
9+
10+
The return type of the [useClaimNFT()](./react.useclaimnft.md) hook.
11+
12+
<b>Signature:</b>
13+
14+
```typescript
15+
export declare type ClaimNFTReturnType<TContract extends DropContract> = TContract extends Erc721 ? Awaited<ReturnType<TContract["claimTo"]>> : TContract extends Erc1155 ? Awaited<ReturnType<TContract["claimTo"]>> : never;
16+
```
17+
<b>References:</b> [DropContract](./react.dropcontract.md)
18+

docs/react.dropcontract.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@thirdweb-dev/react](./react.md) &gt; [DropContract](./react.dropcontract.md)
4+
5+
## DropContract type
6+
7+
> 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.
8+
>
9+
10+
The possible DROP contract types.
11+
12+
<b>Signature:</b>
13+
14+
```typescript
15+
export declare type DropContract = NFTDrop | EditionDrop;
16+
```

docs/react.makebidparams.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@thirdweb-dev/react](./react.md) &gt; [MakeBidParams](./react.makebidparams.md)
4+
5+
## MakeBidParams type
6+
7+
<b>Signature:</b>
8+
9+
```typescript
10+
export declare type MakeBidParams = {
11+
listingId: BigNumberish;
12+
bid: BigNumberish;
13+
};
14+
```

docs/react.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
import { useAddress } from "@thirdweb-dev/react"
1717
```
1818
|
19-
| [useAllListings(contract, filter)](./react.usealllistings.md) | <b><i>(BETA)</i></b> Use this to get a list all listings from your marketplace contract. |
19+
| [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. |
20+
| [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. |
21+
| [useBuyoutListing(contract)](./react.usebuyoutlisting.md) | <b><i>(BETA)</i></b> Use this to buy out an auction listing from your marketplace contract. |
2022
| [useChainId()](./react.usechainid.md) | Hook for accessing the chain ID of the network the current wallet is connected to
2123
```javascript
2224
import { useChainId } from "@thirdweb-dev/react"
@@ -26,6 +28,7 @@ import { useChainId } from "@thirdweb-dev/react"
2628
| [useClaimedNFTs(contract, queryParams)](./react.useclaimednfts.md) | <b><i>(BETA)</i></b> Use this to get a list of \*claimed\* (minted) NFT tokens of your ERC721 Drop contract. |
2729
| [useClaimedNFTSupply(contract)](./react.useclaimednftsupply.md) | |
2830
| [useClaimIneligibilityReasons(\[contract, params, tokenId\])](./react.useclaimineligibilityreasons.md) | <b><i>(BETA)</i></b> Use this to check for reasons that prevent claiming for either ERC20, ERC721 or ERC1155 based contracts. They need to extend the <code>claimCondition</code> extension for this hook to work. |
31+
| [useClaimNFT(contract)](./react.useclaimnft.md) | <b><i>(BETA)</i></b> Use this to mint a new NFT on your [DropContract](./react.dropcontract.md) |
2932
| [useCoinbaseWallet()](./react.usecoinbasewallet.md) | Hook for connecting to a Coinbase wallet.
3033
```javascript
3134
import { useCoinbaseWallet } from "@thirdweb-dev/react"
@@ -49,11 +52,14 @@ import { useDisconnect } from "@thirdweb-dev/react"
4952
import { useGnosis } from "@thirdweb-dev/react"
5053
```
5154
|
55+
| [useListing(contract, listingId)](./react.uselisting.md) | <b><i>(BETA)</i></b> Use this to get a specific listing from the marketplace. |
56+
| [useListings(contract, filter)](./react.uselistings.md) | <b><i>(BETA)</i></b> Use this to get a list all listings from your marketplace contract. |
5257
| [useMagic()](./react.usemagic.md) | Hook for connecting to an email wallet using magic link. This enables users without their own wallets to connect to your application and sign transactions securely using their email.
5358
```javascript
5459
import { useMagic } from "@thirdweb-dev/react"
5560
```
5661
|
62+
| [useMakeBid(contract)](./react.usemakebid.md) | <b><i>(BETA)</i></b> Use this to place a bid on an auction listing from your marketplace contract. |
5763
| [useMarketplace(contractAddress)](./react.usemarketplace.md) | Hook for getting an instance of a <code>Marketplace</code> contract. This contract is used to support marketplace for purchase and sale of on-chain assets. |
5864
| [useMetamask()](./react.usemetamask.md) | Hook for connecting to a Metamask wallet.
5965
```javascript
@@ -93,6 +99,7 @@ import { useNetworkMistmatch } from "@thirdweb-dev/react"
9399
import { useWalletConnect } from "@thirdweb-dev/react"
94100
```
95101
|
102+
| [useWinningBid(contract, listingId)](./react.usewinningbid.md) | <b><i>(BETA)</i></b> Use this to get a the winning bid for an auction listing from your marketplace contract. |
96103

97104
## Interfaces
98105

@@ -120,7 +127,11 @@ import { useWalletConnect } from "@thirdweb-dev/react"
120127
| Type Alias | Description |
121128
| --- | --- |
122129
| [ClaimIneligibilityParameters](./react.claimineligibilityparameters.md) | <b><i>(BETA)</i></b> The options to be passed as the second parameter to the <code>useClaimIneligibilityReasons</code> hook. |
130+
| [ClaimNFTParams](./react.claimnftparams.md) | <b><i>(BETA)</i></b> The params for the [useClaimNFT()](./react.useclaimnft.md) hook mutation. |
131+
| [ClaimNFTReturnType](./react.claimnftreturntype.md) | <b><i>(BETA)</i></b> The return type of the [useClaimNFT()](./react.useclaimnft.md) hook. |
123132
| [ContractAddress](./react.contractaddress.md) | <b><i>(BETA)</i></b> A contract address. |
133+
| [DropContract](./react.dropcontract.md) | <b><i>(BETA)</i></b> The possible DROP contract types. |
134+
| [MakeBidParams](./react.makebidparams.md) | |
124135
| [MintNFTParams](./react.mintnftparams.md) | <b><i>(BETA)</i></b> The params for the [useMintNFT()](./react.usemintnft.md) hook mutation. |
125136
| [MintNFTReturnType](./react.mintnftreturntype.md) | <b><i>(BETA)</i></b> The return type of the [useMintNFT()](./react.usemintnft.md) hook. |
126137
| [NFT](./react.nft.md) | <b><i>(BETA)</i></b> A single NFT token |

docs/react.useauctionwinner.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@thirdweb-dev/react](./react.md) &gt; [useAuctionWinner](./react.useauctionwinner.md)
4+
5+
## useAuctionWinner() function
6+
7+
> 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.
8+
>
9+
10+
Use this to get the winner of an auction listing from your marketplace contract.
11+
12+
<b>Signature:</b>
13+
14+
```typescript
15+
export declare function useAuctionWinner(contract: RequiredParam<Marketplace>, listingId: RequiredParam<BigNumberish>): import("react-query").UseQueryResult<string, unknown>;
16+
```
17+
18+
## Parameters
19+
20+
| Parameter | Type | Description |
21+
| --- | --- | --- |
22+
| contract | [RequiredParam](./react.requiredparam.md)<!-- -->&lt;Marketplace&gt; | an instace of a marketplace contract |
23+
| listingId | [RequiredParam](./react.requiredparam.md)<!-- -->&lt;BigNumberish&gt; | the listing id to check |
24+
25+
<b>Returns:</b>
26+
27+
import("react-query").UseQueryResult&lt;string, unknown&gt;
28+
29+
a response object that includes an array of listings
30+
31+
## Exceptions
32+
33+
an error if the auction is not finished
34+
35+
## Example
36+
37+
38+
```javascript
39+
const { data: auctionWinner, isLoading, error } = useAuctionWinner(<YourMarketplaceContractInstance>, <listingId>);
40+
```
41+

docs/react.usebidbuffer.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@thirdweb-dev/react](./react.md) &gt; [useBidBuffer](./react.usebidbuffer.md)
4+
5+
## useBidBuffer() function
6+
7+
> 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.
8+
>
9+
10+
Use this to get the buffer in basis points between offers from your marketplace contract.
11+
12+
<b>Signature:</b>
13+
14+
```typescript
15+
export declare function useBidBuffer(contract: RequiredParam<Marketplace>): import("react-query").UseQueryResult<BigNumber, unknown>;
16+
```
17+
18+
## Parameters
19+
20+
| Parameter | Type | Description |
21+
| --- | --- | --- |
22+
| contract | [RequiredParam](./react.requiredparam.md)<!-- -->&lt;Marketplace&gt; | an instace of a marketplace contract |
23+
24+
<b>Returns:</b>
25+
26+
import("react-query").UseQueryResult&lt;BigNumber, unknown&gt;
27+
28+
a response object that includes an array of listings
29+
30+
## Example
31+
32+
33+
```javascript
34+
const { data: auctionWinner, isLoading, error } = useAuctionWinner(<YourMarketplaceContractInstance>, <listingId>);
35+
```
36+

docs/react.usebuyoutlisting.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [@thirdweb-dev/react](./react.md) &gt; [useBuyoutListing](./react.usebuyoutlisting.md)
4+
5+
## useBuyoutListing() function
6+
7+
> 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.
8+
>
9+
10+
Use this to buy out an auction listing from your marketplace contract.
11+
12+
<b>Signature:</b>
13+
14+
```typescript
15+
export declare function useBuyoutListing(contract: RequiredParam<Marketplace>): import("react-query").UseMutationResult<Omit<{
16+
receipt: import("@ethersproject/abstract-provider").TransactionReceipt;
17+
data: () => Promise<unknown>;
18+
}, "data">, unknown, BigNumberish, unknown>;
19+
```
20+
21+
## Parameters
22+
23+
| Parameter | Type | Description |
24+
| --- | --- | --- |
25+
| contract | [RequiredParam](./react.requiredparam.md)<!-- -->&lt;Marketplace&gt; | an instace of a Marketplace contract |
26+
27+
<b>Returns:</b>
28+
29+
import("react-query").UseMutationResult&lt;Omit&lt;{ receipt: import("@ethersproject/abstract-provider").TransactionReceipt; data: () =&gt; Promise&lt;unknown&gt;; }, "data"&gt;, unknown, BigNumberish, unknown&gt;
30+
31+
a mutation object that can be used to buy out an auction listing
32+
33+
## Example
34+
35+
36+
```jsx
37+
const Component = () => {
38+
const {
39+
mutate: buyoutListing,
40+
isLoading,
41+
error,
42+
} = useBuyoutListing(">>YourMarketplaceContractInstance<<");
43+
44+
if (error) {
45+
console.error("failed to buyout listing", error);
46+
}
47+
48+
return (
49+
<button
50+
disabled={isLoading}
51+
onClick={() => buyoutListing(listingId)}
52+
>
53+
Buy listing!
54+
</button>
55+
);
56+
};
57+
```
58+

docs/react.useclaimednfts.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ Use this to get a list of \*claimed\* (minted) NFT tokens of your ERC721 Drop co
1212
<b>Signature:</b>
1313

1414
```typescript
15-
export declare function useClaimedNFTs(contract: RequiredParam<NFTDrop>, queryParams?: QueryAllParams): import("react-query").UseQueryResult<NFT<NFTDrop>[], unknown>;
15+
export declare function useClaimedNFTs(contract: RequiredParam<DropContract>, queryParams?: QueryAllParams): import("react-query").UseQueryResult<import("../../types").NFT<DropContract>[], unknown>;
1616
```
1717

1818
## Parameters
1919

2020
| Parameter | Type | Description |
2121
| --- | --- | --- |
22-
| contract | [RequiredParam](./react.requiredparam.md)<!-- -->&lt;NFTDrop&gt; | an instace of a |
22+
| contract | [RequiredParam](./react.requiredparam.md)<!-- -->&lt;[DropContract](./react.dropcontract.md)<!-- -->&gt; | an instace of a [DropContract](./react.dropcontract.md) |
2323
| queryParams | QueryAllParams | <i>(Optional)</i> query params to pass to the query for the sake of pagination |
2424

2525
<b>Returns:</b>
2626

27-
import("react-query").UseQueryResult&lt;[NFT](./react.nft.md)<!-- -->&lt;NFTDrop&gt;\[\], unknown&gt;
27+
import("react-query").UseQueryResult&lt;import("../../types").[NFT](./react.nft.md)<!-- -->&lt;[DropContract](./react.dropcontract.md)<!-- -->&gt;\[\], unknown&gt;
2828

2929
a response object that includes an array of NFTs that are claimed
3030

docs/react.useclaimednftsupply.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
<b>Signature:</b>
88

99
```typescript
10-
export declare function useClaimedNFTSupply(contract: RequiredParam<NFTDrop>): import("react-query").UseQueryResult<BigNumber, unknown>;
10+
export declare function useClaimedNFTSupply(contract: RequiredParam<DropContract>): import("react-query").UseQueryResult<import("ethers").BigNumber, unknown>;
1111
```
1212

1313
## Parameters
1414

1515
| Parameter | Type | Description |
1616
| --- | --- | --- |
17-
| contract | [RequiredParam](./react.requiredparam.md)<!-- -->&lt;NFTDrop&gt; | an instace of a |
17+
| contract | [RequiredParam](./react.requiredparam.md)<!-- -->&lt;[DropContract](./react.dropcontract.md)<!-- -->&gt; | an instace of a [DropContract](./react.dropcontract.md) |
1818

1919
<b>Returns:</b>
2020

21-
import("react-query").UseQueryResult&lt;BigNumber, unknown&gt;
21+
import("react-query").UseQueryResult&lt;import("ethers").BigNumber, unknown&gt;
2222

2323
a response object that includes the number of NFTs that are claimed
2424

0 commit comments

Comments
 (0)