@tokenops/sdk 2.0.0-alpha.2 → 2.0.0-alpha.4

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 (160) hide show
  1. package/CHANGELOG.md +92 -3
  2. package/README.md +76 -34
  3. package/SUPPORT.md +1 -1
  4. package/dist/{chunk-PYYSB5ZN.js → chunk-2ND7US2I.js} +1 -1
  5. package/dist/{chunk-EYDA6Q6C.js → chunk-3ZSPRHR3.js} +63 -12
  6. package/dist/{chunk-X7WBPCEU.js → chunk-67Q6KSVV.js} +4578 -3383
  7. package/dist/{chunk-UHHMVBLU.cjs → chunk-6AYJRUGP.cjs} +7 -50
  8. package/dist/{chunk-FEDX7B6T.cjs → chunk-6FUHF73F.cjs} +5 -5
  9. package/dist/{chunk-NWFMBLSQ.js → chunk-7KY4K4PH.js} +1 -1
  10. package/dist/{chunk-FHWSBGWE.cjs → chunk-ARZ5C3FS.cjs} +7 -7
  11. package/dist/{chunk-SPLNGUFF.js → chunk-AX6MQAWU.js} +2 -2
  12. package/dist/{chunk-IGO5XSPS.js → chunk-BSXEX2SH.js} +3 -3
  13. package/dist/{chunk-44YJPMQC.js → chunk-CHGY6B7L.js} +34 -81
  14. package/dist/{chunk-IUKKNJ2R.cjs → chunk-DFK5GCJP.cjs} +55 -72
  15. package/dist/{chunk-PZZK3O3S.cjs → chunk-E4IV4M4E.cjs} +4598 -3403
  16. package/dist/{chunk-A4DCEE33.js → chunk-GHGF65LN.js} +16 -12
  17. package/dist/{chunk-TWT3STIX.js → chunk-K3R27WX4.js} +8 -46
  18. package/dist/{chunk-GADGBQJO.js → chunk-KJUNBOJQ.js} +52 -71
  19. package/dist/{chunk-MM5BV5CS.cjs → chunk-PO3A2AQX.cjs} +4 -4
  20. package/dist/{chunk-EBLBPUPI.cjs → chunk-QHDMPT7I.cjs} +72 -19
  21. package/dist/{chunk-3YHBO2DL.cjs → chunk-S47IBDTA.cjs} +36 -83
  22. package/dist/{chunk-UG5RKLU2.cjs → chunk-SUYBAF27.cjs} +1 -1
  23. package/dist/{chunk-WJMEBBU7.js → chunk-TWU7L5H7.js} +5 -48
  24. package/dist/{chunk-WJLECC22.cjs → chunk-UUSSWOPR.cjs} +9 -47
  25. package/dist/{chunk-AREQJHKA.cjs → chunk-VHKMWWBA.cjs} +428 -22
  26. package/dist/{chunk-FT5H2Q7Y.cjs → chunk-YAL6JSAZ.cjs} +16 -12
  27. package/dist/{chunk-VW356KR3.js → chunk-YMWMIWBP.js} +421 -25
  28. package/dist/core/addresses.d.ts +4 -4
  29. package/dist/core/errors.d.ts +1 -1
  30. package/dist/core/index.d.ts +1 -0
  31. package/dist/core/pending.d.ts +57 -0
  32. package/dist/core/version.d.ts +1 -1
  33. package/dist/fhe/operators.d.ts +6 -5
  34. package/dist/fhe/types.d.ts +1 -1
  35. package/dist/fhe-airdrop/abis/airdrop-base.d.ts +97 -1
  36. package/dist/fhe-airdrop/abis/ecdsa.d.ts +117 -1
  37. package/dist/fhe-airdrop/abis/factory.d.ts +332 -1
  38. package/dist/fhe-airdrop/abis/merkle.d.ts +116 -1
  39. package/dist/fhe-airdrop/advanced/index.cjs +8 -4
  40. package/dist/fhe-airdrop/advanced/index.d.cts +1 -0
  41. package/dist/fhe-airdrop/advanced/index.d.ts +1 -0
  42. package/dist/fhe-airdrop/advanced/index.js +1 -1
  43. package/dist/fhe-airdrop/advanced/react/index.cjs +145 -137
  44. package/dist/fhe-airdrop/advanced/react/index.d.cts +1 -0
  45. package/dist/fhe-airdrop/advanced/react/index.d.ts +1 -0
  46. package/dist/fhe-airdrop/advanced/react/index.js +85 -78
  47. package/dist/fhe-airdrop/advanced/react/useClearCompliancePolicy.d.ts +3 -1
  48. package/dist/fhe-airdrop/advanced/react/useDisableCustomFee.d.ts +4 -1
  49. package/dist/fhe-airdrop/advanced/react/useFactoryComplianceDelegate.d.ts +2 -4
  50. package/dist/fhe-airdrop/advanced/react/useFactoryRenounceRole.d.ts +4 -3
  51. package/dist/fhe-airdrop/advanced/react/useFactoryRevokeRole.d.ts +9 -7
  52. package/dist/fhe-airdrop/advanced/react/useFactoryRoleMembers.d.ts +6 -5
  53. package/dist/fhe-airdrop/advanced/react/useSetComplianceDelegate.d.ts +7 -7
  54. package/dist/fhe-airdrop/advanced/react/useSetComplianceManagerImpl.d.ts +3 -1
  55. package/dist/fhe-airdrop/advanced/react/useSetCompliancePolicy.d.ts +2 -1
  56. package/dist/fhe-airdrop/advanced/react/useSetCustomFee.d.ts +4 -1
  57. package/dist/fhe-airdrop/advanced/react/useSetDefaultDelegateToCompliance.d.ts +5 -4
  58. package/dist/fhe-airdrop/advanced/react/useSetDefaultGasFee.d.ts +7 -3
  59. package/dist/fhe-airdrop/advanced/react/useSetMaxGasFee.d.ts +37 -0
  60. package/dist/fhe-airdrop/airdrop-base.d.ts +142 -18
  61. package/dist/fhe-airdrop/campaign.d.ts +37 -73
  62. package/dist/fhe-airdrop/compliance-clone.d.ts +21 -0
  63. package/dist/fhe-airdrop/constants.d.ts +11 -1
  64. package/dist/fhe-airdrop/ecdsa.d.ts +79 -26
  65. package/dist/fhe-airdrop/encryption.d.ts +19 -6
  66. package/dist/fhe-airdrop/errors.d.ts +136 -2
  67. package/dist/fhe-airdrop/factory-params.d.ts +2361 -0
  68. package/dist/fhe-airdrop/factory.d.ts +189 -75
  69. package/dist/fhe-airdrop/guards.d.ts +183 -19
  70. package/dist/fhe-airdrop/index.cjs +88 -56
  71. package/dist/fhe-airdrop/index.d.cts +12 -10
  72. package/dist/fhe-airdrop/index.d.ts +12 -10
  73. package/dist/fhe-airdrop/index.js +5 -5
  74. package/dist/fhe-airdrop/merkle-tree.d.ts +9 -9
  75. package/dist/fhe-airdrop/merkle.d.ts +32 -11
  76. package/dist/fhe-airdrop/react/_shared.d.ts +12 -6
  77. package/dist/fhe-airdrop/react/index.cjs +336 -240
  78. package/dist/fhe-airdrop/react/index.d.cts +19 -9
  79. package/dist/fhe-airdrop/react/index.d.ts +19 -9
  80. package/dist/fhe-airdrop/react/index.js +158 -97
  81. package/dist/fhe-airdrop/react/keys.d.ts +54 -7
  82. package/dist/fhe-airdrop/react/useAccessEcdsaClaimAmount.d.ts +6 -3
  83. package/dist/fhe-airdrop/react/useAccessMerkleClaimAmount.d.ts +2 -2
  84. package/dist/fhe-airdrop/react/useAirdropConfig.d.ts +8 -3
  85. package/dist/fhe-airdrop/react/useAirdropPause.d.ts +5 -0
  86. package/dist/fhe-airdrop/react/useBuildMerkleCampaign.d.ts +4 -6
  87. package/dist/fhe-airdrop/react/useComplianceManager.d.ts +2 -2
  88. package/dist/fhe-airdrop/react/useComplianceManagerOf.d.ts +1 -2
  89. package/dist/fhe-airdrop/react/useCreateAndFundEcdsaAirdrop.d.ts +16 -11
  90. package/dist/fhe-airdrop/react/useCreateAndFundMerkleAirdrop.d.ts +23 -7
  91. package/dist/fhe-airdrop/react/useCreateEcdsaAirdrop.d.ts +13 -8
  92. package/dist/fhe-airdrop/react/useCreateMerkleAirdrop.d.ts +27 -7
  93. package/dist/fhe-airdrop/react/useDedupMode.d.ts +16 -0
  94. package/dist/fhe-airdrop/react/useDiscloseHandleToParty.d.ts +4 -3
  95. package/dist/fhe-airdrop/react/useEcdsaClaim.d.ts +6 -4
  96. package/dist/fhe-airdrop/react/useEcdsaClaimAndUnwrap.d.ts +15 -8
  97. package/dist/fhe-airdrop/react/useEcdsaDomain.d.ts +1 -1
  98. package/dist/fhe-airdrop/react/useEncryptCampaignAmounts.d.ts +5 -7
  99. package/dist/fhe-airdrop/react/useExtendClaimWindow.d.ts +4 -1
  100. package/dist/fhe-airdrop/react/useFactoryFees.d.ts +11 -4
  101. package/dist/fhe-airdrop/react/useFundAirdrop.d.ts +3 -4
  102. package/dist/fhe-airdrop/react/useGrantInstanceRoles.d.ts +2 -1
  103. package/dist/fhe-airdrop/react/useIsAirdrop.d.ts +44 -0
  104. package/dist/fhe-airdrop/react/useIsSignatureValid.d.ts +5 -4
  105. package/dist/fhe-airdrop/react/useMerkleClaim.d.ts +4 -1
  106. package/dist/fhe-airdrop/react/useMerkleClaimAndUnwrap.d.ts +14 -3
  107. package/dist/fhe-airdrop/react/usePlanMerkleCampaign.d.ts +18 -3
  108. package/dist/fhe-airdrop/react/usePreflightClaim.d.ts +1 -1
  109. package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +34 -13
  110. package/dist/fhe-airdrop/react/useRefreshComplianceBalance.d.ts +36 -0
  111. package/dist/fhe-airdrop/react/useRescueERC20.d.ts +3 -3
  112. package/dist/fhe-airdrop/react/useRescueNativeToken.d.ts +23 -0
  113. package/dist/fhe-airdrop/react/useResolveGasFee.d.ts +30 -0
  114. package/dist/fhe-airdrop/react/useRotateMerkleRoot.d.ts +5 -2
  115. package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +4 -0
  116. package/dist/fhe-airdrop/react/useTokenOf.d.ts +29 -0
  117. package/dist/fhe-airdrop/react/useUnwrapRequest.d.ts +25 -0
  118. package/dist/fhe-airdrop/react/useWithdrawConfidential.d.ts +4 -0
  119. package/dist/fhe-airdrop/roles.d.ts +82 -7
  120. package/dist/fhe-airdrop/types.d.ts +122 -14
  121. package/dist/fhe-disperse/errors.d.ts +3 -3
  122. package/dist/fhe-disperse/index.cjs +22 -22
  123. package/dist/fhe-disperse/index.d.cts +2 -1
  124. package/dist/fhe-disperse/index.d.ts +2 -1
  125. package/dist/fhe-disperse/index.js +3 -3
  126. package/dist/fhe-disperse/react/index.cjs +27 -25
  127. package/dist/fhe-disperse/react/index.d.cts +2 -1
  128. package/dist/fhe-disperse/react/index.d.ts +2 -1
  129. package/dist/fhe-disperse/react/index.js +8 -6
  130. package/dist/fhe-disperse/react/useDisperse.d.ts +6 -2
  131. package/dist/fhe-disperse/react/useRegister.d.ts +9 -3
  132. package/dist/fhe-disperse/react/useSingletonWithdrawTokenFee.d.ts +7 -2
  133. package/dist/fhe-disperse/react/useWithdrawTokenFee.d.ts +7 -2
  134. package/dist/fhe-disperse/singleton.d.ts +33 -19
  135. package/dist/fhe-disperse/types.d.ts +48 -8
  136. package/dist/fhe-vesting/advanced/index.cjs +6 -6
  137. package/dist/fhe-vesting/advanced/index.js +4 -4
  138. package/dist/fhe-vesting/advanced/react/index.cjs +9 -9
  139. package/dist/fhe-vesting/advanced/react/index.js +6 -6
  140. package/dist/fhe-vesting/factory.d.ts +31 -8
  141. package/dist/fhe-vesting/index.cjs +23 -23
  142. package/dist/fhe-vesting/index.d.cts +3 -2
  143. package/dist/fhe-vesting/index.d.ts +3 -2
  144. package/dist/fhe-vesting/index.js +4 -4
  145. package/dist/fhe-vesting/manager.d.ts +27 -2
  146. package/dist/fhe-vesting/react/index.cjs +126 -126
  147. package/dist/fhe-vesting/react/index.d.cts +3 -2
  148. package/dist/fhe-vesting/react/index.d.ts +3 -2
  149. package/dist/fhe-vesting/react/index.js +5 -5
  150. package/dist/fhe-vesting/react/useCreateManager.d.ts +16 -9
  151. package/dist/fhe-vesting/react/useCreateManagerAndGetAddress.d.ts +9 -5
  152. package/dist/fhe-vesting/react/useSplitVesting.d.ts +9 -3
  153. package/dist/index.cjs +18 -18
  154. package/dist/index.js +1 -1
  155. package/dist/testnet-faucet/faucet.d.ts +3 -0
  156. package/dist/testnet-faucet/index.cjs +15 -15
  157. package/dist/testnet-faucet/index.js +3 -3
  158. package/dist/testnet-faucet/react/index.cjs +9 -9
  159. package/dist/testnet-faucet/react/index.js +4 -4
  160. package/package.json +1 -1
