thirdweb 5.64.4-nightly-c2a90542d7f870c799c297c59cd2b468816f7939-20241031000332 → 5.64.5

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.
Files changed (143) hide show
  1. package/dist/cjs/extensions/erc1155/__generated__/IDropSinglePhase1155/events/ClaimConditionUpdated.js +31 -0
  2. package/dist/cjs/extensions/erc1155/__generated__/IDropSinglePhase1155/events/ClaimConditionUpdated.js.map +1 -0
  3. package/dist/cjs/extensions/erc1155/__generated__/IDropSinglePhase1155/events/TokensClaimed.js +33 -0
  4. package/dist/cjs/extensions/erc1155/__generated__/IDropSinglePhase1155/events/TokensClaimed.js.map +1 -0
  5. package/dist/cjs/extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.js +149 -0
  6. package/dist/cjs/extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.js.map +1 -0
  7. package/dist/cjs/extensions/erc1155/__generated__/IDropSinglePhase1155/write/claim.js +193 -0
  8. package/dist/cjs/extensions/erc1155/__generated__/IDropSinglePhase1155/write/claim.js.map +1 -0
  9. package/dist/cjs/extensions/erc1155/__generated__/IDropSinglePhase1155/write/setClaimConditions.js +173 -0
  10. package/dist/cjs/extensions/erc1155/__generated__/IDropSinglePhase1155/write/setClaimConditions.js.map +1 -0
  11. package/dist/cjs/extensions/erc1155/drops/write/claimTo.js +5 -2
  12. package/dist/cjs/extensions/erc1155/drops/write/claimTo.js.map +1 -1
  13. package/dist/cjs/extensions/erc1155/drops/write/setClaimConditions.js +4 -1
  14. package/dist/cjs/extensions/erc1155/drops/write/setClaimConditions.js.map +1 -1
  15. package/dist/cjs/extensions/erc20/drops/write/claimTo.js +1 -0
  16. package/dist/cjs/extensions/erc20/drops/write/claimTo.js.map +1 -1
  17. package/dist/cjs/extensions/erc20/drops/write/setClaimConditions.js +1 -0
  18. package/dist/cjs/extensions/erc20/drops/write/setClaimConditions.js.map +1 -1
  19. package/dist/cjs/extensions/erc721/__generated__/IDropSinglePhase/events/ClaimConditionUpdated.js +27 -0
  20. package/dist/cjs/extensions/erc721/__generated__/IDropSinglePhase/events/ClaimConditionUpdated.js.map +1 -0
  21. package/dist/cjs/extensions/erc721/__generated__/IDropSinglePhase/events/TokensClaimed.js +33 -0
  22. package/dist/cjs/extensions/erc721/__generated__/IDropSinglePhase/events/TokensClaimed.js.map +1 -0
  23. package/dist/cjs/extensions/erc721/__generated__/IDropSinglePhase/read/claimCondition.js +105 -0
  24. package/dist/cjs/extensions/erc721/__generated__/IDropSinglePhase/read/claimCondition.js.map +1 -0
  25. package/dist/cjs/extensions/erc721/__generated__/IDropSinglePhase/write/claim.js +184 -0
  26. package/dist/cjs/extensions/erc721/__generated__/IDropSinglePhase/write/claim.js.map +1 -0
  27. package/dist/cjs/extensions/erc721/__generated__/IDropSinglePhase/write/setClaimConditions.js +164 -0
  28. package/dist/cjs/extensions/erc721/__generated__/IDropSinglePhase/write/setClaimConditions.js.map +1 -0
  29. package/dist/cjs/extensions/erc721/drops/write/claimTo.js +6 -3
  30. package/dist/cjs/extensions/erc721/drops/write/claimTo.js.map +1 -1
  31. package/dist/cjs/extensions/erc721/drops/write/setClaimConditions.js +4 -1
  32. package/dist/cjs/extensions/erc721/drops/write/setClaimConditions.js.map +1 -1
  33. package/dist/cjs/utils/extensions/drops/get-claim-params.js +20 -0
  34. package/dist/cjs/utils/extensions/drops/get-claim-params.js.map +1 -1
  35. package/dist/cjs/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.js +39 -12
  36. package/dist/cjs/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.js.map +1 -1
  37. package/dist/cjs/version.js +1 -1
  38. package/dist/cjs/version.js.map +1 -1
  39. package/dist/cjs/wallets/smart/index.js +3 -0
  40. package/dist/cjs/wallets/smart/index.js.map +1 -1
  41. package/dist/esm/extensions/erc1155/__generated__/IDropSinglePhase1155/events/ClaimConditionUpdated.js +28 -0
  42. package/dist/esm/extensions/erc1155/__generated__/IDropSinglePhase1155/events/ClaimConditionUpdated.js.map +1 -0
  43. package/dist/esm/extensions/erc1155/__generated__/IDropSinglePhase1155/events/TokensClaimed.js +30 -0
  44. package/dist/esm/extensions/erc1155/__generated__/IDropSinglePhase1155/events/TokensClaimed.js.map +1 -0
  45. package/dist/esm/extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.js +141 -0
  46. package/dist/esm/extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.js.map +1 -0
  47. package/dist/esm/extensions/erc1155/__generated__/IDropSinglePhase1155/write/claim.js +186 -0
  48. package/dist/esm/extensions/erc1155/__generated__/IDropSinglePhase1155/write/claim.js.map +1 -0
  49. package/dist/esm/extensions/erc1155/__generated__/IDropSinglePhase1155/write/setClaimConditions.js +166 -0
  50. package/dist/esm/extensions/erc1155/__generated__/IDropSinglePhase1155/write/setClaimConditions.js.map +1 -0
  51. package/dist/esm/extensions/erc1155/drops/write/claimTo.js +5 -2
  52. package/dist/esm/extensions/erc1155/drops/write/claimTo.js.map +1 -1
  53. package/dist/esm/extensions/erc1155/drops/write/setClaimConditions.js +4 -1
  54. package/dist/esm/extensions/erc1155/drops/write/setClaimConditions.js.map +1 -1
  55. package/dist/esm/extensions/erc20/drops/write/claimTo.js +1 -0
  56. package/dist/esm/extensions/erc20/drops/write/claimTo.js.map +1 -1
  57. package/dist/esm/extensions/erc20/drops/write/setClaimConditions.js +1 -0
  58. package/dist/esm/extensions/erc20/drops/write/setClaimConditions.js.map +1 -1
  59. package/dist/esm/extensions/erc721/__generated__/IDropSinglePhase/events/ClaimConditionUpdated.js +24 -0
  60. package/dist/esm/extensions/erc721/__generated__/IDropSinglePhase/events/ClaimConditionUpdated.js.map +1 -0
  61. package/dist/esm/extensions/erc721/__generated__/IDropSinglePhase/events/TokensClaimed.js +30 -0
  62. package/dist/esm/extensions/erc721/__generated__/IDropSinglePhase/events/TokensClaimed.js.map +1 -0
  63. package/dist/esm/extensions/erc721/__generated__/IDropSinglePhase/read/claimCondition.js +99 -0
  64. package/dist/esm/extensions/erc721/__generated__/IDropSinglePhase/read/claimCondition.js.map +1 -0
  65. package/dist/esm/extensions/erc721/__generated__/IDropSinglePhase/write/claim.js +177 -0
  66. package/dist/esm/extensions/erc721/__generated__/IDropSinglePhase/write/claim.js.map +1 -0
  67. package/dist/esm/extensions/erc721/__generated__/IDropSinglePhase/write/setClaimConditions.js +157 -0
  68. package/dist/esm/extensions/erc721/__generated__/IDropSinglePhase/write/setClaimConditions.js.map +1 -0
  69. package/dist/esm/extensions/erc721/drops/write/claimTo.js +6 -3
  70. package/dist/esm/extensions/erc721/drops/write/claimTo.js.map +1 -1
  71. package/dist/esm/extensions/erc721/drops/write/setClaimConditions.js +4 -1
  72. package/dist/esm/extensions/erc721/drops/write/setClaimConditions.js.map +1 -1
  73. package/dist/esm/utils/extensions/drops/get-claim-params.js +20 -0
  74. package/dist/esm/utils/extensions/drops/get-claim-params.js.map +1 -1
  75. package/dist/esm/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.js +39 -12
  76. package/dist/esm/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.js.map +1 -1
  77. package/dist/esm/version.js +1 -1
  78. package/dist/esm/version.js.map +1 -1
  79. package/dist/esm/wallets/smart/index.js +3 -0
  80. package/dist/esm/wallets/smart/index.js.map +1 -1
  81. package/dist/types/extensions/erc1155/__generated__/IDropSinglePhase1155/events/ClaimConditionUpdated.d.ts +72 -0
  82. package/dist/types/extensions/erc1155/__generated__/IDropSinglePhase1155/events/ClaimConditionUpdated.d.ts.map +1 -0
  83. package/dist/types/extensions/erc1155/__generated__/IDropSinglePhase1155/events/TokensClaimed.d.ts +64 -0
  84. package/dist/types/extensions/erc1155/__generated__/IDropSinglePhase1155/events/TokensClaimed.d.ts.map +1 -0
  85. package/dist/types/extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.d.ts +101 -0
  86. package/dist/types/extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.d.ts.map +1 -0
  87. package/dist/types/extensions/erc1155/__generated__/IDropSinglePhase1155/write/claim.d.ts +139 -0
  88. package/dist/types/extensions/erc1155/__generated__/IDropSinglePhase1155/write/claim.d.ts.map +1 -0
  89. package/dist/types/extensions/erc1155/__generated__/IDropSinglePhase1155/write/setClaimConditions.d.ts +127 -0
  90. package/dist/types/extensions/erc1155/__generated__/IDropSinglePhase1155/write/setClaimConditions.d.ts.map +1 -0
  91. package/dist/types/extensions/erc1155/drops/write/claimTo.d.ts +1 -0
  92. package/dist/types/extensions/erc1155/drops/write/claimTo.d.ts.map +1 -1
  93. package/dist/types/extensions/erc1155/drops/write/setClaimConditions.d.ts +1 -0
  94. package/dist/types/extensions/erc1155/drops/write/setClaimConditions.d.ts.map +1 -1
  95. package/dist/types/extensions/erc20/drops/write/claimTo.d.ts +1 -0
  96. package/dist/types/extensions/erc20/drops/write/claimTo.d.ts.map +1 -1
  97. package/dist/types/extensions/erc20/drops/write/setClaimConditions.d.ts +1 -0
  98. package/dist/types/extensions/erc20/drops/write/setClaimConditions.d.ts.map +1 -1
  99. package/dist/types/extensions/erc721/__generated__/IDropSinglePhase/events/ClaimConditionUpdated.d.ts +54 -0
  100. package/dist/types/extensions/erc721/__generated__/IDropSinglePhase/events/ClaimConditionUpdated.d.ts.map +1 -0
  101. package/dist/types/extensions/erc721/__generated__/IDropSinglePhase/events/TokensClaimed.d.ts +64 -0
  102. package/dist/types/extensions/erc721/__generated__/IDropSinglePhase/events/TokensClaimed.d.ts.map +1 -0
  103. package/dist/types/extensions/erc721/__generated__/IDropSinglePhase/read/claimCondition.d.ts +62 -0
  104. package/dist/types/extensions/erc721/__generated__/IDropSinglePhase/read/claimCondition.d.ts.map +1 -0
  105. package/dist/types/extensions/erc721/__generated__/IDropSinglePhase/write/claim.d.ts +132 -0
  106. package/dist/types/extensions/erc721/__generated__/IDropSinglePhase/write/claim.d.ts.map +1 -0
  107. package/dist/types/extensions/erc721/__generated__/IDropSinglePhase/write/setClaimConditions.d.ts +120 -0
  108. package/dist/types/extensions/erc721/__generated__/IDropSinglePhase/write/setClaimConditions.d.ts.map +1 -0
  109. package/dist/types/extensions/erc721/drops/write/claimTo.d.ts +1 -0
  110. package/dist/types/extensions/erc721/drops/write/claimTo.d.ts.map +1 -1
  111. package/dist/types/extensions/erc721/drops/write/setClaimConditions.d.ts +1 -0
  112. package/dist/types/extensions/erc721/drops/write/setClaimConditions.d.ts.map +1 -1
  113. package/dist/types/utils/extensions/drops/get-claim-params.d.ts +1 -0
  114. package/dist/types/utils/extensions/drops/get-claim-params.d.ts.map +1 -1
  115. package/dist/types/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.d.ts +1 -0
  116. package/dist/types/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.d.ts.map +1 -1
  117. package/dist/types/version.d.ts +1 -1
  118. package/dist/types/version.d.ts.map +1 -1
  119. package/package.json +1 -1
  120. package/src/extensions/erc1155/__generated__/IDropSinglePhase1155/events/ClaimConditionUpdated.ts +43 -0
  121. package/src/extensions/erc1155/__generated__/IDropSinglePhase1155/events/TokensClaimed.ts +53 -0
  122. package/src/extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.ts +160 -0
  123. package/src/extensions/erc1155/__generated__/IDropSinglePhase1155/write/claim.ts +229 -0
  124. package/src/extensions/erc1155/__generated__/IDropSinglePhase1155/write/setClaimConditions.ts +213 -0
  125. package/src/extensions/erc1155/customDrop1155.test.ts +181 -0
  126. package/src/extensions/erc1155/drops/write/claimTo.ts +6 -2
  127. package/src/extensions/erc1155/drops/write/setClaimConditions.ts +5 -1
  128. package/src/extensions/erc20/customDrop20.test.ts +80 -0
  129. package/src/extensions/erc20/drops/write/claimTo.ts +2 -0
  130. package/src/extensions/erc20/drops/write/setClaimConditions.ts +2 -0
  131. package/src/extensions/erc721/__generated__/IDropSinglePhase/events/ClaimConditionUpdated.ts +25 -0
  132. package/src/extensions/erc721/__generated__/IDropSinglePhase/events/TokensClaimed.ts +53 -0
  133. package/src/extensions/erc721/__generated__/IDropSinglePhase/read/claimCondition.ts +105 -0
  134. package/src/extensions/erc721/__generated__/IDropSinglePhase/write/claim.ts +219 -0
  135. package/src/extensions/erc721/__generated__/IDropSinglePhase/write/setClaimConditions.ts +203 -0
  136. package/src/extensions/erc721/customDrop721.test.ts +115 -0
  137. package/src/extensions/erc721/drops/write/claimTo.ts +7 -3
  138. package/src/extensions/erc721/drops/write/setClaimConditions.ts +5 -1
  139. package/src/utils/extensions/drops/get-claim-params.ts +29 -2
  140. package/src/utils/extensions/drops/get-multicall-set-claim-claim-conditon-transactions.ts +46 -16
  141. package/src/version.ts +1 -1
  142. package/src/wallets/smart/index.ts +2 -0
  143. package/src/wallets/smart/smart-wallet-integration.test.ts +33 -0
