@tokenops/sdk 2.0.0-alpha.3 → 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 (151) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +71 -35
  3. package/SUPPORT.md +1 -1
  4. package/dist/{chunk-NGU4JYIR.js → chunk-2ND7US2I.js} +1 -1
  5. package/dist/{chunk-U3TBQRT7.js → chunk-3ZSPRHR3.js} +55 -12
  6. package/dist/{chunk-BXX5TETM.js → chunk-67Q6KSVV.js} +4114 -3267
  7. package/dist/{chunk-JVNJSDQ4.cjs → chunk-6AYJRUGP.cjs} +7 -50
  8. package/dist/{chunk-AHU2HMNE.cjs → chunk-6FUHF73F.cjs} +5 -5
  9. package/dist/{chunk-NWFMBLSQ.js → chunk-7KY4K4PH.js} +1 -1
  10. package/dist/{chunk-YABHXJNH.cjs → chunk-ARZ5C3FS.cjs} +7 -7
  11. package/dist/{chunk-4IB4IY5Y.js → chunk-AX6MQAWU.js} +2 -2
  12. package/dist/{chunk-BPIVVCSQ.js → chunk-BSXEX2SH.js} +3 -3
  13. package/dist/{chunk-PK6Q6J5F.js → chunk-CHGY6B7L.js} +34 -81
  14. package/dist/{chunk-GKYZQJGP.cjs → chunk-DFK5GCJP.cjs} +55 -72
  15. package/dist/{chunk-4AWQJQXY.cjs → chunk-E4IV4M4E.cjs} +4126 -3279
  16. package/dist/{chunk-6HCT4QIX.js → chunk-GHGF65LN.js} +16 -13
  17. package/dist/{chunk-TWT3STIX.js → chunk-K3R27WX4.js} +8 -46
  18. package/dist/{chunk-GCJFAY4X.js → chunk-KJUNBOJQ.js} +52 -71
  19. package/dist/{chunk-6XOAYDC6.cjs → chunk-PO3A2AQX.cjs} +4 -4
  20. package/dist/{chunk-TND5NDV7.cjs → chunk-QHDMPT7I.cjs} +64 -19
  21. package/dist/{chunk-IEKTGJ4J.cjs → chunk-S47IBDTA.cjs} +36 -83
  22. package/dist/{chunk-UG5RKLU2.cjs → chunk-SUYBAF27.cjs} +1 -1
  23. package/dist/{chunk-WRWRA4TN.js → chunk-TWU7L5H7.js} +5 -48
  24. package/dist/{chunk-WJLECC22.cjs → chunk-UUSSWOPR.cjs} +9 -47
  25. package/dist/{chunk-YTIYTV4K.cjs → chunk-VHKMWWBA.cjs} +319 -40
  26. package/dist/{chunk-PG3WXT3K.cjs → chunk-YAL6JSAZ.cjs} +16 -13
  27. package/dist/{chunk-LEYYG4RF.js → chunk-YMWMIWBP.js} +315 -42
  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 +81 -4
  36. package/dist/fhe-airdrop/abis/ecdsa.d.ts +101 -4
  37. package/dist/fhe-airdrop/abis/factory.d.ts +222 -4
  38. package/dist/fhe-airdrop/abis/merkle.d.ts +100 -4
  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 +121 -143
  44. package/dist/fhe-airdrop/advanced/react/index.js +55 -77
  45. package/dist/fhe-airdrop/advanced/react/useClearCompliancePolicy.d.ts +3 -1
  46. package/dist/fhe-airdrop/advanced/react/useDisableCustomFee.d.ts +3 -1
  47. package/dist/fhe-airdrop/advanced/react/useFactoryComplianceDelegate.d.ts +2 -4
  48. package/dist/fhe-airdrop/advanced/react/useSetComplianceDelegate.d.ts +7 -7
  49. package/dist/fhe-airdrop/advanced/react/useSetComplianceManagerImpl.d.ts +3 -1
  50. package/dist/fhe-airdrop/advanced/react/useSetCompliancePolicy.d.ts +2 -1
  51. package/dist/fhe-airdrop/advanced/react/useSetCustomFee.d.ts +3 -1
  52. package/dist/fhe-airdrop/advanced/react/useSetDefaultDelegateToCompliance.d.ts +5 -4
  53. package/dist/fhe-airdrop/advanced/react/useSetDefaultGasFee.d.ts +3 -1
  54. package/dist/fhe-airdrop/advanced/react/useSetMaxGasFee.d.ts +7 -3
  55. package/dist/fhe-airdrop/airdrop-base.d.ts +95 -10
  56. package/dist/fhe-airdrop/campaign.d.ts +37 -73
  57. package/dist/fhe-airdrop/compliance-clone.d.ts +21 -0
  58. package/dist/fhe-airdrop/constants.d.ts +3 -1
  59. package/dist/fhe-airdrop/ecdsa.d.ts +67 -27
  60. package/dist/fhe-airdrop/encryption.d.ts +19 -6
  61. package/dist/fhe-airdrop/errors.d.ts +77 -2
  62. package/dist/fhe-airdrop/factory-params.d.ts +2361 -0
  63. package/dist/fhe-airdrop/factory.d.ts +142 -68
  64. package/dist/fhe-airdrop/guards.d.ts +110 -31
  65. package/dist/fhe-airdrop/index.cjs +79 -59
  66. package/dist/fhe-airdrop/index.d.cts +11 -9
  67. package/dist/fhe-airdrop/index.d.ts +11 -9
  68. package/dist/fhe-airdrop/index.js +5 -5
  69. package/dist/fhe-airdrop/merkle-tree.d.ts +9 -9
  70. package/dist/fhe-airdrop/merkle.d.ts +32 -11
  71. package/dist/fhe-airdrop/react/_shared.d.ts +12 -6
  72. package/dist/fhe-airdrop/react/index.cjs +294 -258
  73. package/dist/fhe-airdrop/react/index.d.cts +16 -9
  74. package/dist/fhe-airdrop/react/index.d.ts +16 -9
  75. package/dist/fhe-airdrop/react/index.js +114 -110
  76. package/dist/fhe-airdrop/react/keys.d.ts +46 -7
  77. package/dist/fhe-airdrop/react/useAccessEcdsaClaimAmount.d.ts +6 -3
  78. package/dist/fhe-airdrop/react/useAccessMerkleClaimAmount.d.ts +2 -2
  79. package/dist/fhe-airdrop/react/useAirdropConfig.d.ts +8 -3
  80. package/dist/fhe-airdrop/react/useAirdropPause.d.ts +5 -0
  81. package/dist/fhe-airdrop/react/useBuildMerkleCampaign.d.ts +4 -6
  82. package/dist/fhe-airdrop/react/useComplianceManager.d.ts +2 -2
  83. package/dist/fhe-airdrop/react/useComplianceManagerOf.d.ts +1 -2
  84. package/dist/fhe-airdrop/react/useCreateAndFundEcdsaAirdrop.d.ts +16 -11
  85. package/dist/fhe-airdrop/react/useCreateAndFundMerkleAirdrop.d.ts +23 -7
  86. package/dist/fhe-airdrop/react/useCreateEcdsaAirdrop.d.ts +13 -8
  87. package/dist/fhe-airdrop/react/useCreateMerkleAirdrop.d.ts +27 -7
  88. package/dist/fhe-airdrop/react/useDedupMode.d.ts +16 -0
  89. package/dist/fhe-airdrop/react/useDiscloseHandleToParty.d.ts +4 -3
  90. package/dist/fhe-airdrop/react/useEcdsaClaim.d.ts +6 -4
  91. package/dist/fhe-airdrop/react/useEcdsaClaimAndUnwrap.d.ts +15 -8
  92. package/dist/fhe-airdrop/react/useEcdsaDomain.d.ts +1 -1
  93. package/dist/fhe-airdrop/react/useEncryptCampaignAmounts.d.ts +5 -7
  94. package/dist/fhe-airdrop/react/useExtendClaimWindow.d.ts +4 -1
  95. package/dist/fhe-airdrop/react/useFundAirdrop.d.ts +3 -4
  96. package/dist/fhe-airdrop/react/useGrantInstanceRoles.d.ts +2 -1
  97. package/dist/fhe-airdrop/react/useIsSignatureValid.d.ts +5 -4
  98. package/dist/fhe-airdrop/react/useMerkleClaim.d.ts +4 -1
  99. package/dist/fhe-airdrop/react/useMerkleClaimAndUnwrap.d.ts +14 -3
  100. package/dist/fhe-airdrop/react/usePlanMerkleCampaign.d.ts +18 -3
  101. package/dist/fhe-airdrop/react/usePreflightClaim.d.ts +1 -1
  102. package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +34 -13
  103. package/dist/fhe-airdrop/react/useRescueERC20.d.ts +3 -3
  104. package/dist/fhe-airdrop/react/useRescueNativeToken.d.ts +23 -0
  105. package/dist/fhe-airdrop/react/useRotateMerkleRoot.d.ts +5 -2
  106. package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +4 -0
  107. package/dist/fhe-airdrop/react/useTokenOf.d.ts +29 -0
  108. package/dist/fhe-airdrop/react/useUnwrapRequest.d.ts +25 -0
  109. package/dist/fhe-airdrop/react/useWithdrawConfidential.d.ts +4 -0
  110. package/dist/fhe-airdrop/roles.d.ts +82 -7
  111. package/dist/fhe-airdrop/types.d.ts +109 -14
  112. package/dist/fhe-disperse/errors.d.ts +3 -3
  113. package/dist/fhe-disperse/index.cjs +22 -22
  114. package/dist/fhe-disperse/index.d.cts +2 -1
  115. package/dist/fhe-disperse/index.d.ts +2 -1
  116. package/dist/fhe-disperse/index.js +3 -3
  117. package/dist/fhe-disperse/react/index.cjs +27 -25
  118. package/dist/fhe-disperse/react/index.d.cts +2 -1
  119. package/dist/fhe-disperse/react/index.d.ts +2 -1
  120. package/dist/fhe-disperse/react/index.js +8 -6
  121. package/dist/fhe-disperse/react/useDisperse.d.ts +6 -2
  122. package/dist/fhe-disperse/react/useRegister.d.ts +9 -3
  123. package/dist/fhe-disperse/react/useSingletonWithdrawTokenFee.d.ts +7 -2
  124. package/dist/fhe-disperse/react/useWithdrawTokenFee.d.ts +7 -2
  125. package/dist/fhe-disperse/singleton.d.ts +33 -19
  126. package/dist/fhe-disperse/types.d.ts +48 -8
  127. package/dist/fhe-vesting/advanced/index.cjs +6 -6
  128. package/dist/fhe-vesting/advanced/index.js +4 -4
  129. package/dist/fhe-vesting/advanced/react/index.cjs +9 -9
  130. package/dist/fhe-vesting/advanced/react/index.js +6 -6
  131. package/dist/fhe-vesting/factory.d.ts +31 -8
  132. package/dist/fhe-vesting/index.cjs +23 -23
  133. package/dist/fhe-vesting/index.d.cts +3 -2
  134. package/dist/fhe-vesting/index.d.ts +3 -2
  135. package/dist/fhe-vesting/index.js +4 -4
  136. package/dist/fhe-vesting/manager.d.ts +27 -2
  137. package/dist/fhe-vesting/react/index.cjs +126 -126
  138. package/dist/fhe-vesting/react/index.d.cts +3 -2
  139. package/dist/fhe-vesting/react/index.d.ts +3 -2
  140. package/dist/fhe-vesting/react/index.js +5 -5
  141. package/dist/fhe-vesting/react/useCreateManager.d.ts +16 -9
  142. package/dist/fhe-vesting/react/useCreateManagerAndGetAddress.d.ts +9 -5
  143. package/dist/fhe-vesting/react/useSplitVesting.d.ts +9 -3
  144. package/dist/index.cjs +18 -18
  145. package/dist/index.js +1 -1
  146. package/dist/testnet-faucet/faucet.d.ts +3 -0
  147. package/dist/testnet-faucet/index.cjs +15 -15
  148. package/dist/testnet-faucet/index.js +3 -3
  149. package/dist/testnet-faucet/react/index.cjs +9 -9
  150. package/dist/testnet-faucet/react/index.js +4 -4
  151. package/package.json +1 -1