@@ -5,9 +5,13 @@ var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
5
5
  var viem = require('viem');
6
6
 
7
7
  // src/fhe-airdrop/constants.ts
8
- var AIRDROP_CONTRACTS_COMMIT = "7175ac82f467f0f88c05aba1a4536892999b4251";
8
+ var AIRDROP_CONTRACTS_COMMIT = "005980df194e0dc66053bd517e9759bd4d580047";
9
9
  var DEPLOYMENT_MODE = { clone: 0, uups: 1 };
10
10
  var DEDUP_MODE = { perAddress: 0, perDedupId: 1, both: 2, none: 3 };
11
+ var DEDUP_MODE_BY_ORDINAL = new Map(
12
+ Object.keys(DEDUP_MODE).map((mode) => [DEDUP_MODE[mode], mode])
13
+ );
14
+ var UINT96_MAX = (1n << 96n) - 1n;
11
15
 
12
16
  // src/fhe-airdrop/errors.ts
13
17
  var MerkleUupsUnsupportedError = class extends chunk67OV5CX2_cjs.TokenOpsSdkError {
@@ -96,6 +100,43 @@ var PredictionDriftError = class extends chunk67OV5CX2_cjs.TokenOpsSdkError {
96
100
  );
97
101
  }
98
102
  };