@@ -0,0 +1,203 @@
1
+ import type { AbiParameterToPrimitiveType } from "abitype";
2
+ import type {
3
+ BaseTransactionOptions,
4
+ WithOverrides,
5
+ } from "../../../../../transaction/types.js";
6
+ import { prepareContractCall } from "../../../../../transaction/prepare-contract-call.js";
7
+ import { encodeAbiParameters } from "../../../../../utils/abi/encodeAbiParameters.js";
8
+ import { once } from "../../../../../utils/promise/once.js";
9
+ import { detectMethod } from "../../../../../utils/bytecode/detectExtension.js";
10
+
11
+ /**
12
+ * Represents the parameters for the "setClaimConditions" function.
13
+ */
14
+ export type SetClaimConditionsParams = WithOverrides<{
15
+ phase: AbiParameterToPrimitiveType<{
16
+ type: "tuple";
17
+ name: "phase";
18
+ components: [
19
+ { type: "uint256"; name: "startTimestamp" },
20
+ { type: "uint256"; name: "maxClaimableSupply" },
21
+ { type: "uint256"; name: "supplyClaimed" },
22
+ { type: "uint256"; name: "quantityLimitPerWallet" },
23
+ { type: "bytes32"; name: "merkleRoot" },
24
+ { type: "uint256"; name: "pricePerToken" },
25
+ { type: "address"; name: "currency" },
26
+ { type: "string"; name: "metadata" },
27
+ ];
28
+ }>;
29
+ resetClaimEligibility: AbiParameterToPrimitiveType<{
30
+ type: "bool";
31
+ name: "resetClaimEligibility";
32
+ }>;
33
+ }>;
34
+
35
+ export const FN_SELECTOR = "0x426cfaf3" as const;
36
+ const FN_INPUTS = [
37
+ {
38
+ type: "tuple",
39
+ name: "phase",
40
+ components: [
41
+ {
42
+ type: "uint256",
43
+ name: "startTimestamp",
44
+ },
45
+ {
46
+ type: "uint256",
47
+ name: "maxClaimableSupply",
48
+ },
49
+ {
50
+ type: "uint256",
51
+ name: "supplyClaimed",
52
+ },
53
+ {
54
+ type: "uint256",
55
+ name: "quantityLimitPerWallet",
56
+ },
57
+ {
58
+ type: "bytes32",
59
+ name: "merkleRoot",
60
+ },
61
+ {
62
+ type: "uint256",
63
+ name: "pricePerToken",
64
+ },
65
+ {
66
+ type: "address",
67
+ name: "currency",
68
+ },
69
+ {
70
+ type: "string",
71
+ name: "metadata",
72
+ },
73
+ ],
74
+ },
75
+ {
76
+ type: "bool",
77
+ name: "resetClaimEligibility",
78
+ },
79
+ ] as const;
80
+ const FN_OUTPUTS = [] as const;
81
+
82
+ /**
83
+ * Checks if the `setClaimConditions` method is supported by the given contract.
84
+ * @param availableSelectors An array of 4byte function selectors of the contract. You can get this in various ways, such as using "whatsabi" or if you have the ABI of the contract available you can use it to generate the selectors.
85
+ * @returns A boolean indicating if the `setClaimConditions` method is supported.
86
+ * @extension ERC721
87
+ * @example
88
+ * ```ts
89
+ * import { isSetClaimConditionsSupported } from "thirdweb/extensions/erc721";
90
+ *
91
+ * const supported = isSetClaimConditionsSupported(["0x..."]);
92
+ * ```
93
+ */
94
+ export function isSetClaimConditionsSupported(availableSelectors: string[]) {
95
+ return detectMethod({
96
+ availableSelectors,
97
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
98
+ });
99
+ }
100
+
101
+ /**
102
+ * Encodes the parameters for the "setClaimConditions" function.
103
+ * @param options - The options for the setClaimConditions function.
104
+ * @returns The encoded ABI parameters.
105
+ * @extension ERC721
106
+ * @example
107
+ * ```ts
108
+ * import { encodeSetClaimConditionsParams } from "thirdweb/extensions/erc721";
109
+ * const result = encodeSetClaimConditionsParams({
110
+ * phase: ...,
111
+ * resetClaimEligibility: ...,
112
+ * });
113
+ * ```
114
+ */
115
+ export function encodeSetClaimConditionsParams(
116
+ options: SetClaimConditionsParams,
117
+ ) {
118
+ return encodeAbiParameters(FN_INPUTS, [
119
+ options.phase,
120
+ options.resetClaimEligibility,
121
+ ]);
122
+ }
123
+
124
+ /**
125
+ * Encodes the "setClaimConditions" function into a Hex string with its parameters.
126
+ * @param options - The options for the setClaimConditions function.
127
+ * @returns The encoded hexadecimal string.
128
+ * @extension ERC721
129
+ * @example
130
+ * ```ts
131
+ * import { encodeSetClaimConditions } from "thirdweb/extensions/erc721";
132
+ * const result = encodeSetClaimConditions({
133
+ * phase: ...,
134
+ * resetClaimEligibility: ...,
135
+ * });
136
+ * ```
137
+ */
138
+ export function encodeSetClaimConditions(options: SetClaimConditionsParams) {
139
+ // we do a "manual" concat here to avoid the overhead of the "concatHex" function
140
+ // we can do this because we know the specific formats of the values
141
+ return (FN_SELECTOR +
142
+ encodeSetClaimConditionsParams(options).slice(
143
+ 2,
144
+ )) as `${typeof FN_SELECTOR}${string}`;
145
+ }
146
+
147
+ /**
148
+ * Prepares a transaction to call the "setClaimConditions" function on the contract.
149
+ * @param options - The options for the "setClaimConditions" function.
150
+ * @returns A prepared transaction object.
151
+ * @extension ERC721
152
+ * @example
153
+ * ```ts
154
+ * import { sendTransaction } from "thirdweb";
155
+ * import { setClaimConditions } from "thirdweb/extensions/erc721";
156
+ *
157
+ * const transaction = setClaimConditions({
158
+ * contract,
159
+ * phase: ...,
160
+ * resetClaimEligibility: ...,
161
+ * overrides: {
162
+ * ...
163
+ * }
164
+ * });
165
+ *
166
+ * // Send the transaction
167
+ * await sendTransaction({ transaction, account });
168
+ * ```
169
+ */
170
+ export function setClaimConditions(
171
+ options: BaseTransactionOptions<
172
+ | SetClaimConditionsParams
173
+ | {
174
+ asyncParams: () => Promise<SetClaimConditionsParams>;
175
+ }
176
+ >,
177
+ ) {
178
+ const asyncOptions = once(async () => {
179
+ return "asyncParams" in options ? await options.asyncParams() : options;
180
+ });
181
+
182
+ return prepareContractCall({
183
+ contract: options.contract,
184
+ method: [FN_SELECTOR, FN_INPUTS, FN_OUTPUTS] as const,
185
+ params: async () => {
186
+ const resolvedOptions = await asyncOptions();
187
+ return [
188
+ resolvedOptions.phase,
189
+ resolvedOptions.resetClaimEligibility,
190
+ ] as const;
191
+ },
192
+ value: async () => (await asyncOptions()).overrides?.value,
193
+ accessList: async () => (await asyncOptions()).overrides?.accessList,
194
+ gas: async () => (await asyncOptions()).overrides?.gas,
195
+ gasPrice: async () => (await asyncOptions()).overrides?.gasPrice,
196
+ maxFeePerGas: async () => (await asyncOptions()).overrides?.maxFeePerGas,
197
+ maxPriorityFeePerGas: async () =>
198
+ (await asyncOptions()).overrides?.maxPriorityFeePerGas,
199
+ nonce: async () => (await asyncOptions()).overrides?.nonce,
200
+ extraGas: async () => (await asyncOptions()).overrides?.extraGas,
201
+ erc20Value: async () => (await asyncOptions()).overrides?.erc20Value,
202
+ });
203
+ }
@@ -0,0 +1,115 @@
1
+ import { fetchDeployMetadata } from "../../utils/any-evm/deploy-metadata.js";
2
+
3
+ import { beforeAll, describe, expect, it } from "vitest";
4
+ import { ANVIL_CHAIN } from "../../../test/src/chains.js";
5
+ import { TEST_CLIENT } from "../../../test/src/test-clients.js";
6
+ import { TEST_ACCOUNT_C } from "../../../test/src/test-wallets.js";
7
+ import { type ThirdwebContract, getContract } from "../../contract/contract.js";
8
+ import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
9
+ import { deployContractfromDeployMetadata } from "../prebuilts/deploy-published.js";
10
+ import { balanceOf } from "./__generated__/IERC721A/read/balanceOf.js";
11
+ import { nextTokenIdToMint } from "./__generated__/IERC721Enumerable/read/nextTokenIdToMint.js";
12
+ import { claimTo } from "./drops/write/claimTo.js";
13
+ import { setClaimConditions } from "./drops/write/setClaimConditions.js";
14
+ import { getNFT } from "./read/getNFT.js";
15
+ import { lazyMint } from "./write/lazyMint.js";
16
+
17
+ describe.runIf(process.env.TW_SECRET_KEY)(
18
+ "CustomDropERC721",
19
+ {
20
+ retry: 0,
21
+ },
22
+ () => {
23
+ let contract: ThirdwebContract;
24
+
25
+ beforeAll(async () => {
26
+ const customDropDeployMetadata = await fetchDeployMetadata({
27
+ client: TEST_CLIENT,
28
+ uri: "ipfs://QmY6CHFuhDpQzuv3y3NyQBPdAa7cYjZGJgFeFcw9BfSMQx",
29
+ });
30
+ const contractAddress = await deployContractfromDeployMetadata({
31
+ chain: ANVIL_CHAIN,
32
+ client: TEST_CLIENT,
33
+ account: TEST_ACCOUNT_C,
34
+ deployMetadata: customDropDeployMetadata,
35
+ initializeParams: {
36
+ defaultAdmin: TEST_ACCOUNT_C.address,
37
+ name: "TestCustomDropERC721",
38
+ symbol: "TT",
39
+ },
40
+ });
41
+
42
+ contract = getContract({
43
+ address: contractAddress,
44
+ chain: ANVIL_CHAIN,
45
+ client: TEST_CLIENT,
46
+ });
47
+ // this deploys a contract, it may take some time
48
+ }, 60_000);
49
+
50
+ it("should allow for lazy minting tokens", async () => {
51
+ const mintTx = lazyMint({
52
+ contract,
53
+ nfts: [
54
+ { name: "Test NFT" },
55
+ { name: "Test NFT 2" },
56
+ { name: "Test NFT 3" },
57
+ { name: "Test NFT 4" },
58
+ { name: "Test NFT 5" },
59
+ { name: "Test NFT 6" },
60
+ ],
61
+ });
62
+ await sendAndConfirmTransaction({
63
+ transaction: mintTx,
64
+ account: TEST_ACCOUNT_C,
65
+ });
66
+
67
+ await expect(nextTokenIdToMint({ contract })).resolves.toBe(6n);
68
+ await expect(
69
+ getNFT({ contract, tokenId: 0n }),
70
+ ).resolves.toMatchInlineSnapshot(`
71
+ {
72
+ "id": 0n,
73
+ "metadata": {
74
+ "name": "Test NFT",
75
+ },
76
+ "owner": null,
77
+ "tokenURI": "ipfs://QmTo68Dm1ntSp2BHLmE9gesS6ELuXosRz5mAgFCK6tfsRk/0",
78
+ "type": "ERC721",
79
+ }
80
+ `);
81
+ });
82
+
83
+ it("should allow to claim tokens", async () => {
84
+ await expect(
85
+ balanceOf({ contract, owner: TEST_ACCOUNT_C.address }),
86
+ ).resolves.toBe(0n);
87
+ await sendAndConfirmTransaction({
88
+ transaction: setClaimConditions({
89
+ contract,
90
+ phases: [
91
+ {
92
+ startTime: new Date(0),
93
+ maxClaimableSupply: 10n,
94
+ },
95
+ ],
96
+ singlePhaseDrop: true,
97
+ }),
98
+ account: TEST_ACCOUNT_C,
99
+ });
100
+ const claimTx = claimTo({
101
+ contract,
102
+ to: TEST_ACCOUNT_C.address,
103
+ quantity: 1n,
104
+ singlePhaseDrop: true,
105
+ });
106
+ await sendAndConfirmTransaction({
107
+ transaction: claimTx,
108
+ account: TEST_ACCOUNT_C,
109
+ });
110
+ await expect(
111
+ balanceOf({ contract, owner: TEST_ACCOUNT_C.address }),
112
+ ).resolves.toBe(1n);
113
+ });
114
+ },
115
+ );
@@ -6,6 +6,7 @@ import {
6
6
  claim,
7
7
  isClaimSupported,
8
8
  } from "../../__generated__/IDrop/write/claim.js";
