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
27 changes: 27 additions & 0 deletions docs/sdk.editiondrop.getclaimtransaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/sdk](./sdk.md) &gt; [EditionDrop](./sdk.editiondrop.md) &gt; [getClaimTransaction](./sdk.editiondrop.getclaimtransaction.md)

## EditionDrop.getClaimTransaction() method

Construct a claim transaction without executing it. This is useful for estimating the gas cost of a claim transaction, overriding transaction options and having fine grained control over the transaction execution.

<b>Signature:</b>

```typescript
getClaimTransaction(destinationAddress: string, tokenId: BigNumberish, quantity: BigNumberish, checkERC20Allowance?: boolean): Promise<TransactionTask>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| destinationAddress | string | |
| tokenId | BigNumberish | |
| quantity | BigNumberish | |
| checkERC20Allowance | boolean | <i>(Optional)</i> |

<b>Returns:</b>

Promise&lt;TransactionTask&gt;

1 change: 1 addition & 0 deletions docs/sdk.editiondrop.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const contract = sdk.getEditionDrop("{{contract_address}}");
| [claimTo(destinationAddress, tokenId, quantity, checkERC20Allowance)](./sdk.editiondrop.claimto.md) | | Claim NFTs to a specific Wallet |
| [createBatch(metadatas, options)](./sdk.editiondrop.createbatch.md) | | Create a batch of NFTs to be claimed in the future |
| [getAll(queryParams)](./sdk.editiondrop.getall.md) | | Get All Minted NFTs |
| [getClaimTransaction(destinationAddress, tokenId, quantity, checkERC20Allowance)](./sdk.editiondrop.getclaimtransaction.md) | | Construct a claim transaction without executing it. This is useful for estimating the gas cost of a claim transaction, overriding transaction options and having fine grained control over the transaction execution. |
| [getOwned(walletAddress)](./sdk.editiondrop.getowned.md) | | Get Owned NFTs |
| [getTotalCount()](./sdk.editiondrop.gettotalcount.md) | | Get the number of NFTs minted |
| [isTransferRestricted()](./sdk.editiondrop.istransferrestricted.md) | | Get whether users can transfer NFTs from this contract |
Expand Down
26 changes: 26 additions & 0 deletions docs/sdk.nftdrop.getclaimtransaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/sdk](./sdk.md) &gt; [NFTDrop](./sdk.nftdrop.md) &gt; [getClaimTransaction](./sdk.nftdrop.getclaimtransaction.md)

## NFTDrop.getClaimTransaction() method

Construct a claim transaction without executing it. This is useful for estimating the gas cost of a claim transaction, overriding transaction options and having fine grained control over the transaction execution.

<b>Signature:</b>

```typescript
getClaimTransaction(destinationAddress: string, quantity: BigNumberish, checkERC20Allowance?: boolean): Promise<TransactionTask>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| destinationAddress | string | |
| quantity | BigNumberish | |
| checkERC20Allowance | boolean | <i>(Optional)</i> |

<b>Returns:</b>

Promise&lt;TransactionTask&gt;

1 change: 1 addition & 0 deletions docs/sdk.nftdrop.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const contract = sdk.getNFTDrop("{{contract_address}}");
| [getAll(queryParams)](./sdk.nftdrop.getall.md) | | Get All Minted NFTs |
| [getAllClaimed(queryParams)](./sdk.nftdrop.getallclaimed.md) | | Get All Claimed NFTs |
| [getAllUnclaimed(queryParams)](./sdk.nftdrop.getallunclaimed.md) | | Get All Unclaimed NFTs |
| [getClaimTransaction(destinationAddress, quantity, checkERC20Allowance)](./sdk.nftdrop.getclaimtransaction.md) | | Construct a claim transaction without executing it. This is useful for estimating the gas cost of a claim transaction, overriding transaction options and having fine grained control over the transaction execution. |
| [getOwned(walletAddress)](./sdk.nftdrop.getowned.md) | | Get Owned NFTs |
| [getOwnedTokenIds(walletAddress)](./sdk.nftdrop.getownedtokenids.md) | | Get all token ids of NFTs owned by a specific wallet. |
| [isTransferRestricted()](./sdk.nftdrop.istransferrestricted.md) | | Get whether users can transfer NFTs from this contract |
Expand Down
26 changes: 26 additions & 0 deletions docs/sdk.signaturedrop.getclaimtransaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/sdk](./sdk.md) &gt; [SignatureDrop](./sdk.signaturedrop.md) &gt; [getClaimTransaction](./sdk.signaturedrop.getclaimtransaction.md)