103
+ var CreateCommitmentMismatchError = class extends chunk67OV5CX2_cjs.TokenOpsSdkError {
104
+ name = "CreateCommitmentMismatchError";
105
+ constructor(args) {
106
+ const rebuild = args.field === "airdrop" ? " Anything bound to the old prediction (Merkle leaves, vouchers, encrypted inputs) must be rebuilt." : "";
107
+ const { cause, ...context } = args;
108
+ super(
109
+ `${args.method}: the factory would deploy with ${args.field} = ${args.actual ?? "?"}, but the create committed to ${args.expected ?? "?"}. Nothing was deployed and the salt is unused; re-quote and retry.${rebuild}`,
110
+ { code: "TOKENOPS_CREATE_COMMITMENT_MISMATCH", cause, context }
111
+ );
112
+ }
113
+ };
114
+ var ClawbackRequiresPauseError = class extends chunk67OV5CX2_cjs.TokenOpsSdkError {
115
+ name = "ClawbackRequiresPauseError";
116
+ constructor(args) {
117
+ super(
118
+ `${args.method}: withdrawConfidential is refused while the campaign is unpaused inside its claim window. Pause first (PAUSER_ROLE), or run it outside the window (before startTime or after endTime).`,
119
+ {
120
+ code: "TOKENOPS_CLAWBACK_REQUIRES_PAUSE",
121
+ cause: args.cause,
122
+ context: { method: args.method, contractAddress: args.contractAddress }
123
+ }
124
+ );
125
+ }
126
+ };
127
+ var NativeRescueRequiresZeroFeeError = class extends chunk67OV5CX2_cjs.TokenOpsSdkError {
128
+ name = "NativeRescueRequiresZeroFeeError";
129
+ constructor(args) {
130
+ super(
131
+ `${args.method}: rescueNativeToken is only available on a zero-fee campaign; this instance charges a gas fee, so its ETH is fee revenue - use withdrawGasFee.`,
132
+ {
133
+ code: "TOKENOPS_NATIVE_RESCUE_REQUIRES_ZERO_FEE",
134
+ cause: args.cause,
135
+ context: { method: args.method, contractAddress: args.contractAddress }
136
+ }
137
+ );
138
+ }
139
+ };
99
140
  var UpgradeabilityNotAllowedError = class extends chunk67OV5CX2_cjs.TokenOpsSdkError {
100
141
  name = "UpgradeabilityNotAllowedError";
101
142
  constructor(args) {
@@ -205,6 +246,42 @@ var ClaimWindowClosedError = class extends chunk67OV5CX2_cjs.TokenOpsSdkError {
205
246
  });
206
247
  }
207
248
  };