9
+ import { isClaimConditionSupported } from "../../__generated__/IDropSinglePhase/read/claimCondition.js";
9
10
  import { isGetActiveClaimConditionSupported } from "../read/getActiveClaimCondition.js";
10
11
 
11
12
  /**
@@ -16,6 +17,7 @@ export type ClaimToParams = {
16
17
  to: Address;
17
18
  quantity: bigint;
18
19
  from?: Address;
20
+ singlePhaseDrop?: boolean;
19
21
  };
20
22
 
21
23
  /**
@@ -61,6 +63,7 @@ export function claimTo(options: BaseTransactionOptions<ClaimToParams>) {
61
63
  to: options.to,
62
64
  quantity: options.quantity,
63
65
  from: options.from,
66
+ singlePhaseDrop: options.singlePhaseDrop,
64
67
  }),
65
68
  });
66
69
  }
@@ -80,9 +83,10 @@ export function claimTo(options: BaseTransactionOptions<ClaimToParams>) {
80
83
  export function isClaimToSupported(availableSelectors: string[]) {
81
84
  return (
82
85
  isClaimSupported(availableSelectors) &&
83
- // required to check if the contract supports the getActiveClaimCondition method
84
- isGetActiveClaimConditionSupported(availableSelectors) &&
85
86
  // requires contractMetadata for claimer proofs
86
- isGetContractMetadataSupported(availableSelectors)
87
+ isGetContractMetadataSupported(availableSelectors) &&
88
+ // required to check if the contract supports the getActiveClaimCondition method
89
+ (isGetActiveClaimConditionSupported(availableSelectors) ||
90
+ isClaimConditionSupported(availableSelectors))
87
91
  );
88
92
  }
@@ -8,6 +8,7 @@ import {
8
8
  } from "../../../common/__generated__/IMulticall/write/multicall.js";
9
9
  import { isGetContractMetadataSupported } from "../../../common/read/getContractMetadata.js";
10
10
  import { isSetClaimConditionsSupported as isSetClaimConditionsSupportedGenerated } from "../../__generated__/IDrop/write/setClaimConditions.js";
11
+ import { isSetClaimConditionsSupported as isSetClaimConditionsSupportedGeneratedSinglePhase } from "../../__generated__/IDropSinglePhase/write/setClaimConditions.js";
11
12
 
12
13
  /**
13
14
  * @extension ERC721
@@ -15,6 +16,7 @@ import { isSetClaimConditionsSupported as isSetClaimConditionsSupportedGenerated
15
16
  export type SetClaimConditionsParams = {
16
17
  phases: ClaimConditionsInput[];
17
18
  resetClaimEligibility?: boolean;
19
+ singlePhaseDrop?: boolean;
18
20
  };
19
21
 
20
22
  /**
@@ -55,6 +57,7 @@ export function setClaimConditions(
55
57
  phases: options.phases,
56
58
  resetClaimEligibility: options.resetClaimEligibility,
57
59
  tokenDecimals: 0,
60
+ singlePhase: options.singlePhaseDrop,
58
61
  }),
59
62
  };
60
63
  },
@@ -80,6 +83,7 @@ export function isSetClaimConditionsSupported(availableSelectors: string[]) {
80
83
  isGetContractMetadataSupported(availableSelectors) &&
81
84
  isSetContractURISupported(availableSelectors) &&
82
85
  // needs to actually be able to set the claim Conditions
83
- isSetClaimConditionsSupportedGenerated(availableSelectors)
86
+ (isSetClaimConditionsSupportedGenerated(availableSelectors) ||
87
+ isSetClaimConditionsSupportedGeneratedSinglePhase(availableSelectors))
84
88
  );
85
89
  }
@@ -6,13 +6,14 @@ import {
6
6
  import type { ThirdwebContract } from "../../../contract/contract.js";
7
7
  import { getContractMetadata } from "../../../extensions/common/read/getContractMetadata.js";
8
8
  import type { Hex } from "../../encoding/hex.js";
9
- import type { OverrideProof } from "./types.js";
9
+ import type { ClaimCondition, OverrideProof } from "./types.js";
10
10
 
11
11
  export type GetClaimParamsOptions = {
12
12
  contract: ThirdwebContract;
13
13
  to: string;
14
14
  quantity: bigint;
15
15
  from?: string;
16
+ singlePhaseDrop?: boolean;
16
17
  } & (
17
18
  | {
18
19
  type: "erc721";
@@ -47,9 +48,18 @@ export type GetClaimParamsOptions = {
47
48
  * @extension COMMON
48
49
  */