## SignatureDrop.getClaimTransaction() method

Construct a claim transaction without executing it. This is useful for estimating the gas cost of a claim transaction, overriding transaction options and having fine grained control over the transaction execution.

<b>Signature:</b>

```typescript
getClaimTransaction(destinationAddress: string, quantity: BigNumberish, checkERC20Allowance?: boolean): Promise<TransactionTask>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| destinationAddress | string | |
| quantity | BigNumberish | |
| checkERC20Allowance | boolean | <i>(Optional)</i> |

<b>Returns:</b>

Promise&lt;TransactionTask&gt;

1 change: 1 addition & 0 deletions docs/sdk.signaturedrop.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const contract = sdk.getSignatureDrop("{{contract_address}}");
| [getAll(queryParams)](./sdk.signaturedrop.getall.md) | | Get All Minted NFTs |
| [getAllClaimed(queryParams)](./sdk.signaturedrop.getallclaimed.md) | | Get All Claimed NFTs |
| [getAllUnclaimed(queryParams)](./sdk.signaturedrop.getallunclaimed.md) | | Get All Unclaimed NFTs |
| [getClaimTransaction(destinationAddress, quantity, checkERC20Allowance)](./sdk.signaturedrop.getclaimtransaction.md) | | Construct a claim transaction without executing it. This is useful for estimating the gas cost of a claim transaction, overriding transaction options and having fine grained control over the transaction execution. |
| [getOwned(walletAddress)](./sdk.signaturedrop.getowned.md) | | Get Owned NFTs |
| [getOwnedTokenIds(walletAddress)](./sdk.signaturedrop.getownedtokenids.md) | | |
| [isTransferRestricted()](./sdk.signaturedrop.istransferrestricted.md) | | Get whether users can transfer NFTs from this contract |
Expand Down
6 changes: 5 additions & 1 deletion etc/sdk.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { BigNumberish } from 'ethers';
import { BytesLike } from 'ethers';
import { CallOverrides } from 'ethers';
import { ContractInterface } from 'ethers';
import type { ContractTransaction } from 'ethers';
import { ContractTransaction } from 'ethers';
import { ethers } from 'ethers';
import type { Event as Event_2 } from 'ethers';
import EventEmitter from 'eventemitter3';
Expand Down Expand Up @@ -1962,6 +1962,8 @@ export class EditionDrop extends Erc1155<DropERC1155> {
// (undocumented)
events: ContractEvents<DropERC1155>;
getAll(queryParams?: QueryAllParams): Promise<EditionMetadata[]>;
// Warning: (ae-forgotten-export) The symbol "TransactionTask" needs to be exported by the entry point index.d.ts
getClaimTransaction(destinationAddress: string, tokenId: BigNumberish, quantity: BigNumberish, checkERC20Allowance?: boolean): Promise<TransactionTask>;
getOwned(walletAddress?: string): Promise<EditionMetadataOwner[]>;
getTotalCount(): Promise<BigNumber>;
// (undocumented)
Expand Down Expand Up @@ -3741,6 +3743,7 @@ export class NFTDrop extends Erc721<DropERC721> {
getAll(queryParams?: QueryAllParams): Promise<NFTMetadataOwner[]>;
getAllClaimed(queryParams?: QueryAllParams): Promise<NFTMetadataOwner[]>;
getAllUnclaimed(queryParams?: QueryAllParams): Promise<NFTMetadata[]>;
getClaimTransaction(destinationAddress: string, quantity: BigNumberish, checkERC20Allowance?: boolean): Promise<TransactionTask>;
getOwned(walletAddress?: string): Promise<NFTMetadataOwner[]>;
getOwnedTokenIds(walletAddress?: string): Promise<BigNumber[]>;
// @internal (undocumented)
Expand Down Expand Up @@ -5711,6 +5714,7 @@ export class SignatureDrop extends Erc721<SignatureDrop_2> {
getAll(queryParams?: QueryAllParams): Promise<NFTMetadataOwner[]>;
getAllClaimed(queryParams?: QueryAllParams): Promise<NFTMetadataOwner[]>;
getAllUnclaimed(queryParams?: QueryAllParams): Promise<NFTMetadata[]>;
getClaimTransaction(destinationAddress: string, quantity: BigNumberish, checkERC20Allowance?: boolean): Promise<TransactionTask>;
getOwned(walletAddress?: string): Promise<NFTMetadataOwner[]>;
// Warning: (ae-unresolved-inheritdoc-reference) The @inheritDoc reference could not be resolved: No member was found with name "tokendIds"
//
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/sdk",
"version": "2.3.33",
"version": "2.3.34-1",
"description": "The main thirdweb SDK.",
"repository": {
"type": "git",
Expand Down
55 changes: 39 additions & 16 deletions src/contracts/edition-drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { getRoleHash } from "../common";

import { EditionMetadata, EditionMetadataOwner } from "../schema";
import { uploadOrExtractURIs } from "../common/nft";
import { TransactionTask } from "../core/classes/TransactionTask";

/**
* Setup a collection of NFTs with a customizable number of each NFT that are minted as users claim them.
Expand Down Expand Up @@ -299,6 +300,41 @@ export class EditionDrop extends Erc1155<DropERC1155> {
return results;
}

/**
* Construct a claim transaction without executing it.
* This is useful for estimating the gas cost of a claim transaction, overriding transaction options and having fine grained control over the transaction execution.
* @param destinationAddress
* @param tokenId
* @param quantity
* @param checkERC20Allowance
*/
public async getClaimTransaction(
destinationAddress: string,
tokenId: BigNumberish,
quantity: BigNumberish,
checkERC20Allowance = true, // TODO split up allowance checks
): Promise<TransactionTask> {
const claimVerification = await this.prepareClaim(
tokenId,
quantity,
checkERC20Allowance,
);
return TransactionTask.make({
contractWrapper: this.contractWrapper,
functionName: "claim",
args: [
destinationAddress,
tokenId,
quantity,
claimVerification.currencyAddress,
claimVerification.price,
claimVerification.proofs,
claimVerification.maxQuantityPerTransaction,
],
overrides: claimVerification.overrides,
});
}

/**
* Claim NFTs to a specific Wallet
*
Expand Down Expand Up @@ -328,26 +364,13 @@ export class EditionDrop extends Erc1155<DropERC1155> {
quantity: BigNumberish,
checkERC20Allowance = true,
): Promise<TransactionResult> {
const claimVerification = await this.prepareClaim(
const task = await this.getClaimTransaction(
destinationAddress,
tokenId,
quantity,
checkERC20Allowance,
);
return {
receipt: await this.contractWrapper.sendTransaction(
"claim",
[
destinationAddress,
tokenId,
quantity,
claimVerification.currencyAddress,
claimVerification.price,
claimVerification.proofs,
claimVerification.maxQuantityPerTransaction,
],
claimVerification.overrides,
),
};
return await task.execute();
}

/**
Expand Down
48 changes: 35 additions & 13 deletions src/contracts/nft-drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
} from "contracts/DropERC721";
import { UploadProgressEvent } from "../types/events";
import { uploadOrExtractURIs } from "../common/nft";
import { TransactionTask } from "../core/classes/TransactionTask";

/**
* Setup a collection of one-of-one NFTs that are minted as users claim them.
Expand Down Expand Up @@ -447,6 +448,37 @@ export class NFTDrop extends Erc721<DropERC721> {
return results;
}

/**
* Construct a claim transaction without executing it.
* This is useful for estimating the gas cost of a claim transaction, overriding transaction options and having fine grained control over the transaction execution.
* @param destinationAddress
* @param quantity
* @param checkERC20Allowance
*/
public async getClaimTransaction(
destinationAddress: string,
quantity: BigNumberish,
checkERC20Allowance = true, // TODO split up allowance checks
): Promise<TransactionTask> {
const claimVerification = await this.prepareClaim(
quantity,
checkERC20Allowance,
);
return TransactionTask.make({
contractWrapper: this.contractWrapper,
functionName: "claim",
args: [
destinationAddress,
quantity,
claimVerification.currencyAddress,
claimVerification.price,
claimVerification.proofs,
claimVerification.maxQuantityPerTransaction,
],
overrides: claimVerification.overrides,
});
}

/**
* Claim unique NFTs to a specific Wallet
*
Expand Down Expand Up @@ -474,22 +506,12 @@ export class NFTDrop extends Erc721<DropERC721> {
quantity: BigNumberish,
checkERC20Allowance = true,
): Promise<TransactionResultWithId<NFTMetadataOwner>[]> {
const claimVerification = await this.prepareClaim(
const task = await this.getClaimTransaction(
destinationAddress,
quantity,
checkERC20Allowance,
);
const receipt = await this.contractWrapper.sendTransaction(
"claim",
[
destinationAddress,
quantity,
claimVerification.currencyAddress,
claimVerification.price,
claimVerification.proofs,
claimVerification.maxQuantityPerTransaction,
],
claimVerification.overrides,
);
const { receipt } = await task.execute();
const event = this.contractWrapper.parseLogs<TokensClaimedEvent>(
"TokensClaimed",
receipt?.logs,
Expand Down
54 changes: 38 additions & 16 deletions src/contracts/signature-drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
import { DelayedReveal, DropClaimConditions } from "../core/index";
import { Erc721WithQuantitySignatureMintable } from "../core/classes/erc-721-with-quantity-signature-mintable";
import { uploadOrExtractURIs } from "../common/nft";
import { TransactionTask } from "../core/classes/TransactionTask";

/**
* Setup a collection of NFTs where when it comes to minting, you can authorize
Expand Down Expand Up @@ -463,6 +464,40 @@ export class SignatureDrop extends Erc721<SignatureDropContract> {
return results;
}

/**
* Construct a claim transaction without executing it.
* This is useful for estimating the gas cost of a claim transaction, overriding transaction options and having fine grained control over the transaction execution.
* @param destinationAddress
* @param quantity
* @param checkERC20Allowance
*/
public async getClaimTransaction(
destinationAddress: string,
quantity: BigNumberish,
checkERC20Allowance = true, // TODO split up allowance checks
): Promise<TransactionTask> {
const claimVerification = await this.prepareClaim(
quantity,
checkERC20Allowance,
);
return TransactionTask.make({
contractWrapper: this.contractWrapper,
functionName: "claim",
args: [
destinationAddress,
quantity,
claimVerification.currencyAddress,
claimVerification.price,
{
proof: claimVerification.proofs,
maxQuantityInAllowlist: claimVerification.maxQuantityPerTransaction,
},
ethers.utils.toUtf8Bytes(""),
],
overrides: claimVerification.overrides,
});
}

/**
* Claim unique NFTs to a specific Wallet
*
Expand Down Expand Up @@ -490,25 +525,12 @@ export class SignatureDrop extends Erc721<SignatureDropContract> {
quantity: BigNumberish,
checkERC20Allowance = true,
): Promise<TransactionResultWithId<NFTMetadataOwner>[]> {
const claimVerification = await this.prepareClaim(
const task = await this.getClaimTransaction(
destinationAddress,
quantity,
checkERC20Allowance,
);
const receipt = await this.contractWrapper.sendTransaction(
"claim",
[
destinationAddress,
quantity,
claimVerification.currencyAddress,
claimVerification.price,
{
proof: claimVerification.proofs,
maxQuantityInAllowlist: claimVerification.maxQuantityPerTransaction,
},
ethers.utils.toUtf8Bytes(""),
],
claimVerification.overrides,
);
const { receipt } = await task.execute();
const event = this.contractWrapper.parseLogs<TokensClaimedEvent>(
"TokensClaimed",
receipt?.logs,
Expand Down
Loading