@tokenops/sdk 1.0.0 → 1.5.1

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 (162) hide show
  1. package/README.md +120 -26
  2. package/dist/{chunk-5SGMJADP.cjs → chunk-2NCLOQ56.cjs} +9 -9
  3. package/dist/{chunk-QIHZVLIK.js → chunk-2PWNH3UE.js} +35 -6
  4. package/dist/{chunk-T5LVV3KY.cjs → chunk-4WPGQSNT.cjs} +3 -3
  5. package/dist/{chunk-SUOG3BQS.cjs → chunk-5X5WL5CU.cjs} +266 -103
  6. package/dist/{chunk-56UI7LUR.cjs → chunk-67OV5CX2.cjs} +19 -0
  7. package/dist/{chunk-WRCUDSUJ.js → chunk-6BMP4ICG.js} +2 -2
  8. package/dist/{chunk-XXXDQSHE.js → chunk-6R4KNAPK.js} +5 -3
  9. package/dist/{chunk-XSNLAS5M.js → chunk-AOP6HMPW.js} +1 -1
  10. package/dist/{chunk-62DF53UQ.cjs → chunk-C7BRZXJA.cjs} +19 -21
  11. package/dist/{chunk-UOG4PJL5.js → chunk-DUZIIRPF.js} +181 -14
  12. package/dist/{chunk-Q7ARQSUH.cjs → chunk-FAXIIH5R.cjs} +3 -3
  13. package/dist/chunk-FT4LNBOS.js +11 -0
  14. package/dist/chunk-IJFQ5L4I.js +2171 -0
  15. package/dist/{chunk-52TC6BF7.js → chunk-IXLO7GO5.js} +210 -47
  16. package/dist/{chunk-CQIPRNS7.cjs → chunk-JK4XMMKM.cjs} +3 -3
  17. package/dist/{chunk-ITQ7WKVC.cjs → chunk-JYOTGRSO.cjs} +8 -8
  18. package/dist/{chunk-VDXVNZCO.cjs → chunk-KLKI352M.cjs} +85 -29
  19. package/dist/{chunk-5SA2HF2W.cjs → chunk-MCRBVJGZ.cjs} +24 -22
  20. package/dist/{chunk-ECT3NL2L.js → chunk-NTZY6IB7.js} +4 -4
  21. package/dist/{chunk-ZHFLRKFY.js → chunk-ODLTEGHB.js} +1 -1
  22. package/dist/{chunk-HGXNRR25.js → chunk-ORFTDNFZ.js} +4 -4
  23. package/dist/{chunk-72YGZEQE.js → chunk-OXTLPTO3.js} +9 -11
  24. package/dist/{chunk-HTOMTEA3.cjs → chunk-PFXURMBZ.cjs} +77 -48
  25. package/dist/{chunk-OLDGMKW2.cjs → chunk-PUPKNW3R.cjs} +35 -2
  26. package/dist/{chunk-IVE3QEGD.js → chunk-QBJ7O2B4.js} +18 -1
  27. package/dist/{chunk-JFLEEXKP.js → chunk-SG65XWH7.js} +58 -2
  28. package/dist/{chunk-K6MFFDBJ.cjs → chunk-T46YXSBP.cjs} +11 -11
  29. package/dist/{chunk-NS44KBV5.cjs → chunk-TEBM66WA.cjs} +12 -12
  30. package/dist/{chunk-6ECAHP5O.cjs → chunk-TIUKIY5V.cjs} +200 -33
  31. package/dist/{chunk-QCA7O2Q5.cjs → chunk-V2PXZVBF.cjs} +4 -4
  32. package/dist/{chunk-JFR5J4FL.cjs → chunk-W7IGCOVL.cjs} +11 -11
  33. package/dist/chunk-WENHUPZC.cjs +2180 -0
  34. package/dist/{chunk-ZXCOJY2Z.js → chunk-WMACINXO.js} +1 -1
  35. package/dist/{chunk-COPFW5Z4.js → chunk-XGGTQQFH.js} +31 -2
  36. package/dist/{chunk-CMRETRZO.js → chunk-YQIBBEFJ.js} +1 -1
  37. package/dist/{chunk-BE2AIZ3K.js → chunk-ZA673I3O.js} +1 -1
  38. package/dist/chunk-ZQUE2B3Q.cjs +33 -0
  39. package/dist/{chunk-FYQ2UW4T.js → chunk-ZWXJTBZO.js} +1 -1
  40. package/dist/core/addresses.d.ts +22 -0
  41. package/dist/core/errors.d.ts +41 -1
  42. package/dist/core/revert-mapper.d.ts +77 -0
  43. package/dist/core/telemetry.d.ts +0 -3
  44. package/dist/core/wagmi-compat.d.ts +40 -0
  45. package/dist/fhe/index.cjs +112 -66
  46. package/dist/fhe/index.d.cts +1 -1
  47. package/dist/fhe/index.d.ts +1 -1
  48. package/dist/fhe/index.js +50 -8
  49. package/dist/fhe/operators.d.ts +1 -1
  50. package/dist/fhe/react/index.cjs +7 -7
  51. package/dist/fhe/react/index.js +2 -2
  52. package/dist/fhe/sepolia-encryptor-web.d.ts +27 -1
  53. package/dist/fhe/sepolia-encryptor.d.ts +38 -0
  54. package/dist/fhe-airdrop/advanced/factory-advanced.d.ts +3 -3
  55. package/dist/fhe-airdrop/advanced/index.cjs +9 -8
  56. package/dist/fhe-airdrop/advanced/index.d.cts +2 -2
  57. package/dist/fhe-airdrop/advanced/index.d.ts +2 -2
  58. package/dist/fhe-airdrop/advanced/index.js +7 -6
  59. package/dist/fhe-airdrop/advanced/react/index.cjs +14 -13
  60. package/dist/fhe-airdrop/advanced/react/index.d.cts +1 -1
  61. package/dist/fhe-airdrop/advanced/react/index.d.ts +1 -1
  62. package/dist/fhe-airdrop/advanced/react/index.js +10 -9
  63. package/dist/fhe-airdrop/airdrop.d.ts +2 -0
  64. package/dist/fhe-airdrop/encryption.d.ts +8 -0
  65. package/dist/fhe-airdrop/factory.d.ts +94 -11
  66. package/dist/fhe-airdrop/index.cjs +61 -57
  67. package/dist/fhe-airdrop/index.d.cts +3 -3
  68. package/dist/fhe-airdrop/index.d.ts +3 -3
  69. package/dist/fhe-airdrop/index.js +7 -7
  70. package/dist/fhe-airdrop/react/index.cjs +163 -133
  71. package/dist/fhe-airdrop/react/index.d.cts +4 -3
  72. package/dist/fhe-airdrop/react/index.d.ts +4 -3
  73. package/dist/fhe-airdrop/react/index.js +38 -13
  74. package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +2 -0
  75. package/dist/fhe-airdrop/react/useAirdropIsSignatureValid.d.ts +3 -2
  76. package/dist/fhe-airdrop/react/useClaim.d.ts +2 -0
  77. package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +8 -0
  78. package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +8 -0
  79. package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +8 -0
  80. package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +51 -0
  81. package/dist/fhe-airdrop/types.d.ts +45 -0
  82. package/dist/fhe-disperse/encryption.d.ts +8 -0
  83. package/dist/fhe-disperse/index.cjs +69 -65
  84. package/dist/fhe-disperse/index.d.cts +1 -1
  85. package/dist/fhe-disperse/index.d.ts +1 -1
  86. package/dist/fhe-disperse/index.js +8 -8
  87. package/dist/fhe-disperse/react/index.cjs +90 -86
  88. package/dist/fhe-disperse/react/index.d.cts +1 -1
  89. package/dist/fhe-disperse/react/index.d.ts +1 -1
  90. package/dist/fhe-disperse/react/index.js +10 -10
  91. package/dist/fhe-disperse/react/useCalculateFee.d.ts +7 -0
  92. package/dist/fhe-disperse/react/useDisperse.d.ts +9 -0
  93. package/dist/fhe-disperse/react/usePreflightDisperse.d.ts +7 -0
  94. package/dist/fhe-disperse/react/useSingletonCalculateFee.d.ts +7 -0
  95. package/dist/fhe-disperse/react/useSingletonWithdrawTokenFee.d.ts +8 -2
  96. package/dist/fhe-disperse/react/useWithdrawTokenFee.d.ts +6 -0
  97. package/dist/fhe-disperse/singleton.d.ts +29 -0
  98. package/dist/fhe-disperse/subtotals.d.ts +6 -0
  99. package/dist/fhe-vesting/advanced/factory-advanced.d.ts +2 -2
  100. package/dist/fhe-vesting/advanced/index.cjs +8 -8
  101. package/dist/fhe-vesting/advanced/index.d.cts +2 -2
  102. package/dist/fhe-vesting/advanced/index.d.ts +2 -2
  103. package/dist/fhe-vesting/advanced/index.js +6 -6
  104. package/dist/fhe-vesting/advanced/react/index.cjs +15 -14
  105. package/dist/fhe-vesting/advanced/react/index.d.cts +1 -1
  106. package/dist/fhe-vesting/advanced/react/index.d.ts +1 -1
  107. package/dist/fhe-vesting/advanced/react/index.js +12 -11
  108. package/dist/fhe-vesting/encryption.d.ts +8 -0
  109. package/dist/fhe-vesting/factory.d.ts +6 -8
  110. package/dist/fhe-vesting/index.cjs +79 -75
  111. package/dist/fhe-vesting/index.d.cts +2 -2
  112. package/dist/fhe-vesting/index.d.ts +2 -2
  113. package/dist/fhe-vesting/index.js +9 -9
  114. package/dist/fhe-vesting/manager.d.ts +101 -3
  115. package/dist/fhe-vesting/react/index.cjs +241 -219
  116. package/dist/fhe-vesting/react/index.d.cts +3 -2
  117. package/dist/fhe-vesting/react/index.d.ts +3 -2
  118. package/dist/fhe-vesting/react/index.js +29 -12
  119. package/dist/fhe-vesting/react/useAdminClaim.d.ts +2 -0
  120. package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +2 -0
  121. package/dist/fhe-vesting/react/useBatchCreateVesting.d.ts +8 -0
  122. package/dist/fhe-vesting/react/useClaim.d.ts +2 -0
  123. package/dist/fhe-vesting/react/useCreateVesting.d.ts +8 -0
  124. package/dist/fhe-vesting/react/useManagerWithdrawTokenFee.d.ts +7 -1
  125. package/dist/fhe-vesting/react/usePartialClaim.d.ts +8 -0
  126. package/dist/fhe-vesting/react/usePreflightCreateVesting.d.ts +37 -0
  127. package/dist/fhe-vesting/react/useVestingClaim.d.ts +2 -0
  128. package/dist/fhe-vesting/react/useWithdrawAdmin.d.ts +6 -0
  129. package/dist/fhe-vesting/react/useWithdrawTokenFee.d.ts +6 -0
  130. package/dist/fhe-vesting/types.d.ts +34 -2
  131. package/dist/index.cjs +73 -49
  132. package/dist/index.d.cts +1 -1
  133. package/dist/index.d.ts +1 -1
  134. package/dist/index.js +2 -2
  135. package/dist/testnet-faucet/abis/confidential-test-token.d.ts +1039 -0
  136. package/dist/testnet-faucet/abis/index.d.ts +2 -0
  137. package/dist/testnet-faucet/abis/test-token.d.ts +253 -0
  138. package/dist/testnet-faucet/errors.d.ts +21 -0
  139. package/dist/testnet-faucet/faucet.d.ts +173 -0
  140. package/dist/testnet-faucet/index.cjs +212 -0
  141. package/dist/testnet-faucet/index.d.cts +8 -0
  142. package/dist/testnet-faucet/index.d.ts +8 -0
  143. package/dist/testnet-faucet/index.js +7 -0
  144. package/dist/testnet-faucet/react/_shared.d.ts +61 -0
  145. package/dist/testnet-faucet/react/index.cjs +384 -0
  146. package/dist/testnet-faucet/react/index.d.cts +39 -0
  147. package/dist/testnet-faucet/react/index.d.ts +39 -0
  148. package/dist/testnet-faucet/react/index.js +220 -0
  149. package/dist/testnet-faucet/react/useConfidentialBalance.d.ts +25 -0
  150. package/dist/testnet-faucet/react/useFaucetDecimals.d.ts +9 -0
  151. package/dist/testnet-faucet/react/useFaucetMetadata.d.ts +14 -0
  152. package/dist/testnet-faucet/react/useFaucetRate.d.ts +11 -0
  153. package/dist/testnet-faucet/react/useInferredTotalSupply.d.ts +11 -0
  154. package/dist/testnet-faucet/react/useMaxTotalSupply.d.ts +10 -0
  155. package/dist/testnet-faucet/react/useMintConfidential.d.ts +35 -0
  156. package/dist/testnet-faucet/react/useMintUnderlying.d.ts +31 -0
  157. package/dist/testnet-faucet/react/useUnderlyingBalance.d.ts +19 -0
  158. package/dist/testnet-faucet/react/useUnderlyingDecimals.d.ts +9 -0
  159. package/dist/testnet-faucet/react/useUnderlyingTokenAddress.d.ts +12 -0
  160. package/dist/testnet-faucet/types.d.ts +92 -0
  161. package/dist/testnet-faucet/validate.d.ts +44 -0
  162. package/package.json +79 -30