249
+ var GasFeeNotAcceptedError = class extends chunk67OV5CX2_cjs.TokenOpsSdkError {
250
+ name = "GasFeeNotAcceptedError";
251
+ constructor(args) {
252
+ const detail = args.resolvedFee !== void 0 && args.maxAcceptedGasFee !== void 0 ? ` The factory resolved ${args.resolvedFee} wei; \`maxAcceptedGasFee\` is ${args.maxAcceptedGasFee} wei.` : "";
253
+ super(
254
+ `${args.method}: the resolved per-claim gas fee exceeds \`common.maxAcceptedGasFee\`.${detail} The fee is frozen into the instance at create and cannot be changed after. Every claimant pays it on every claim, so raise the bound only if that is a fee you accept charging them.`,
255
+ {
256
+ code: "TOKENOPS_GAS_FEE_NOT_ACCEPTED",
257
+ cause: args.cause,
258
+ context: {
259
+ method: args.method,
260
+ contractAddress: args.contractAddress,
261
+ resolvedFee: args.resolvedFee,
262
+ maxAcceptedGasFee: args.maxAcceptedGasFee
263
+ }
264
+ }
265
+ );
266
+ }
267
+ };
268
+ var UnrecognisedAirdropError = class extends chunk67OV5CX2_cjs.TokenOpsSdkError {
269
+ name = "UnrecognisedAirdropError";
270
+ constructor(args) {
271
+ super(
272
+ `${args.method}: ${args.contractAddress} was not created by the factory at ${args.factory}, so it is not a TokenOps airdrop. Treat its ABI, its events and its pool as unverified.`,
273
+ {
274
+ code: "TOKENOPS_UNRECOGNISED_AIRDROP",
275
+ cause: args.cause,
276
+ context: {
277
+ method: args.method,
278
+ contractAddress: args.contractAddress,
279
+ factory: args.factory
280
+ }
281
+ }
282
+ );
283
+ }
284
+ };
208
285
  var airdropProductMapper = (name, errArgs, ctx) => {
209
286
  switch (name) {
210
287
  // ---- guarded conditions, caught on-chain instead of pre-flight -------
@@ -252,12 +329,16 @@ var airdropProductMapper = (name, errArgs, ctx) => {
252
329
  return new chunk67OV5CX2_cjs.FheHandleNotAllowedError({ ...ctx, handle });
253
330
  }
254
331
  // ---- Merkle-specific ----------------------------------------------
255
- case "InvalidMerkleProof":
332
+ case "InvalidMerkleProof": {
333
+ const leaf = errArgs?.[0];
334
+ const merkleRoot = errArgs?.[1];
256
335
  return new chunk67OV5CX2_cjs.InvalidArgumentError({
257
336
  method: ctx.method,
258
337
  argument: "merkleProof",
259
- reason: "the contract reverted with `InvalidMerkleProof` \u2014 the proof does not verify against the current on-chain root. If the root was recently rotated, rebuild the proof against the new root."
338
+ reason: "the contract reverted with `InvalidMerkleProof` \u2014 the proof does not verify against the current on-chain root. If the root was recently rotated, rebuild the proof against the new root.",
339
+ ...leaf !== void 0 || merkleRoot !== void 0 ? { value: { leaf, merkleRoot } } : {}
260
340
  });
341
+ }
261
342
  case "RootImmutable":
262
343
  return new chunk67OV5CX2_cjs.FeatureDisabledError({ ...ctx, feature: "merkleRootRotation" });
263
344
  case "ZeroAccount":
@@ -289,6 +370,25 @@ var airdropProductMapper = (name, errArgs, ctx) => {
289
370
  }
290
371
  // ---- argument-validation bucket: reverts not already covered by the
291
372
  // cross-product default mapper's `Zero*`/`Invalid*` list ---------------
373
+ case "GasFeeNotAccepted": {
374
+ const resolvedFee = errArgs?.[0];
375
+ const maxAcceptedGasFee = errArgs?.[1];
376
+ return new GasFeeNotAcceptedError({ ...ctx, resolvedFee, maxAcceptedGasFee });
377
+ }
378
+ case "GasFeeExceedsMaximum": {
379
+ return gasFeeExceedsMaximumError({
380
+ method: ctx.method,
381
+ gasFee: errArgs?.[0],
382
+ maxGasFee: errArgs?.[1]
383
+ });
384
+ }
385
+ case "ZeroUnwrapRequestId":
386
+ return invalidArg(
387
+ ctx,
388
+ "token",
389
+ name,
390
+ "the wrapper returned the zero request id, which names no handle to read the delivered amount from; the campaign token is not a conforming ERC7984ERC20Wrapper"
391
+ );
292
392
  case "ZeroToken":
293
393
  return invalidArg(ctx, "token", name);
294
394
  case "ZeroFeeCollector":
@@ -321,7 +421,7 @@ var airdropProductMapper = (name, errArgs, ctx) => {
321
421
  ctx,
322
422
  "admin",
323
423
  name,
324
- "revoking or renouncing the sole DEFAULT_ADMIN_ROLE member would leave the instance permanently ungovernable"
424
+ "revoking or renouncing the sole DEFAULT_ADMIN_ROLE member would leave the contract permanently ungovernable. Declared once and enforced by BOTH the instances and the factory, each on its own admin set (audit-14) - grant a second admin first, then renounce"
325
425
  );
326
426
  case "LastFeeCollector":
327
427
  return invalidArg(
@@ -345,7 +445,7 @@ var airdropProductMapper = (name, errArgs, ctx) => {
345
445
  ctx,
346
446
  "complianceDelegate",
347
447
  name,
348
- "required while the default compliance-delegate policy is on"
448
+ "the factory requires a non-zero delegate (constructor, setter and create)"
349
449
  );
350
450
  case "IndexOutOfBounds": {
351
451
  const index = errArgs?.[0];
@@ -368,6 +468,48 @@ var airdropProductMapper = (name, errArgs, ctx) => {
368
468
  value: existingAirdrop
369
469
  });
370
470
  }
471
+ case "PredictionMismatch":
472
+ case "ManagerImplementationMismatch":
473
+ case "ComplianceDelegateMismatch": {
474
+ const field = name === "PredictionMismatch" ? "airdrop" : name === "ManagerImplementationMismatch" ? "complianceManagerImpl" : "complianceDelegate";
475
+ return new CreateCommitmentMismatchError({
476
+ method: ctx.method,
477
+ contractAddress: ctx.contractAddress,
478
+ field,
479
+ expected: errArgs?.[0],
480
+ actual: errArgs?.[1]
481
+ });
482
+ }
483
+ case "InvalidImplementation":
484
+ return invalidArg(ctx, "implementation", name, void 0, errArgs?.[0]);
485
+ case "EndTimeInPast": {
486
+ const endTime = numberArg(errArgs?.[0]);
487
+ const currentTime = numberArg(errArgs?.[1]);
488
+ return invalidArg(
489
+ ctx,
490
+ "endTime",
491
+ name,
492
+ endTime !== void 0 && currentTime !== void 0 ? `endTime ${endTime} is not after the chain time ${currentTime}` : void 0,
493
+ endTime !== void 0 || currentTime !== void 0 ? { endTime, currentTime } : void 0
494
+ );
495
+ }
496
+ case "InvalidDuration": {
497
+ const fromTime = numberArg(errArgs?.[0]);
498
+ const toTime = numberArg(errArgs?.[1]);
499
+ return invalidArg(
500
+ ctx,
501
+ "duration",
502
+ name,
503
+ fromTime !== void 0 && toTime !== void 0 ? `${toTime} does not come after ${fromTime}` : void 0,
504
+ fromTime !== void 0 || toTime !== void 0 ? { fromTime, toTime } : void 0
505
+ );
506
+ }
507
+ case "UninitializedHandle":
508
+ return invalidArg(ctx, "handle", name);
509
+ case "ClawbackRequiresPause":
510
+ return new ClawbackRequiresPauseError(ctx);
511
+ case "NativeRescueRequiresZeroFee":
512
+ return new NativeRescueRequiresZeroFeeError(ctx);
371
513
  case "ZeroSigner":
372
514
  return invalidArg(ctx, "signer", name);
373
515
  case "ZeroMerkleRoot":
@@ -375,7 +517,7 @@ var airdropProductMapper = (name, errArgs, ctx) => {
375
517
  ctx,
376
518
  "merkleRoot",
377
519
  name,
378
- "a zero root is only permitted when `isMerkleRootMutable` is true"
520
+ "a zero root is permitted only at create on a mutable-root campaign, and never as a rotation target"
379
521
  );
380
522
  // ---- compliance manager clone (`ComplianceRoleManager`) --------------
381
523
  case "ZeroAirdrop":
@@ -415,15 +557,26 @@ var airdropProductMapper = (name, errArgs, ctx) => {
415
557
  return void 0;
416
558
  }
417
559
  };
418
- function invalidArg(ctx, argument, revertName, detail) {
560
+ function gasFeeExceedsMaximumError(args) {
561
+ const { gasFee, maxGasFee } = args;
562
+ return new chunk67OV5CX2_cjs.InvalidArgumentError({
563
+ method: args.method,
564
+ argument: "gasFee",
565
+ reason: `exceeds the factory's own maximum${gasFee !== void 0 && maxGasFee !== void 0 ? ` (${gasFee} wei > ${maxGasFee} wei)` : ""}; \`setMaxGasFee\` is DEFAULT_ADMIN_ROLE-gated and bounds what FEE_MANAGER_ROLE may configure`,
566
+ value: gasFee
567
+ });
568
+ }
569
+ function invalidArg(ctx, argument, revertName, detail, value) {
419
570
  const suffix = detail ? ` ${detail}.` : "";
420
571
  return new chunk67OV5CX2_cjs.InvalidArgumentError({
421
572
  method: ctx.method,
422
573
  argument,
423
- reason: `the contract reverted with \`${revertName}\`.${suffix}`
574
+ reason: `the contract reverted with \`${revertName}\`.${suffix}`,
575
+ ...value !== void 0 ? { value } : {}
424
576
  });
425
577
  }
426
578
  function numberArg(value) {
579
+ if (typeof value === "number") return value;
427
580
  return typeof value === "bigint" ? Number(value) : void 0;
428
581
  }
429
582
  var SUPPORTED_CHAIN_IDS = [1, 11155111, 31337];
@@ -480,6 +633,39 @@ async function assertSaltAvailable(args) {
480
633
  predictedAddress: args.predictedAddress
481
634
  });
482
635
  }