49
50
  export async function getClaimParams(options: GetClaimParamsOptions) {
50
- const cc = await (async () => {
51
+ const cc: ClaimCondition = await (async () => {
51
52
  if (options.type === "erc1155") {
52
53
  // lazy-load the getActiveClaimCondition function
54
+ if (options.singlePhaseDrop) {
55
+ const { claimCondition } = await import(
56
+ "../../../extensions/erc1155/__generated__/IDropSinglePhase1155/read/claimCondition.js"
57
+ );
58
+ return await claimCondition({
59
+ contract: options.contract,
60
+ tokenId: options.tokenId,
61
+ });
62
+ }
53
63
  const { getActiveClaimCondition } = await import(
54
64
  "../../../extensions/erc1155/drops/read/getActiveClaimCondition.js"
55
65
  );
@@ -60,6 +70,14 @@ export async function getClaimParams(options: GetClaimParamsOptions) {
60
70
  }
61
71
  if (options.type === "erc721") {
62
72
  // lazy-load the getActiveClaimCondition function
73
+ if (options.singlePhaseDrop) {
74
+ const { claimCondition } = await import(
75
+ "../../../extensions/erc721/__generated__/IDropSinglePhase/read/claimCondition.js"
76
+ );
77
+ return await claimCondition({
78
+ contract: options.contract,
79
+ });
80
+ }
63
81
  const { getActiveClaimCondition } = await import(
64
82
  "../../../extensions/erc721/drops/read/getActiveClaimCondition.js"
65
83
  );
@@ -71,6 +89,15 @@ export async function getClaimParams(options: GetClaimParamsOptions) {
71
89
  // otherwise erc20 case!
72
90
 
73
91
  // lazy-load the getActiveClaimCondition function
92
+ if (options.singlePhaseDrop) {
93
+ // same ABI as erc721
94
+ const { claimCondition } = await import(
95
+ "../../../extensions/erc721/__generated__/IDropSinglePhase/read/claimCondition.js"
96
+ );
97
+ return await claimCondition({
98
+ contract: options.contract,
99
+ });
100
+ }
74
101
  const { getActiveClaimCondition } = await import(
75
102
  "../../../extensions/erc20/drops/read/getActiveClaimCondition.js"
76
103
  );
@@ -15,6 +15,7 @@ export async function getMulticallSetClaimConditionTransactions(options: {
15
15
  tokenDecimals: number;
16
16
  tokenId?: bigint;
17
17
  resetClaimEligibility?: boolean;
18
+ singlePhase?: boolean;
18
19
  }): Promise<Hex[]> {
19
20
  const merkleInfos: Record<string, string> = {};
20
21
  const phases = await Promise.all(
@@ -94,23 +95,52 @@ export async function getMulticallSetClaimConditionTransactions(options: {
94
95
  let encodedSetClaimConditions: Hex;
95
96
  if (options.tokenId !== undefined) {
96
97
  // 1155
97
- const { encodeSetClaimConditions } = await import(
98
- "../../../extensions/erc1155/__generated__/IDrop1155/write/setClaimConditions.js"
99
- );
100
- encodedSetClaimConditions = encodeSetClaimConditions({
101
- tokenId: options.tokenId,
102
- phases: sortedPhases,
103
- resetClaimEligibility: options.resetClaimEligibility || false,
104
- });
98
+ if (options.singlePhase) {
99
+ const { encodeSetClaimConditions } = await import(
100
+ "../../../extensions/erc1155/__generated__/IDropSinglePhase1155/write/setClaimConditions.js"
101
+ );
102
+ const phase = sortedPhases[0];
103
+ if (!phase) {
104
+ throw new Error("No phase provided");
105
+ }
106
+ encodedSetClaimConditions = encodeSetClaimConditions({
107
+ tokenId: options.tokenId,
108
+ phase,
109
+ resetClaimEligibility: options.resetClaimEligibility || false,
110
+ });
111
+ } else {
112
+ const { encodeSetClaimConditions } = await import(
113
+ "../../../extensions/erc1155/__generated__/IDrop1155/write/setClaimConditions.js"
114
+ );
115
+ encodedSetClaimConditions = encodeSetClaimConditions({
116
+ tokenId: options.tokenId,
117
+ phases: sortedPhases,
118
+ resetClaimEligibility: options.resetClaimEligibility || false,
119
+ });
120
+ }
105
121
  } else {
106
- // 721
107
- const { encodeSetClaimConditions } = await import(
108
- "../../../extensions/erc721/__generated__/IDrop/write/setClaimConditions.js"
109
- );
110
- encodedSetClaimConditions = encodeSetClaimConditions({
111
- phases: sortedPhases,
112
- resetClaimEligibility: options.resetClaimEligibility || false,
113
- });
122
+ // erc721 or erc20
123
+ if (options.singlePhase) {
124
+ const { encodeSetClaimConditions } = await import(
125
+ "../../../extensions/erc721/__generated__/IDropSinglePhase/write/setClaimConditions.js"
126
+ );
127
+ const phase = sortedPhases[0];
128
+ if (!phase) {
129
+ throw new Error("No phase provided");
130
+ }
131
+ encodedSetClaimConditions = encodeSetClaimConditions({
132
+ phase,
133
+ resetClaimEligibility: options.resetClaimEligibility || false,
134
+ });
135
+ } else {
136
+ const { encodeSetClaimConditions } = await import(
137
+ "../../../extensions/erc721/__generated__/IDrop/write/setClaimConditions.js"
138
+ );
139
+ encodedSetClaimConditions = encodeSetClaimConditions({
140
+ phases: sortedPhases,
141
+ resetClaimEligibility: options.resetClaimEligibility || false,
142
+ });
143
+ }
114
144
  }
115
145
  encodedTransactions.push(encodedSetClaimConditions);
116
146
  return encodedTransactions;
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "5.64.4-nightly-c2a90542d7f870c799c297c59cd2b468816f7939-20241031000332";
1
+ export const version = "5.64.5";
@@ -225,6 +225,8 @@ async function createSmartAccount(
225
225
  };
226
226
  };
227
227
  paymasterOverride = options.overrides?.paymaster || paymasterCallback;
228
+ } else {
229
+ paymasterOverride = options.overrides?.paymaster;
228
230
  }
229
231
  const executeTx = prepareExecute({
230
232
  accountContract,
@@ -18,7 +18,9 @@ import { setContractURI } from "../../extensions/marketplace/__generated__/IMark
18
18
  import { estimateGasCost } from "../../transaction/actions/estimate-gas-cost.js";
19
19
  import { sendAndConfirmTransaction } from "../../transaction/actions/send-and-confirm-transaction.js";
20
20
  import { sendBatchTransaction } from "../../transaction/actions/send-batch-transaction.js";
21
+ import { sendTransaction } from "../../transaction/actions/send-transaction.js";
21
22
  import { waitForReceipt } from "../../transaction/actions/wait-for-tx-receipt.js";
23
+ import { prepareTransaction } from "../../transaction/prepare-transaction.js";
22
24
  import { isContractDeployed } from "../../utils/bytecode/is-contract-deployed.js";
23
25
  import { sleep } from "../../utils/sleep.js";
24
26
  import type { Account, Wallet } from "../interfaces/wallet.js";
@@ -364,5 +366,36 @@ describe.runIf(process.env.TW_SECRET_KEY).sequential(
364
366
  });
365
367
  expect(balance).toEqual(2n);
366
368
  });
369
+
370
+ it("can use a different paymaster", async () => {
371
+ const wallet = smartWallet({
372
+ chain,
373
+ factoryAddress: factoryAddress,
374
+ gasless: true,
375
+ overrides: {
376
+ paymaster: async () => {
377
+ return {
378
+ paymaster: "0x",
379
+ paymasterData: "0x",
380
+ };
381
+ },
382
+ },
383
+ });
384
+ const newSmartAccount = await wallet.connect({
385
+ client: TEST_CLIENT,
386
+ personalAccount,
387
+ });
388
+ const transaction = prepareTransaction({
389
+ client: TEST_CLIENT,
390
+ chain,
391
+ value: 0n,
392
+ });
393
+ await expect(
394
+ sendTransaction({
395
+ transaction,
396
+ account: newSmartAccount,
397
+ }),
398
+ ).rejects.toThrowError(/AA21 didn't pay prefund/);
399
+ });
367
400
  },
368
401
  );