@tokenops/sdk 1.5.1 → 2.0.0-alpha.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 (222) hide show
  1. package/CHANGELOG.md +198 -2
  2. package/CONTRIBUTING.md +4 -2
  3. package/README.md +146 -90
  4. package/SECURITY.md +7 -1
  5. package/SUPPORT.md +47 -0
  6. package/dist/{chunk-YQIBBEFJ.js → chunk-335Z2W67.js} +1 -1
  7. package/dist/{chunk-2NCLOQ56.cjs → chunk-3QHNYEQD.cjs} +77 -0
  8. package/dist/chunk-456VDDA3.js +370 -0
  9. package/dist/{chunk-SG65XWH7.js → chunk-4RAAATVY.js} +1 -3
  10. package/dist/{chunk-6BMP4ICG.js → chunk-4TSDNZQ3.js} +60 -2
  11. package/dist/{chunk-PUPKNW3R.cjs → chunk-5576FRT3.cjs} +30 -6
  12. package/dist/{chunk-AOP6HMPW.js → chunk-6GNR22OV.js} +75 -1
  13. package/dist/{chunk-NTZY6IB7.js → chunk-6NAVMWZQ.js} +4 -3
  14. package/dist/{chunk-C7BRZXJA.cjs → chunk-6PXXGACR.cjs} +8 -7
  15. package/dist/{chunk-IJFQ5L4I.js → chunk-74QFZ5MK.js} +4 -3
  16. package/dist/chunk-7AFPOE7N.cjs +59 -0
  17. package/dist/chunk-AXIPOR3C.js +56 -0
  18. package/dist/chunk-CTED3MTR.cjs +380 -0
  19. package/dist/{chunk-XGGTQQFH.js → chunk-DZHYSUGY.js} +28 -7
  20. package/dist/{chunk-OXTLPTO3.js → chunk-EAJ7SYHE.js} +4 -3
  21. package/dist/{chunk-V2PXZVBF.cjs → chunk-FGEB7RMY.cjs} +4 -4
  22. package/dist/chunk-GKKDAW44.js +8823 -0
  23. package/dist/{chunk-2PWNH3UE.js → chunk-H5POPGOZ.js} +63 -5
  24. package/dist/{chunk-W7IGCOVL.cjs → chunk-JQYC66TO.cjs} +9 -8
  25. package/dist/{chunk-PFXURMBZ.cjs → chunk-JZLGCTGK.cjs} +68 -8
  26. package/dist/{chunk-JYOTGRSO.cjs → chunk-KFRDLKMA.cjs} +61 -1
  27. package/dist/chunk-M4IT6DNJ.cjs +608 -0
  28. package/dist/{chunk-KLKI352M.cjs → chunk-MVDQMV25.cjs} +0 -3
  29. package/dist/chunk-NCVX3K2N.cjs +161 -0
  30. package/dist/chunk-NWFMBLSQ.js +4 -0
  31. package/dist/chunk-O5676ZWY.js +585 -0
  32. package/dist/chunk-PUX5VXDB.cjs +8845 -0
  33. package/dist/{chunk-IXLO7GO5.js → chunk-TWT3STIX.js} +46 -80
  34. package/dist/chunk-UG5RKLU2.cjs +6 -0
  35. package/dist/chunk-VP2B4WM2.js +154 -0
  36. package/dist/{chunk-5X5WL5CU.cjs → chunk-WJLECC22.cjs} +51 -88
  37. package/dist/{chunk-WENHUPZC.cjs → chunk-XAYGD4E4.cjs} +9 -8
  38. package/dist/core/addresses.d.ts +15 -3
  39. package/dist/core/brands.d.ts +8 -2
  40. package/dist/core/errors.d.ts +71 -10
  41. package/dist/core/preflight.d.ts +1 -0
  42. package/dist/fhe/erc7984-abi.d.ts +1 -0
  43. package/dist/fhe/index.cjs +34 -13
  44. package/dist/fhe/index.d.cts +1 -0
  45. package/dist/fhe/index.d.ts +1 -0
  46. package/dist/fhe/index.js +19 -6
  47. package/dist/fhe/mock-erc7984.d.ts +4 -4
  48. package/dist/fhe/operators.d.ts +160 -3
  49. package/dist/fhe/react/index.cjs +14 -0
  50. package/dist/fhe/react/index.d.cts +2 -0
  51. package/dist/fhe/react/index.d.ts +2 -0
  52. package/dist/fhe/react/index.js +6 -0
  53. package/dist/fhe/react/useEnsureOperator.d.ts +56 -0
  54. package/dist/fhe/react/useIsOperator.d.ts +54 -0
  55. package/dist/fhe/sepolia-encryptor-web.d.ts +18 -3
  56. package/dist/fhe/types.d.ts +6 -0
  57. package/dist/fhe-airdrop/abis/{cloneable.d.ts → airdrop-base.d.ts} +254 -396
  58. package/dist/fhe-airdrop/abis/compliance.d.ts +422 -0
  59. package/dist/fhe-airdrop/abis/ecdsa.d.ts +1316 -0
  60. package/dist/fhe-airdrop/abis/factory.d.ts +1319 -190
  61. package/dist/fhe-airdrop/abis/index.d.ts +5 -2
  62. package/dist/fhe-airdrop/abis/merkle.d.ts +1238 -0
  63. package/dist/fhe-airdrop/advanced/index.cjs +10 -12
  64. package/dist/fhe-airdrop/advanced/index.d.cts +34 -11
  65. package/dist/fhe-airdrop/advanced/index.d.ts +34 -11
  66. package/dist/fhe-airdrop/advanced/index.js +2 -8
  67. package/dist/fhe-airdrop/advanced/react/index.cjs +34 -48
  68. package/dist/fhe-airdrop/advanced/react/index.d.cts +9 -3
  69. package/dist/fhe-airdrop/advanced/react/index.d.ts +9 -3
  70. package/dist/fhe-airdrop/advanced/react/index.js +33 -48
  71. package/dist/fhe-airdrop/advanced/react/usePredictEcdsaAirdropAddress.d.ts +33 -0
  72. package/dist/fhe-airdrop/advanced/react/usePredictMerkleAirdropAddress.d.ts +27 -0
  73. package/dist/fhe-airdrop/airdrop-base.d.ts +600 -0
  74. package/dist/fhe-airdrop/campaign.d.ts +297 -0
  75. package/dist/fhe-airdrop/compliance.d.ts +302 -0
  76. package/dist/fhe-airdrop/constants.d.ts +33 -0
  77. package/dist/fhe-airdrop/ecdsa.d.ts +263 -0
  78. package/dist/fhe-airdrop/encryption.d.ts +92 -14
  79. package/dist/fhe-airdrop/errors.d.ts +245 -15
  80. package/dist/fhe-airdrop/factory.d.ts +533 -274
  81. package/dist/fhe-airdrop/guards.d.ts +273 -0
  82. package/dist/fhe-airdrop/index.cjs +1089 -33
  83. package/dist/fhe-airdrop/index.d.cts +46 -8
  84. package/dist/fhe-airdrop/index.d.ts +46 -8
  85. package/dist/fhe-airdrop/index.js +929 -7
  86. package/dist/fhe-airdrop/merkle-tree.d.ts +103 -0
  87. package/dist/fhe-airdrop/merkle.d.ts +180 -0
  88. package/dist/fhe-airdrop/react/_shared.d.ts +144 -71
  89. package/dist/fhe-airdrop/react/index.cjs +364 -413
  90. package/dist/fhe-airdrop/react/index.d.cts +53 -72
  91. package/dist/fhe-airdrop/react/index.d.ts +53 -72
  92. package/dist/fhe-airdrop/react/index.js +258 -369
  93. package/dist/fhe-airdrop/react/useAirdropGasFee.d.ts +10 -5
  94. package/dist/fhe-airdrop/react/useAirdropHasRole.d.ts +15 -6
  95. package/dist/fhe-airdrop/react/useAirdropPause.d.ts +30 -0
  96. package/dist/fhe-airdrop/react/useAirdropPaused.d.ts +17 -0
  97. package/dist/fhe-airdrop/react/useAirdropToken.d.ts +11 -4
  98. package/dist/fhe-airdrop/react/useAirdropWindow.d.ts +37 -0
  99. package/dist/fhe-airdrop/react/useClaimedAmount.d.ts +29 -0
  100. package/dist/fhe-airdrop/react/useComplianceManager.d.ts +16 -0
  101. package/dist/fhe-airdrop/react/useCreateEcdsaAirdrop.d.ts +28 -0
  102. package/dist/fhe-airdrop/react/useCreateMerkleAirdrop.d.ts +25 -0
  103. package/dist/fhe-airdrop/react/useEcdsaClaim.d.ts +23 -0
  104. package/dist/fhe-airdrop/react/useEffectiveUpgradeable.d.ts +20 -0
  105. package/dist/fhe-airdrop/react/useExtendClaimWindow.d.ts +17 -12
  106. package/dist/fhe-airdrop/react/useFactoryFees.d.ts +28 -0
  107. package/dist/fhe-airdrop/react/useFactoryRegistry.d.ts +35 -0
  108. package/dist/fhe-airdrop/react/useFundAirdrop.d.ts +35 -0
  109. package/dist/fhe-airdrop/react/useGrantInstanceRoles.d.ts +35 -0
  110. package/dist/fhe-airdrop/react/useMerkleClaim.d.ts +34 -0
  111. package/dist/fhe-airdrop/react/useMerkleRoot.d.ts +15 -0
  112. package/dist/fhe-airdrop/react/useSetMerkleRoot.d.ts +22 -0
  113. package/dist/fhe-airdrop/react/useWithdrawConfidential.d.ts +23 -0
  114. package/dist/fhe-airdrop/roles.d.ts +147 -0
  115. package/dist/fhe-airdrop/types.d.ts +68 -55
  116. package/dist/fhe-disperse/errors.d.ts +55 -0
  117. package/dist/fhe-disperse/index.cjs +34 -25
  118. package/dist/fhe-disperse/index.d.cts +1 -1
  119. package/dist/fhe-disperse/index.d.ts +1 -1
  120. package/dist/fhe-disperse/index.js +6 -5
  121. package/dist/fhe-disperse/react/index.cjs +42 -23
  122. package/dist/fhe-disperse/react/index.d.cts +3 -1
  123. package/dist/fhe-disperse/react/index.d.ts +3 -1
  124. package/dist/fhe-disperse/react/index.js +9 -6
  125. package/dist/fhe-vesting/advanced/index.cjs +8 -7
  126. package/dist/fhe-vesting/advanced/index.js +6 -5
  127. package/dist/fhe-vesting/advanced/react/index.cjs +12 -11
  128. package/dist/fhe-vesting/advanced/react/index.js +9 -8
  129. package/dist/fhe-vesting/index.cjs +35 -34
  130. package/dist/fhe-vesting/index.js +7 -6
  131. package/dist/fhe-vesting/manager.d.ts +19 -0
  132. package/dist/fhe-vesting/react/index.cjs +160 -140
  133. package/dist/fhe-vesting/react/index.d.cts +6 -4
  134. package/dist/fhe-vesting/react/index.d.ts +6 -4
  135. package/dist/fhe-vesting/react/index.js +24 -16
  136. package/dist/fhe-vesting/react/useAccessClaimableAmount.d.ts +11 -3
  137. package/dist/fhe-vesting/react/useAccessSettledAmount.d.ts +11 -3
  138. package/dist/fhe-vesting/react/useAccessTotalAllocation.d.ts +11 -3
  139. package/dist/fhe-vesting/react/useAccessVestedAmount.d.ts +11 -3
  140. package/dist/fhe-vesting/react/useAdminGetClaimableAmount.d.ts +1 -1
  141. package/dist/fhe-vesting/react/useAdminGetSettledAmount.d.ts +1 -1
  142. package/dist/fhe-vesting/react/useAdminGetTotalAllocation.d.ts +1 -1
  143. package/dist/fhe-vesting/react/useAdminGetVestedAmount.d.ts +1 -1
  144. package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +8 -0
  145. package/dist/fhe-vesting/react/useClaim.d.ts +1 -1
  146. package/dist/fhe-vesting/react/useDiscloseHandleToParty.d.ts +1 -1
  147. package/dist/fhe-vesting/react/useManagerDiscloseHandleToParty.d.ts +1 -1
  148. package/dist/fhe-vesting/react/usePartialClaim.d.ts +1 -1
  149. package/dist/fhe-vesting/react/useVestingInfo.d.ts +1 -1
  150. package/dist/fhe-vesting/types.d.ts +12 -1
  151. package/dist/index.cjs +27 -15
  152. package/dist/index.js +1 -1
  153. package/dist/testnet-faucet/index.cjs +17 -16
  154. package/dist/testnet-faucet/index.js +5 -4
  155. package/dist/testnet-faucet/react/index.cjs +11 -10
  156. package/dist/testnet-faucet/react/index.js +6 -5
  157. package/package.json +18 -9
  158. package/dist/chunk-4WPGQSNT.cjs +0 -44
  159. package/dist/chunk-6R4KNAPK.js +0 -1630
  160. package/dist/chunk-DUZIIRPF.js +0 -1655
  161. package/dist/chunk-MCRBVJGZ.cjs +0 -1637
  162. package/dist/chunk-ODLTEGHB.js +0 -41
  163. package/dist/chunk-ORFTDNFZ.js +0 -105
  164. package/dist/chunk-T46YXSBP.cjs +0 -109
  165. package/dist/chunk-TIUKIY5V.cjs +0 -1663
  166. package/dist/fhe-airdrop/advanced/factory-advanced.d.ts +0 -53
  167. package/dist/fhe-airdrop/advanced/react/usePredictAirdropAddress.d.ts +0 -49
  168. package/dist/fhe-airdrop/airdrop.d.ts +0 -310
  169. package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +0 -31
  170. package/dist/fhe-airdrop/react/useAirdropCanExtendClaimWindow.d.ts +0 -7
  171. package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +0 -27
  172. package/dist/fhe-airdrop/react/useAirdropClaimTypehash.d.ts +0 -10
  173. package/dist/fhe-airdrop/react/useAirdropClaimedSignatures.d.ts +0 -16
  174. package/dist/fhe-airdrop/react/useAirdropDeploymentBlockNumber.d.ts +0 -6
  175. package/dist/fhe-airdrop/react/useAirdropDomainSeparator.d.ts +0 -8
  176. package/dist/fhe-airdrop/react/useAirdropEndTime.d.ts +0 -10
  177. package/dist/fhe-airdrop/react/useAirdropFactoryCustomFee.d.ts +0 -17
  178. package/dist/fhe-airdrop/react/useAirdropFactoryDefaultGasFee.d.ts +0 -10
  179. package/dist/fhe-airdrop/react/useAirdropFactoryDisableCustomFee.d.ts +0 -15
  180. package/dist/fhe-airdrop/react/useAirdropFactoryFeeCollector.d.ts +0 -11
  181. package/dist/fhe-airdrop/react/useAirdropFactoryInitCodeHash.d.ts +0 -17
  182. package/dist/fhe-airdrop/react/useAirdropFactorySetCustomFee.d.ts +0 -17
  183. package/dist/fhe-airdrop/react/useAirdropFactorySetDefaultGasFee.d.ts +0 -16
  184. package/dist/fhe-airdrop/react/useAirdropFactorySetFeeCollector.d.ts +0 -15
  185. package/dist/fhe-airdrop/react/useAirdropGrantRole.d.ts +0 -16
  186. package/dist/fhe-airdrop/react/useAirdropHasClaimEnded.d.ts +0 -7
  187. package/dist/fhe-airdrop/react/useAirdropHasClaimStarted.d.ts +0 -7
  188. package/dist/fhe-airdrop/react/useAirdropIsClaimWindowActive.d.ts +0 -9
  189. package/dist/fhe-airdrop/react/useAirdropIsPaused.d.ts +0 -8
  190. package/dist/fhe-airdrop/react/useAirdropIsSignatureClaimed.d.ts +0 -22
  191. package/dist/fhe-airdrop/react/useAirdropIsSignatureValid.d.ts +0 -51
  192. package/dist/fhe-airdrop/react/useAirdropRevokeRole.d.ts +0 -15
  193. package/dist/fhe-airdrop/react/useAirdropStartTime.d.ts +0 -10
  194. package/dist/fhe-airdrop/react/useAirdropWithdrawGasFee.d.ts +0 -15
  195. package/dist/fhe-airdrop/react/useAirdropWithdrawOtherConfidentialToken.d.ts +0 -14
  196. package/dist/fhe-airdrop/react/useAirdropWithdrawOtherToken.d.ts +0 -14
  197. package/dist/fhe-airdrop/react/useClaim.d.ts +0 -31
  198. package/dist/fhe-airdrop/react/useConfidentialAirdropFactoryImplementation.d.ts +0 -11
  199. package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +0 -41
  200. package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +0 -48
  201. package/dist/fhe-airdrop/react/useCreateConfidentialAirdrop.d.ts +0 -29
  202. package/dist/fhe-airdrop/react/useCreateConfidentialAirdropAndGetAddress.d.ts +0 -31
  203. package/dist/fhe-airdrop/react/useDisableCustomFee.d.ts +0 -14
  204. package/dist/fhe-airdrop/react/useFactoryCustomFee.d.ts +0 -17
  205. package/dist/fhe-airdrop/react/useFactoryDefaultGasFee.d.ts +0 -10
  206. package/dist/fhe-airdrop/react/useFactoryFeeCollector.d.ts +0 -11
  207. package/dist/fhe-airdrop/react/useFactoryInitCodeHash.d.ts +0 -17
  208. package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +0 -33
  209. package/dist/fhe-airdrop/react/useGetClaimAmount.d.ts +0 -30
  210. package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +0 -51
  211. package/dist/fhe-airdrop/react/useSetCustomFee.d.ts +0 -16
  212. package/dist/fhe-airdrop/react/useSetDefaultGasFee.d.ts +0 -15
  213. package/dist/fhe-airdrop/react/useSetFeeCollector.d.ts +0 -14
  214. package/dist/fhe-airdrop/react/useSetPaused.d.ts +0 -14
  215. package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +0 -31
  216. package/dist/fhe-airdrop/react/useWithdraw.d.ts +0 -12
  217. package/dist/fhe-airdrop/react/useWithdrawOtherConfidentialToken.d.ts +0 -13
  218. package/dist/fhe-airdrop/react/useWithdrawOtherToken.d.ts +0 -13
  219. package/dist/fhe-vesting/react/useGetClaimableAmount.d.ts +0 -13
  220. package/dist/fhe-vesting/react/useGetSettledAmount.d.ts +0 -14
  221. package/dist/fhe-vesting/react/useGetTotalAllocation.d.ts +0 -13
  222. package/dist/fhe-vesting/react/useGetVestedAmount.d.ts +0 -25
