@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
@@ -8,29 +8,32 @@ var DEPLOYED_ADDRESSES = {
8
8
  // mainnet omitted — not deployed.
9
9
  }
10
10
  },
11
- // Airdrop v2 (tokenops-fhe-airdrop-v2 @ c5c12c2). The four contracts deploy
12
- // together in one scripted run, so a chain either has all of them or none —
13
- // which is what `chainsWithDeployment` assumes.
11
+ // Airdrop v2 (tokenops-fhe-airdrop-v2 @ AIRDROP_CONTRACTS_COMMIT). The four
12
+ // contracts deploy together in one scripted run, so a chain either has all of
13
+ // them or none - which is what `chainsWithDeployment` assumes.
14
14
  //
15
- // Every address moved again at c5c12c2. The internal-audit round changed the
16
- // factory and all three implementations, and CREATE3 returns a consumed salt's
17
- // EXISTING address without comparing codehashes - so the run bumps the canonical
18
- // salt version (2.0.0 → 2.0.2) rather than redeploying over itself. A campaign
19
- // planned against the previous factory therefore predicts an address the new
20
- // factory will never produce; `PredictionDriftError` is what catches that.
15
+ // Deployed with the CREATE3 salt version
16
+ // "sdk-preview-13cad511", set at deploy time; the contracts branch is unchanged
17
+ // and still names "2.0.2", which is already consumed on Sepolia, so a redeploy
18
+ // needs its own fresh salt version. A salt change is needed
19
+ // at all because CREATE3 returns a consumed salt's EXISTING address without
20
+ // comparing codehashes, so redeploying changed bytecode under the same salt
21
+ // would silently resolve to the old contracts. A campaign planned against a
22
+ // previous factory therefore predicts an address the new factory will never
23
+ // produce; `PredictionDriftError` is what catches that.
21
24
  fheAirdrop: {
22
25
  airdropFactory: {
23
- [sepolia.id]: "0xA10ff713cfeE5348313Cda0B2CA1b190A1194cab"
26
+ [sepolia.id]: "0xD5906f366Ff50909F403c8EDfDe680015563046a"
24
27
  // mainnet omitted — ZamaConfig-gated, not deployed.
25
28
  },
26
29
  ecdsaImplementation: {
27
- [sepolia.id]: "0x8d4E8F379f73D5488a76B6C3CC8a2fD489936BDe"
30
+ [sepolia.id]: "0xE27A2aF9dCBda2B06535d5502e6dbB90364b43bA"
28
31
  },
29
32
  merkleImplementation: {
30
- [sepolia.id]: "0x4B4F43Ed9aB3F9D10468b59C03d14f55A9d4E82F"
33
+ [sepolia.id]: "0xccea0A916dBe5aB939915a402942EE6AFDcD505E"
31
34
  },
32
35
  complianceManagerImplementation: {
33
- [sepolia.id]: "0x14bdE71e6b32b50dF1a5Dca1bccD150a319168e2"
36
+ [sepolia.id]: "0x076719596c21F0Eb358AC45649C3db387D98FADf"
34
37
  }
35
38
  },
