thirdweb 5.93.14-nightly-169ae22a86787af674cf20ac4e8d1e4a06c84d77-20250404043931 → 5.93.15-nightly-386138e4f06b14aac2fea2ab4a7a0497932f74a7-20250406000354
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/chains/chain-definitions/monad-testnet.js +20 -0
- package/dist/cjs/chains/chain-definitions/monad-testnet.js.map +1 -0
- package/dist/cjs/exports/chains.js +3 -1
- package/dist/cjs/exports/chains.js.map +1 -1
- package/dist/cjs/exports/extensions/erc1155.js +4 -2
- package/dist/cjs/exports/extensions/erc1155.js.map +1 -1
- package/dist/cjs/extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.js +31 -37
- package/dist/cjs/extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.js.map +1 -1
- package/dist/cjs/extensions/erc1155/drops/read/getActiveClaimCondition.js +30 -7
- package/dist/cjs/extensions/erc1155/drops/read/getActiveClaimCondition.js.map +1 -1
- package/dist/cjs/extensions/erc1155/drops/read/getClaimConditions.js +32 -14
- package/dist/cjs/extensions/erc1155/drops/read/getClaimConditions.js.map +1 -1
- package/dist/cjs/extensions/erc1155/drops/write/resetClaimEligibility.js +31 -2
- package/dist/cjs/extensions/erc1155/drops/write/resetClaimEligibility.js.map +1 -1
- package/dist/cjs/utils/extensions/drops/get-claim-params.js +0 -7
- package/dist/cjs/utils/extensions/drops/get-claim-params.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/chains/chain-definitions/monad-testnet.js +17 -0
- package/dist/esm/chains/chain-definitions/monad-testnet.js.map +1 -0
- package/dist/esm/exports/chains.js +1 -0
- package/dist/esm/exports/chains.js.map +1 -1
- package/dist/esm/exports/extensions/erc1155.js +1 -0
- package/dist/esm/exports/extensions/erc1155.js.map +1 -1
- package/dist/esm/extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.js +31 -37
- package/dist/esm/extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.js.map +1 -1
- package/dist/esm/extensions/erc1155/drops/read/getActiveClaimCondition.js +30 -7
- package/dist/esm/extensions/erc1155/drops/read/getActiveClaimCondition.js.map +1 -1
- package/dist/esm/extensions/erc1155/drops/read/getClaimConditions.js +32 -14
- package/dist/esm/extensions/erc1155/drops/read/getClaimConditions.js.map +1 -1
- package/dist/esm/extensions/erc1155/drops/write/resetClaimEligibility.js +33 -4
- package/dist/esm/extensions/erc1155/drops/write/resetClaimEligibility.js.map +1 -1
- package/dist/esm/utils/extensions/drops/get-claim-params.js +0 -7
- package/dist/esm/utils/extensions/drops/get-claim-params.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/chains/chain-definitions/monad-testnet.d.ts +7 -0
- package/dist/types/chains/chain-definitions/monad-testnet.d.ts.map +1 -0
- package/dist/types/exports/chains.d.ts +1 -0
- package/dist/types/exports/chains.d.ts.map +1 -1
- package/dist/types/exports/extensions/erc1155.d.ts +1 -0
- package/dist/types/exports/extensions/erc1155.d.ts.map +1 -1
- package/dist/types/extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.d.ts +2 -20
- package/dist/types/extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.d.ts.map +1 -1
- package/dist/types/extensions/erc1155/drops/read/getActiveClaimCondition.d.ts.map +1 -1
- package/dist/types/extensions/erc1155/drops/read/getClaimConditions.d.ts.map +1 -1
- package/dist/types/extensions/erc1155/drops/write/resetClaimEligibility.d.ts +3 -1
- package/dist/types/extensions/erc1155/drops/write/resetClaimEligibility.d.ts.map +1 -1
- package/dist/types/utils/extensions/drops/get-claim-params.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/chains/chain-definitions/monad-testnet.ts +17 -0
- package/src/exports/chains.ts +1 -0
- package/src/exports/extensions/erc1155.ts +1 -0
- package/src/extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.ts +31 -37
- package/src/extensions/erc1155/customDrop1155.test.ts +86 -0
- package/src/extensions/erc1155/drops/read/getActiveClaimCondition.ts +42 -6
- package/src/extensions/erc1155/drops/read/getClaimConditions.ts +49 -18
- package/src/extensions/erc1155/drops/write/resetClaimEligibility.ts +54 -5
- package/src/utils/extensions/drops/get-claim-params.ts +0 -9
- package/src/version.ts +1 -1
@@ -7,13 +7,16 @@ import { TEST_CLIENT } from "../../../test/src/test-clients.js";
|
|
7
7
|
import {
|
8
8
|
TEST_ACCOUNT_B,
|
9
9
|
TEST_ACCOUNT_C,
|
10
|
+
TEST_ACCOUNT_D,
|
10
11
|
} from "../../../test/src/test-wallets.js";
|
11
12
|
import { type ThirdwebContract, getContract } from "../../contract/contract.js";
|
12
13
|
import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
|
13
14
|
import { deployContractfromDeployMetadata } from "../prebuilts/deploy-published.js";
|
14
15
|
import { balanceOf } from "./__generated__/IERC1155/read/balanceOf.js";
|
15
16
|
import { nextTokenIdToMint } from "./__generated__/IERC1155Enumerable/read/nextTokenIdToMint.js";
|
17
|
+
import { getClaimConditions } from "./drops/read/getClaimConditions.js";
|
16
18
|
import { claimTo } from "./drops/write/claimTo.js";
|
19
|
+
import { resetClaimEligibility } from "./drops/write/resetClaimEligibility.js";
|
17
20
|
import { setClaimConditions } from "./drops/write/setClaimConditions.js";
|
18
21
|
import { getNFT } from "./read/getNFT.js";
|
19
22
|
import { lazyMint } from "./write/lazyMint.js";
|
@@ -92,6 +95,14 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
|
92
95
|
}),
|
93
96
|
account: TEST_ACCOUNT_C,
|
94
97
|
});
|
98
|
+
|
99
|
+
const condition = await getClaimConditions({
|
100
|
+
contract,
|
101
|
+
tokenId: 0n,
|
102
|
+
});
|
103
|
+
expect(condition.length).to.eq(1);
|
104
|
+
expect(condition[0]?.maxClaimableSupply).to.eq(10n);
|
105
|
+
|
95
106
|
const claimTx = claimTo({
|
96
107
|
contract,
|
97
108
|
to: TEST_ACCOUNT_C.address,
|
@@ -166,5 +177,80 @@ describe.runIf(process.env.TW_SECRET_KEY)(
|
|
166
177
|
chainId: ${contract.chain.id}]
|
167
178
|
`);
|
168
179
|
});
|
180
|
+
|
181
|
+
it("should reset claim eligibility", async () => {
|
182
|
+
await sendAndConfirmTransaction({
|
183
|
+
transaction: setClaimConditions({
|
184
|
+
contract,
|
185
|
+
phases: [
|
186
|
+
{
|
187
|
+
startTime: new Date(0),
|
188
|
+
maxClaimableSupply: 10n,
|
189
|
+
maxClaimablePerWallet: 1n,
|
190
|
+
},
|
191
|
+
],
|
192
|
+
tokenId: 0n,
|
193
|
+
singlePhaseDrop: true,
|
194
|
+
}),
|
195
|
+
account: TEST_ACCOUNT_C,
|
196
|
+
});
|
197
|
+
// claim one token
|
198
|
+
const claimTx = claimTo({
|
199
|
+
contract,
|
200
|
+
to: TEST_ACCOUNT_D.address,
|
201
|
+
tokenId: 0n,
|
202
|
+
quantity: 1n,
|
203
|
+
singlePhaseDrop: true,
|
204
|
+
});
|
205
|
+
await sendAndConfirmTransaction({
|
206
|
+
transaction: claimTx,
|
207
|
+
account: TEST_ACCOUNT_D,
|
208
|
+
});
|
209
|
+
await expect(
|
210
|
+
balanceOf({ contract, owner: TEST_ACCOUNT_D.address, tokenId: 0n }),
|
211
|
+
).resolves.toBe(1n);
|
212
|
+
|
213
|
+
// attempt to claim another token (this should fail)
|
214
|
+
await expect(
|
215
|
+
sendAndConfirmTransaction({
|
216
|
+
transaction: claimTo({
|
217
|
+
tokenId: 0n,
|
218
|
+
contract,
|
219
|
+
to: TEST_ACCOUNT_D.address,
|
220
|
+
quantity: 1n,
|
221
|
+
}),
|
222
|
+
account: TEST_ACCOUNT_D,
|
223
|
+
}),
|
224
|
+
).rejects.toThrowErrorMatchingInlineSnapshot(`
|
225
|
+
[TransactionError: Error - !Qty
|
226
|
+
|
227
|
+
contract: ${contract.address}
|
228
|
+
chainId: ${contract.chain.id}]
|
229
|
+
`);
|
230
|
+
|
231
|
+
// reset claim eligibility
|
232
|
+
await sendAndConfirmTransaction({
|
233
|
+
transaction: resetClaimEligibility({
|
234
|
+
tokenId: 0n,
|
235
|
+
contract,
|
236
|
+
singlePhaseDrop: true,
|
237
|
+
}),
|
238
|
+
account: TEST_ACCOUNT_C,
|
239
|
+
});
|
240
|
+
// attempt to claim another token (this should succeed)
|
241
|
+
await sendAndConfirmTransaction({
|
242
|
+
transaction: claimTo({
|
243
|
+
tokenId: 0n,
|
244
|
+
contract,
|
245
|
+
to: TEST_ACCOUNT_D.address,
|
246
|
+
quantity: 1n,
|
247
|
+
}),
|
248
|
+
account: TEST_ACCOUNT_D,
|
249
|
+
});
|
250
|
+
// check that the account has claimed two tokens
|
251
|
+
await expect(
|
252
|
+
balanceOf({ tokenId: 0n, contract, owner: TEST_ACCOUNT_D.address }),
|
253
|
+
).resolves.toBe(2n);
|
254
|
+
});
|
169
255
|
},
|
170
256
|
);
|
@@ -9,6 +9,10 @@ import {
|
|
9
9
|
getClaimConditionById,
|
10
10
|
isGetClaimConditionByIdSupported,
|
11
11
|
} from "../../__generated__/IDrop1155/read/getClaimConditionById.js";
|
12
|
+
import {
|
13
|
+
claimCondition,
|
14
|
+
isClaimConditionSupported,
|
15
|
+
} from "../../__generated__/IDropSinglePhase1155/read/claimCondition.js";
|
12
16
|
|
13
17
|
export type GetActiveClaimConditionParams = GetActiveClaimConditionIdParams;
|
14
18
|
/**
|
@@ -26,12 +30,43 @@ export type GetActiveClaimConditionParams = GetActiveClaimConditionIdParams;
|
|
26
30
|
export async function getActiveClaimCondition(
|
27
31
|
options: BaseTransactionOptions<GetActiveClaimConditionParams>,
|
28
32
|
): Promise<ClaimCondition> {
|
29
|
-
|
33
|
+
const getActiveClaimConditionMultiPhase = async () => {
|
30
34
|
const conditionId = await getActiveClaimConditionId(options);
|
31
35
|
return getClaimConditionById({ ...options, conditionId });
|
32
|
-
}
|
33
|
-
|
36
|
+
};
|
37
|
+
|
38
|
+
const getActiveClaimConditionSinglePhase = async () => {
|
39
|
+
const [
|
40
|
+
startTimestamp,
|
41
|
+
maxClaimableSupply,
|
42
|
+
supplyClaimed,
|
43
|
+
quantityLimitPerWallet,
|
44
|
+
merkleRoot,
|
45
|
+
pricePerToken,
|
46
|
+
currency,
|
47
|
+
metadata,
|
48
|
+
] = await claimCondition({ ...options, tokenId: options.tokenId });
|
49
|
+
return {
|
50
|
+
startTimestamp,
|
51
|
+
maxClaimableSupply,
|
52
|
+
supplyClaimed,
|
53
|
+
quantityLimitPerWallet,
|
54
|
+
merkleRoot,
|
55
|
+
pricePerToken,
|
56
|
+
currency,
|
57
|
+
metadata,
|
58
|
+
};
|
59
|
+
};
|
60
|
+
const results = await Promise.allSettled([
|
61
|
+
getActiveClaimConditionMultiPhase(),
|
62
|
+
getActiveClaimConditionSinglePhase(),
|
63
|
+
]);
|
64
|
+
|
65
|
+
const condition = results.find((result) => result.status === "fulfilled");
|
66
|
+
if (condition?.status === "fulfilled") {
|
67
|
+
return condition.value;
|
34
68
|
}
|
69
|
+
throw new Error("Claim condition not found");
|
35
70
|
}
|
36
71
|
|
37
72
|
/**
|
@@ -49,9 +84,10 @@ export async function getActiveClaimCondition(
|
|
49
84
|
export function isGetActiveClaimConditionSupported(
|
50
85
|
availableSelectors: string[],
|
51
86
|
) {
|
52
|
-
// if multi phase is supported, return true
|
53
87
|
return (
|
54
|
-
|
55
|
-
|
88
|
+
// check multi-phase
|
89
|
+
(isGetActiveClaimConditionIdSupported(availableSelectors) &&
|
90
|
+
isGetClaimConditionByIdSupported(availableSelectors)) ||
|
91
|
+
isClaimConditionSupported(availableSelectors) // check single phase
|
56
92
|
);
|
57
93
|
}
|
@@ -2,6 +2,7 @@ import type { BaseTransactionOptions } from "../../../../transaction/types.js";
|
|
2
2
|
import type { ClaimCondition } from "../../../../utils/extensions/drops/types.js";
|
3
3
|
import * as MultiPhase from "../../__generated__/IDrop1155/read/claimCondition.js";
|
4
4
|
import * as MultiById from "../../__generated__/IDrop1155/read/getClaimConditionById.js";
|
5
|
+
import * as SinglePhase from "../../__generated__/IDropSinglePhase1155/read/claimCondition.js";
|
5
6
|
|
6
7
|
export type GetClaimConditionsParams = {
|
7
8
|
tokenId: bigint;
|
@@ -21,24 +22,53 @@ export type GetClaimConditionsParams = {
|
|
21
22
|
export async function getClaimConditions(
|
22
23
|
options: BaseTransactionOptions<GetClaimConditionsParams>,
|
23
24
|
): Promise<ClaimCondition[]> {
|
24
|
-
|
25
|
-
|
25
|
+
const [multi, single] = await Promise.allSettled([
|
26
|
+
(async () => {
|
27
|
+
const [startId, count] = await MultiPhase.claimCondition(options);
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
29
|
+
const conditionPromises: Array<
|
30
|
+
ReturnType<typeof MultiById.getClaimConditionById>
|
31
|
+
> = [];
|
32
|
+
for (let i = startId; i < startId + count; i++) {
|
33
|
+
conditionPromises.push(
|
34
|
+
MultiById.getClaimConditionById({
|
35
|
+
...options,
|
36
|
+
conditionId: i,
|
37
|
+
}),
|
38
|
+
);
|
39
|
+
}
|
40
|
+
return Promise.all(conditionPromises);
|
41
|
+
})(),
|
42
|
+
SinglePhase.claimCondition(options).then(
|
43
|
+
([
|
44
|
+
startTimestamp,
|
45
|
+
maxClaimableSupply,
|
46
|
+
supplyClaimed,
|
47
|
+
quantityLimitPerWallet,
|
48
|
+
merkleRoot,
|
49
|
+
pricePerToken,
|
50
|
+
currency,
|
51
|
+
metadata,
|
52
|
+
]) => ({
|
53
|
+
startTimestamp,
|
54
|
+
maxClaimableSupply,
|
55
|
+
supplyClaimed,
|
56
|
+
quantityLimitPerWallet,
|
57
|
+
merkleRoot,
|
58
|
+
pricePerToken,
|
59
|
+
currency,
|
60
|
+
metadata,
|
61
|
+
}),
|
62
|
+
),
|
63
|
+
]);
|
64
|
+
if (multi.status === "fulfilled") {
|
65
|
+
return multi.value;
|
41
66
|
}
|
67
|
+
if (single.status === "fulfilled") {
|
68
|
+
return [single.value];
|
69
|
+
}
|
70
|
+
|
71
|
+
throw new Error("Claim condition not found");
|
42
72
|
}
|
43
73
|
|
44
74
|
/**
|
@@ -56,7 +86,8 @@ export async function getClaimConditions(
|
|
56
86
|
export function isGetClaimConditionsSupported(availableSelectors: string[]) {
|
57
87
|
// if multi phase is supported, return true
|
58
88
|
return (
|
59
|
-
MultiPhase.isClaimConditionSupported(availableSelectors) &&
|
60
|
-
|
89
|
+
(MultiPhase.isClaimConditionSupported(availableSelectors) &&
|
90
|
+
MultiById.isGetClaimConditionByIdSupported(availableSelectors)) ||
|
91
|
+
SinglePhase.isClaimConditionSupported(availableSelectors)
|
61
92
|
);
|
62
93
|
}
|
@@ -3,8 +3,16 @@ import type { BaseTransactionOptions } from "../../../../transaction/types.js";
|
|
3
3
|
import type { ClaimCondition } from "../../../../utils/extensions/drops/types.js";
|
4
4
|
import {
|
5
5
|
isSetClaimConditionsSupported,
|
6
|
-
setClaimConditions,
|
6
|
+
setClaimConditions as setClaimConditionsMultiPhase,
|
7
7
|
} from "../../__generated__/IDrop1155/write/setClaimConditions.js";
|
8
|
+
import {
|
9
|
+
claimCondition as claimConditionSinglePhase,
|
10
|
+
isClaimConditionSupported,
|
11
|
+
} from "../../__generated__/IDropSinglePhase1155/read/claimCondition.js";
|
12
|
+
import {
|
13
|
+
isSetClaimConditionsSupported as isSetClaimConditionsSupportedGeneratedSinglePhase,
|
14
|
+
setClaimConditions as setClaimConditionsSinglePhase,
|
15
|
+
} from "../../__generated__/IDropSinglePhase1155/write/setClaimConditions.js";
|
8
16
|
import {
|
9
17
|
type GetClaimConditionsParams,
|
10
18
|
getClaimConditions,
|
@@ -31,10 +39,49 @@ export type ResetClaimEligibilityParams = GetClaimConditionsParams;
|
|
31
39
|
* ```
|
32
40
|
*/
|
33
41
|
export function resetClaimEligibility(
|
34
|
-
options: BaseTransactionOptions<ResetClaimEligibilityParams
|
42
|
+
options: BaseTransactionOptions<ResetClaimEligibilityParams> & {
|
43
|
+
singlePhaseDrop?: boolean;
|
44
|
+
},
|
35
45
|
) {
|
46
|
+
if (options.singlePhaseDrop) {
|
47
|
+
return setClaimConditionsSinglePhase({
|
48
|
+
contract: options.contract,
|
49
|
+
asyncParams: async () => {
|
50
|
+
// get existing condition
|
51
|
+
const existingCondition = await claimConditionSinglePhase(options).then(
|
52
|
+
([
|
53
|
+
startTimestamp,
|
54
|
+
maxClaimableSupply,
|
55
|
+
supplyClaimed,
|
56
|
+
quantityLimitPerWallet,
|
57
|
+
merkleRoot,
|
58
|
+
pricePerToken,
|
59
|
+
currency,
|
60
|
+
metadata,
|
61
|
+
]) => ({
|
62
|
+
startTimestamp,
|
63
|
+
maxClaimableSupply,
|
64
|
+
supplyClaimed,
|
65
|
+
quantityLimitPerWallet,
|
66
|
+
merkleRoot,
|
67
|
+
pricePerToken,
|
68
|
+
currency,
|
69
|
+
metadata,
|
70
|
+
}),
|
71
|
+
);
|
72
|
+
|
73
|
+
// then simply return the exact same ones, but with the resetClaimEligibility flag set to true
|
74
|
+
return {
|
75
|
+
tokenId: options.tokenId,
|
76
|
+
// type is necessary because of viem hex shenanigans (strict vs non-strict `0x` prefix string)
|
77
|
+
phase: existingCondition,
|
78
|
+
resetClaimEligibility: true,
|
79
|
+
};
|
80
|
+
},
|
81
|
+
});
|
82
|
+
}
|
36
83
|
// download existing conditions
|
37
|
-
return
|
84
|
+
return setClaimConditionsMultiPhase({
|
38
85
|
contract: options.contract,
|
39
86
|
asyncParams: async () => {
|
40
87
|
// get existing conditions
|
@@ -70,7 +117,9 @@ export function resetClaimEligibility(
|
|
70
117
|
*/
|
71
118
|
export function isResetClaimEligibilitySupported(availableSelectors: string[]) {
|
72
119
|
return (
|
73
|
-
isGetClaimConditionsSupported(availableSelectors) &&
|
74
|
-
|
120
|
+
(isGetClaimConditionsSupported(availableSelectors) &&
|
121
|
+
isSetClaimConditionsSupported(availableSelectors)) ||
|
122
|
+
isClaimConditionSupported(availableSelectors) ||
|
123
|
+
isSetClaimConditionsSupportedGeneratedSinglePhase(availableSelectors)
|
75
124
|
);
|
76
125
|
}
|
@@ -50,15 +50,6 @@ export async function getClaimParams(options: GetClaimParamsOptions) {
|
|
50
50
|
const cc: ClaimCondition = await (async () => {
|
51
51
|
if (options.type === "erc1155") {
|
52
52
|
// lazy-load the getActiveClaimCondition function
|
53
|
-
if (options.singlePhaseDrop) {
|
54
|
-
const { claimCondition } = await import(
|
55
|
-
"../../../extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.js"
|
56
|
-
);
|
57
|
-
return await claimCondition({
|
58
|
-
contract: options.contract,
|
59
|
-
tokenId: options.tokenId,
|
60
|
-
});
|
61
|
-
}
|
62
53
|
const { getActiveClaimCondition } = await import(
|
63
54
|
"../../../extensions/erc1155/drops/read/getActiveClaimCondition.js"
|
64
55
|
);
|
package/src/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = "5.93.
|
1
|
+
export const version = "5.93.15-nightly-386138e4f06b14aac2fea2ab4a7a0497932f74a7-20250406000354";
|