@@ -5,9 +5,12 @@ 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 = "c5c12c2087f61bcd5bd1daa802563ed3cd68f002";
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
+ );
11
14
  var UINT96_MAX = (1n << 96n) - 1n;
12
15
 
13
16
  // src/fhe-airdrop/errors.ts
@@ -97,6 +100,43 @@ var PredictionDriftError = class extends chunk67OV5CX2_cjs.TokenOpsSdkError {
97
100
  );
98
101
  }
99
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
+ };
100
140
  var UpgradeabilityNotAllowedError = class extends chunk67OV5CX2_cjs.TokenOpsSdkError {
101
141
  name = "UpgradeabilityNotAllowedError";
102
142
  constructor(args) {
@@ -289,12 +329,16 @@ var airdropProductMapper = (name, errArgs, ctx) => {
289
329
  return new chunk67OV5CX2_cjs.FheHandleNotAllowedError({ ...ctx, handle });
290
330
  }
291
331
  // ---- Merkle-specific ----------------------------------------------
292
- case "InvalidMerkleProof":
332
+ case "InvalidMerkleProof": {
333
+ const leaf = errArgs?.[0];
334
+ const merkleRoot = errArgs?.[1];
293
335
  return new chunk67OV5CX2_cjs.InvalidArgumentError({
294
336
  method: ctx.method,
295
337
  argument: "merkleProof",
296
- 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 } } : {}
297
340
  });
341
+ }
298
342
  case "RootImmutable":