36
39
  fheDisperse: {
@@ -2,7 +2,7 @@ import { mapZamaError } from './chunk-WMACINXO.js';
2
2
  import { resolveEncryptor, encryptUint64Batch, scaleRatio, encryptUint64 } from './chunk-6GNR22OV.js';
3
3
  import { getFhevmAclAddress, requireFhevmAclAddress, ACL_ALLOWED_EVENT } from './chunk-ZWXJTBZO.js';
4
4
  import { erc7984OperatorAbi } from './chunk-7VELUOMI.js';
5
- import { SDK_VERSION } from './chunk-NWFMBLSQ.js';
5
+ import { SDK_VERSION } from './chunk-7KY4K4PH.js';
6
6
  import { mapContractRevert, isContractRevert } from './chunk-4RAAATVY.js';
7
7
  import { normaliseAddress } from './chunk-ZA673I3O.js';
8
8
  import { asEncryptedHandle, asTxHash } from './chunk-KWFFIJYX.js';
@@ -1650,6 +1650,8 @@ var ConfidentialVestingManagerClient = class {
1650
1650
  * {@link OperatorNotApprovedError} (the SDK's mapping of the on-chain
1651
1651
  * `ERC7984UnauthorizedSpender` revert, whose message is the canonical
1652
1652
  * `OPERATOR_NOT_APPROVED_REMEDIATION` copy).
1653
+ * Both helpers wait for their receipt by default; a Safe / multisig signer
1654
+ * passes `waitForReceipt: false` to them.
1653
1655
  *
1654
1656
  * @returns Transaction hash. Parse the `VestingCreated` event to extract the `vestingId`.
1655
1657
  * @example
@@ -1706,6 +1708,8 @@ var ConfidentialVestingManagerClient = class {
1706
1708
  * {@link OperatorNotApprovedError} (the SDK's mapping of the on-chain
1707
1709
  * `ERC7984UnauthorizedSpender` revert, whose message is the canonical
1708
1710
  * `OPERATOR_NOT_APPROVED_REMEDIATION` copy).
1711
+ * Both helpers wait for their receipt by default; a Safe / multisig signer
1712
+ * passes `waitForReceipt: false` to them.
1709
1713
  *
1710
1714
  * @returns Transaction hash.
1711
1715
  */
@@ -1929,51 +1933,6 @@ var ConfidentialVestingManagerClient = class {
1929
1933
  }
1930
1934
  return this.#simpleWrite("batchRevokeVesting", [vestingIds], account);
1931
1935
  }
1932
- /**
1933
- * Split a vesting into two positions.
1934
- *
1935
- * The `numerator/denominator` ratio is auto-scaled via `scaleRatio` to the
1936
- * universal split constant `FHE_SPLIT_DENOMINATOR` (`90_090_000` =
1937
- * LCM(1..16, 10_000)) unless `args.preScaled` is set. Every confidential
1938
- * split lands on the same plaintext denominator so the constant itself
1939
- * leaks no information about the split's shape; only the encrypted
1940
- * numerator carries the share. `90_090_000` is well above the contract's
1941
- * `MIN_SPLIT_DENOMINATOR` (10_000) floor. The SDK encrypts `numerator` —
1942
- * pass plaintext.
1943
- *
1944
- * Two natural input shapes both produce exact integer numerators against
1945
- * the universal denominator:
1946
- * - `n/m` with `m ∈ 1..16` (halves, thirds, …, sixteenths)
1947
- * - `bps/10_000` (basis points)
1948
- *
1949
- * Use the {@link share} builder to construct them without manual math:
1950
- * `share.fraction(1, 7)` or `share.basisPoints(250)` → pass the returned
1951
- * `{ numerator, denominator }` with `preScaled: true`.
1952
- *
1953
- * @param args.numerator Plaintext share numerator (kept confidential on-chain).
1954
- * @param args.denominator Plaintext denominator — auto-scaled to 90_090_000.
1955
- * @param args.newRecipient Recipient address for the split-off position.
1956
- * @returns `{ hash, newVestingId }` — the receipt-derived id of the
1957
- * newly-created vesting position, required for any follow-up call
1958
- * (claim, transfer, disclose) on the split-off position.
1959
- * @example
1960
- * const { newVestingId } = await manager.splitVesting({
1961
- * vestingId,
1962
- * numerator: 1n, denominator: 2n, // 50% split; SDK scales to 45_045_000 / 90_090_000
1963
- * newRecipient: "0xNewRecipient",
1964
- * });
1965
- *
1966
- * @example
1967
- * // Basis-point style via the guided builder:
1968
- * const ratio = share.basisPoints(250); // 2.5%
1969
- * const { newVestingId } = await manager.splitVesting({
1970
- * vestingId,
1971
- * numerator: ratio.numerator,
1972
- * denominator: ratio.denominator,
1973
- * preScaled: true,
1974
- * newRecipient: "0xNewRecipient",
1975
- * });
1976
- */
1977
1936
  async splitVesting(args) {
1978
1937
  const wallet = this.#requireWallet("splitVesting");
1979
1938
  const account = this.#resolveAccount(wallet, args.account, "splitVesting");
@@ -2026,6 +1985,9 @@ var ConfidentialVestingManagerClient = class {
2026
1985
  accountAddress(account)
2027
1986
  );
2028
1987
  }
1988
+ if (args.waitForReceipt === false) {
1989
+ return { hash, newVestingId: void 0, pending: true };
1990
+ }
2029
1991
  const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
2030
1992
  const ours = receipt.logs.filter(
2031
1993
  (log) => log.address.toLowerCase() === this.address.toLowerCase()
@@ -1,9 +1,9 @@
1
- import { resolveEncryptor, encryptUint64Batch, encryptUint64 } from './chunk-BXX5TETM.js';
2
- import { assertPredictionFresh, FeeCollectorSelfAdministeredError } from './chunk-LEYYG4RF.js';
1
+ import { merkleConfidentialAirdropAbi, resolveEncryptor, encryptUint64Batch } from './chunk-67Q6KSVV.js';
2
+ import { assertPredictionFresh, FeeCollectorSelfAdministeredError } from './chunk-YMWMIWBP.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';
6
- import { keccak256, encodeAbiParameters, isAddress, isAddressEqual, zeroAddress } from 'viem';
6
+ import { keccak256, encodeAbiParameters, isAddress, isAddressEqual, zeroAddress, encodeFunctionData } from 'viem';
7
7
 
8
8
  function leafOf(args) {
9
9
  const inner = keccak256(
@@ -146,7 +146,7 @@ function validateCampaignRecipientsInternal(recipients, method) {
146
146
  seen.set(key, index);
147
147
  });
148
148
  }
149
- async function encryptRoster({ instance, recipients, encryptor, submitter }, method) {
149
+ async function encryptRoster({ instance, recipients, encryptor }, method) {
150
150
  validateCampaignRecipientsInternal(recipients, method);
151
151
  if (!isAddress(instance, { strict: false })) {
152
152
  throw new InvalidArgumentError({
@@ -169,67 +169,30 @@ async function encryptRoster({ instance, recipients, encryptor, submitter }, met
169
169
  hint: "Pass an encryptor instance, or a lazy factory that returns one."
170
170
  });
171
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
- }
189
172
  const airdrop = normaliseAddress(instance);
190
173
  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
- });
174
+ const chunks = [];
175
+ for (let i = 0; i < recipients.length; i += MERKLE_BATCH_LIMIT) {
176
+ chunks.push(recipients.slice(i, i + MERKLE_BATCH_LIMIT));
216
177
  }
217
- const encrypted = await Promise.all(
218
- recipients.map(
219
- (r, i) => encryptUint64({
178
+ const encryptedChunks = await Promise.all(
179
+ chunks.map(
180
+ (chunk) => encryptUint64Batch({
220
181
  encryptor: enc,
221
182
  contractAddress: airdrop,
222
- userAddress: accounts[i],
223
- value: r.cumulativeTotal
183
+ userAddress: airdrop,
184
+ values: chunk.map((r) => r.cumulativeTotal)
224
185
  })
225
186
  )
226
187
  );
227
- return accounts.map((account, i) => ({
228
- account,
229
- boundTo: account,
230
- handle: encrypted[i].handle,
231
- inputProof: encrypted[i].inputProof
232
- }));
188
+ return accounts.map((account, i) => {
189
+ const chunk = encryptedChunks[Math.floor(i / MERKLE_BATCH_LIMIT)];
190
+ return {
191
+ account,
192
+ handle: chunk.handles[i % MERKLE_BATCH_LIMIT],
193
+ inputProof: chunk.inputProof
194
+ };
195
+ });
233
196
  }
234
197
  async function encryptCampaignAmounts(args) {
235
198
  return encryptRoster(args, "encryptCampaignAmounts");
@@ -237,13 +200,9 @@ async function encryptCampaignAmounts(args) {
237
200
  async function buildMerkleCampaign({
238
201
  instance,
239
202
  recipients,
240
- encryptor,
241
- submitter
203
+ encryptor
242
204
  }) {
243
- const leaves = await encryptRoster(
244
- { instance, recipients, encryptor, submitter },
245
- "buildMerkleCampaign"
246
- );
205
+ const leaves = await encryptRoster({ instance, recipients, encryptor }, "buildMerkleCampaign");
247
206
  return buildMerkleTreeInternal({ instance, leaves }, "buildMerkleCampaign");
248
207
  }
249
208
  async function planMerkleCampaign({
@@ -253,8 +212,7 @@ async function planMerkleCampaign({
253
212
  creator,
254
213
  userSalt,
255
214
  recipients,
256
- encryptor,
257
- submitter
215
+ encryptor
258
216
  }) {
259
217
  validateCampaignRecipientsInternal(recipients, "planMerkleCampaign");
260
218
  const initCodeHashBefore = await factory.getMerkleInitCodeHash({ params, mode });
@@ -267,8 +225,7 @@ async function planMerkleCampaign({
267
225
  const campaign = await buildMerkleCampaign({
268
226
  instance: predictedAddress,
269
227
  recipients,
270
- encryptor,
271
- submitter
228
+ encryptor
272
229
  });
273
230
  const initCodeHashAfter = await factory.getMerkleInitCodeHash({ params, mode });
274
231
  assertPredictionFresh({
@@ -284,14 +241,12 @@ async function rotateMerkleRoot({
284
241
  airdrop,
285
242
  recipients,
286
243
  encryptor,
287
- submitter,
288
244
  account
289
245
  }) {
290
246
  const campaign = await buildMerkleCampaign({
291
247
  instance: airdrop.address,
292
248
  recipients,
293
- encryptor,
294
- submitter
249
+ encryptor
295
250
  });
296
251
  const hash = await airdrop.setMerkleRoot({ newRoot: campaign.root, account });
297
252
  return { ...campaign, hash };
@@ -337,6 +292,32 @@ function planInstanceRoleSplit(args) {
337
292
  }
338
293
  return steps;
339
294
  }
295
+ function encodeInstanceRoleSplit(args) {
296
+ const constants = {
297
+ DEFAULT_ADMIN_ROLE: DEFAULT_ADMIN_ROLE_CONSTANT,
298
+ ...args.roleConstants
299
+ };
300
+ const resolved = args.steps.map((step, i) => {
301
+ const role = constants[step.role];
302
+ if (role === void 0) {
303
+ throw new InvalidArgumentError({
304
+ method: "encodeInstanceRoleSplit",
305
+ argument: `roleConstants.${step.role}`,
306
+ reason: `steps[${i}] needs the ${step.role} constant; read it off the instance`
307
+ });
308
+ }
309
+ return { step, role };
310
+ });
311
+ return resolved.map(({ step, role }) => ({
312
+ to: args.airdrop,
313
+ data: encodeFunctionData({
314
+ abi: merkleConfidentialAirdropAbi,
315
+ functionName: step.kind === "grant" ? "grantRole" : "revokeRole",
316
+ args: [role, step.account]
317
+ }),
318
+ value: 0n
319
+ }));
320
+ }
340
321
  function roleGetterAbiEntry(name) {
341
322
  return {
342
323
  inputs: [],
@@ -420,4 +401,4 @@ async function grantInstanceRoles(args) {
420
401
  return outcomes;
421
402
  }
422
403
 
423
- export { buildMerkleCampaign, buildMerkleTree, encryptCampaignAmounts, grantInstanceRoles, leafOf, planInstanceRoleSplit, planMerkleCampaign, rotateMerkleRoot, validateCampaignRecipients };
404
+ export { MERKLE_BATCH_LIMIT, buildMerkleCampaign, buildMerkleTree, encodeInstanceRoleSplit, encryptCampaignAmounts, grantInstanceRoles, leafOf, planInstanceRoleSplit, planMerkleCampaign, rotateMerkleRoot, validateCampaignRecipients };
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkJVNJSDQ4_cjs = require('./chunk-JVNJSDQ4.cjs');
3
+ var chunk6AYJRUGP_cjs = require('./chunk-6AYJRUGP.cjs');
4
4
 
5
5
  // src/fhe-vesting/advanced/factory-advanced.ts
6
- var ConfidentialVestingFactoryAdvancedClient = class extends chunkJVNJSDQ4_cjs.ConfidentialVestingFactoryClient {
6
+ var ConfidentialVestingFactoryAdvancedClient = class extends chunk6AYJRUGP_cjs.ConfidentialVestingFactoryClient {
7
7
  /**
8
8
  * Compute the deterministic CREATE2 clone address as the factory would have
9
9
  * computed it at `args.blockNumber`.
@@ -20,7 +20,7 @@ var ConfidentialVestingFactoryAdvancedClient = class extends chunkJVNJSDQ4_cjs.C
20
20
  if (hasOptions) {
21
21
  return this.publicClient.readContract({
22
22
  address: this.address,
23
- abi: chunkJVNJSDQ4_cjs.confidentialVestingFactoryAbi,
23
+ abi: chunk6AYJRUGP_cjs.confidentialVestingFactoryAbi,
24
24
  functionName: "predictManagerAddressWithOptions",
25
25
  args: [
26
26
  args.token,
@@ -34,7 +34,7 @@ var ConfidentialVestingFactoryAdvancedClient = class extends chunkJVNJSDQ4_cjs.C
34
34
  }
35
35
  return this.publicClient.readContract({
36
36
  address: this.address,
37
- abi: chunkJVNJSDQ4_cjs.confidentialVestingFactoryAbi,
37
+ abi: chunk6AYJRUGP_cjs.confidentialVestingFactoryAbi,
38
38
  functionName: "predictManagerAddress",
39
39
  args: [args.token, args.userSalt, args.deployer],
40
40
  blockNumber: args.blockNumber
@@ -1,9 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunk4AWQJQXY_cjs = require('./chunk-4AWQJQXY.cjs');
4
- var chunkPG3WXT3K_cjs = require('./chunk-PG3WXT3K.cjs');
3
+ var chunkE4IV4M4E_cjs = require('./chunk-E4IV4M4E.cjs');
4
+ var chunkYAL6JSAZ_cjs = require('./chunk-YAL6JSAZ.cjs');
5
5
  var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
6
6
  var react = require('react');
7
+ var viem = require('viem');
7
8
  var wagmi = require('wagmi');
8
9
 
9
10
  var FHE_AIRDROP_KEY = "tokenops-sdk";
@@ -39,10 +40,14 @@ function normalizeKeyArg(value) {
39
40
  if (typeof value === "string" && value.startsWith("0x")) return value.toLowerCase();
40
41
  return value;
41
42
  }
43
+ function staleUntilNonZeroAddress(query) {
44
+ const data = query.state.data;
45
+ return data !== void 0 && !viem.isAddressEqual(data, viem.zeroAddress) ? Infinity : 0;
46
+ }
42
47
  function tryResolveAirdropFactoryAddress(override, chainId) {
43
48
  if (override) return override;
44
49
  if (chainId === void 0) return void 0;
45
- return chunkPG3WXT3K_cjs.getFheAirdropFactoryAddress(chainId);
50
+ return chunkYAL6JSAZ_cjs.getFheAirdropFactoryAddress(chainId);
46
51
  }
47
52
  function computeAirdropFactoryResolutionError(override, chainId) {
48
53
  if (override) return void 0;
@@ -54,7 +59,7 @@ function computeAirdropFactoryResolutionError(override, chainId) {
54
59
  clientLabel: "ConfidentialAirdropFactoryClient"
55
60
  });
56
61
  }
57
- const resolved = chunkPG3WXT3K_cjs.getFheAirdropFactoryAddress(chainId);
62
+ const resolved = chunkYAL6JSAZ_cjs.getFheAirdropFactoryAddress(chainId);
58
63
  if (!resolved) {
59
64
  return new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
60
65
  reason: "registry-not-deployed",
@@ -78,13 +83,13 @@ function useMemoAirdropFactoryClient(opts = {}) {
78
83
  const client = react.useMemo(() => {
79
84
  if (!publicClient) return void 0;
80
85
  if (!resolvedAddress) return void 0;
81
- return chunk4AWQJQXY_cjs.createConfidentialAirdropFactoryClient({
86
+ return chunkE4IV4M4E_cjs.createConfidentialAirdropFactoryClient({
82
87
  publicClient,
83
88
  ...walletClient ? { walletClient } : {},
84
89
  address: resolvedAddress,
85
90
  ...chainId !== void 0 ? { chainId } : {},
86
91
  // Lazy — invoked per-encryption inside the headless client.
87
- encryptor: () => chunk4AWQJQXY_cjs.resolveEncryptor(encryptorSourceRef.current),
92
+ encryptor: () => chunkE4IV4M4E_cjs.resolveEncryptor(encryptorSourceRef.current),
88
93
  ...telemetry ? { telemetry } : {}
89
94
  });
90
95
  }, [publicClient, walletClient, resolvedAddress, chainId, telemetry]);
@@ -105,7 +110,7 @@ function useMemoAirdropBaseClient(opts) {
105
110
  const client = react.useMemo(() => {
106
111
  if (!publicClient) return void 0;
107
112
  if (!opts.address) return void 0;
108
- return chunk4AWQJQXY_cjs.createAirdropBaseClient({
113
+ return chunkE4IV4M4E_cjs.createAirdropBaseClient({
109
114
  publicClient,
110
115
  ...walletClient ? { walletClient } : {},
111
116
  address: opts.address,
@@ -123,7 +128,7 @@ function useMemoMerkleAirdropClient(opts) {
123
128
  const client = react.useMemo(() => {
124
129
  if (!publicClient) return void 0;
125
130
  if (!opts.address) return void 0;
126
- return chunk4AWQJQXY_cjs.createMerkleAirdropClient({
131
+ return chunkE4IV4M4E_cjs.createMerkleAirdropClient({
127
132
  publicClient,
128
133
  ...walletClient ? { walletClient } : {},
129
134
  address: opts.address,
@@ -141,7 +146,7 @@ function useMemoComplianceManagerClient(opts) {
141
146
  const client = react.useMemo(() => {
142
147
  if (!publicClient) return void 0;
143
148
  if (!opts.address) return void 0;
144
- return chunk4AWQJQXY_cjs.createComplianceManagerClient({
149
+ return chunkE4IV4M4E_cjs.createComplianceManagerClient({
145
150
  publicClient,
146
151
  ...walletClient ? { walletClient } : {},
147
152
  address: opts.address,
@@ -159,11 +164,11 @@ function useMemoEcdsaAirdropClient(opts) {
159
164
  const client = react.useMemo(() => {
160
165
  if (!publicClient) return void 0;
161
166
  if (!opts.address) return void 0;
162
- return chunk4AWQJQXY_cjs.createEcdsaAirdropClient({
167
+ return chunkE4IV4M4E_cjs.createEcdsaAirdropClient({
163
168
  publicClient,
164
169
  ...walletClient ? { walletClient } : {},
165
170
  address: opts.address,
166
- dedupMode: opts.dedupMode,
171
+ ...opts.dedupMode !== void 0 ? { dedupMode: opts.dedupMode } : {},
167
172
  ...chainId !== void 0 ? { chainId } : {},
168
173
  ...telemetry ? { telemetry } : {}
169
174
  });
@@ -176,6 +181,7 @@ var AIRDROP_FN = {
176
181
  // instance reads
177
182
  claimedAmount: "getClaimedAmount",
178
183
  paused: "paused",
184
+ dedupMode: "dedupMode",
179
185
  window: "window",
180
186
  config: "config",
181
187
  merkleRoot: "merkleRoot",
@@ -192,20 +198,29 @@ var AIRDROP_FN = {
192
198
  resolvedGasFee: "resolvedGasFee",
193
199
  customFee: "customFee",
194
200
  implementations: "implementations",
201
+ tokenOf: "tokenOf",
202
+ complianceManagerOf: "complianceManagerOf",
195
203
  compliancePolicy: "compliancePolicy",
196
204
  upgradeabilityPolicy: "upgradeabilityPolicy",
197
205
  factoryHasRole: "factoryHasRole",
198
206
  factoryRoleMembers: "factoryRoleMembers",
207
+ effectiveDelegateToCompliance: "effectiveDelegateToCompliance",
208
+ effectiveUpgradeable: "effectiveUpgradeable",
209
+ complianceDelegate: "complianceDelegate",
210
+ ecdsaInitCodeHash: "getEcdsaInitCodeHash",
211
+ predictEcdsaAddress: "predictEcdsaAirdropAddress",
212
+ merkleInitCodeHash: "getMerkleInitCodeHash",
213
+ predictMerkleAddress: "predictMerkleAirdropAddress",
199
214
  // compliance-manager reads
200
215
  complianceInfo: "complianceInfo",
201
216
  activeDelegate: "isActiveDelegate",
202
- clientDelegates: "clientDelegates",
203
217
  complianceHasRole: "complianceHasRole",
204
218
  complianceRoleMembers: "complianceRoleMembers"
205
219
  };
206
220
  var airdropKeys = {
207
221
  /** One account's cumulative delivered total. Keyed on the CLAIM IDENTITY, never the sender. */
208
222
  claimedAmount: (s, account) => airdropQueryKey({ ...s, fn: AIRDROP_FN.claimedAmount, args: [account] }),
223
+ dedupMode: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.dedupMode, args: [] }),
209
224
  paused: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.paused, args: [] }),
210
225
  window: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.window, args: [] }),
211
226
  config: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.config, args: [] }),
@@ -223,15 +238,17 @@ var airdropKeys = {
223
238
  isSignatureValidAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.isSignatureValid }),
224
239
  fees: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.fees, args: [] }),
225
240
  customFee: (s, creator) => airdropQueryKey({ ...s, fn: AIRDROP_FN.customFee, args: [creator] }),
226
- customFeeAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.customFee }),
227
241
  resolvedGasFee: (s, creator) => airdropQueryKey({ ...s, fn: AIRDROP_FN.resolvedGasFee, args: [creator] }),
228
242
  /** Every creator's resolved fee; the default and any override both move it. */
229
243
  resolvedGasFeeAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.resolvedGasFee }),
244
+ registry: (s, offset, limit) => airdropQueryKey({ ...s, fn: AIRDROP_FN.registry, args: [offset, limit] }),
230
245
  /** Every registry page, whatever offset/limit was queried. */
231
246
  registryAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.registry }),
232
247
  isAirdrop: (s, candidate) => airdropQueryKey({ ...s, fn: AIRDROP_FN.isAirdrop, args: [candidate] }),
233
248
  /** Every genuineness answer from this factory; a create adds one address. */
234
249
  isAirdropAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.isAirdrop }),
250
+ tokenOf: (s, airdrop) => airdropQueryKey({ ...s, fn: AIRDROP_FN.tokenOf, args: [airdrop] }),
251
+ complianceManagerOf: (s, airdrop) => airdropQueryKey({ ...s, fn: AIRDROP_FN.complianceManagerOf, args: [airdrop] }),
235
252
  implementations: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.implementations, args: [] }),