@@ -14,6 +14,7 @@ import { type SdkTelemetry } from "../core/telemetry.js";
14
14
  *
15
15
  * `uint48` upper bound (`2**48 - 1 ≈ 8.9e+14`) is comfortably past year 9999
16
16
  * in unix seconds, so a "far-future" deadline is structurally safe.
17
+ * @public
17
18
  */
18
19
  export declare const ERC7984_SET_OPERATOR_ABI: readonly [{
19
20
  readonly type: "function";
@@ -35,8 +36,10 @@ export declare const ERC7984_SET_OPERATOR_ABI: readonly [{
35
36
  * about expiry — typical for local-chain dev loops and end-to-end fixture
36
37
  * setup. For production flows, scope the deadline to the expected operation
37
38
  * window (e.g. `Date.now()/1000 + 3600`).
39
+ * @public
38
40
  */
39
41
  export declare const ERC7984_OPERATOR_MAX_DEADLINE: bigint;
42
+ /** @public */
40
43
  export interface SetOperatorArgs {
41
44
  /** Read-only viem client for receipt waiting. */
42
45
  publicClient: PublicClient;
@@ -108,16 +111,17 @@ export interface SetOperatorArgs {
108
111
  * await setOperator({
109
112
  * publicClient,
110
113
  * walletClient,
111
- * token: DEPLOYED_ADDRESSES.tokens.testConfidential[31337]!,
114
+ * token: "0xYourToken", // ERC-7984 token address
112
115
  * spender: manager,
113
116
  * // deadline defaults to ERC7984_OPERATOR_MAX_DEADLINE (forever).
114
117
  * });
115
118
  *
116
- * // Now safe to call manager.createVesting / factory.fundConfidentialAirdrop / etc.
119
+ * // Now safe to call manager.createVesting / factory.fundAirdrop / etc.
117
120
  * ```
118
121
  *
119
122
  * @throws {@link TokenOpsContractError} if the writeContract or receipt-wait
120
123
  * step throws. The original viem error is attached as the cause.
124
+ * @public
121
125
  */
122
126
  export declare function setOperator(args: SetOperatorArgs): Promise<Hex>;
123
127
  /**
@@ -125,6 +129,7 @@ export declare function setOperator(args: SetOperatorArgs): Promise<Hex>;
125
129
  * minus the `deadline` field — revoke is a fixed `until=0` call that cannot
126
130
  * accept a non-zero deadline (the ERC-7984 contract treats `0` as the revoke
127
131
  * convention; any non-zero `until` would be a re-grant, not a revoke).
132
+ * @public
128
133
  */
129
134
  export interface RevokeOperatorArgs {
130
135
  /** Read-only viem client for receipt waiting. */
@@ -177,7 +182,7 @@ export interface RevokeOperatorArgs {
177
182
  * await revokeOperator({
178
183
  * publicClient,
179
184
  * walletClient,
180
- * token: DEPLOYED_ADDRESSES.tokens.testConfidential[31337]!,
185
+ * token: "0xYourToken", // ERC-7984 token address
181
186
  * spender: staleManager, // old manager clone after deploying a new one
182
187
  * });
183
188
  * // `staleManager` can no longer call `confidentialTransferFrom` against
@@ -186,5 +191,157 @@ export interface RevokeOperatorArgs {
186
191
  *
187
192
  * @throws {@link TokenOpsContractError} if the writeContract or receipt-wait
188
193
  * step throws. The original viem error is attached as the cause.
194
+ * @public
189
195
  */
190
196
  export declare function revokeOperator(args: RevokeOperatorArgs): Promise<Hex>;
197
+ /**
198
+ * Arguments for {@link isOperator}. Read-only — no wallet required.
199
+ *
200
+ * @public
201
+ */
202
+ export interface IsOperatorArgs {
203
+ /** Read-only viem client the `isOperator` view call goes through. */
204
+ publicClient: PublicClient;
205
+ /** ERC-7984 token contract address. */
206
+ token: Address;
207
+ /** Account that owns the tokens (the operator-authorization granter). */
208
+ holder: Address;
209
+ /**
210
+ * Address whose operator status is being checked — typically a manager
211
+ * clone (`/fhe-vesting`), an airdrop clone/factory (`/fhe-airdrop`), or
212
+ * the disperse singleton (`/fhe-disperse`).
213
+ */
214
+ spender: Address;
215
+ /** Optional telemetry sink — span emits as `fhe.isOperator`. */
216
+ telemetry?: SdkTelemetry;
217
+ }
218
+ /**
219
+ * Check whether `spender` is currently an authorized ERC-7984 operator for
220
+ * `holder` on `token`. Read-only sibling of {@link setOperator} — the
221
+ * contract-side check is `until >= block.timestamp`, so an expired grant
222
+ * reads `false` here without any revoke transaction having happened.
223
+ *
224
+ * Use this to gate UX ("Approve operator" button vs "Create vesting" button)
225
+ * or as a cheap pre-check before flows that would otherwise fail with
226
+ * {@link OperatorNotApprovedError} — the SDK's mapping of the on-chain
227
+ * `ERC7984UnauthorizedSpender` revert, whose message is the canonical
228
+ * {@link OPERATOR_NOT_APPROVED_REMEDIATION} copy. For a check-then-set in
229
+ * one call, see {@link ensureOperator}.
230
+ *
231
+ * @example
232
+ * ```ts
233
+ * import { isOperator } from "@tokenops/sdk/fhe";
234
+ *
235
+ * const authorized = await isOperator({
236
+ * publicClient,
237
+ * token,
238
+ * holder: account.address,
239
+ * spender: manager,
240
+ * });
241
+ * if (!authorized) {
242
+ * // prompt the user to run setOperator / ensureOperator first
243
+ * }
244
+ * ```
245
+ *
246
+ * @throws {@link TokenOpsContractError} if the read call itself fails (RPC
247
+ * error, non-ERC-7984 token). The original viem error is attached as the
248
+ * cause.
249
+ * @public
250
+ */
251
+ export declare function isOperator(args: IsOperatorArgs): Promise<boolean>;
252
+ /**
253
+ * Arguments for {@link ensureOperator}. Same shape as {@link SetOperatorArgs}
254
+ * except `deadline` is **required**: `ensureOperator` only sends a
255
+ * transaction when the authorization is missing, so the expiry it would
256
+ * grant must be an explicit caller decision — the SDK refuses to default a
257
+ * security-sensitive approval window (a silent
258
+ * {@link ERC7984_OPERATOR_MAX_DEADLINE} would grant "forever").
259
+ * @public
260
+ */
261
+ export interface EnsureOperatorArgs {
262
+ /** Read-only viem client for the `isOperator` pre-check + receipt waiting. */
263
+ publicClient: PublicClient;
264
+ /** Wallet client used to send the `setOperator` call (only when needed). */
265
+ walletClient: WalletClient;
266
+ /**
267
+ * Account that owns the tokens. Same `Account | Address` semantics and
268
+ * fallback hierarchy as {@link SetOperatorArgs} — also used to derive the
269
+ * `holder` for the read-side `isOperator` pre-check.
270
+ */
271
+ account?: Account | Address;
272
+ /** ERC-7984 token contract address. */
273
+ token: Address;
274
+ /** Address being authorized to pull tokens. */
275
+ spender: Address;
276
+ /**
277
+ * `uint48` unix timestamp after which the operator authorization expires.
278
+ * Required — scope it to the expected operation window (e.g.
279
+ * `BigInt(Math.floor(Date.now() / 1000) + 3600)` for one hour). Pass
280
+ * {@link ERC7984_OPERATOR_MAX_DEADLINE} only when you explicitly want a
281
+ * never-expiring grant (local dev loops, test fixtures).
282
+ */
283
+ deadline: bigint;
284
+ /**
285
+ * If `true` (default), waits for the transaction to be mined before
286
+ * returning. Only relevant when a transaction is actually sent.
287
+ */
288
+ waitForReceipt?: boolean;
289
+ /** Optional telemetry sink — span emits as `fhe.ensureOperator`. */
290
+ telemetry?: SdkTelemetry;
291
+ }
292
+ /**
293
+ * Result of {@link ensureOperator}.
294
+ *
295
+ * @public
296
+ */
297
+ export interface EnsureOperatorResult {
298
+ /**
299
+ * `true` when the authorization was already in place and no transaction
300
+ * was sent; `false` when this call performed the `setOperator` write.
301
+ */
302
+ alreadyOperator: boolean;
303
+ /**
304
+ * Transaction hash of the `setOperator` call, or `null` when no
305
+ * transaction was needed (`alreadyOperator === true`).
306
+ */
307
+ hash: Hex | null;
308
+ }
309
+ /**
310
+ * Idempotent operator authorization: check {@link isOperator} first and call
311
+ * {@link setOperator} only when the grant is missing. The no-op path sends
312
+ * no transaction and costs one `eth_call`.
313
+ *
314
+ * This is the recommended pre-step before any flow that pulls tokens from
315
+ * the caller's balance (`createVesting` / `batchCreateVesting`,
316
+ * `fundAirdrop` / `createAndFund{Ecdsa,Merkle}Airdrop`, disperse
317
+ * registration) — skipping it fails with {@link OperatorNotApprovedError},
318
+ * the SDK's mapping of the on-chain `ERC7984UnauthorizedSpender` revert,
319
+ * whose message is the canonical {@link OPERATOR_NOT_APPROVED_REMEDIATION}
320
+ * copy.
321
+ *
322
+ * **Note on expiry:** the pre-check only tells you the grant is currently
323
+ * active, not until when. If an existing grant expires mid-flow,
324
+ * `ensureOperator` will not have refreshed it — pass a fresh
325
+ * {@link setOperator} call instead when you need to extend a window.
326
+ *
327
+ * @example
328
+ * ```ts
329
+ * import { ensureOperator } from "@tokenops/sdk/fhe";
330
+ *
331
+ * const oneHour = BigInt(Math.floor(Date.now() / 1000) + 3600);
332
+ * const { alreadyOperator, hash } = await ensureOperator({
333
+ * publicClient,
334
+ * walletClient,
335
+ * token,
336
+ * spender: manager,
337
+ * deadline: oneHour,
338
+ * });
339
+ * // Now safe to call manager.createVesting / factory.fundAirdrop / etc.
340
+ * ```
341
+ *
342
+ * @throws {@link TokenOpsContractError} if no holder account can be
343
+ * resolved, if `deadline` is outside `(0, 2**48 - 1]`, or if the
344
+ * read/write/receipt step fails.
345
+ * @public
346
+ */
347
+ export declare function ensureOperator(args: EnsureOperatorArgs): Promise<EnsureOperatorResult>;
@@ -1,7 +1,13 @@
1
1
  'use strict';
2
2
 
3
+ var chunk7AFPOE7N_cjs = require('../../chunk-7AFPOE7N.cjs');
4
+ require('../../chunk-ZQUE2B3Q.cjs');
5
+ require('../../chunk-KFRDLKMA.cjs');
6
+ require('../../chunk-FWHYQZ5E.cjs');
7
+ require('../../chunk-JK4XMMKM.cjs');
3
8
  require('../../chunk-66IHPTOK.cjs');
4
9
  var chunk67OV5CX2_cjs = require('../../chunk-67OV5CX2.cjs');
10
+ require('../../chunk-VJKZWYYJ.cjs');
5
11
  var react = require('react');
6
12
 
7
13
  function resolveUserDecryptor(source) {
@@ -83,6 +89,14 @@ function serializableSlice(v) {
83
89
  return out;
84
90
  }
85
91
 
92
+ Object.defineProperty(exports, "useEnsureOperator", {
93
+ enumerable: true,
94
+ get: function () { return chunk7AFPOE7N_cjs.useEnsureOperator; }
95
+ });
96
+ Object.defineProperty(exports, "useIsOperator", {
97
+ enumerable: true,
98
+ get: function () { return chunk7AFPOE7N_cjs.useIsOperator; }
99
+ });
86
100
  Object.defineProperty(exports, "TokenOpsContractError", {
87
101
  enumerable: true,
88
102
  get: function () { return chunk67OV5CX2_cjs.TokenOpsContractError; }
@@ -7,4 +7,6 @@
7
7
  * `EncryptedHandle` return value).
8
8
  */
9
9
  export { useDecryptedHandle, type UseDecryptedHandleOptions, type UseDecryptedHandleResult, type UserDecryptor, type UserDecryptorSource, } from "./use-decrypted-handle.js";
10
+ export { useIsOperator, type UseIsOperatorOptions } from "./useIsOperator.js";
11
+ export { useEnsureOperator, type UseEnsureOperatorOptions, type EnsureOperatorVariables, } from "./useEnsureOperator.js";
10
12
  export { TokenOpsSdkError, isTokenOpsSdkError, TokenOpsValidationError, TokenOpsContractError, } from "../../core/errors.js";
@@ -7,4 +7,6 @@
7
7
  * `EncryptedHandle` return value).
8
8
  */
9
9
  export { useDecryptedHandle, type UseDecryptedHandleOptions, type UseDecryptedHandleResult, type UserDecryptor, type UserDecryptorSource, } from "./use-decrypted-handle.js";
10
+ export { useIsOperator, type UseIsOperatorOptions } from "./useIsOperator.js";
11
+ export { useEnsureOperator, type UseEnsureOperatorOptions, type EnsureOperatorVariables, } from "./useEnsureOperator.js";
10
12
  export { TokenOpsSdkError, isTokenOpsSdkError, TokenOpsValidationError, TokenOpsContractError, } from "../../core/errors.js";
@@ -1,6 +1,12 @@
1
+ export { useEnsureOperator, useIsOperator } from '../../chunk-AXIPOR3C.js';
2
+ import '../../chunk-FT4LNBOS.js';
3
+ import '../../chunk-4TSDNZQ3.js';
4
+ import '../../chunk-7VELUOMI.js';
5
+ import '../../chunk-ZA673I3O.js';
1
6
  import '../../chunk-KWFFIJYX.js';
2
7
  import { TokenOpsValidationError } from '../../chunk-QBJ7O2B4.js';
3
8
  export { TokenOpsContractError, TokenOpsSdkError, TokenOpsValidationError, isTokenOpsSdkError } from '../../chunk-QBJ7O2B4.js';
9
+ import '../../chunk-Q2GP5UDC.js';
4
10
  import { useState, useRef, useEffect } from 'react';
5
11
 
6
12
  function resolveUserDecryptor(source) {
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Cross-product mutation hook over {@link ensureOperator} — check-then-set
3
+ * operator authorization that sends no transaction when the grant already
4
+ * exists.
5
+ *
6
+ * Lives in `/fhe/react` (not a product subpath) because the operator
7
+ * prerequisite is identical across all three product flows; the product
8
+ * `react/` barrels re-export it for discoverability.
9
+ */
10
+ import { type UseMutationResult } from "@tanstack/react-query";
11
+ import type { Account, Address } from "viem";
12
+ import type { SdkTelemetry } from "../../core/telemetry.js";
13
+ import { type EnsureOperatorResult } from "../operators.js";
14
+ /** Hook-level options for {@link useEnsureOperator}. */
15
+ export interface UseEnsureOperatorOptions {
16
+ /** Override the chain id used for client resolution. */
17
+ chainId?: number | undefined;
18
+ /** Optional telemetry adapter — forwarded to the headless helper. */
19
+ telemetry?: SdkTelemetry | undefined;
20
+ }
21
+ /** Per-mutation variables for {@link useEnsureOperator}. */
22
+ export interface EnsureOperatorVariables {
23
+ /** ERC-7984 token contract address. */
24
+ token: Address;
25
+ /** Address being authorized to pull tokens. */
26
+ spender: Address;
27
+ /**
28
+ * `uint48` unix timestamp after which the authorization expires. Required
29
+ * — the expiry window is an explicit caller decision (see
30
+ * {@link ensureOperator}). Pass `ERC7984_OPERATOR_MAX_DEADLINE` only when
31
+ * you explicitly want a never-expiring grant.
32
+ */
33
+ deadline: bigint;
34
+ /** Override the from-account; defaults to the connected wallet's account. */
35
+ account?: Account | Address;
36
+ /** If `true` (default), waits for the transaction to be mined. */
37
+ waitForReceipt?: boolean;
38
+ }
39
+ /**
40
+ * Ensure `spender` is an ERC-7984 operator for the connected account on
41
+ * `token`, sending a `setOperator` transaction only when the grant is
42
+ * missing. Resolves to `{ alreadyOperator, hash }` — `hash` is `null` on
43
+ * the no-op path.
44
+ *
45
+ * This is the mutation half of the operator-prerequisite pair; use
46
+ * {@link useIsOperator} for the read side, and invalidate/refetch it after
47
+ * this mutation succeeds.
48
+ *
49
+ * @example
50
+ * ```tsx
51
+ * const ensure = useEnsureOperator();
52
+ * const oneHour = BigInt(Math.floor(Date.now() / 1000) + 3600);
53
+ * ensure.mutate({ token, spender: manager, deadline: oneHour });
54
+ * ```
55
+ */
56
+ export declare function useEnsureOperator(options?: UseEnsureOperatorOptions): UseMutationResult<EnsureOperatorResult, Error, EnsureOperatorVariables>;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Cross-product query hook over {@link isOperator} — "is `spender` currently
3
+ * an authorized ERC-7984 operator for `holder` on `token`?".
4
+ *
5
+ * Lives in `/fhe/react` (not a product subpath) because the operator
6
+ * prerequisite is identical across all three product flows; the product
7
+ * `react/` barrels re-export it for discoverability.
8
+ */
9
+ import { type UseQueryResult } from "@tanstack/react-query";
10
+ import type { Address } from "viem";
11
+ import type { SdkTelemetry } from "../../core/telemetry.js";
12
+ /** Options accepted by {@link useIsOperator}. */
13
+ export interface UseIsOperatorOptions {
14
+ /** ERC-7984 token contract address. Query stays disabled while `undefined`. */
15
+ token?: Address | undefined;
16
+ /**
17
+ * Address whose operator status is being checked — typically a manager
18
+ * clone, an airdrop factory/clone, or the disperse singleton. Query stays
19
+ * disabled while `undefined`.
20
+ */
21
+ spender?: Address | undefined;
22
+ /**
23
+ * Account that owns the tokens. Defaults to the connected wallet's
24
+ * account. Query stays disabled while neither is available.
25
+ */
26
+ holder?: Address | undefined;
27
+ /** Override the chain id used for client resolution. */
28
+ chainId?: number | undefined;
29
+ /** Set `false` to pause the query without unmounting. Defaults to `true`. */
30
+ enabled?: boolean | undefined;
31
+ /** Optional telemetry adapter — forwarded to the headless helper. */
32
+ telemetry?: SdkTelemetry | undefined;
33
+ }
34
+ /**
35
+ * Read `spender`'s ERC-7984 operator status for `holder` on `token`.
36
+ *
37
+ * Typical use: gate the "create" call-to-action behind the operator
38
+ * prerequisite so builders never hit {@link OperatorNotApprovedError} — the
39
+ * SDK's mapping of the on-chain `ERC7984UnauthorizedSpender` revert, whose
40
+ * message is the canonical {@link OPERATOR_NOT_APPROVED_REMEDIATION} copy:
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * const { data: authorized } = useIsOperator({ token, spender: manager });
45
+ * return authorized
46
+ * ? <CreateVestingButton />
47
+ * : <ApproveOperatorButton />; // wire to useEnsureOperator
48
+ * ```
49
+ *
50
+ * After a successful {@link useEnsureOperator} / `setOperator` mutation,
51
+ * invalidate this query (its key starts with
52
+ * `["tokenops-sdk", "fhe", "isOperator", ...]`) or refetch it.
53
+ */
54
+ export declare function useIsOperator(options?: UseIsOperatorOptions): UseQueryResult<boolean, Error>;
@@ -3,9 +3,10 @@ import type { Encryptor } from "../fhe-vesting/encryption.js";
3
3
  import { type EncryptorInitPhase, type SepoliaEncryptorLogger } from "./sepolia-encryptor.js";
4
4
  /**
5
5
  * Configuration for {@link createSepoliaEncryptorWeb}. Minimal by design:
6
- * the browser path doesn't expose worker pool sizing or storage knobs (the
7
- * Web Worker is single-threaded by default, and `RelayerWeb` already
8
- * defaults to `IndexedDBStorage` for FHE artifact caching).
6
+ * the browser path doesn't expose storage knobs (`RelayerWeb` already
7
+ * defaults to `IndexedDBStorage` for FHE artifact caching). Worker-pool
8
+ * sizing is the one opt-in performance knob — see `threads`; the default
9
+ * stays single-threaded so no special headers are required.
9
10
  */
10
11
  export interface CreateSepoliaEncryptorWebOpts {
11
12
  /** Viem `PublicClient` — used only to resolve the chain id for the
@@ -68,6 +69,20 @@ export interface CreateSepoliaEncryptorWebOpts {
68
69
  * swallowed so a UI observer can never break encryption.
69
70
  */
70
71
  onPhase?: (phase: EncryptorInitPhase) => void;
72
+ /**
73
+ * Opt-in WASM worker-pool size for multi-threaded encryption (forwarded
74
+ * to `RelayerWeb`'s config). `4`–`8` gives ~2–3× faster encryption but
75
+ * requires the page to be **cross-origin isolated** — headers
76
+ * `Cross-Origin-Opener-Policy: same-origin` and
77
+ * `Cross-Origin-Embedder-Policy: require-corp` — without which browsers
78
+ * hide `SharedArrayBuffer` and encryption silently falls back to
79
+ * single-threaded. The SDK logs a loud warning when `threads > 1` is set
80
+ * on a non-isolated page.
81
+ *
82
+ * Omit for the default single-threaded worker — no special headers
83
+ * required.
84
+ */
85
+ threads?: number;
71
86
  }
72
87
  /**
73
88
  * Returned by {@link createSepoliaEncryptorWeb}. Same structural
@@ -13,6 +13,7 @@ import type { Hex } from "viem";
13
13
  * The current SDK only produces uint64 ciphertexts. If a future version
14
14
  * adds encryption helpers for other widths (e.g. `encryptUint128`), this
15
15
  * type may be specialised; existing uint64 usage will keep type-checking.
16
+ * @public
16
17
  */
17
18
  export interface EncryptedInput {
18
19
  handle: Hex;
@@ -24,6 +25,7 @@ export interface EncryptedInput {
24
25
  * encryptor returns from a batched `encrypt({ values: [...] })` call.
25
26
  *
26
27
  * `handles[i]` corresponds to the i-th plaintext value passed in.
28
+ * @public
27
29
  */
28
30
  export interface EncryptedInputs {
29
31
  handles: Hex[];
@@ -37,6 +39,7 @@ export interface EncryptedInputs {
37
39
  * Pass `handle` to the Zama relayer's `userDecrypt` to obtain the plaintext.
38
40
  * `hash` is the tx that committed the persistent ACL grant — surface it if
39
41
  * your UI needs to show the receipt.
42
+ * @public
40
43
  */
41
44
  export interface EncryptedViewResult {
42
45
  handle: Hex;
@@ -48,15 +51,18 @@ export interface EncryptedViewResult {
48
51
  * match the rest of the SDK or the on-chain calldata layout (the contracts
49
52
  * accept `bytes inputProof`). This alias points at the corrected shape and
50
53
  * will be removed in the next major.
54
+ * @public
51
55
  */
52
56
  export type EncryptedInput64 = EncryptedInput;
53
57
  /**
54
58
  * @deprecated Use `Hex` from `viem` directly. This alias added no narrowing
55
59
  * beyond `Hex` and will be removed in the next major.
60
+ * @public
56
61
  */
57
62
  export type EncryptedHandle = Hex;
58
63
  /**
59
64
  * @deprecated Use `Hex` from `viem` directly. This alias added no narrowing
60
65
  * beyond `Hex` and will be removed in the next major.
66
+ * @public
61
67
  */
62
68
  export type ExternalInputProof = Hex;