@tokenops/sdk 2.0.0-alpha.1 → 2.0.0-alpha.3

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 (155) hide show
  1. package/CHANGELOG.md +67 -2
  2. package/README.md +14 -8
  3. package/dist/{chunk-PUX5VXDB.cjs → chunk-4AWQJQXY.cjs} +1415 -69
  4. package/dist/{chunk-74QFZ5MK.js → chunk-4IB4IY5Y.js} +1 -1
  5. package/dist/{chunk-DZHYSUGY.js → chunk-6HCT4QIX.js} +12 -5
  6. package/dist/{chunk-FGEB7RMY.cjs → chunk-6XOAYDC6.cjs} +4 -4
  7. package/dist/{chunk-XAYGD4E4.cjs → chunk-AHU2HMNE.cjs} +3 -3
  8. package/dist/{chunk-6NAVMWZQ.js → chunk-BPIVVCSQ.js} +2 -2
  9. package/dist/{chunk-GKKDAW44.js → chunk-BXX5TETM.js} +1401 -59
  10. package/dist/{chunk-456VDDA3.js → chunk-GCJFAY4X.js} +78 -25
  11. package/dist/{chunk-CTED3MTR.cjs → chunk-GKYZQJGP.cjs} +82 -29
  12. package/dist/{chunk-JZLGCTGK.cjs → chunk-IEKTGJ4J.cjs} +2 -2
  13. package/dist/{chunk-6PXXGACR.cjs → chunk-JVNJSDQ4.cjs} +2 -2
  14. package/dist/{chunk-O5676ZWY.js → chunk-LEYYG4RF.js} +232 -6
  15. package/dist/{chunk-335Z2W67.js → chunk-NGU4JYIR.js} +1 -1
  16. package/dist/{chunk-5576FRT3.cjs → chunk-PG3WXT3K.cjs} +12 -5
  17. package/dist/{chunk-H5POPGOZ.js → chunk-PK6Q6J5F.js} +1 -1
  18. package/dist/chunk-TND5NDV7.cjs +263 -0
  19. package/dist/chunk-U3TBQRT7.js +253 -0
  20. package/dist/{chunk-EAJ7SYHE.js → chunk-WRWRA4TN.js} +1 -1
  21. package/dist/{chunk-JQYC66TO.cjs → chunk-YABHXJNH.cjs} +5 -5
  22. package/dist/{chunk-M4IT6DNJ.cjs → chunk-YTIYTV4K.cjs} +236 -4
  23. package/dist/core/addresses.d.ts +4 -4
  24. package/dist/core/errors.d.ts +1 -1
  25. package/dist/fhe/types.d.ts +2 -2
  26. package/dist/fhe-airdrop/abis/airdrop-base.d.ts +19 -0
  27. package/dist/fhe-airdrop/abis/ecdsa.d.ts +19 -0
  28. package/dist/fhe-airdrop/abis/factory.d.ts +113 -0
  29. package/dist/fhe-airdrop/abis/merkle.d.ts +43 -12
  30. package/dist/fhe-airdrop/advanced/index.cjs +4 -4
  31. package/dist/fhe-airdrop/advanced/index.js +1 -1
  32. package/dist/fhe-airdrop/advanced/react/index.cjs +620 -9
  33. package/dist/fhe-airdrop/advanced/react/index.d.cts +35 -0
  34. package/dist/fhe-airdrop/advanced/react/index.d.ts +35 -0
  35. package/dist/fhe-airdrop/advanced/react/index.js +590 -7
  36. package/dist/fhe-airdrop/advanced/react/useClearCompliancePolicy.d.ts +28 -0
  37. package/dist/fhe-airdrop/advanced/react/useClearUpgradeabilityPolicy.d.ts +26 -0
  38. package/dist/fhe-airdrop/advanced/react/useDisableCustomFee.d.ts +26 -0
  39. package/dist/fhe-airdrop/advanced/react/useEcdsaInitCodeHash.d.ts +30 -0
  40. package/dist/fhe-airdrop/advanced/react/useFactoryComplianceDelegate.d.ts +25 -0
  41. package/dist/fhe-airdrop/advanced/react/useFactoryCompliancePolicy.d.ts +38 -0
  42. package/dist/fhe-airdrop/advanced/react/useFactoryCustomFee.d.ts +24 -0
  43. package/dist/fhe-airdrop/advanced/react/useFactoryGrantRole.d.ts +32 -0
  44. package/dist/fhe-airdrop/advanced/react/useFactoryHasRole.d.ts +27 -0
  45. package/dist/fhe-airdrop/advanced/react/useFactoryImplementations.d.ts +33 -0
  46. package/dist/fhe-airdrop/advanced/react/useFactoryRenounceRole.d.ts +37 -0
  47. package/dist/fhe-airdrop/advanced/react/useFactoryRevokeRole.d.ts +37 -0
  48. package/dist/fhe-airdrop/advanced/react/useFactoryRoleConstants.d.ts +46 -0
  49. package/dist/fhe-airdrop/advanced/react/useFactoryRoleMembers.d.ts +48 -0
  50. package/dist/fhe-airdrop/advanced/react/useFactoryUpgradeabilityPolicy.d.ts +39 -0
  51. package/dist/fhe-airdrop/advanced/react/useMerkleInitCodeHash.d.ts +24 -0
  52. package/dist/fhe-airdrop/advanced/react/useSetComplianceDelegate.d.ts +33 -0
  53. package/dist/fhe-airdrop/advanced/react/useSetComplianceManagerImpl.d.ts +27 -0
  54. package/dist/fhe-airdrop/advanced/react/useSetCompliancePolicy.d.ts +28 -0
  55. package/dist/fhe-airdrop/advanced/react/useSetCustomFee.d.ts +29 -0
  56. package/dist/fhe-airdrop/advanced/react/useSetDefaultDelegateToCompliance.d.ts +31 -0
  57. package/dist/fhe-airdrop/advanced/react/useSetDefaultGasFee.d.ts +30 -0
  58. package/dist/fhe-airdrop/advanced/react/useSetDefaultUpgradeable.d.ts +27 -0
  59. package/dist/fhe-airdrop/advanced/react/useSetEcdsaImplementation.d.ts +34 -0
  60. package/dist/fhe-airdrop/advanced/react/useSetFeeCollector.d.ts +27 -0
  61. package/dist/fhe-airdrop/advanced/react/useSetMaxGasFee.d.ts +33 -0
  62. package/dist/fhe-airdrop/advanced/react/useSetMerkleImplementation.d.ts +30 -0
  63. package/dist/fhe-airdrop/advanced/react/useSetUpgradeabilityPolicy.d.ts +31 -0
  64. package/dist/fhe-airdrop/airdrop-base.d.ts +55 -8
  65. package/dist/fhe-airdrop/campaign.d.ts +61 -20
  66. package/dist/fhe-airdrop/constants.d.ts +9 -1
  67. package/dist/fhe-airdrop/ecdsa.d.ts +13 -0
  68. package/dist/fhe-airdrop/errors.d.ts +87 -0
  69. package/dist/fhe-airdrop/factory.d.ts +62 -22
  70. package/dist/fhe-airdrop/guards.d.ts +133 -4
  71. package/dist/fhe-airdrop/index.cjs +86 -971
  72. package/dist/fhe-airdrop/index.d.cts +4 -4
  73. package/dist/fhe-airdrop/index.d.ts +4 -4
  74. package/dist/fhe-airdrop/index.js +8 -927
  75. package/dist/fhe-airdrop/merkle-tree.d.ts +32 -38
  76. package/dist/fhe-airdrop/merkle.d.ts +52 -31
  77. package/dist/fhe-airdrop/react/_shared.d.ts +13 -0
  78. package/dist/fhe-airdrop/react/index.cjs +997 -87
  79. package/dist/fhe-airdrop/react/index.d.cts +53 -4
  80. package/dist/fhe-airdrop/react/index.d.ts +53 -4
  81. package/dist/fhe-airdrop/react/index.js +887 -27
  82. package/dist/fhe-airdrop/react/keys.d.ts +98 -0
  83. package/dist/fhe-airdrop/react/useAccessEcdsaClaimAmount.d.ts +26 -0
  84. package/dist/fhe-airdrop/react/useAccessMerkleClaimAmount.d.ts +27 -0
  85. package/dist/fhe-airdrop/react/useAddComplianceDelegate.d.ts +37 -0
  86. package/dist/fhe-airdrop/react/useAdminBatchDiscloseBalanceToParties.d.ts +36 -0
  87. package/dist/fhe-airdrop/react/useAdminDiscloseBalanceToParty.d.ts +31 -0
  88. package/dist/fhe-airdrop/react/useAdminGetCurrentBalance.d.ts +27 -0
  89. package/dist/fhe-airdrop/react/useAirdropConfig.d.ts +49 -0
  90. package/dist/fhe-airdrop/react/useAirdropDeploymentMode.d.ts +28 -0
  91. package/dist/fhe-airdrop/react/useAirdropGrantRole.d.ts +35 -0
  92. package/dist/fhe-airdrop/react/useAirdropRenounceRole.d.ts +36 -0
  93. package/dist/fhe-airdrop/react/useAirdropRevokeRole.d.ts +33 -0
  94. package/dist/fhe-airdrop/react/useAirdropRoleAdmin.d.ts +28 -0
  95. package/dist/fhe-airdrop/react/useAirdropRoleConstants.d.ts +67 -0
  96. package/dist/fhe-airdrop/react/useAirdropRoleMembers.d.ts +49 -0
  97. package/dist/fhe-airdrop/react/useAirdropUpgradeToAndCall.d.ts +45 -0
  98. package/dist/fhe-airdrop/react/useBatchDiscloseHandlesToParty.d.ts +32 -0
  99. package/dist/fhe-airdrop/react/useBuildMerkleCampaign.d.ts +68 -0
  100. package/dist/fhe-airdrop/react/useComplianceGrantRole.d.ts +32 -0
  101. package/dist/fhe-airdrop/react/useComplianceHasRole.d.ts +37 -0
  102. package/dist/fhe-airdrop/react/useComplianceInfo.d.ts +50 -0
  103. package/dist/fhe-airdrop/react/useComplianceManagerOf.d.ts +32 -0
  104. package/dist/fhe-airdrop/react/useComplianceRenounceRole.d.ts +38 -0
  105. package/dist/fhe-airdrop/react/useComplianceRevokeRole.d.ts +36 -0
  106. package/dist/fhe-airdrop/react/useComplianceRoleConstants.d.ts +41 -0
  107. package/dist/fhe-airdrop/react/useComplianceRoleMembers.d.ts +45 -0
  108. package/dist/fhe-airdrop/react/useCreateAndFundEcdsaAirdrop.d.ts +55 -0
  109. package/dist/fhe-airdrop/react/useCreateAndFundMerkleAirdrop.d.ts +52 -0
  110. package/dist/fhe-airdrop/react/useDiscloseHandleToParty.d.ts +35 -0
  111. package/dist/fhe-airdrop/react/useEcdsaClaim.d.ts +4 -3
  112. package/dist/fhe-airdrop/react/useEcdsaClaimAndUnwrap.d.ts +27 -0
  113. package/dist/fhe-airdrop/react/useEcdsaDomain.d.ts +41 -0
  114. package/dist/fhe-airdrop/react/useEffectiveDelegateToCompliance.d.ts +26 -0
  115. package/dist/fhe-airdrop/react/useEncryptCampaignAmounts.d.ts +59 -0
  116. package/dist/fhe-airdrop/react/useFactoryFees.d.ts +11 -4
  117. package/dist/fhe-airdrop/react/useIsActiveDelegate.d.ts +29 -0
  118. package/dist/fhe-airdrop/react/useIsAirdrop.d.ts +44 -0
  119. package/dist/fhe-airdrop/react/useIsMerkleRootMutable.d.ts +21 -0
  120. package/dist/fhe-airdrop/react/useIsSignatureValid.d.ts +46 -0
  121. package/dist/fhe-airdrop/react/useMerkleClaim.d.ts +7 -19
  122. package/dist/fhe-airdrop/react/useMerkleClaimAndUnwrap.d.ts +29 -0
  123. package/dist/fhe-airdrop/react/usePlanMerkleCampaign.d.ts +53 -0
  124. package/dist/fhe-airdrop/react/usePreflightClaim.d.ts +46 -0
  125. package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +67 -0
  126. package/dist/fhe-airdrop/react/useRefreshComplianceBalance.d.ts +36 -0
  127. package/dist/fhe-airdrop/react/useRescueERC20.d.ts +30 -0
  128. package/dist/fhe-airdrop/react/useRescueOtherConfidentialToken.d.ts +34 -0
  129. package/dist/fhe-airdrop/react/useResolveGasFee.d.ts +30 -0
  130. package/dist/fhe-airdrop/react/useRevokeComplianceDelegate.d.ts +37 -0
  131. package/dist/fhe-airdrop/react/useRotateMerkleRoot.d.ts +52 -0
  132. package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +42 -0
  133. package/dist/fhe-airdrop/react/useWithdrawGasFee.d.ts +37 -0
  134. package/dist/fhe-airdrop/types.d.ts +27 -1
  135. package/dist/fhe-disperse/index.cjs +21 -21
  136. package/dist/fhe-disperse/index.js +2 -2
  137. package/dist/fhe-disperse/react/index.cjs +22 -22
  138. package/dist/fhe-disperse/react/index.js +3 -3
  139. package/dist/fhe-vesting/advanced/index.cjs +5 -5
  140. package/dist/fhe-vesting/advanced/index.js +3 -3
  141. package/dist/fhe-vesting/advanced/react/index.cjs +7 -7
  142. package/dist/fhe-vesting/advanced/react/index.js +4 -4
  143. package/dist/fhe-vesting/index.cjs +8 -8
  144. package/dist/fhe-vesting/index.js +2 -2
  145. package/dist/fhe-vesting/react/index.cjs +114 -114
  146. package/dist/fhe-vesting/react/index.js +3 -3
  147. package/dist/index.cjs +18 -18
  148. package/dist/index.js +1 -1
  149. package/dist/testnet-faucet/index.cjs +14 -14
  150. package/dist/testnet-faucet/index.js +2 -2
  151. package/dist/testnet-faucet/react/index.cjs +8 -8
  152. package/dist/testnet-faucet/react/index.js +3 -3
  153. package/package.json +1 -1
  154. package/dist/chunk-NCVX3K2N.cjs +0 -161
  155. package/dist/chunk-VP2B4WM2.js +0 -154