299
343
  return new chunk67OV5CX2_cjs.FeatureDisabledError({ ...ctx, feature: "merkleRootRotation" });
300
344
  case "ZeroAccount":
@@ -332,13 +376,10 @@ var airdropProductMapper = (name, errArgs, ctx) => {
332
376
  return new GasFeeNotAcceptedError({ ...ctx, resolvedFee, maxAcceptedGasFee });
333
377
  }
334
378
  case "GasFeeExceedsMaximum": {
335
- const gasFee = errArgs?.[0];
336
- const maxGasFee = errArgs?.[1];
337
- return new chunk67OV5CX2_cjs.InvalidArgumentError({
379
+ return gasFeeExceedsMaximumError({
338
380
  method: ctx.method,
339
- argument: "gasFee",
340
- 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`,
341
- value: gasFee
381
+ gasFee: errArgs?.[0],
382
+ maxGasFee: errArgs?.[1]
342
383
  });
343
384
  }
344
385
  case "ZeroUnwrapRequestId":
@@ -404,7 +445,7 @@ var airdropProductMapper = (name, errArgs, ctx) => {
404
445
  ctx,
405
446
  "complianceDelegate",
406
447
  name,
407
- "required while the default compliance-delegate policy is on"
448
+ "the factory requires a non-zero delegate (constructor, setter and create)"
408
449
  );
409
450
  case "IndexOutOfBounds": {
410
451
  const index = errArgs?.[0];
@@ -427,6 +468,48 @@ var airdropProductMapper = (name, errArgs, ctx) => {
427
468
  value: existingAirdrop
428
469
  });
429
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);
430
513
  case "ZeroSigner":
431
514
  return invalidArg(ctx, "signer", name);
432
515
  case "ZeroMerkleRoot":
@@ -434,7 +517,7 @@ var airdropProductMapper = (name, errArgs, ctx) => {
434
517
  ctx,
435
518
  "merkleRoot",
436
519
  name,
437
- "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"
438
521
  );
439
522
  // ---- compliance manager clone (`ComplianceRoleManager`) --------------
440
523
  case "ZeroAirdrop":
@@ -474,15 +557,26 @@ var airdropProductMapper = (name, errArgs, ctx) => {
474
557
  return void 0;
475
558
  }
476
559
  };
477
- 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) {
478
570
  const suffix = detail ? ` ${detail}.` : "";
479
571
  return new chunk67OV5CX2_cjs.InvalidArgumentError({
480
572
  method: ctx.method,
481
573
  argument,
482
- reason: `the contract reverted with \`${revertName}\`.${suffix}`
574
+ reason: `the contract reverted with \`${revertName}\`.${suffix}`,
575
+ ...value !== void 0 ? { value } : {}
483
576
  });
484
577
  }
485
578
  function numberArg(value) {
579
+ if (typeof value === "number") return value;
486
580
  return typeof value === "bigint" ? Number(value) : void 0;
487
581
  }
488
582
  var SUPPORTED_CHAIN_IDS = [1, 11155111, 31337];
@@ -549,9 +643,12 @@ function assertMaxAcceptedGasFeeRange(value, method) {
549
643
  });
550
644
  }
