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
3 changes: 2 additions & 1 deletion docs/sdk.droperc1155claimconditions.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export declare class DropErc1155ClaimConditions
| [getActive(tokenId)](./sdk.droperc1155claimconditions.getactive.md) | | Get the currently active claim condition |
| [getAll(tokenId)](./sdk.droperc1155claimconditions.getall.md) | | Get all the claim conditions |
| [getClaimIneligibilityReasons(tokenId, quantity, addressToCheck)](./sdk.droperc1155claimconditions.getclaimineligibilityreasons.md) | | For any claim conditions that a particular wallet is violating, this function returns human-readable information about the breaks in the condition that can be used to inform the user. |
| [set(tokenId, claimConditionInputs, resetClaimEligibilityForAll)](./sdk.droperc1155claimconditions.set.md) | | Set public mint conditions on a NFT |
| [set(tokenId, claimConditionInputs, resetClaimEligibilityForAll)](./sdk.droperc1155claimconditions.set.md) | | Set claim conditions on a single NFT |
| [setBatch(tokenIds, claimConditionInputs, resetClaimEligibilityForAll)](./sdk.droperc1155claimconditions.setbatch.md) | | Set claim conditions on multiple NFTs at once |
| [update(tokenId, index, claimConditionInput)](./sdk.droperc1155claimconditions.update.md) | | Update a single claim condition with new data. |

4 changes: 2 additions & 2 deletions docs/sdk.droperc1155claimconditions.set.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## DropErc1155ClaimConditions.set() method

Set public mint conditions on a NFT
Set claim conditions on a single NFT

<b>Signature:</b>

Expand All @@ -26,7 +26,7 @@ Promise&lt;[TransactionResult](./sdk.transactionresult.md)<!-- -->&gt;

## Remarks

Sets the public mint conditions that need to be fulfilled by users to claim a particular NFT in this bundle.
Sets the public mint conditions that need to be fulfilled by users to claim a particular NFT in this contract.

## Example

Expand Down
55 changes: 55 additions & 0 deletions docs/sdk.droperc1155claimconditions.setbatch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/sdk](./sdk.md) &gt; [DropErc1155ClaimConditions](./sdk.droperc1155claimconditions.md) &gt; [setBatch](./sdk.droperc1155claimconditions.setbatch.md)

## DropErc1155ClaimConditions.setBatch() method

Set claim conditions on multiple NFTs at once

<b>Signature:</b>

```typescript
setBatch(tokenIds: BigNumberish[], claimConditionInputs: ClaimConditionInput[], resetClaimEligibilityForAll?: boolean): Promise<{
receipt: ethers.providers.TransactionReceipt;
}>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| tokenIds | BigNumberish\[\] | the token ids to set the claim conditions on |
| claimConditionInputs | [ClaimConditionInput](./sdk.claimconditioninput.md)<!-- -->\[\] | The claim conditions |
| resetClaimEligibilityForAll | boolean | <i>(Optional)</i> Whether to reset the state of who already claimed NFTs previously |

<b>Returns:</b>

Promise&lt;{ receipt: ethers.providers.TransactionReceipt; }&gt;

## Remarks

Sets the claim conditions that need to be fulfilled by users to claim the given NFTs in this contract.

## Example


```javascript
const presaleStartTime = new Date();
const publicSaleStartTime = new Date(Date.now() + 60 * 60 * 24 * 1000);
const claimConditions = [
{
startTime: presaleStartTime, // start the presale now
maxQuantity: 2, // limit how many mints for this presale
price: 0.01, // presale price
snapshot: ['0x...', '0x...'], // limit minting to only certain addresses
},
{
startTime: publicSaleStartTime, // 24h after presale, start public sale
price: 0.08, // public sale price
}
]);