@@ -1,5 +1,5 @@
1
- import { resolveEncryptor, encryptUint64 } from './chunk-GKKDAW44.js';
2
- import { assertPredictionFresh, FeeCollectorSelfAdministeredError } from './chunk-O5676ZWY.js';
1
+ import { resolveEncryptor, encryptUint64Batch, encryptUint64 } from './chunk-BXX5TETM.js';
2
+ import { assertPredictionFresh, FeeCollectorSelfAdministeredError } from './chunk-LEYYG4RF.js';
3
3
  import { normaliseAddress } from './chunk-ZA673I3O.js';
4
4
  import { InvalidArgumentError, MissingWalletClientError, MissingAccountError, ContractRevertError, MissingEncryptorError, isTokenOpsSdkError, UnknownWriteFailureError } from './chunk-QBJ7O2B4.js';
5
5
  import { StandardMerkleTree } from '@openzeppelin/merkle-tree';
@@ -9,7 +9,7 @@ function leafOf(args) {
9
9
  const inner = keccak256(
10
10
  encodeAbiParameters(
11
11
  [{ type: "address" }, { type: "address" }, { type: "bytes32" }],
12
- [args.instance, args.recipient, args.handle]
12
+ [args.instance, args.account, args.handle]
13
13
  )
14
14
  );
15
15
  return keccak256(inner);
@@ -40,19 +40,19 @@ function assertLeaves(instance, leaves, method) {
40
40
  }
41
41
  const seen = /* @__PURE__ */ new Map();
42
42
  leaves.forEach((leaf, index) => {
43
- if (!isAddress(leaf.recipient, { strict: false })) {
43
+ if (!isAddress(leaf.account, { strict: false })) {
44
44
  throw new InvalidArgumentError({
45
45
  method,
46
- argument: `leaves[${index}].recipient`,
46
+ argument: `leaves[${index}].account`,
47
47
  reason: "is not a 20-byte hex address",
48
- value: leaf.recipient
48
+ value: leaf.account
49
49
  });
50
50
  }
51
- if (isAddressEqual(leaf.recipient, zeroAddress)) {
51
+ if (isAddressEqual(leaf.account, zeroAddress)) {
52
52
  throw new InvalidArgumentError({
53
53
  method,
54
- argument: `leaves[${index}].recipient`,
55
- reason: "is the zero address, whose leaf can never be claimed"
54
+ argument: `leaves[${index}].account`,
55
+ reason: "is the zero address; the contract rejects it with ZeroAccount"
56
56
  });
57
57
  }
58
58
  if (!HANDLE_PATTERN.test(leaf.handle)) {
@@ -63,13 +63,13 @@ function assertLeaves(instance, leaves, method) {
63
63
  value: leaf.handle
64
64
  });
65
65
  }
66
- const key = leaf.recipient.toLowerCase();
66
+ const key = leaf.account.toLowerCase();
67
67
  const first = seen.get(key);
68
68
  if (first !== void 0) {
69
69
  throw new InvalidArgumentError({
70
70
  method,
71
- argument: `leaves[${index}].recipient`,
72
- reason: `appears twice (also at index ${first}); one root pays max, not sum, of a recipient's leaves \u2014 merge them into a single cumulative total`
71
+ argument: `leaves[${index}].account`,
72
+ reason: `appears twice (also at index ${first}); one root pays max, not sum, of an account's leaves \u2014 merge them into a single cumulative total`
73
73
  });
74
74
  }
75
75
  seen.set(key, index);
@@ -81,22 +81,23 @@ function buildMerkleTree(args) {
81
81
  function buildMerkleTreeInternal({ instance, leaves }, method) {
82
82
  assertLeaves(instance, leaves, method);
83
83
  const airdrop = normaliseAddress(instance);
84
- const accounts = leaves.map((leaf) => normaliseAddress(leaf.recipient));
84
+ const accounts = leaves.map((leaf) => normaliseAddress(leaf.account));
85
85
  const rows = accounts.map((account, i) => [airdrop, account, leaves[i].handle]);
86
86
  const tree = StandardMerkleTree.of(rows, ["address", "address", "bytes32"]);
87
87
  return {
88
88
  root: tree.root,
89
- // `getProof(i)` indexes the INPUT array, not the tree: `StandardMerkleTree`
90
- // sorts leaves internally but keeps `values` in insertion order, so entry
91
- // `i` always belongs to `leaves[i]`.
89
+ // `getProof(i)` indexes the INPUT array, not the tree: `StandardMerkleTree` sorts
90
+ // leaves internally but keeps `values` in insertion order, so entry `i` always belongs
91
+ // to `leaves[i]`.
92
92
  entries: leaves.map((leaf, i) => ({
93
93
  ...leaf,
94
- recipient: accounts[i],
94
+ account: accounts[i],
95
95
  merkleProof: tree.getProof(i)
96
96
  }))
97
97
  };
98
98
  }
99
99
  var MAX_UINT64 = (1n << 64n) - 1n;
100
+ var MERKLE_BATCH_LIMIT = 2048 / 64;
100
101
  function validateCampaignRecipients(recipients) {
101
102
  validateCampaignRecipientsInternal(recipients, "validateCampaignRecipients");
102
103
  }
@@ -145,7 +146,7 @@ function validateCampaignRecipientsInternal(recipients, method) {
145
146
  seen.set(key, index);
146
147
  });
147
148
  }
148
- async function encryptRoster({ instance, recipients, encryptor }, method) {
149
+ async function encryptRoster({ instance, recipients, encryptor, submitter }, method) {
149
150
  validateCampaignRecipientsInternal(recipients, method);
150
151
  if (!isAddress(instance, { strict: false })) {
151
152
  throw new InvalidArgumentError({
@@ -168,8 +169,51 @@ async function encryptRoster({ instance, recipients, encryptor }, method) {
168
169
  hint: "Pass an encryptor instance, or a lazy factory that returns one."
169
170
  });
170
171
  }
172
+ if (submitter !== void 0) {
173
+ if (!isAddress(submitter, { strict: false })) {
174
+ throw new InvalidArgumentError({
175
+ method,
176
+ argument: "submitter",
177
+ reason: "is not a 20-byte hex address",
178
+ value: submitter
179
+ });
180
+ }
181
+ if (isAddressEqual(submitter, zeroAddress)) {
182
+ throw new InvalidArgumentError({
183
+ method,
184
+ argument: "submitter",
185
+ reason: "is the zero address; no proof can be bound to it, so no leaf would be claimable"
186
+ });
187
+ }
188
+ }
171
189
  const airdrop = normaliseAddress(instance);
172
190
  const accounts = recipients.map((r) => normaliseAddress(r.recipient));
191
+ if (submitter !== void 0) {
192
+ const boundTo = normaliseAddress(submitter);
193
+ const chunks = [];
194
+ for (let i = 0; i < recipients.length; i += MERKLE_BATCH_LIMIT) {
195
+ chunks.push(recipients.slice(i, i + MERKLE_BATCH_LIMIT));
196
+ }
197
+ const encryptedChunks = await Promise.all(
198
+ chunks.map(
199
+ (chunk) => encryptUint64Batch({
200
+ encryptor: enc,
201
+ contractAddress: airdrop,
202
+ userAddress: boundTo,
203
+ values: chunk.map((r) => r.cumulativeTotal)
204
+ })
205
+ )
206
+ );
207
+ return accounts.map((account, i) => {
208
+ const chunk = encryptedChunks[Math.floor(i / MERKLE_BATCH_LIMIT)];
209
+ return {
210
+ account,
211
+ boundTo,
212
+ handle: chunk.handles[i % MERKLE_BATCH_LIMIT],
213
+ inputProof: chunk.inputProof
214
+ };
215
+ });
216
+ }
173
217
  const encrypted = await Promise.all(
174
218
  recipients.map(
175
219
  (r, i) => encryptUint64({
@@ -180,8 +224,9 @@ async function encryptRoster({ instance, recipients, encryptor }, method) {
180
224
  })
181
225
  )
182
226
  );
183
- return accounts.map((recipient, i) => ({
184
- recipient,
227
+ return accounts.map((account, i) => ({
228
+ account,
229
+ boundTo: account,
185
230
  handle: encrypted[i].handle,
186
231
  inputProof: encrypted[i].inputProof
187
232
  }));
@@ -192,9 +237,13 @@ async function encryptCampaignAmounts(args) {
192
237
  async function buildMerkleCampaign({
193
238
  instance,
194
239
  recipients,
195
- encryptor
240
+ encryptor,
241
+ submitter
196
242
  }) {
197
- const leaves = await encryptRoster({ instance, recipients, encryptor }, "buildMerkleCampaign");
243
+ const leaves = await encryptRoster(
244
+ { instance, recipients, encryptor, submitter },
245
+ "buildMerkleCampaign"
246
+ );
198
247
  return buildMerkleTreeInternal({ instance, leaves }, "buildMerkleCampaign");
199
248
  }
200
249
  async function planMerkleCampaign({
@@ -204,7 +253,8 @@ async function planMerkleCampaign({
204
253
  creator,
205
254
  userSalt,
206
255
  recipients,
207
- encryptor
256
+ encryptor,
257
+ submitter
208
258
  }) {
209
259
  validateCampaignRecipientsInternal(recipients, "planMerkleCampaign");
210
260
  const initCodeHashBefore = await factory.getMerkleInitCodeHash({ params, mode });
@@ -217,7 +267,8 @@ async function planMerkleCampaign({
217
267
  const campaign = await buildMerkleCampaign({
218
268
  instance: predictedAddress,
219
269
  recipients,
220
- encryptor
270
+ encryptor,
271
+ submitter
221
272
  });
222
273
  const initCodeHashAfter = await factory.getMerkleInitCodeHash({ params, mode });
223
274
  assertPredictionFresh({
@@ -233,12 +284,14 @@ async function rotateMerkleRoot({
233
284
  airdrop,
234
285
  recipients,
235
286
  encryptor,
287
+ submitter,
236
288
  account
237
289
  }) {
238
290
  const campaign = await buildMerkleCampaign({
239
291
  instance: airdrop.address,
240
292
  recipients,
241
- encryptor
293
+ encryptor,
294
+ submitter
242
295
  });
243
296
  const hash = await airdrop.setMerkleRoot({ newRoot: campaign.root, account });
244
297
  return { ...campaign, hash };
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunkPUX5VXDB_cjs = require('./chunk-PUX5VXDB.cjs');
4
- var chunkM4IT6DNJ_cjs = require('./chunk-M4IT6DNJ.cjs');
3
+ var chunk4AWQJQXY_cjs = require('./chunk-4AWQJQXY.cjs');
4
+ var chunkYTIYTV4K_cjs = require('./chunk-YTIYTV4K.cjs');
5
5
  var chunkJK4XMMKM_cjs = require('./chunk-JK4XMMKM.cjs');
6
6
  var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
7
7
  var merkleTree = require('@openzeppelin/merkle-tree');
@@ -11,7 +11,7 @@ function leafOf(args) {
11
11
  const inner = viem.keccak256(
12
12
  viem.encodeAbiParameters(
13
13
  [{ type: "address" }, { type: "address" }, { type: "bytes32" }],
14
- [args.instance, args.recipient, args.handle]
14
+ [args.instance, args.account, args.handle]
15
15
  )
16
16
  );
17
17
  return viem.keccak256(inner);
@@ -42,19 +42,19 @@ function assertLeaves(instance, leaves, method) {
42
42
  }
43
43
  const seen = /* @__PURE__ */ new Map();
44
44
  leaves.forEach((leaf, index) => {
45
- if (!viem.isAddress(leaf.recipient, { strict: false })) {
45
+ if (!viem.isAddress(leaf.account, { strict: false })) {
46
46
  throw new chunk67OV5CX2_cjs.InvalidArgumentError({
47
47
  method,
48
- argument: `leaves[${index}].recipient`,
48
+ argument: `leaves[${index}].account`,
49
49
  reason: "is not a 20-byte hex address",
50
- value: leaf.recipient
50
+ value: leaf.account
51
51
  });
52
52
  }
53
- if (viem.isAddressEqual(leaf.recipient, viem.zeroAddress)) {
53
+ if (viem.isAddressEqual(leaf.account, viem.zeroAddress)) {
54
54
  throw new chunk67OV5CX2_cjs.InvalidArgumentError({
55
55
  method,
56
- argument: `leaves[${index}].recipient`,
57
- reason: "is the zero address, whose leaf can never be claimed"
56
+ argument: `leaves[${index}].account`,
57
+ reason: "is the zero address; the contract rejects it with ZeroAccount"
58
58
  });
59
59
  }
60
60
  if (!HANDLE_PATTERN.test(leaf.handle)) {
@@ -65,13 +65,13 @@ function assertLeaves(instance, leaves, method) {
65
65
  value: leaf.handle
66
66
  });
67
67
  }
68
- const key = leaf.recipient.toLowerCase();
68
+ const key = leaf.account.toLowerCase();
69
69
  const first = seen.get(key);
70
70
  if (first !== void 0) {
71
71
  throw new chunk67OV5CX2_cjs.InvalidArgumentError({
72
72
  method,
73
- argument: `leaves[${index}].recipient`,
74
- reason: `appears twice (also at index ${first}); one root pays max, not sum, of a recipient's leaves \u2014 merge them into a single cumulative total`
73
+ argument: `leaves[${index}].account`,
74
+ reason: `appears twice (also at index ${first}); one root pays max, not sum, of an account's leaves \u2014 merge them into a single cumulative total`
75
75
  });
76
76
  }
77
77
  seen.set(key, index);
@@ -83,22 +83,23 @@ function buildMerkleTree(args) {
83
83
  function buildMerkleTreeInternal({ instance, leaves }, method) {
84
84
  assertLeaves(instance, leaves, method);
85
85
  const airdrop = chunkJK4XMMKM_cjs.normaliseAddress(instance);
86
- const accounts = leaves.map((leaf) => chunkJK4XMMKM_cjs.normaliseAddress(leaf.recipient));
86
+ const accounts = leaves.map((leaf) => chunkJK4XMMKM_cjs.normaliseAddress(leaf.account));
87
87
  const rows = accounts.map((account, i) => [airdrop, account, leaves[i].handle]);
88
88
  const tree = merkleTree.StandardMerkleTree.of(rows, ["address", "address", "bytes32"]);
89
89
  return {
90
90
  root: tree.root,
91
- // `getProof(i)` indexes the INPUT array, not the tree: `StandardMerkleTree`
92
- // sorts leaves internally but keeps `values` in insertion order, so entry
93
- // `i` always belongs to `leaves[i]`.
91
+ // `getProof(i)` indexes the INPUT array, not the tree: `StandardMerkleTree` sorts
92
+ // leaves internally but keeps `values` in insertion order, so entry `i` always belongs
93
+ // to `leaves[i]`.
94
94
  entries: leaves.map((leaf, i) => ({
95
95
  ...leaf,
96
- recipient: accounts[i],
96
+ account: accounts[i],
97
97
  merkleProof: tree.getProof(i)
98
98
  }))
99
99
  };
100
100
  }
101
101
  var MAX_UINT64 = (1n << 64n) - 1n;
102
+ var MERKLE_BATCH_LIMIT = 2048 / 64;
102
103
  function validateCampaignRecipients(recipients) {
103
104
  validateCampaignRecipientsInternal(recipients, "validateCampaignRecipients");
104
105
  }
@@ -147,7 +148,7 @@ function validateCampaignRecipientsInternal(recipients, method) {
147
148
  seen.set(key, index);
148
149
  });
149
150
  }
150
- async function encryptRoster({ instance, recipients, encryptor }, method) {
151
+ async function encryptRoster({ instance, recipients, encryptor, submitter }, method) {
151
152
  validateCampaignRecipientsInternal(recipients, method);
152
153
  if (!viem.isAddress(instance, { strict: false })) {
153
154
  throw new chunk67OV5CX2_cjs.InvalidArgumentError({
@@ -164,17 +165,60 @@ async function encryptRoster({ instance, recipients, encryptor }, method) {
164
165
  reason: "is the zero address; inputs must be bound to the airdrop instance"
165
166
  });
166
167
  }
167
- const enc = chunkPUX5VXDB_cjs.resolveEncryptor(encryptor);
168
+ const enc = chunk4AWQJQXY_cjs.resolveEncryptor(encryptor);
168
169
  if (!enc) {
169
170
  throw new chunk67OV5CX2_cjs.MissingEncryptorError(method, {
170
171
  hint: "Pass an encryptor instance, or a lazy factory that returns one."
171
172
  });
172
173
  }
174
+ if (submitter !== void 0) {
175
+ if (!viem.isAddress(submitter, { strict: false })) {
176
+ throw new chunk67OV5CX2_cjs.InvalidArgumentError({
177
+ method,
178
+ argument: "submitter",
179
+ reason: "is not a 20-byte hex address",
180
+ value: submitter
181
+ });
182
+ }
183
+ if (viem.isAddressEqual(submitter, viem.zeroAddress)) {
184
+ throw new chunk67OV5CX2_cjs.InvalidArgumentError({
185
+ method,
186
+ argument: "submitter",
187
+ reason: "is the zero address; no proof can be bound to it, so no leaf would be claimable"
188
+ });
189
+ }
190
+ }
173
191
  const airdrop = chunkJK4XMMKM_cjs.normaliseAddress(instance);
174
192
  const accounts = recipients.map((r) => chunkJK4XMMKM_cjs.normaliseAddress(r.recipient));
193
+ if (submitter !== void 0) {
194
+ const boundTo = chunkJK4XMMKM_cjs.normaliseAddress(submitter);
195
+ const chunks = [];
196
+ for (let i = 0; i < recipients.length; i += MERKLE_BATCH_LIMIT) {
197
+ chunks.push(recipients.slice(i, i + MERKLE_BATCH_LIMIT));
198
+ }
199
+ const encryptedChunks = await Promise.all(
200
+ chunks.map(
201
+ (chunk) => chunk4AWQJQXY_cjs.encryptUint64Batch({
202
+ encryptor: enc,
203
+ contractAddress: airdrop,
204
+ userAddress: boundTo,
205
+ values: chunk.map((r) => r.cumulativeTotal)
206
+ })
207
+ )
208
+ );
209
+ return accounts.map((account, i) => {
210
+ const chunk = encryptedChunks[Math.floor(i / MERKLE_BATCH_LIMIT)];
211
+ return {
212
+ account,
213
+ boundTo,
214
+ handle: chunk.handles[i % MERKLE_BATCH_LIMIT],
215
+ inputProof: chunk.inputProof
216
+ };
217
+ });
218
+ }
175
219
  const encrypted = await Promise.all(
176
220
  recipients.map(
177
- (r, i) => chunkPUX5VXDB_cjs.encryptUint64({
221
+ (r, i) => chunk4AWQJQXY_cjs.encryptUint64({
178
222
  encryptor: enc,
179
223
  contractAddress: airdrop,
180
224
  userAddress: accounts[i],
@@ -182,8 +226,9 @@ async function encryptRoster({ instance, recipients, encryptor }, method) {
182
226
  })
183
227
  )
184
228
  );
185
- return accounts.map((recipient, i) => ({
186
- recipient,
229
+ return accounts.map((account, i) => ({
230
+ account,
231
+ boundTo: account,
187
232
  handle: encrypted[i].handle,
188
233
  inputProof: encrypted[i].inputProof
189
234
  }));
@@ -194,9 +239,13 @@ async function encryptCampaignAmounts(args) {
194
239
  async function buildMerkleCampaign({
195
240
  instance,
196
241
  recipients,
197
- encryptor
242
+ encryptor,
243
+ submitter
198
244
  }) {
199
- const leaves = await encryptRoster({ instance, recipients, encryptor }, "buildMerkleCampaign");
245
+ const leaves = await encryptRoster(
246
+ { instance, recipients, encryptor, submitter },
247
+ "buildMerkleCampaign"
248
+ );
200
249
  return buildMerkleTreeInternal({ instance, leaves }, "buildMerkleCampaign");
201
250
  }
202
251
  async function planMerkleCampaign({
@@ -206,7 +255,8 @@ async function planMerkleCampaign({
206
255
  creator,
207
256
  userSalt,
208
257
  recipients,
209
- encryptor
258
+ encryptor,
259
+ submitter
210
260
  }) {
211
261
  validateCampaignRecipientsInternal(recipients, "planMerkleCampaign");
212
262
  const initCodeHashBefore = await factory.getMerkleInitCodeHash({ params, mode });
@@ -219,10 +269,11 @@ async function planMerkleCampaign({
219
269
  const campaign = await buildMerkleCampaign({
220
270
  instance: predictedAddress,
221
271
  recipients,
222
- encryptor
272
+ encryptor,
273
+ submitter
223
274
  });
224
275
  const initCodeHashAfter = await factory.getMerkleInitCodeHash({ params, mode });
225
- chunkM4IT6DNJ_cjs.assertPredictionFresh({
276
+ chunkYTIYTV4K_cjs.assertPredictionFresh({
226
277
  variant: "merkle",
227
278
  initCodeHashBefore,
228
279
  initCodeHashAfter,
@@ -235,12 +286,14 @@ async function rotateMerkleRoot({
235
286
  airdrop,
236
287
  recipients,
237
288
  encryptor,
289
+ submitter,
238
290
  account
239
291
  }) {
240
292
  const campaign = await buildMerkleCampaign({
241
293
  instance: airdrop.address,
242
294
  recipients,
243
- encryptor
295
+ encryptor,
296
+ submitter
244
297
  });
245
298
  const hash = await airdrop.setMerkleRoot({ newRoot: campaign.root, account });
246
299
  return { ...campaign, hash };
@@ -258,7 +311,7 @@ var ASSIGNABLE_ROLES = [
258
311
  function planInstanceRoleSplit(args) {
259
312
  const { assignment, caller, airdropType } = args;
260
313
  if (assignment.feeCollector !== void 0) {
261
- throw new chunkM4IT6DNJ_cjs.FeeCollectorSelfAdministeredError({ requestedGrantee: assignment.feeCollector });
314
+ throw new chunkYTIYTV4K_cjs.FeeCollectorSelfAdministeredError({ requestedGrantee: assignment.feeCollector });
262
315
  }
263
316
  const steps = [];
264
317
  for (const { key, role, variant } of ASSIGNABLE_ROLES) {
@@ -4,7 +4,7 @@ var chunkTEBM66WA_cjs = require('./chunk-TEBM66WA.cjs');
4
4
  var chunkFAXIIH5R_cjs = require('./chunk-FAXIIH5R.cjs');
5
5
  var chunkUG5RKLU2_cjs = require('./chunk-UG5RKLU2.cjs');
6
6
  var chunkMVDQMV25_cjs = require('./chunk-MVDQMV25.cjs');
7
- var chunk5576FRT3_cjs = require('./chunk-5576FRT3.cjs');
7
+ var chunkPG3WXT3K_cjs = require('./chunk-PG3WXT3K.cjs');
8
8
  var chunkJK4XMMKM_cjs = require('./chunk-JK4XMMKM.cjs');
9
9
  var chunk66IHPTOK_cjs = require('./chunk-66IHPTOK.cjs');
10
10
  var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
@@ -2052,7 +2052,7 @@ var ConfidentialDisperseClient = class {
2052
2052
  this.#telemetry = config.telemetry;
2053
2053
  const chainId = config.chainId ?? config.publicClient.chain?.id;
2054
2054
  const addressOverride = config.address ? chunkJK4XMMKM_cjs.normaliseAddress(config.address) : void 0;
2055
- const resolved = addressOverride ?? (chainId === void 0 ? void 0 : chunk5576FRT3_cjs.getFheDisperseSingletonAddress(chainId));
2055
+ const resolved = addressOverride ?? (chainId === void 0 ? void 0 : chunkPG3WXT3K_cjs.getFheDisperseSingletonAddress(chainId));
2056
2056
  if (!resolved) {
2057
2057
  throw new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
2058
2058
  reason: chainId === void 0 ? "chain-id-missing" : "registry-not-deployed",
@@ -2,7 +2,7 @@
2
2
 
3
3
  var chunkUG5RKLU2_cjs = require('./chunk-UG5RKLU2.cjs');
4
4
  var chunkMVDQMV25_cjs = require('./chunk-MVDQMV25.cjs');
5
- var chunk5576FRT3_cjs = require('./chunk-5576FRT3.cjs');
5
+ var chunkPG3WXT3K_cjs = require('./chunk-PG3WXT3K.cjs');
6
6
  var chunkJK4XMMKM_cjs = require('./chunk-JK4XMMKM.cjs');
7
7
  var chunk66IHPTOK_cjs = require('./chunk-66IHPTOK.cjs');
8
8
  var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
@@ -446,7 +446,7 @@ var ConfidentialVestingFactoryClient = class {
446
446
  this.walletClient = config.walletClient;
447
447
  const chainId = config.chainId ?? config.publicClient.chain?.id;
448
448
  const addressOverride = config.address ? chunkJK4XMMKM_cjs.normaliseAddress(config.address) : void 0;
449
- const resolved = addressOverride ?? (chainId === void 0 ? void 0 : chunk5576FRT3_cjs.getFheVestingFactoryAddress(chainId));
449
+ const resolved = addressOverride ?? (chainId === void 0 ? void 0 : chunkPG3WXT3K_cjs.getFheVestingFactoryAddress(chainId));
450
450
  if (!resolved) {
451
451
  throw new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
452
452
  reason: chainId === void 0 ? "chain-id-missing" : "registry-not-deployed",