236
253
  compliancePolicy: (s, creator) => airdropQueryKey({ ...s, fn: AIRDROP_FN.compliancePolicy, args: [creator] }),
237
254
  compliancePolicyAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.compliancePolicy }),
@@ -240,22 +257,50 @@ var airdropKeys = {
240
257
  factoryHasRole: (s, role, holder) => airdropQueryKey({ ...s, fn: AIRDROP_FN.factoryHasRole, args: [role, holder] }),
241
258
  factoryHasRoleAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.factoryHasRole }),
242
259
  factoryRoleMembers: (s, role) => airdropQueryKey({ ...s, fn: AIRDROP_FN.factoryRoleMembers, args: [role] }),
243
- factoryRoleMembersAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.factoryRoleMembers }),
260
+ effectiveDelegateToCompliance: (s, creator) => airdropQueryKey({ ...s, fn: AIRDROP_FN.effectiveDelegateToCompliance, args: [creator] }),
261
+ /** Every creator's effective compliance default; the factory-wide default moves them all. */
262
+ effectiveDelegateToComplianceAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.effectiveDelegateToCompliance }),
263
+ effectiveUpgradeable: (s, creator) => airdropQueryKey({ ...s, fn: AIRDROP_FN.effectiveUpgradeable, args: [creator] }),
264
+ /** Every creator's effective upgradeability; the factory-wide default moves them all. */
265
+ effectiveUpgradeableAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.effectiveUpgradeable }),
266
+ complianceDelegate: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.complianceDelegate, args: [] }),
267
+ /** Keyed on `mode` only: `params` does not affect the hash (see `useEcdsaInitCodeHash`). */
268
+ ecdsaInitCodeHash: (s, mode) => airdropQueryKey({ ...s, fn: AIRDROP_FN.ecdsaInitCodeHash, args: [mode] }),
269
+ ecdsaInitCodeHashAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.ecdsaInitCodeHash }),
270
+ predictEcdsaAddress: (s, mode, deployer, userSalt) => airdropQueryKey({ ...s, fn: AIRDROP_FN.predictEcdsaAddress, args: [mode, deployer, userSalt] }),
271
+ predictEcdsaAddressAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.predictEcdsaAddress }),
272
+ merkleInitCodeHash: (s, mode) => airdropQueryKey({ ...s, fn: AIRDROP_FN.merkleInitCodeHash, args: [mode] }),
273
+ merkleInitCodeHashAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.merkleInitCodeHash }),
274
+ predictMerkleAddress: (s, mode, deployer, userSalt) => airdropQueryKey({
275
+ ...s,
276
+ fn: AIRDROP_FN.predictMerkleAddress,
277
+ args: [mode, deployer, userSalt]
278
+ }),
279
+ predictMerkleAddressAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.predictMerkleAddress }),
244
280
  complianceInfo: (s) => airdropQueryKey({ ...s, fn: AIRDROP_FN.complianceInfo, args: [] }),