636
+ function assertMaxAcceptedGasFeeRange(value, method) {
637
+ if (value < 0n || value > UINT96_MAX) {
638
+ throw new chunk67OV5CX2_cjs.InvalidArgumentError({
639
+ method,
640
+ argument: "common.maxAcceptedGasFee",
641
+ reason: `is outside uint96 (0 to ${UINT96_MAX}); the params tuple cannot be ABI-encoded at all`,
642
+ value
643
+ });
644
+ }
645
+ }
646
+ function assertWithinCeiling(method, resolvedFee, maxGasFee) {
647
+ if (resolvedFee > maxGasFee) {
648
+ throw gasFeeExceedsMaximumError({ method, gasFee: resolvedFee, maxGasFee });
649
+ }
650
+ }
651
+ function assertResolvedFeeAccepted(args, resolvedFee) {
652
+ if (resolvedFee <= args.maxAcceptedGasFee) return;
653
+ throw new GasFeeNotAcceptedError({
654
+ method: args.method,
655
+ contractAddress: args.factory.address,
656
+ resolvedFee,
657
+ maxAcceptedGasFee: args.maxAcceptedGasFee
658
+ });
659
+ }
660
+ async function assertCreateGasFee(args) {
661
+ assertMaxAcceptedGasFeeRange(args.maxAcceptedGasFee, args.method);
662
+ const [resolvedFee, maxGasFee] = await Promise.all([
663
+ args.factory.resolveGasFee(args.creator),
664
+ args.factory.maxGasFee()
665
+ ]);
666
+ assertWithinCeiling(args.method, resolvedFee, maxGasFee);
667
+ assertResolvedFeeAccepted(args, resolvedFee);
668
+ }
483
669
  function assertPredictionFresh(args) {
484
670
  if (args.initCodeHashBefore.toLowerCase() === args.initCodeHashAfter.toLowerCase()) return;
485
671
  throw new PredictionDriftError({
@@ -490,6 +676,112 @@ function assertPredictionFresh(args) {
490
676
  predictedAddress: args.predictedAddress
491
677
  });
492
678
  }
679
+ var END_TIME_MARGIN_SECONDS = 60;
680
+ function invalidCreateParam(method, argument, revertName, reason, value) {
681
+ return new chunk67OV5CX2_cjs.InvalidArgumentError({
682
+ method,
683
+ argument,
684
+ reason: `${reason}; the instance initializer reverts \`${revertName}\``,
685
+ value
686
+ });
687
+ }
688
+ function assertCreateParamsWellFormed(args, method) {
689
+ const { common } = args.params;
690
+ if (viem.isAddressEqual(common.token, viem.zeroAddress)) {
691
+ throw invalidCreateParam(
692
+ method,
693
+ "common.token",
694
+ "ZeroToken",
695
+ "is the zero address",
696
+ common.token
697
+ );
698
+ }
699
+ const now = Math.floor(Date.now() / 1e3);
700
+ if (common.endTime <= now + END_TIME_MARGIN_SECONDS) {
701
+ throw invalidCreateParam(
702
+ method,
703
+ "common.endTime",
704
+ "EndTimeInPast",
705
+ `is not at least ${END_TIME_MARGIN_SECONDS}s in the future`,
706
+ common.endTime
707
+ );
708
+ }
709
+ if (common.startTime > common.endTime) {
710
+ throw invalidCreateParam(
711
+ method,
712
+ "common.startTime",
713
+ "InvalidStartTime",
714
+ "is after `endTime`",
715
+ common.startTime
716
+ );
717
+ }
718
+ if (common.startTime === common.endTime) {
719
+ throw invalidCreateParam(
720
+ method,
721
+ "common.startTime",
722
+ "InvalidDuration",
723
+ "equals `endTime`, leaving a zero-length claim window",
724
+ common.startTime
725
+ );
726
+ }
727
+ if (args.variant === "merkle") {
728
+ const { merkleRoot, isMerkleRootMutable } = args.params;
729
+ if (!isMerkleRootMutable && BigInt(merkleRoot) === 0n) {
730
+ throw invalidCreateParam(
731
+ method,
732
+ "merkleRoot",
733
+ "ZeroMerkleRoot",
734
+ "is zero on an immutable-root campaign, so no claim could ever verify",
735
+ merkleRoot
736
+ );
737
+ }
738
+ } else if (viem.isAddressEqual(args.params.signer, viem.zeroAddress)) {
739
+ throw invalidCreateParam(
740
+ method,
741
+ "signer",
742
+ "ZeroSigner",
743
+ "is the zero address",
744
+ args.params.signer
745
+ );
746
+ }
747
+ }
748
+ function resolvePlannedCreate(args) {
749
+ const { method, params, expected, expectedInitCodeHash, plan } = args;
750
+ if (!plan) return { expected, expectedInitCodeHash };
751
+ if (params.merkleRoot.toLowerCase() !== plan.root.toLowerCase()) {
752
+ throw new chunk67OV5CX2_cjs.InvalidArgumentError({
753
+ method,
754
+ argument: "params.merkleRoot",
755
+ reason: "differs from plan.root; the plan's entries verify only against the root they were built into",
756
+ value: params.merkleRoot
757
+ });
758
+ }
759
+ if (expected?.airdrop !== void 0 && !viem.isAddressEqual(expected.airdrop, plan.predictedAddress)) {
760
+ throw new chunk67OV5CX2_cjs.InvalidArgumentError({
761
+ method,
762
+ argument: "expected.airdrop",
763
+ reason: "differs from plan.predictedAddress; a plan's leaves are bound to its predicted address, so the two cannot name different instances",
764
+ value: expected.airdrop
765
+ });
766
+ }
767
+ if (expectedInitCodeHash !== void 0 && expectedInitCodeHash.toLowerCase() !== plan.initCodeHashAfter.toLowerCase()) {
768
+ throw new chunk67OV5CX2_cjs.InvalidArgumentError({
769
+ method,
770
+ argument: "expectedInitCodeHash",
771
+ reason: "differs from plan.initCodeHashAfter; pass one or the other",
772
+ value: expectedInitCodeHash
773
+ });
774
+ }
775
+ return {
776
+ expected: { ...definedFields(expected), airdrop: plan.predictedAddress },
777
+ expectedInitCodeHash: plan.initCodeHashAfter
778
+ };
779
+ }
780
+ var COMMITMENT_FIELDS = ["airdrop", "complianceManagerImpl", "complianceDelegate"];
781
+ function definedFields(pinned) {
782
+ if (!pinned) return {};
783
+ return Object.fromEntries(Object.entries(pinned).filter(([, value]) => value !== void 0));
784
+ }
493
785
  async function preflightCreate(args) {
494
786
  const method = args.variant === "merkle" ? "createMerkleAirdrop" : "createEcdsaAirdrop";
495
787
  const blockers = [];
@@ -497,6 +789,39 @@ async function preflightCreate(args) {
497
789
  if (args.variant === "merkle") {
498
790
  collect(blockers, () => assertMerkleModeSupported(args.mode));
499
791
  }
792
+ const encodable = collect(
793
+ blockers,
794
+ () => assertMaxAcceptedGasFeeRange(args.params.common.maxAcceptedGasFee, method)
795
+ );
796
+ if (!encodable) return { ready: false, blockers };
797
+ collect(blockers, () => assertCreateParamsWellFormed(args, method));
798
+ let pins = { expected: args.expected, expectedInitCodeHash: args.expectedInitCodeHash };
799
+ if (args.variant === "merkle") {
800
+ const { params, plan } = args;
801
+ collect(blockers, () => {
802
+ pins = resolvePlannedCreate({ method, params, ...pins, plan });
803
+ });
804
+ }
805
+ const { expected, expectedInitCodeHash } = pins;
806
+ await collectAsync(blockers, async () => {
807
+ const [resolvedFee, maxGasFee] = await Promise.all([
808
+ args.factory.resolveGasFee(args.creator),
809
+ args.factory.maxGasFee()
810
+ ]);
811
+ collect(blockers, () => assertWithinCeiling(method, resolvedFee, maxGasFee));
812
+ collect(
813
+ blockers,
814
+ () => assertResolvedFeeAccepted(
815
+ {
816
+ factory: args.factory,
817
+ creator: args.creator,
818
+ maxAcceptedGasFee: args.params.common.maxAcceptedGasFee,
819
+ method
820
+ },
821
+ resolvedFee
822
+ )
823
+ );
824
+ });
500
825
  const predictArgs = {
501
826
  mode: args.mode,
502
827
  deployer: args.creator,
@@ -528,7 +853,7 @@ async function preflightCreate(args) {
528
853
  blockers,
529
854
  () => assertSaltAvailable({
530
855
  publicClient: args.factory.publicClient,
531
- predictedAddress,
856
+ predictedAddress: expected?.airdrop ?? predictedAddress,
532
857
  variant: args.variant,
533
858
  mode: args.mode,
534
859
  deployer: args.creator,
@@ -536,25 +861,74 @@ async function preflightCreate(args) {
536
861
  method
537
862
  })
538
863
  );
539
- if (args.expectedInitCodeHash !== void 0) {
864
+ if (expectedInitCodeHash !== void 0) {
865
+ const initCodeHashBefore = expectedInitCodeHash;
540
866
  collect(
541
867
  blockers,
542
868
  () => assertPredictionFresh({
543
869
  variant: args.variant,
544
- initCodeHashBefore: args.expectedInitCodeHash,
870
+ initCodeHashBefore,
545
871
  initCodeHashAfter: liveInitCodeHash,
546
- predictedAddress,
872
+ predictedAddress: expected?.airdrop ?? predictedAddress,
547
873
  method
548
874
  })
549
875
  );
550
876
  }
551
- return { ready: blockers.length === 0, blockers };
877
+ const pinned = Object.keys(definedFields(expected)).length > 0;
878
+ let fresh;
879
+ try {
880
+ fresh = await args.factory.quoteCreateCommitments({
881
+ ...args.variant === "merkle" ? { variant: "merkle", params: args.params } : { variant: "ecdsa", params: args.params },
882
+ mode: args.mode,
883
+ deployer: args.creator,
884
+ userSalt: args.userSalt,
885
+ expected: { airdrop: predictedAddress }
886
+ });
887
+ } catch (err) {
888
+ if (pinned) {
889
+ if (!chunk67OV5CX2_cjs.isTokenOpsSdkError(err)) throw err;
890
+ blockers.push(err);
891
+ }
892
+ }
893
+ let commitments;
894
+ if (fresh) {
895
+ commitments = { ...fresh, ...definedFields(expected) };
896
+ for (const field of COMMITMENT_FIELDS) {
897
+ const pinned2 = expected?.[field];
898
+ if (pinned2 === void 0 || viem.isAddressEqual(pinned2, fresh[field])) continue;
899
+ blockers.push(
900
+ new CreateCommitmentMismatchError({
901
+ method,
902
+ contractAddress: args.factory.address,
903
+ field,
904
+ expected: pinned2,
905
+ actual: fresh[field]
906
+ })
907
+ );
908
+ }
909
+ }
910
+ return { ready: blockers.length === 0, blockers, ...commitments ? { commitments } : {} };
911
+ }
912
+ async function assertKnownAirdrop(args) {
913
+ if (args.factory.chainId !== args.chainId) {
914
+ throw new chunk67OV5CX2_cjs.InvalidArgumentError({
915
+ method: args.method,
916
+ argument: "factory",
917
+ reason: `is bound to chain ${args.factory.chainId} but the airdrop is on chain ${args.chainId}; a registry answer from another chain proves nothing about this instance`,
918
+ value: args.factory.address
919
+ });
920
+ }
921
+ if (await args.factory.isAirdrop(args.airdrop)) return;
922
+ throw new UnrecognisedAirdropError({
923
+ method: args.method,
924
+ contractAddress: args.airdrop,
925
+ factory: args.factory.address
926
+ });
552
927
  }
553
928
  function assertMerkleClaimIdentity(args) {
554
- const { method, account, submitter, boundTo, to, entrypoint = "claim" } = args;
929
+ const { method, account, submitter, to, entrypoint = "claim" } = args;
555
930
  for (const [argument, value] of [
556
931
  ["account", account],
557
- ["entry.boundTo", boundTo],
558
932
  ["to", to],
559
933
  ["submitter", submitter]
560
934
  ]) {
@@ -574,13 +948,6 @@ function assertMerkleClaimIdentity(args) {
574
948
  reason: "is the zero address; the claim identity is mandatory and is never defaulted from the caller"
575
949
  });
576
950
  }
577
- if (boundTo !== void 0 && !viem.isAddressEqual(boundTo, submitter)) {
578
- throw new chunk67OV5CX2_cjs.InvalidArgumentError({
579
- method,
580
- argument: "entry.boundTo",
581
- reason: `is ${boundTo}, but this transaction is sent from ${submitter}; the FHE input proof is bound to the sender, so only ${boundTo} can submit this entry`
582
- });
583
- }
584
951
  if (entrypoint === "claimAndUnwrap") {
585
952
  if (!viem.isAddressEqual(account, submitter)) {
586
953
  throw new chunk67OV5CX2_cjs.InvalidArgumentError({
@@ -601,6 +968,17 @@ async function preflightClaim(args) {
601
968
  const method = "preflightClaim";
602
969
  const blockers = [];
603
970
  collect(blockers, () => assertSupportedChain(airdrop.chainId));
971
+ if (args.factory) {
972
+ await collectAsync(
973
+ blockers,
974
+ () => assertKnownAirdrop({
975
+ factory: args.factory,
976
+ airdrop: airdrop.address,
977
+ chainId: airdrop.chainId,
978
+ method
979
+ })
980
+ );
981
+ }
604
982
  if (args.account !== void 0 || args.entrypoint !== void 0) {
605
983
  collect(
606
984
  blockers,
@@ -673,9 +1051,11 @@ async function preflightClaim(args) {
673
1051
  function collect(blockers, run) {
674
1052
  try {
675
1053
  run();
1054
+ return true;
676
1055
  } catch (err) {
677
1056
  if (!chunk67OV5CX2_cjs.isTokenOpsSdkError(err)) throw err;
678
1057
  blockers.push(err);
1058
+ return false;
679
1059
  }
680
1060
  }
681
1061
  async function collectAsync(blockers, run) {
@@ -686,28 +1066,54 @@ async function collectAsync(blockers, run) {
686
1066
  blockers.push(err);
687
1067
  }
688
1068
  }
1069
+ var CLONE_INIT_CODE_PREFIX = "0x3d602d80600a3d3981f3363d3d373d3d3d363d73";
1070
+ var CLONE_INIT_CODE_SUFFIX = "5af43d82803e903d91602b57fd5bf3";
1071
+ function predictComplianceManagerClone(args) {
1072
+ const salt = viem.keccak256(
1073
+ viem.encodeAbiParameters(
1074
+ [{ type: "address" }, { type: "string" }],
1075
+ [viem.getAddress(args.airdrop), "compliance"]
1076
+ )
1077
+ );
1078
+ const initCode = `${CLONE_INIT_CODE_PREFIX}${viem.getAddress(args.managerImplementation).slice(2).toLowerCase()}${CLONE_INIT_CODE_SUFFIX}`;
1079
+ return viem.getCreate2Address({
1080
+ from: viem.getAddress(args.factory),
1081
+ salt,
1082
+ bytecodeHash: viem.keccak256(initCode)
1083
+ });
1084
+ }
689
1085
 
690
1086
  exports.AIRDROP_CONTRACTS_COMMIT = AIRDROP_CONTRACTS_COMMIT;
691
1087
  exports.AlreadyClaimedError = AlreadyClaimedError;
692
1088
  exports.ClaimNotStartedError = ClaimNotStartedError;
693
1089
  exports.ClaimWindowClosedError = ClaimWindowClosedError;
1090
+ exports.ClawbackRequiresPauseError = ClawbackRequiresPauseError;
1091
+ exports.CreateCommitmentMismatchError = CreateCommitmentMismatchError;
694
1092
  exports.DEDUP_MODE = DEDUP_MODE;
1093
+ exports.DEDUP_MODE_BY_ORDINAL = DEDUP_MODE_BY_ORDINAL;
695
1094
  exports.DEPLOYMENT_MODE = DEPLOYMENT_MODE;
696
1095
  exports.DedupIdConsumedError = DedupIdConsumedError;
697
1096
  exports.FeeCollectorSelfAdministeredError = FeeCollectorSelfAdministeredError;
1097
+ exports.GasFeeNotAcceptedError = GasFeeNotAcceptedError;
698
1098
  exports.MerkleUupsUnsupportedError = MerkleUupsUnsupportedError;
1099
+ exports.NativeRescueRequiresZeroFeeError = NativeRescueRequiresZeroFeeError;
699
1100
  exports.NonStockWrapperError = NonStockWrapperError;
700
1101
  exports.PredictionDriftError = PredictionDriftError;
701
1102
  exports.SaltCollisionError = SaltCollisionError;
702
1103
  exports.SignatureExpiredError = SignatureExpiredError;
1104
+ exports.UINT96_MAX = UINT96_MAX;
703
1105
  exports.UnauthorizedRedirectError = UnauthorizedRedirectError;
1106
+ exports.UnrecognisedAirdropError = UnrecognisedAirdropError;
704
1107
  exports.UpgradeabilityNotAllowedError = UpgradeabilityNotAllowedError;
705
1108
  exports.airdropProductMapper = airdropProductMapper;
1109
+ exports.assertCreateGasFee = assertCreateGasFee;
706
1110
  exports.assertMerkleClaimIdentity = assertMerkleClaimIdentity;
707
1111
  exports.assertMerkleModeSupported = assertMerkleModeSupported;
708
1112
  exports.assertPredictionFresh = assertPredictionFresh;
709
1113
  exports.assertSaltAvailable = assertSaltAvailable;
710
1114
  exports.assertStockWrapper = assertStockWrapper;
711
1115
  exports.assertSupportedChain = assertSupportedChain;
1116
+ exports.predictComplianceManagerClone = predictComplianceManagerClone;
712
1117
  exports.preflightClaim = preflightClaim;
713
1118
  exports.preflightCreate = preflightCreate;
1119
+ exports.resolvePlannedCreate = resolvePlannedCreate;
@@ -10,28 +10,32 @@ var DEPLOYED_ADDRESSES = {
10
10
  // mainnet omitted — not deployed.
11
11
  }
12
12
  },
13
- // Airdrop v2 (tokenops-fhe-airdrop-v2 @ 7175ac8). The four contracts deploy
14
- // together in one scripted run, so a chain either has all of them or none —
15
- // which is what `chainsWithDeployment` assumes.
13
+ // Airdrop v2 (tokenops-fhe-airdrop-v2 @ AIRDROP_CONTRACTS_COMMIT). The four
14
+ // contracts deploy together in one scripted run, so a chain either has all of
15
+ // them or none - which is what `chainsWithDeployment` assumes.
16
16
  //
17
- // Every address moved at 7175ac8: `claim`'s breaking signature change forced a
18
- // fresh Merkle implementation, and the run redeploys the whole system rather
19
- // than repointing one implementation slot. A campaign planned against the old
20
- // factory therefore predicts an address the new factory will never produce —
21
- // `PredictionDriftError` is what catches that.
17
+ // Deployed with the CREATE3 salt version
18
+ // "sdk-preview-13cad511", set at deploy time; the contracts branch is unchanged
19
+ // and still names "2.0.2", which is already consumed on Sepolia, so a redeploy
20
+ // needs its own fresh salt version. A salt change is needed
21
+ // at all because CREATE3 returns a consumed salt's EXISTING address without
22
+ // comparing codehashes, so redeploying changed bytecode under the same salt
23
+ // would silently resolve to the old contracts. A campaign planned against a
24
+ // previous factory therefore predicts an address the new factory will never
25
+ // produce; `PredictionDriftError` is what catches that.
22
26
  fheAirdrop: {
23
27
  airdropFactory: {
24
- [chains.sepolia.id]: "0x174A7CB40F64aBC4C95CecB4172A066Cf531e4E9"
28
+ [chains.sepolia.id]: "0xD5906f366Ff50909F403c8EDfDe680015563046a"
25
29
  // mainnet omitted — ZamaConfig-gated, not deployed.
26
30
  },
27
31
  ecdsaImplementation: {
28
- [chains.sepolia.id]: "0xDeD7AB391f87B8F891F89AaEC64C7c9C800C6645"
32
+ [chains.sepolia.id]: "0xE27A2aF9dCBda2B06535d5502e6dbB90364b43bA"
29
33
  },
30
34
  merkleImplementation: {
31
- [chains.sepolia.id]: "0x815E65Cdd707F07F09332537b47C530d0E87aAf5"
35
+ [chains.sepolia.id]: "0xccea0A916dBe5aB939915a402942EE6AFDcD505E"
32
36
  },
33
37
  complianceManagerImplementation: {
34
- [chains.sepolia.id]: "0x885474FA494748C85410482244a406C6Ad570CCe"
38
+ [chains.sepolia.id]: "0x076719596c21F0Eb358AC45649C3db387D98FADf"
35
39
  }
36
40
  },
37
41
  fheDisperse: {