551
645
  }
552
- async function assertGasFeeAccepted(args) {
553
- assertMaxAcceptedGasFeeRange(args.maxAcceptedGasFee, args.method);
554
- const resolvedFee = await args.factory.resolveGasFee(args.creator);
646
+ function assertWithinCeiling(method, resolvedFee, maxGasFee) {
647
+ if (resolvedFee > maxGasFee) {
648
+ throw gasFeeExceedsMaximumError({ method, gasFee: resolvedFee, maxGasFee });
649
+ }
650
+ }
651
+ function assertResolvedFeeAccepted(args, resolvedFee) {
555
652
  if (resolvedFee <= args.maxAcceptedGasFee) return;
556
653
  throw new GasFeeNotAcceptedError({
557
654
  method: args.method,
@@ -560,6 +657,15 @@ async function assertGasFeeAccepted(args) {
560
657
  maxAcceptedGasFee: args.maxAcceptedGasFee
561
658
  });
562
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
+ }
563
669
  function assertPredictionFresh(args) {
564
670
  if (args.initCodeHashBefore.toLowerCase() === args.initCodeHashAfter.toLowerCase()) return;
565
671
  throw new PredictionDriftError({
@@ -570,6 +676,112 @@ function assertPredictionFresh(args) {
570
676
  predictedAddress: args.predictedAddress
571
677
  });
572
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
+ }
573
785
  async function preflightCreate(args) {
574
786
  const method = args.variant === "merkle" ? "createMerkleAirdrop" : "createEcdsaAirdrop";
575
787
  const blockers = [];
@@ -582,15 +794,34 @@ async function preflightCreate(args) {
582
794
  () => assertMaxAcceptedGasFeeRange(args.params.common.maxAcceptedGasFee, method)
583
795
  );
584
796
  if (!encodable) return { ready: false, blockers };
585
- await collectAsync(
586
- blockers,
587
- () => assertGasFeeAccepted({
588
- factory: args.factory,
589
- creator: args.creator,
590
- maxAcceptedGasFee: args.params.common.maxAcceptedGasFee,
591
- method
592
- })
593
- );
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
+ });
594
825
  const predictArgs = {
595
826
  mode: args.mode,
596
827
  deployer: args.creator,
@@ -622,7 +853,7 @@ async function preflightCreate(args) {
622
853
  blockers,
623
854
  () => assertSaltAvailable({
624
855
  publicClient: args.factory.publicClient,
625
- predictedAddress,
856
+ predictedAddress: expected?.airdrop ?? predictedAddress,
626
857
  variant: args.variant,
627
858
  mode: args.mode,
628
859
  deployer: args.creator,
@@ -630,19 +861,53 @@ async function preflightCreate(args) {
630
861
  method
631
862
  })
632
863
  );
633
- if (args.expectedInitCodeHash !== void 0) {
864
+ if (expectedInitCodeHash !== void 0) {
865
+ const initCodeHashBefore = expectedInitCodeHash;
634
866
  collect(
635
867
  blockers,
636
868
  () => assertPredictionFresh({
637
869
  variant: args.variant,
638
- initCodeHashBefore: args.expectedInitCodeHash,
870
+ initCodeHashBefore,
639
871
  initCodeHashAfter: liveInitCodeHash,
640
- predictedAddress,
872
+ predictedAddress: expected?.airdrop ?? predictedAddress,
641
873
  method
642
874
  })
643
875
  );
644
876
  }
645
- 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 } : {} };
646
911
  }
647
912
  async function assertKnownAirdrop(args) {
648
913
  if (args.factory.chainId !== args.chainId) {
@@ -661,10 +926,9 @@ async function assertKnownAirdrop(args) {
661
926
  });
662
927
  }
663
928
  function assertMerkleClaimIdentity(args) {
664
- const { method, account, submitter, boundTo, to, entrypoint = "claim" } = args;
929
+ const { method, account, submitter, to, entrypoint = "claim" } = args;
665
930
  for (const [argument, value] of [
666
931
  ["account", account],
667
- ["entry.boundTo", boundTo],
668
932
  ["to", to],
669
933
  ["submitter", submitter]
670
934
  ]) {
@@ -684,13 +948,6 @@ function assertMerkleClaimIdentity(args) {
684
948
  reason: "is the zero address; the claim identity is mandatory and is never defaulted from the caller"
685
949
  });
686
950
  }
687
- if (boundTo !== void 0 && !viem.isAddressEqual(boundTo, submitter)) {
688
- throw new chunk67OV5CX2_cjs.InvalidArgumentError({
689
- method,
690
- argument: "entry.boundTo",
691
- 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`
692
- });
693
- }
694
951
  if (entrypoint === "claimAndUnwrap") {
695
952
  if (!viem.isAddressEqual(account, submitter)) {
696
953
  throw new chunk67OV5CX2_cjs.InvalidArgumentError({
@@ -809,17 +1066,37 @@ async function collectAsync(blockers, run) {
809
1066
  blockers.push(err);
810
1067
  }
811
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
+ }
812
1085
 
813
1086
  exports.AIRDROP_CONTRACTS_COMMIT = AIRDROP_CONTRACTS_COMMIT;
814
1087
  exports.AlreadyClaimedError = AlreadyClaimedError;
815
1088
  exports.ClaimNotStartedError = ClaimNotStartedError;
816
1089
  exports.ClaimWindowClosedError = ClaimWindowClosedError;
1090
+ exports.ClawbackRequiresPauseError = ClawbackRequiresPauseError;
1091
+ exports.CreateCommitmentMismatchError = CreateCommitmentMismatchError;
817
1092
  exports.DEDUP_MODE = DEDUP_MODE;
1093
+ exports.DEDUP_MODE_BY_ORDINAL = DEDUP_MODE_BY_ORDINAL;
818
1094
  exports.DEPLOYMENT_MODE = DEPLOYMENT_MODE;
819
1095
  exports.DedupIdConsumedError = DedupIdConsumedError;
820
1096
  exports.FeeCollectorSelfAdministeredError = FeeCollectorSelfAdministeredError;
821
1097
  exports.GasFeeNotAcceptedError = GasFeeNotAcceptedError;
822
1098
  exports.MerkleUupsUnsupportedError = MerkleUupsUnsupportedError;
1099
+ exports.NativeRescueRequiresZeroFeeError = NativeRescueRequiresZeroFeeError;
823
1100
  exports.NonStockWrapperError = NonStockWrapperError;
824
1101
  exports.PredictionDriftError = PredictionDriftError;
825
1102
  exports.SaltCollisionError = SaltCollisionError;
@@ -829,12 +1106,14 @@ exports.UnauthorizedRedirectError = UnauthorizedRedirectError;
829
1106
  exports.UnrecognisedAirdropError = UnrecognisedAirdropError;
830
1107
  exports.UpgradeabilityNotAllowedError = UpgradeabilityNotAllowedError;
831
1108
  exports.airdropProductMapper = airdropProductMapper;
832
- exports.assertGasFeeAccepted = assertGasFeeAccepted;
1109
+ exports.assertCreateGasFee = assertCreateGasFee;
833
1110
  exports.assertMerkleClaimIdentity = assertMerkleClaimIdentity;
834
1111
  exports.assertMerkleModeSupported = assertMerkleModeSupported;
835
1112
  exports.assertPredictionFresh = assertPredictionFresh;
836
1113
  exports.assertSaltAvailable = assertSaltAvailable;
837
1114
  exports.assertStockWrapper = assertStockWrapper;
838
1115
  exports.assertSupportedChain = assertSupportedChain;
1116
+ exports.predictComplianceManagerClone = predictComplianceManagerClone;
839
1117
  exports.preflightClaim = preflightClaim;
840
1118
  exports.preflightCreate = preflightCreate;
1119
+ exports.resolvePlannedCreate = resolvePlannedCreate;
@@ -10,29 +10,32 @@ var DEPLOYED_ADDRESSES = {
10
10
  // mainnet omitted — not deployed.
11
11
  }
12
12
  },
13
- // Airdrop v2 (tokenops-fhe-airdrop-v2 @ c5c12c2). 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 again at c5c12c2. The internal-audit round changed the
18
- // factory and all three implementations, and CREATE3 returns a consumed salt's
19
- // EXISTING address without comparing codehashes - so the run bumps the canonical
20
- // salt version (2.0.0 → 2.0.2) rather than redeploying over itself. A campaign
21
- // planned against the previous factory therefore predicts an address the new
22
- // factory will never produce; `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.
23
26
  fheAirdrop: {
24
27
  airdropFactory: {
25
- [chains.sepolia.id]: "0xA10ff713cfeE5348313Cda0B2CA1b190A1194cab"
28
+ [chains.sepolia.id]: "0xD5906f366Ff50909F403c8EDfDe680015563046a"
26
29
  // mainnet omitted — ZamaConfig-gated, not deployed.
27
30
  },
28
31
  ecdsaImplementation: {
29
- [chains.sepolia.id]: "0x8d4E8F379f73D5488a76B6C3CC8a2fD489936BDe"
32
+ [chains.sepolia.id]: "0xE27A2aF9dCBda2B06535d5502e6dbB90364b43bA"
30
33
  },
31
34
  merkleImplementation: {
32
- [chains.sepolia.id]: "0x4B4F43Ed9aB3F9D10468b59C03d14f55A9d4E82F"
35
+ [chains.sepolia.id]: "0xccea0A916dBe5aB939915a402942EE6AFDcD505E"
33
36
  },
34
37
  complianceManagerImplementation: {
35
- [chains.sepolia.id]: "0x14bdE71e6b32b50dF1a5Dca1bccD150a319168e2"
38
+ [chains.sepolia.id]: "0x076719596c21F0Eb358AC45649C3db387D98FADf"
36
39
  }
37
40
  },
38
41
  fheDisperse: {