245
281
  activeDelegate: (s, delegate) => airdropQueryKey({ ...s, fn: AIRDROP_FN.activeDelegate, args: [delegate] }),
246
- activeDelegateAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.activeDelegate }),
247
- clientDelegates: (s, index) => airdropQueryKey({ ...s, fn: AIRDROP_FN.clientDelegates, args: [index] }),
248
- clientDelegatesAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.clientDelegates }),
249
282
  complianceHasRole: (s, role, holder) => airdropQueryKey({ ...s, fn: AIRDROP_FN.complianceHasRole, args: [role, holder] }),
250
283
  complianceHasRoleAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.complianceHasRole }),
251
- complianceRoleMembers: (s, role) => airdropQueryKey({ ...s, fn: AIRDROP_FN.complianceRoleMembers, args: [role] }),
252
- complianceRoleMembersAll: (s) => airdropQueryKeyPrefix({ ...s, fn: AIRDROP_FN.complianceRoleMembers })
284
+ complianceRoleMembers: (s, role) => airdropQueryKey({ ...s, fn: AIRDROP_FN.complianceRoleMembers, args: [role] })
253
285
  };
286
+ function invalidateAfterCreate(queryClient, scope, airdrop) {
287
+ for (const queryKey of [
288
+ airdropKeys.registryAll(scope),
289
+ airdropKeys.isAirdropAll(scope),
290
+ airdropKeys.preflightCreateAll(scope),
291
+ airdropKeys.tokenOf(scope, airdrop),
292
+ airdropKeys.complianceManagerOf(scope, airdrop)
293
+ ]) {
294
+ void queryClient.invalidateQueries({ queryKey });
295
+ }
296
+ }
254
297
 
255
298
  exports.AIRDROP_FN = AIRDROP_FN;
256
299
  exports.airdropKeys = airdropKeys;
257
300
  exports.airdropQueryKey = airdropQueryKey;
258
301
  exports.airdropQueryKeyPrefix = airdropQueryKeyPrefix;
302
+ exports.invalidateAfterCreate = invalidateAfterCreate;
303
+ exports.staleUntilNonZeroAddress = staleUntilNonZeroAddress;
259
304
  exports.useMemoAirdropBaseClient = useMemoAirdropBaseClient;
260
305
  exports.useMemoAirdropFactoryClient = useMemoAirdropFactoryClient;
261
306
  exports.useMemoComplianceManagerClient = useMemoComplianceManagerClient;