@@ -1,11 +1,12 @@
1
1
  'use strict';
2
2
 
3
- var chunkVDXVNZCO_cjs = require('./chunk-VDXVNZCO.cjs');
4
- var chunkOLDGMKW2_cjs = require('./chunk-OLDGMKW2.cjs');
5
- var chunkCQIPRNS7_cjs = require('./chunk-CQIPRNS7.cjs');
3
+ var chunkFWHYQZ5E_cjs = require('./chunk-FWHYQZ5E.cjs');
4
+ var chunkKLKI352M_cjs = require('./chunk-KLKI352M.cjs');
5
+ var chunkPUPKNW3R_cjs = require('./chunk-PUPKNW3R.cjs');
6
+ var chunkJK4XMMKM_cjs = require('./chunk-JK4XMMKM.cjs');
6
7
  var chunkVJKZWYYJ_cjs = require('./chunk-VJKZWYYJ.cjs');
7
8
  var chunk66IHPTOK_cjs = require('./chunk-66IHPTOK.cjs');
8
- var chunk56UI7LUR_cjs = require('./chunk-56UI7LUR.cjs');
9
+ var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
9
10
  var viem = require('viem');
10
11
 
11
12
  // src/fhe-airdrop/abis/factory.ts
@@ -935,7 +936,7 @@ function resolveEncryptor(source) {
935
936
  var MAX_UINT64 = (1n << 64n) - 1n;
936
937
  function assertUint64(value, label) {
937
938
  if (value < 0n || value > MAX_UINT64) {
938
- throw new chunk56UI7LUR_cjs.InvalidArgumentError({
939
+ throw new chunk67OV5CX2_cjs.InvalidArgumentError({
939
940
  method: "encryptUint64",
940
941
  argument: label,
941
942
  reason: "exceeds uint64 range (0..2^64-1)",
@@ -956,7 +957,7 @@ async function encryptUint64({
956
957
  userAddress
957
958
  });
958
959
  if (handles.length !== 1) {
959
- throw new chunk56UI7LUR_cjs.InvalidArgumentError({
960
+ throw new chunk67OV5CX2_cjs.InvalidArgumentError({
960
961
  method: "encryptUint64",
961
962
  argument: "handles",
962
963
  reason: `expected 1 handle, got ${handles.length}`,
@@ -975,7 +976,7 @@ async function encryptUint64Batch({
975
976
  values
976
977
  }) {
977
978
  if (values.length === 0) {
978
- throw new chunk56UI7LUR_cjs.InvalidArgumentError({
979
+ throw new chunk67OV5CX2_cjs.InvalidArgumentError({
979
980
  method: "encryptUint64Batch",
980
981
  argument: "values",
981
982
  reason: "must be non-empty"
@@ -988,7 +989,7 @@ async function encryptUint64Batch({
988
989
  userAddress
989
990
  });
990
991
  if (handles.length !== values.length) {
991
- throw new chunk56UI7LUR_cjs.InvalidArgumentError({
992
+ throw new chunk67OV5CX2_cjs.InvalidArgumentError({
992
993
  method: "encryptUint64Batch",
993
994
  argument: "handles",
994
995
  reason: `expected ${values.length} handles, got ${handles.length}`,
@@ -1002,17 +1003,17 @@ async function encryptUint64Batch({
1002
1003
  }
1003
1004
  async function signClaimAuthorization(args) {
1004
1005
  if (args.encryptedAmountHandle.length !== 66) {
1005
- throw new chunk56UI7LUR_cjs.TokenOpsSdkError(
1006
+ throw new chunk67OV5CX2_cjs.TokenOpsSdkError(
1006
1007
  `signClaimAuthorization: encryptedAmountHandle must be a 32-byte hex string (0x + 64 chars), got length ${args.encryptedAmountHandle.length}`
1007
1008
  );
1008
1009
  }
1009
1010
  const account = args.walletClient.account;
1010
1011
  if (!account) {
1011
- throw new chunk56UI7LUR_cjs.MissingAccountError("signClaimAuthorization");
1012
+ throw new chunk67OV5CX2_cjs.MissingAccountError("signClaimAuthorization");
1012
1013
  }
1013
1014
  const chainId = args.walletClient.chain?.id;
1014
1015
  if (!chainId) {
1015
- throw new chunk56UI7LUR_cjs.InvalidArgumentError({
1016
+ throw new chunk67OV5CX2_cjs.InvalidArgumentError({
1016
1017
  method: "signClaimAuthorization",
1017
1018
  argument: "walletClient.chain.id",
1018
1019
  reason: "required for EIP712 chainId binding; pass a walletClient constructed with a known chain (e.g. `createWalletClient({ chain: sepolia, ... })`)."
@@ -1052,10 +1053,10 @@ var ConfidentialAirdropFactoryClient = class {
1052
1053
  this.walletClient = config.walletClient;
1053
1054
  this.encryptor = config.encryptor;
1054
1055
  const chainId = config.chainId ?? config.publicClient.chain?.id;
1055
- const addressOverride = config.address ? chunkCQIPRNS7_cjs.normaliseAddress(config.address) : void 0;
1056
- const resolved = addressOverride ?? (chainId === void 0 ? void 0 : chunkOLDGMKW2_cjs.getFheAirdropFactoryAddress(chainId));
1056
+ const addressOverride = config.address ? chunkJK4XMMKM_cjs.normaliseAddress(config.address) : void 0;
1057
+ const resolved = addressOverride ?? (chainId === void 0 ? void 0 : chunkPUPKNW3R_cjs.getFheAirdropFactoryAddress(chainId));
1057
1058
  if (!resolved) {
1058
- throw new chunk56UI7LUR_cjs.DeploymentAddressUnavailableError({
1059
+ throw new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
1059
1060
  reason: chainId === void 0 ? "chain-id-missing" : "registry-not-deployed",
1060
1061
  product: "fheAirdrop",
1061
1062
  contract: "confidentialAirdropFactory",
@@ -1071,7 +1072,7 @@ var ConfidentialAirdropFactoryClient = class {
1071
1072
  hasWallet: !!this.walletClient,
1072
1073
  aclResolved: true,
1073
1074
  // factory has no ACL dependency; constant for funnel-shape parity with client.
1074
- sdkVersion: chunkVDXVNZCO_cjs.SDK_VERSION
1075
+ sdkVersion: chunkKLKI352M_cjs.SDK_VERSION
1075
1076
  });
1076
1077
  }
1077
1078
  // ----------------------- writes -----------------------
@@ -1079,11 +1080,10 @@ var ConfidentialAirdropFactoryClient = class {
1079
1080
  * Deploy a new airdrop clone via the factory and return its address, parsed
1080
1081
  * from the `ConfidentialAirdropCreated` event in the tx receipt.
1081
1082
  *
1082
- * **This is the headline factory entry point.** R02 ADR P-1 collapses the
1083
- * old hash-only + `…AndGetAddress` pair down to one rich-return method —
1084
- * 90 %+ of consumers want the deployed address back, and the SDK already
1085
- * waits + parses the event, so there's no reason to make consumers do it
1086
- * themselves.
1083
+ * **This is the headline factory entry point.** It returns one rich-return
1084
+ * shape: most consumers want the deployed address back, and the SDK already
1085
+ * waits for and parses the event, so there's no reason to make consumers do
1086
+ * it themselves.
1087
1087
  *
1088
1088
  * Internally: `writeContract` → {@link PublicClient.waitForTransactionReceipt} →
1089
1089
  * `parseEventLogs({ eventName: "ConfidentialAirdropCreated" })`.
@@ -1119,9 +1119,17 @@ var ConfidentialAirdropFactoryClient = class {
1119
1119
  * Prerequisites: caller must have set this factory as an operator on the
1120
1120
  * token: `token.setOperator(factoryAddress, deadline)`.
1121
1121
  *
1122
+ * **Silent-zero transfers.** ERC-7984 transfers do not revert when the sender's encrypted balance is insufficient — the transfer succeeds and moves an encrypted zero instead. This is by design: reverting would leak balance information. The transaction receipt alone cannot tell you whether value actually moved.
1123
+ *
1124
+ * **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
1125
+ * convention (1 token = 1_000_000 base units), not the 18 decimals typical of
1126
+ * ERC-20. Amount parameters are base units of the token's actual decimals:
1127
+ * for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
1128
+ * transparent TTT test token uses 18 decimals.
1129
+ *
1122
1130
  * Symmetric with {@link ConfidentialAirdropFactoryClient.createConfidentialAirdrop}
1123
1131
  * — both return `{ hash, airdrop }` parsed from the
1124
- * `ConfidentialAirdropCreated` event (R02 ADR P-1).
1132
+ * `ConfidentialAirdropCreated` event.
1125
1133
  *
1126
1134
  * @example
1127
1135
  * const { hash, airdrop } = await factory.createAndFundConfidentialAirdrop({
@@ -1181,6 +1189,14 @@ var ConfidentialAirdropFactoryClient = class {
1181
1189
  * Prerequisites: caller must have set this factory as an operator on the token:
1182
1190
  * `token.setOperator(factoryAddress, deadline)`
1183
1191
  *
1192
+ * **Silent-zero transfers.** ERC-7984 transfers do not revert when the sender's encrypted balance is insufficient — the transfer succeeds and moves an encrypted zero instead. This is by design: reverting would leak balance information. The transaction receipt alone cannot tell you whether value actually moved.
1193
+ *
1194
+ * **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
1195
+ * convention (1 token = 1_000_000 base units), not the 18 decimals typical of
1196
+ * ERC-20. Amount parameters are base units of the token's actual decimals:
1197
+ * for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
1198
+ * transparent TTT test token uses 18 decimals.
1199
+ *
1184
1200
  * @returns Transaction hash.
1185
1201
  */
1186
1202
  async fundConfidentialAirdrop(args) {
@@ -1250,6 +1266,14 @@ var ConfidentialAirdropFactoryClient = class {
1250
1266
  * Symmetry with {@link ConfidentialAirdropFactoryClient.createConfidentialAirdropAndGetAddress}
1251
1267
  * — use this when you also need to seed the pool in the same transaction.
1252
1268
  *
1269
+ * **Silent-zero transfers.** ERC-7984 transfers do not revert when the sender's encrypted balance is insufficient — the transfer succeeds and moves an encrypted zero instead. This is by design: reverting would leak balance information. The transaction receipt alone cannot tell you whether value actually moved.
1270
+ *
1271
+ * **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
1272
+ * convention (1 token = 1_000_000 base units), not the 18 decimals typical of
1273
+ * ERC-20. Amount parameters are base units of the token's actual decimals:
1274
+ * for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
1275
+ * transparent TTT test token uses 18 decimals.
1276
+ *
1253
1277
  * Internally: {@link ConfidentialAirdropFactoryClient.createAndFundConfidentialAirdrop} →
1254
1278
  * {@link PublicClient.waitForTransactionReceipt} →
1255
1279
  * `parseEventLogs({ eventName: "ConfidentialAirdropCreated" })`.
@@ -1296,9 +1320,8 @@ var ConfidentialAirdropFactoryClient = class {
1296
1320
  * Alias for {@link ConfidentialAirdropFactoryClient.implementation} that matches
1297
1321
  * the contract's storage field name (`_airdropImplementation`).
1298
1322
  *
1299
- * Shipped proactively in R17 for parity with `fhe-vesting`'s
1300
- * `managerImplementation()` alias (commit 6f6d7bc, closing
1301
- * backend-integrator-r14 minor). The airdrop factory has the same
1323
+ * Provided for parity with `fhe-vesting`'s `managerImplementation()` alias.
1324
+ * The airdrop factory has the same
1302
1325
  * LibClone shape mirroring `_airdropImplementation` storage, so server
1303
1326
  * devs reading the Solidity first reach for `factory.airdropImplementation()`
1304
1327
  * via autocomplete and would otherwise hit a TS2551 on the SDK's
@@ -1333,6 +1356,149 @@ var ConfidentialAirdropFactoryClient = class {
1333
1356
  async getInitCodeHash(args) {
1334
1357
  return this.#read("getInitCodeHash", [toAbiParams(args.params), args.gasFee]);
1335
1358
  }
1359
+ // ----------------------- preflight -----------------------
1360
+ /**
1361
+ * Read-only preflight for {@link createConfidentialAirdrop} /
1362
+ * {@link createAndFundConfidentialAirdrop}. Runs the
1363
+ * deterministic-from-off-chain checks and reports blockers both as
1364
+ * human-readable strings (`blockers`) and as typed {@link TokenOpsSdkError}s
1365
+ * (`blockerErrors`), index-aligned.
1366
+ *
1367
+ * Preflight is **opt-in**. Consumers who have already validated state can
1368
+ * skip this call and invoke the write directly — they'll receive the same
1369
+ * typed errors at write time via the revert mapper.
1370
+ *
1371
+ * Report fields: `isFactoryOperator`, `gasFee`, `predictedAirdrop`,
1372
+ * `alreadyDeployed`, `ready`, `blockers`, `blockerErrors` — see
1373
+ * {@link CreateAirdropPreflightReport} for the meaning of each.
1374
+ *
1375
+ * Checks performed (all read-only, no gas):
1376
+ * - Structural `params` validation mirroring the factory + clone
1377
+ * `initialize` requirements (`InvalidArgumentError` blockers): `token` and
1378
+ * `admin` are checksummed non-zero addresses,
1379
+ * `startTimestamp < endTimestamp`, and `endTimestamp` is in the future
1380
+ * (the clone's `initialize` reverts with `EndTimeInPast`).
1381
+ * - Operator: creator has approved this factory as an ERC-7984 operator on
1382
+ * `params.token` — a blocker only when `funding: true`
1383
+ * ({@link OperatorNotApprovedError}); otherwise informational via
1384
+ * `isFactoryOperator`.
1385
+ * - Collision (only when `userSalt` is supplied): bytecode already at the
1386
+ * predicted CREATE2 address means a repeat create with the same
1387
+ * `(params, userSalt, gasFee)` would revert
1388
+ * ({@link AlreadyInitializedError} blocker).
1389
+ *
1390
+ * **Not preflight-detectable — read before trusting `ready: true`:** the
1391
+ * creator's confidential token balance is an encrypted `euint64` the SDK
1392
+ * cannot read in plaintext, and an underfunded `createAndFund` does **not**
1393
+ * revert — the ERC-7984 transfer silently moves an encrypted zero. Confirm
1394
+ * the creator's balance covers the pool before submitting.
1395
+ *
1396
+ * @param args See {@link PreflightCreateAirdropArgs}.
1397
+ * @returns A {@link CreateAirdropPreflightReport}.
1398
+ */
1399
+ async preflightCreateAirdrop(args) {
1400
+ const { params, creator, userSalt, funding } = args;
1401
+ const blockers = [];
1402
+ const blockerErrors = [];
1403
+ const pushBlocker = (err) => {
1404
+ blockerErrors.push(err);
1405
+ blockers.push(err.message);
1406
+ };
1407
+ const tokenOk = viem.isAddress(params.token, { strict: true }) && params.token !== ZERO_ADDRESS;
1408
+ if (!tokenOk) {
1409
+ pushBlocker(
1410
+ new chunk67OV5CX2_cjs.InvalidArgumentError({
1411
+ method: "createConfidentialAirdrop",
1412
+ argument: "params.token",
1413
+ reason: "must be a valid, non-zero EIP-55 checksummed address",
1414
+ value: params.token
1415
+ })
1416
+ );
1417
+ }
1418
+ const adminOk = viem.isAddress(params.admin, { strict: true }) && params.admin !== ZERO_ADDRESS;
1419
+ if (!adminOk) {
1420
+ pushBlocker(
1421
+ new chunk67OV5CX2_cjs.InvalidArgumentError({
1422
+ method: "createConfidentialAirdrop",
1423
+ argument: "params.admin",
1424
+ reason: "must be a valid, non-zero EIP-55 checksummed address",
1425
+ value: params.admin
1426
+ })
1427
+ );
1428
+ }
1429
+ if (params.startTimestamp >= params.endTimestamp) {
1430
+ pushBlocker(
1431
+ new chunk67OV5CX2_cjs.InvalidArgumentError({
1432
+ method: "createConfidentialAirdrop",
1433
+ argument: "params.startTimestamp/params.endTimestamp",
1434
+ reason: "startTimestamp must be strictly less than endTimestamp",
1435
+ value: { startTimestamp: params.startTimestamp, endTimestamp: params.endTimestamp }
1436
+ })
1437
+ );
1438
+ }
1439
+ const [block, customFee, defaultFee, isFactoryOperator] = await Promise.all([
1440
+ this.publicClient.getBlock(),
1441
+ this.getCustomFee(creator),
1442
+ this.defaultGasFee(),
1443
+ tokenOk ? this.publicClient.readContract({
1444
+ address: params.token,
1445
+ abi: chunkFWHYQZ5E_cjs.erc7984OperatorAbi,
1446
+ functionName: "isOperator",
1447
+ args: [creator, this.address]
1448
+ }) : Promise.resolve(false)
1449
+ ]);
1450
+ const gasFee = customFee.enabled ? customFee.gasFee : defaultFee;
1451
+ if (params.endTimestamp <= Number(block.timestamp)) {
1452
+ pushBlocker(
1453
+ new chunk67OV5CX2_cjs.InvalidArgumentError({
1454
+ method: "createConfidentialAirdrop",
1455
+ argument: "params.endTimestamp",
1456
+ reason: "must be in the future (the clone's initialize reverts with EndTimeInPast)",
1457
+ value: params.endTimestamp
1458
+ })
1459
+ );
1460
+ }
1461
+ if (funding === true && !isFactoryOperator) {
1462
+ pushBlocker(
1463
+ new chunk67OV5CX2_cjs.OperatorNotApprovedError({
1464
+ method: "createAndFundConfidentialAirdrop",
1465
+ contractAddress: this.address,
1466
+ tokenAddress: params.token,
1467
+ holder: creator,
1468
+ spender: this.address
1469
+ })
1470
+ );
1471
+ }
1472
+ let predictedAirdrop;
1473
+ let alreadyDeployed;
1474
+ if (userSalt !== void 0 && tokenOk && adminOk) {
1475
+ predictedAirdrop = await this.#read("predictAirdropAddress", [
1476
+ toAbiParams(params),
1477
+ userSalt,
1478
+ creator,
1479
+ gasFee
1480
+ ]);
1481
+ const bytecode = await this.publicClient.getCode({ address: predictedAirdrop });
1482
+ alreadyDeployed = bytecode !== void 0 && bytecode !== "0x";
1483
+ if (alreadyDeployed) {
1484
+ pushBlocker(
1485
+ new chunk67OV5CX2_cjs.AlreadyInitializedError({
1486
+ method: "createConfidentialAirdrop",
1487
+ contractAddress: predictedAirdrop
1488
+ })
1489
+ );
1490
+ }
1491
+ }
1492
+ return {
1493
+ isFactoryOperator,
1494
+ gasFee,
1495
+ predictedAirdrop,
1496
+ alreadyDeployed,
1497
+ ready: blockers.length === 0,
1498
+ blockers,
1499
+ blockerErrors
1500
+ };
1501
+ }
1336
1502
  // ----------------------- internals -----------------------
1337
1503
  /**
1338
1504
  * Wait for the receipt of a clone-deploy tx and parse the
@@ -1349,12 +1515,12 @@ var ConfidentialAirdropFactoryClient = class {
1349
1515
  });
1350
1516
  const ours = events.filter((ev) => ev.address.toLowerCase() === this.address.toLowerCase());
1351
1517
  if (ours.length === 0) {
1352
- throw new chunk56UI7LUR_cjs.TokenOpsSdkError(
1518
+ throw new chunk67OV5CX2_cjs.TokenOpsSdkError(
1353
1519
  `${method}: no ConfidentialAirdropCreated event from factory ${this.address} in tx ${hash}`
1354
1520
  );
1355
1521
  }
1356
1522
  if (ours.length > 1) {
1357
- throw new chunk56UI7LUR_cjs.TokenOpsSdkError(
1523
+ throw new chunk67OV5CX2_cjs.TokenOpsSdkError(
1358
1524
  `${method}: ${ours.length} ConfidentialAirdropCreated events from factory ${this.address} in tx ${hash}; ambiguous result`
1359
1525
  );
1360
1526
  }
@@ -1362,14 +1528,14 @@ var ConfidentialAirdropFactoryClient = class {
1362
1528
  }
1363
1529
  #requireWallet(method) {
1364
1530
  if (!this.walletClient) {
1365
- throw new chunk56UI7LUR_cjs.MissingWalletClientError(method);
1531
+ throw new chunk67OV5CX2_cjs.MissingWalletClientError(method);
1366
1532
  }
1367
1533
  return this.walletClient;
1368
1534
  }
1369
1535
  #resolveAccount(wallet, override, method) {
1370
1536
  const acct = override ?? wallet.account;
1371
1537
  if (!acct) {
1372
- throw new chunk56UI7LUR_cjs.MissingAccountError(method);
1538
+ throw new chunk67OV5CX2_cjs.MissingAccountError(method);
1373
1539
  }
1374
1540
  return acct;
1375
1541
  }
@@ -1383,14 +1549,14 @@ var ConfidentialAirdropFactoryClient = class {
1383
1549
  const hasAmount = amount !== void 0;
1384
1550
  const hasInput = preEncrypted !== void 0;
1385
1551
  if (hasAmount && hasInput) {
1386
- throw new chunk56UI7LUR_cjs.InvalidArgumentError({
1552
+ throw new chunk67OV5CX2_cjs.InvalidArgumentError({
1387
1553
  method,
1388
1554
  argument: "amount/encryptedInput",
1389
1555
  reason: "exactly one of `amount` (plaintext, SDK encrypts) or `encryptedInput` (pre-encrypted) must be supplied \u2014 got both"
1390
1556
  });
1391
1557
  }
1392
1558
  if (!hasAmount && !hasInput) {
1393
- throw new chunk56UI7LUR_cjs.InvalidArgumentError({
1559
+ throw new chunk67OV5CX2_cjs.InvalidArgumentError({
1394
1560
  method,
1395
1561
  argument: "amount/encryptedInput",
1396
1562
  reason: "exactly one of `amount` (plaintext, SDK encrypts) or `encryptedInput` (pre-encrypted) must be supplied \u2014 got neither"
@@ -1399,7 +1565,7 @@ var ConfidentialAirdropFactoryClient = class {
1399
1565
  if (hasInput) return preEncrypted;
1400
1566
  const enc = encryptor ?? resolveEncryptor(this.encryptor);
1401
1567
  if (!enc) {
1402
- throw new chunk56UI7LUR_cjs.MissingEncryptorError("encryptAmount", {
1568
+ throw new chunk67OV5CX2_cjs.MissingEncryptorError("encryptAmount", {
1403
1569
  hint: "Pass `encryptor` to the call or the client config (eager or lazy factory)."
1404
1570
  });
1405
1571
  }
@@ -1428,7 +1594,7 @@ var ConfidentialAirdropFactoryClient = class {
1428
1594
  }
1429
1595
  }
1430
1596
  #mapRevert(method, err, account) {
1431
- return chunkVDXVNZCO_cjs.mapContractRevert(err, {
1597
+ return chunkKLKI352M_cjs.mapContractRevert(err, {
1432
1598
  method,
1433
1599
  contractAddress: this.address,
1434
1600
  abi: confidentialAirdropFactoryAbi,
@@ -1456,7 +1622,7 @@ var ConfidentialAirdropFactoryClient = class {
1456
1622
  ...value !== void 0 ? { value } : {}
1457
1623
  });
1458
1624
  } catch (err) {
1459
- if (chunkVDXVNZCO_cjs.isContractRevert(err)) {
1625
+ if (chunkKLKI352M_cjs.isContractRevert(err)) {
1460
1626
  throw this.#mapRevert(method, err, accountAddress(account));
1461
1627
  }
1462
1628
  }
@@ -1474,6 +1640,7 @@ var ConfidentialAirdropFactoryClient = class {
1474
1640
  function createConfidentialAirdropFactoryClient(config) {
1475
1641
  return new ConfidentialAirdropFactoryClient(config);
1476
1642
  }
1643
+ var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
1477
1644
  function accountAddress(account) {
1478
1645
  return typeof account === "string" ? account : account.address;
1479
1646
  }
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunk62DF53UQ_cjs = require('./chunk-62DF53UQ.cjs');
3
+ var chunkC7BRZXJA_cjs = require('./chunk-C7BRZXJA.cjs');
4
4
 
5
5
  // src/fhe-vesting/advanced/factory-advanced.ts
6
- var ConfidentialVestingFactoryAdvancedClient = class extends chunk62DF53UQ_cjs.ConfidentialVestingFactoryClient {
6
+ var ConfidentialVestingFactoryAdvancedClient = class extends chunkC7BRZXJA_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 chunk62DF53UQ_cjs.C
20
20
  if (hasOptions) {
21
21
  return this.publicClient.readContract({
22
22
  address: this.address,
23
- abi: chunk62DF53UQ_cjs.confidentialVestingFactoryAbi,
23
+ abi: chunkC7BRZXJA_cjs.confidentialVestingFactoryAbi,
24
24
  functionName: "predictManagerAddressWithOptions",
25
25
  args: [
26
26
  args.token,
@@ -34,7 +34,7 @@ var ConfidentialVestingFactoryAdvancedClient = class extends chunk62DF53UQ_cjs.C
34
34
  }
35
35
  return this.publicClient.readContract({
36
36
  address: this.address,
37
- abi: chunk62DF53UQ_cjs.confidentialVestingFactoryAbi,
37
+ abi: chunkC7BRZXJA_cjs.confidentialVestingFactoryAbi,
38
38
  functionName: "predictManagerAddress",
39
39
  args: [args.token, args.userSalt, args.deployer],
40
40
  blockNumber: args.blockNumber
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkSUOG3BQS_cjs = require('./chunk-SUOG3BQS.cjs');
4
- var chunk62DF53UQ_cjs = require('./chunk-62DF53UQ.cjs');
5
- var chunkOLDGMKW2_cjs = require('./chunk-OLDGMKW2.cjs');
6
- var chunk56UI7LUR_cjs = require('./chunk-56UI7LUR.cjs');
3
+ var chunk5X5WL5CU_cjs = require('./chunk-5X5WL5CU.cjs');
4
+ var chunkC7BRZXJA_cjs = require('./chunk-C7BRZXJA.cjs');
5
+ var chunkPUPKNW3R_cjs = require('./chunk-PUPKNW3R.cjs');
6
+ var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
7
7
  var react = require('react');
8
8
  var wagmi = require('wagmi');
9
9
 
@@ -25,7 +25,7 @@ function useHookFiredEvent(hookName, telemetry, hasWallet, chainId) {
25
25
  function tryResolveFactoryAddress(override, chainId) {
26
26
  if (override) return override;
27
27
  if (chainId === void 0) return void 0;
28
- return chunkOLDGMKW2_cjs.getFheVestingFactoryAddress(chainId);
28
+ return chunkPUPKNW3R_cjs.getFheVestingFactoryAddress(chainId);
29
29
  }
30
30
  function useMemoFactoryClient(opts = {}) {
31
31
  const publicClient = wagmi.usePublicClient({ chainId: opts.chainId });
@@ -38,7 +38,7 @@ function useMemoFactoryClient(opts = {}) {
38
38
  const client = react.useMemo(() => {
39
39
  if (!publicClient) return void 0;
40
40
  if (!resolvedAddress) return void 0;
41
- return chunk62DF53UQ_cjs.createConfidentialVestingFactoryClient({
41
+ return chunkC7BRZXJA_cjs.createConfidentialVestingFactoryClient({
42
42
  publicClient,
43
43
  ...walletClient ? { walletClient } : {},
44
44
  address: resolvedAddress,
@@ -58,16 +58,16 @@ function useMemoFactoryClient(opts = {}) {
58
58
  function computeFactoryResolutionError(override, chainId) {
59
59
  if (override) return void 0;
60
60
  if (chainId === void 0) {
61
- return new chunk56UI7LUR_cjs.DeploymentAddressUnavailableError({
61
+ return new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
62
62
  reason: "chain-id-missing",
63
63
  product: "fheVesting",
64
64
  contract: "confidentialVestingFactory",
65
65
  clientLabel: "ConfidentialVestingFactoryClient"
66
66
  });
67
67
  }
68
- const resolved = chunkOLDGMKW2_cjs.getFheVestingFactoryAddress(chainId);
68
+ const resolved = chunkPUPKNW3R_cjs.getFheVestingFactoryAddress(chainId);
69
69
  if (!resolved) {
70
- return new chunk56UI7LUR_cjs.DeploymentAddressUnavailableError({
70
+ return new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
71
71
  reason: "registry-not-deployed",
72
72
  product: "fheVesting",
73
73
  contract: "confidentialVestingFactory",
@@ -88,13 +88,13 @@ function useMemoManagerClient(opts) {
88
88
  const client = react.useMemo(() => {
89
89
  if (!publicClient) return void 0;
90
90
  if (!opts.address) return void 0;
91
- return chunkSUOG3BQS_cjs.createConfidentialVestingManagerClient({
91
+ return chunk5X5WL5CU_cjs.createConfidentialVestingManagerClient({
92
92
  publicClient,
93
93
  ...walletClient ? { walletClient } : {},
94
94
  address: opts.address,
95
95
  // Lazy — invoked per-encryption inside the headless client. Picks up
96
96
  // whichever EncryptorSource the consumer last passed in.
97
- encryptor: () => chunkSUOG3BQS_cjs.resolveEncryptor(encryptorSourceRef.current),
97
+ encryptor: () => chunk5X5WL5CU_cjs.resolveEncryptor(encryptorSourceRef.current),
98
98
  ...opts.aclAddress ? { aclAddress: opts.aclAddress } : {},
99
99
  ...telemetry ? { telemetry } : {}
100
100
  });