const tokenIds = [0,1,2]; // the ids of the NFTs to set claim conditions on
await dropContract.claimConditions.setBatch(tokenIds, claimConditions);
```

3 changes: 3 additions & 0 deletions etc/sdk.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,9 @@ export class DropErc1155ClaimConditions {
getAll(tokenId: BigNumberish): Promise<ClaimCondition[]>;
getClaimIneligibilityReasons(tokenId: BigNumberish, quantity: BigNumberish, addressToCheck?: string): Promise<ClaimEligibility[]>;
set(tokenId: BigNumberish, claimConditionInputs: ClaimConditionInput[], resetClaimEligibilityForAll?: boolean): Promise<TransactionResult>;
setBatch(tokenIds: BigNumberish[], claimConditionInputs: ClaimConditionInput[], resetClaimEligibilityForAll?: boolean): Promise<{
receipt: ethers.providers.TransactionReceipt;
}>;
update(tokenId: BigNumberish, index: number, claimConditionInput: ClaimConditionInput): Promise<TransactionResult>;
}

Expand Down
61 changes: 52 additions & 9 deletions src/core/classes/drop-erc1155-claim-conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@ export class DropErc1155ClaimConditions {
*****************************************/

/**
* Set public mint conditions on a NFT
* Set claim conditions on a single NFT
*
* @remarks Sets the public mint conditions that need to be fulfilled by users to claim a particular NFT in this bundle.
* @remarks Sets the public mint conditions that need to be fulfilled by users to claim a particular NFT in this contract.
*
* @example
* ```javascript
Expand Down Expand Up @@ -301,6 +301,48 @@ export class DropErc1155ClaimConditions {
claimConditionInputs: ClaimConditionInput[],
resetClaimEligibilityForAll = false,
): Promise<TransactionResult> {
return this.setBatch(
[tokenId],
claimConditionInputs,
resetClaimEligibilityForAll,
);
}

/**
* Set claim conditions on multiple NFTs at once
*
* @remarks Sets the claim conditions that need to be fulfilled by users to claim the given NFTs in this contract.
*
* @example
* ```javascript
* const presaleStartTime = new Date();
* const publicSaleStartTime = new Date(Date.now() + 60 * 60 * 24 * 1000);
* const claimConditions = [
* {
* startTime: presaleStartTime, // start the presale now
* maxQuantity: 2, // limit how many mints for this presale
* price: 0.01, // presale price
* snapshot: ['0x...', '0x...'], // limit minting to only certain addresses
* },
* {
* startTime: publicSaleStartTime, // 24h after presale, start public sale
* price: 0.08, // public sale price
* }
* ]);
*
* const tokenIds = [0,1,2]; // the ids of the NFTs to set claim conditions on
* await dropContract.claimConditions.setBatch(tokenIds, claimConditions);
* ```
*
* @param tokenIds - the token ids to set the claim conditions on
* @param claimConditionInputs - The claim conditions
* @param resetClaimEligibilityForAll - Whether to reset the state of who already claimed NFTs previously
*/
public async setBatch(
tokenIds: BigNumberish[],
claimConditionInputs: ClaimConditionInput[],
resetClaimEligibilityForAll = false,
) {
// process inputs
const { snapshotInfos, sortedConditions } =
await processClaimConditionInputs(
Expand Down Expand Up @@ -340,13 +382,14 @@ export class DropErc1155ClaimConditions {
);
}

encoded.push(
this.contractWrapper.readContract.interface.encodeFunctionData(
"setClaimConditions",
[tokenId, sortedConditions, resetClaimEligibilityForAll],
),
);

tokenIds.forEach((tokenId) => {
encoded.push(
this.contractWrapper.readContract.interface.encodeFunctionData(
"setClaimConditions",
[tokenId, sortedConditions, resetClaimEligibilityForAll],
),
);
});
return {
receipt: await this.contractWrapper.multiCall(encoded),
};
Expand Down
23 changes: 23 additions & 0 deletions test/edition-drop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,29 @@ describe("Edition Drop Contract", async () => {
await bdContract.claim("0", 1);
});

it("should set multiple claim conditions at once", async () => {
await bdContract.createBatch([
{
name: "test1",
description: "test1",
},
{
name: "test2",
description: "test2",
},
]);
await bdContract.claimConditions.setBatch(
[0, 1],
[
{
price: 1,
},
],
);
await bdContract.claim("0", 1);
await bdContract.claim("1", 1);
});

describe("eligibility", () => {
beforeEach(async () => {
await bdContract.createBatch([
Expand Down