@tokenops/sdk 1.0.0

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 (371) hide show
  1. package/CHANGELOG.md +207 -0
  2. package/CONTRIBUTING.md +113 -0
  3. package/LICENSE +32 -0
  4. package/README.md +677 -0
  5. package/SECURITY.md +59 -0
  6. package/dist/chunk-52TC6BF7.js +2755 -0
  7. package/dist/chunk-56UI7LUR.cjs +516 -0
  8. package/dist/chunk-5SA2HF2W.cjs +1635 -0
  9. package/dist/chunk-5SGMJADP.cjs +139 -0
  10. package/dist/chunk-62DF53UQ.cjs +749 -0
  11. package/dist/chunk-66IHPTOK.cjs +20 -0
  12. package/dist/chunk-6ECAHP5O.cjs +1496 -0
  13. package/dist/chunk-72YGZEQE.js +742 -0
  14. package/dist/chunk-7VELUOMI.js +35 -0
  15. package/dist/chunk-BE2AIZ3K.js +23 -0
  16. package/dist/chunk-CMRETRZO.js +46 -0
  17. package/dist/chunk-COPFW5Z4.js +82 -0
  18. package/dist/chunk-CQIPRNS7.cjs +25 -0
  19. package/dist/chunk-ECT3NL2L.js +124 -0
  20. package/dist/chunk-FWHYQZ5E.cjs +37 -0
  21. package/dist/chunk-FYQ2UW4T.js +37 -0
  22. package/dist/chunk-HGXNRR25.js +105 -0
  23. package/dist/chunk-HTOMTEA3.cjs +3406 -0
  24. package/dist/chunk-ITQ7WKVC.cjs +101 -0
  25. package/dist/chunk-IVE3QEGD.js +478 -0
  26. package/dist/chunk-JFLEEXKP.js +325 -0
  27. package/dist/chunk-JFR5J4FL.cjs +128 -0
  28. package/dist/chunk-K6MFFDBJ.cjs +109 -0
  29. package/dist/chunk-KWFFIJYX.js +11 -0
  30. package/dist/chunk-NS44KBV5.cjs +89 -0
  31. package/dist/chunk-OLDGMKW2.cjs +93 -0
  32. package/dist/chunk-Q2GP5UDC.js +29 -0
  33. package/dist/chunk-Q7ARQSUH.cjs +42 -0
  34. package/dist/chunk-QCA7O2Q5.cjs +49 -0
  35. package/dist/chunk-QIHZVLIK.js +3388 -0
  36. package/dist/chunk-SUOG3BQS.cjs +2772 -0
  37. package/dist/chunk-T5LVV3KY.cjs +44 -0
  38. package/dist/chunk-UOG4PJL5.js +1488 -0
  39. package/dist/chunk-VDXVNZCO.cjs +329 -0
  40. package/dist/chunk-VJKZWYYJ.cjs +32 -0
  41. package/dist/chunk-WRCUDSUJ.js +96 -0
  42. package/dist/chunk-XSNLAS5M.js +135 -0
  43. package/dist/chunk-XXXDQSHE.js +1628 -0
  44. package/dist/chunk-ZHFLRKFY.js +41 -0
  45. package/dist/chunk-ZXCOJY2Z.js +87 -0
  46. package/dist/core/addresses.d.ts +59 -0
  47. package/dist/core/brands.d.ts +87 -0
  48. package/dist/core/chains.d.ts +102 -0
  49. package/dist/core/errors.d.ts +687 -0
  50. package/dist/core/index.d.ts +7 -0
  51. package/dist/core/normalise.d.ts +27 -0
  52. package/dist/core/preflight.d.ts +25 -0
  53. package/dist/core/revert-mapper.d.ts +74 -0
  54. package/dist/core/telemetry.d.ts +50 -0
  55. package/dist/core/types.d.ts +10 -0
  56. package/dist/core/version.d.ts +15 -0
  57. package/dist/core/zama-error-mapper.d.ts +27 -0
  58. package/dist/fhe/acl.d.ts +73 -0
  59. package/dist/fhe/erc7984-abi.d.ts +53 -0
  60. package/dist/fhe/index.cjs +599 -0
  61. package/dist/fhe/index.d.cts +11 -0
  62. package/dist/fhe/index.d.ts +11 -0
  63. package/dist/fhe/index.js +394 -0
  64. package/dist/fhe/mock-encryptor.d.ts +90 -0
  65. package/dist/fhe/mock-erc7984.d.ts +134 -0
  66. package/dist/fhe/operators.d.ts +190 -0
  67. package/dist/fhe/react/index.cjs +102 -0
  68. package/dist/fhe/react/index.d.cts +10 -0
  69. package/dist/fhe/react/index.d.ts +10 -0
  70. package/dist/fhe/react/index.js +85 -0
  71. package/dist/fhe/react/use-decrypted-handle.d.ts +102 -0
  72. package/dist/fhe/scale-ratio.d.ts +168 -0
  73. package/dist/fhe/sepolia-encryptor-web.d.ts +101 -0
  74. package/dist/fhe/sepolia-encryptor.d.ts +132 -0
  75. package/dist/fhe/types.d.ts +62 -0
  76. package/dist/fhe-airdrop/abis/cloneable.d.ts +781 -0
  77. package/dist/fhe-airdrop/abis/factory.d.ts +714 -0
  78. package/dist/fhe-airdrop/abis/index.d.ts +2 -0
  79. package/dist/fhe-airdrop/advanced/factory-advanced.d.ts +53 -0
  80. package/dist/fhe-airdrop/advanced/index.cjs +21 -0
  81. package/dist/fhe-airdrop/advanced/index.d.cts +13 -0
  82. package/dist/fhe-airdrop/advanced/index.d.ts +13 -0
  83. package/dist/fhe-airdrop/advanced/index.js +8 -0
  84. package/dist/fhe-airdrop/advanced/react/index.cjs +61 -0
  85. package/dist/fhe-airdrop/advanced/react/index.d.cts +5 -0
  86. package/dist/fhe-airdrop/advanced/react/index.d.ts +5 -0
  87. package/dist/fhe-airdrop/advanced/react/index.js +59 -0
  88. package/dist/fhe-airdrop/advanced/react/usePredictAirdropAddress.d.ts +49 -0
  89. package/dist/fhe-airdrop/airdrop.d.ts +308 -0
  90. package/dist/fhe-airdrop/encryption.d.ts +109 -0
  91. package/dist/fhe-airdrop/errors.d.ts +60 -0
  92. package/dist/fhe-airdrop/factory.d.ts +281 -0
  93. package/dist/fhe-airdrop/index.cjs +227 -0
  94. package/dist/fhe-airdrop/index.d.cts +10 -0
  95. package/dist/fhe-airdrop/index.d.ts +10 -0
  96. package/dist/fhe-airdrop/index.js +10 -0
  97. package/dist/fhe-airdrop/react/_shared.d.ts +107 -0
  98. package/dist/fhe-airdrop/react/index.cjs +638 -0
  99. package/dist/fhe-airdrop/react/index.d.cts +90 -0
  100. package/dist/fhe-airdrop/react/index.d.ts +90 -0
  101. package/dist/fhe-airdrop/react/index.js +430 -0
  102. package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +31 -0
  103. package/dist/fhe-airdrop/react/useAirdropCanExtendClaimWindow.d.ts +7 -0
  104. package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +25 -0
  105. package/dist/fhe-airdrop/react/useAirdropClaimTypehash.d.ts +10 -0
  106. package/dist/fhe-airdrop/react/useAirdropClaimedSignatures.d.ts +16 -0
  107. package/dist/fhe-airdrop/react/useAirdropDeploymentBlockNumber.d.ts +6 -0
  108. package/dist/fhe-airdrop/react/useAirdropDomainSeparator.d.ts +8 -0
  109. package/dist/fhe-airdrop/react/useAirdropEndTime.d.ts +10 -0
  110. package/dist/fhe-airdrop/react/useAirdropFactoryCustomFee.d.ts +17 -0
  111. package/dist/fhe-airdrop/react/useAirdropFactoryDefaultGasFee.d.ts +10 -0
  112. package/dist/fhe-airdrop/react/useAirdropFactoryDisableCustomFee.d.ts +15 -0
  113. package/dist/fhe-airdrop/react/useAirdropFactoryFeeCollector.d.ts +11 -0
  114. package/dist/fhe-airdrop/react/useAirdropFactoryInitCodeHash.d.ts +17 -0
  115. package/dist/fhe-airdrop/react/useAirdropFactorySetCustomFee.d.ts +17 -0
  116. package/dist/fhe-airdrop/react/useAirdropFactorySetDefaultGasFee.d.ts +16 -0
  117. package/dist/fhe-airdrop/react/useAirdropFactorySetFeeCollector.d.ts +15 -0
  118. package/dist/fhe-airdrop/react/useAirdropGasFee.d.ts +11 -0
  119. package/dist/fhe-airdrop/react/useAirdropGrantRole.d.ts +16 -0
  120. package/dist/fhe-airdrop/react/useAirdropHasClaimEnded.d.ts +7 -0
  121. package/dist/fhe-airdrop/react/useAirdropHasClaimStarted.d.ts +7 -0
  122. package/dist/fhe-airdrop/react/useAirdropHasRole.d.ts +14 -0
  123. package/dist/fhe-airdrop/react/useAirdropIsClaimWindowActive.d.ts +9 -0
  124. package/dist/fhe-airdrop/react/useAirdropIsPaused.d.ts +8 -0
  125. package/dist/fhe-airdrop/react/useAirdropIsSignatureClaimed.d.ts +22 -0
  126. package/dist/fhe-airdrop/react/useAirdropIsSignatureValid.d.ts +50 -0
  127. package/dist/fhe-airdrop/react/useAirdropRevokeRole.d.ts +15 -0
  128. package/dist/fhe-airdrop/react/useAirdropStartTime.d.ts +10 -0
  129. package/dist/fhe-airdrop/react/useAirdropToken.d.ts +11 -0
  130. package/dist/fhe-airdrop/react/useAirdropWithdrawGasFee.d.ts +15 -0
  131. package/dist/fhe-airdrop/react/useAirdropWithdrawOtherConfidentialToken.d.ts +14 -0
  132. package/dist/fhe-airdrop/react/useAirdropWithdrawOtherToken.d.ts +14 -0
  133. package/dist/fhe-airdrop/react/useClaim.d.ts +29 -0
  134. package/dist/fhe-airdrop/react/useConfidentialAirdropFactoryImplementation.d.ts +11 -0
  135. package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +33 -0
  136. package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +40 -0
  137. package/dist/fhe-airdrop/react/useCreateConfidentialAirdrop.d.ts +29 -0
  138. package/dist/fhe-airdrop/react/useCreateConfidentialAirdropAndGetAddress.d.ts +31 -0
  139. package/dist/fhe-airdrop/react/useDisableCustomFee.d.ts +14 -0
  140. package/dist/fhe-airdrop/react/useExtendClaimWindow.d.ts +16 -0
  141. package/dist/fhe-airdrop/react/useFactoryCustomFee.d.ts +17 -0
  142. package/dist/fhe-airdrop/react/useFactoryDefaultGasFee.d.ts +10 -0
  143. package/dist/fhe-airdrop/react/useFactoryFeeCollector.d.ts +11 -0
  144. package/dist/fhe-airdrop/react/useFactoryInitCodeHash.d.ts +17 -0
  145. package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +25 -0
  146. package/dist/fhe-airdrop/react/useGetClaimAmount.d.ts +30 -0
  147. package/dist/fhe-airdrop/react/useSetCustomFee.d.ts +16 -0
  148. package/dist/fhe-airdrop/react/useSetDefaultGasFee.d.ts +15 -0
  149. package/dist/fhe-airdrop/react/useSetFeeCollector.d.ts +14 -0
  150. package/dist/fhe-airdrop/react/useSetPaused.d.ts +14 -0
  151. package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +31 -0
  152. package/dist/fhe-airdrop/react/useWithdraw.d.ts +12 -0
  153. package/dist/fhe-airdrop/react/useWithdrawOtherConfidentialToken.d.ts +13 -0
  154. package/dist/fhe-airdrop/react/useWithdrawOtherToken.d.ts +13 -0
  155. package/dist/fhe-airdrop/types.d.ts +21 -0
  156. package/dist/fhe-disperse/abis/index.d.ts +2 -0
  157. package/dist/fhe-disperse/abis/singleton.d.ts +1297 -0
  158. package/dist/fhe-disperse/abis/wallet.d.ts +111 -0
  159. package/dist/fhe-disperse/encryption.d.ts +77 -0
  160. package/dist/fhe-disperse/errors.d.ts +39 -0
  161. package/dist/fhe-disperse/index.cjs +248 -0
  162. package/dist/fhe-disperse/index.d.cts +14 -0
  163. package/dist/fhe-disperse/index.d.ts +14 -0
  164. package/dist/fhe-disperse/index.js +11 -0
  165. package/dist/fhe-disperse/react/_shared.d.ts +104 -0
  166. package/dist/fhe-disperse/react/index.cjs +752 -0
  167. package/dist/fhe-disperse/react/index.d.cts +82 -0
  168. package/dist/fhe-disperse/react/index.d.ts +82 -0
  169. package/dist/fhe-disperse/react/index.js +522 -0
  170. package/dist/fhe-disperse/react/useAccessEncryptedFeeReserve.d.ts +35 -0
  171. package/dist/fhe-disperse/react/useApproveTokenOnWallets.d.ts +25 -0
  172. package/dist/fhe-disperse/react/useBatchDiscloseHandlesToParty.d.ts +16 -0
  173. package/dist/fhe-disperse/react/useCalculateFee.d.ts +26 -0
  174. package/dist/fhe-disperse/react/useDeploymentBlockNumber.d.ts +11 -0
  175. package/dist/fhe-disperse/react/useDisableCustomFee.d.ts +20 -0
  176. package/dist/fhe-disperse/react/useDiscloseHandleToParty.d.ts +20 -0
  177. package/dist/fhe-disperse/react/useDisperse.d.ts +28 -0
  178. package/dist/fhe-disperse/react/useGetBatchLimits.d.ts +12 -0
  179. package/dist/fhe-disperse/react/useGetFeeConfig.d.ts +15 -0
  180. package/dist/fhe-disperse/react/useGetFees.d.ts +19 -0
  181. package/dist/fhe-disperse/react/useGetWallets.d.ts +19 -0
  182. package/dist/fhe-disperse/react/useGrantRole.d.ts +24 -0
  183. package/dist/fhe-disperse/react/useHasApprovedSubwallets.d.ts +25 -0
  184. package/dist/fhe-disperse/react/useHasRole.d.ts +22 -0
  185. package/dist/fhe-disperse/react/useIsPaused.d.ts +11 -0
  186. package/dist/fhe-disperse/react/useIsRegistered.d.ts +15 -0
  187. package/dist/fhe-disperse/react/usePause.d.ts +18 -0
  188. package/dist/fhe-disperse/react/usePredictWallets.d.ts +19 -0
  189. package/dist/fhe-disperse/react/usePreflightDisperse.d.ts +37 -0
  190. package/dist/fhe-disperse/react/useRecoverERC20FromWallets.d.ts +21 -0
  191. package/dist/fhe-disperse/react/useRecoverFromWallets.d.ts +21 -0
  192. package/dist/fhe-disperse/react/useRegister.d.ts +40 -0
  193. package/dist/fhe-disperse/react/useRescueConfidentialTokens.d.ts +21 -0
  194. package/dist/fhe-disperse/react/useRescueERC20.d.ts +21 -0
  195. package/dist/fhe-disperse/react/useRevokeRole.d.ts +24 -0
  196. package/dist/fhe-disperse/react/useRevokeTokenOnWallets.d.ts +24 -0
  197. package/dist/fhe-disperse/react/useSetCustomFee.d.ts +24 -0
  198. package/dist/fhe-disperse/react/useSetFeeConfig.d.ts +23 -0
  199. package/dist/fhe-disperse/react/useSetMaxBatchSizeDirect.d.ts +20 -0
  200. package/dist/fhe-disperse/react/useSetMaxBatchSizeHolding.d.ts +20 -0
  201. package/dist/fhe-disperse/react/useSetMaxBatchSizeTokenFee.d.ts +20 -0
  202. package/dist/fhe-disperse/react/useSingletonBatchDiscloseHandlesToParty.d.ts +13 -0
  203. package/dist/fhe-disperse/react/useSingletonBatchLimits.d.ts +12 -0
  204. package/dist/fhe-disperse/react/useSingletonCalculateFee.d.ts +26 -0
  205. package/dist/fhe-disperse/react/useSingletonDeploymentBlockNumber.d.ts +11 -0
  206. package/dist/fhe-disperse/react/useSingletonDisableCustomFee.d.ts +21 -0
  207. package/dist/fhe-disperse/react/useSingletonDiscloseHandleToParty.d.ts +17 -0
  208. package/dist/fhe-disperse/react/useSingletonFees.d.ts +19 -0
  209. package/dist/fhe-disperse/react/useSingletonGrantRole.d.ts +26 -0
  210. package/dist/fhe-disperse/react/useSingletonHasApprovedSubwallets.d.ts +25 -0
  211. package/dist/fhe-disperse/react/useSingletonHasRole.d.ts +23 -0
  212. package/dist/fhe-disperse/react/useSingletonIsPaused.d.ts +11 -0
  213. package/dist/fhe-disperse/react/useSingletonIsRegistered.d.ts +15 -0
  214. package/dist/fhe-disperse/react/useSingletonPause.d.ts +19 -0
  215. package/dist/fhe-disperse/react/useSingletonPredictWallets.d.ts +19 -0
  216. package/dist/fhe-disperse/react/useSingletonRevokeRole.d.ts +26 -0
  217. package/dist/fhe-disperse/react/useSingletonSetCustomFee.d.ts +25 -0
  218. package/dist/fhe-disperse/react/useSingletonUnpause.d.ts +18 -0
  219. package/dist/fhe-disperse/react/useSingletonWalletImplementation.d.ts +12 -0
  220. package/dist/fhe-disperse/react/useSingletonWallets.d.ts +19 -0
  221. package/dist/fhe-disperse/react/useSingletonWithdrawGasFee.d.ts +21 -0
  222. package/dist/fhe-disperse/react/useSingletonWithdrawTokenFee.d.ts +50 -0
  223. package/dist/fhe-disperse/react/useUnpause.d.ts +17 -0
  224. package/dist/fhe-disperse/react/useWalletImplementation.d.ts +12 -0
  225. package/dist/fhe-disperse/react/useWithdrawGasFee.d.ts +26 -0
  226. package/dist/fhe-disperse/react/useWithdrawTokenFee.d.ts +70 -0
  227. package/dist/fhe-disperse/singleton.d.ts +442 -0
  228. package/dist/fhe-disperse/subtotals.d.ts +14 -0
  229. package/dist/fhe-disperse/types.d.ts +332 -0
  230. package/dist/fhe-disperse/validate.d.ts +78 -0
  231. package/dist/fhe-vesting/abis/factory.d.ts +676 -0
  232. package/dist/fhe-vesting/abis/index.d.ts +3 -0
  233. package/dist/fhe-vesting/abis/manager.d.ts +1797 -0
  234. package/dist/fhe-vesting/advanced/factory-advanced.d.ts +52 -0
  235. package/dist/fhe-vesting/advanced/index.cjs +21 -0
  236. package/dist/fhe-vesting/advanced/index.d.cts +12 -0
  237. package/dist/fhe-vesting/advanced/index.d.ts +12 -0
  238. package/dist/fhe-vesting/advanced/index.js +8 -0
  239. package/dist/fhe-vesting/advanced/react/index.cjs +75 -0
  240. package/dist/fhe-vesting/advanced/react/index.d.cts +5 -0
  241. package/dist/fhe-vesting/advanced/react/index.d.ts +5 -0
  242. package/dist/fhe-vesting/advanced/react/index.js +73 -0
  243. package/dist/fhe-vesting/advanced/react/usePredictManagerAddress.d.ts +41 -0
  244. package/dist/fhe-vesting/encryption.d.ts +104 -0
  245. package/dist/fhe-vesting/errors.d.ts +183 -0
  246. package/dist/fhe-vesting/factory.d.ts +207 -0
  247. package/dist/fhe-vesting/index.cjs +269 -0
  248. package/dist/fhe-vesting/index.d.cts +9 -0
  249. package/dist/fhe-vesting/index.d.ts +9 -0
  250. package/dist/fhe-vesting/index.js +12 -0
  251. package/dist/fhe-vesting/manager.d.ts +808 -0
  252. package/dist/fhe-vesting/react/_shared.d.ts +122 -0
  253. package/dist/fhe-vesting/react/index.cjs +1054 -0
  254. package/dist/fhe-vesting/react/index.d.cts +123 -0
  255. package/dist/fhe-vesting/react/index.d.ts +123 -0
  256. package/dist/fhe-vesting/react/index.js +771 -0
  257. package/dist/fhe-vesting/react/useAcceptVestingTransfer.d.ts +12 -0
  258. package/dist/fhe-vesting/react/useAccessClaimableAmount.d.ts +14 -0
  259. package/dist/fhe-vesting/react/useAccessSettledAmount.d.ts +15 -0
  260. package/dist/fhe-vesting/react/useAccessTotalAllocation.d.ts +14 -0
  261. package/dist/fhe-vesting/react/useAccessVestedAmount.d.ts +26 -0
  262. package/dist/fhe-vesting/react/useAdminBatchDiscloseToParty.d.ts +16 -0
  263. package/dist/fhe-vesting/react/useAdminClaim.d.ts +9 -0
  264. package/dist/fhe-vesting/react/useAdminDiscloseToParty.d.ts +8 -0
  265. package/dist/fhe-vesting/react/useAdminGetClaimableAmount.d.ts +13 -0
  266. package/dist/fhe-vesting/react/useAdminGetSettledAmount.d.ts +13 -0
  267. package/dist/fhe-vesting/react/useAdminGetTokenBalance.d.ts +13 -0
  268. package/dist/fhe-vesting/react/useAdminGetTotalAllocation.d.ts +13 -0
  269. package/dist/fhe-vesting/react/useAdminGetVestedAmount.d.ts +15 -0
  270. package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +8 -0
  271. package/dist/fhe-vesting/react/useAllRecipients.d.ts +8 -0
  272. package/dist/fhe-vesting/react/useAllRecipientsLength.d.ts +6 -0
  273. package/dist/fhe-vesting/react/useAllRecipientsSliced.d.ts +13 -0
  274. package/dist/fhe-vesting/react/useBatchCreateVesting.d.ts +24 -0
  275. package/dist/fhe-vesting/react/useBatchDiscloseHandlesToParty.d.ts +13 -0
  276. package/dist/fhe-vesting/react/useBatchDiscloseToParty.d.ts +18 -0
  277. package/dist/fhe-vesting/react/useBatchRevokeVesting.d.ts +12 -0
  278. package/dist/fhe-vesting/react/useCancelVestingTransfer.d.ts +12 -0
  279. package/dist/fhe-vesting/react/useClaim.d.ts +19 -0
  280. package/dist/fhe-vesting/react/useConfidentialVestingFactoryImplementation.d.ts +11 -0
  281. package/dist/fhe-vesting/react/useCreateManager.d.ts +32 -0
  282. package/dist/fhe-vesting/react/useCreateManagerAndGetAddress.d.ts +31 -0
  283. package/dist/fhe-vesting/react/useCreateVesting.d.ts +38 -0
  284. package/dist/fhe-vesting/react/useDirectVestingTransfer.d.ts +13 -0
  285. package/dist/fhe-vesting/react/useDisableCustomFee.d.ts +14 -0
  286. package/dist/fhe-vesting/react/useDiscloseHandleToParty.d.ts +14 -0
  287. package/dist/fhe-vesting/react/useDiscloseToParty.d.ts +14 -0
  288. package/dist/fhe-vesting/react/useFactoryCustomFee.d.ts +17 -0
  289. package/dist/fhe-vesting/react/useFactoryDefaultFeeType.d.ts +11 -0
  290. package/dist/fhe-vesting/react/useFactoryDefaultGasFee.d.ts +10 -0
  291. package/dist/fhe-vesting/react/useFactoryDefaultTokenFee.d.ts +10 -0
  292. package/dist/fhe-vesting/react/useFactoryFeeCollector.d.ts +10 -0
  293. package/dist/fhe-vesting/react/useFactoryInitCodeHash.d.ts +18 -0
  294. package/dist/fhe-vesting/react/useGetClaimableAmount.d.ts +13 -0
  295. package/dist/fhe-vesting/react/useGetSettledAmount.d.ts +14 -0
  296. package/dist/fhe-vesting/react/useGetTotalAllocation.d.ts +13 -0
  297. package/dist/fhe-vesting/react/useGetVestedAmount.d.ts +25 -0
  298. package/dist/fhe-vesting/react/useGrantRole.d.ts +15 -0
  299. package/dist/fhe-vesting/react/useHasRole.d.ts +14 -0
  300. package/dist/fhe-vesting/react/useInitiateVestingTransfer.d.ts +12 -0
  301. package/dist/fhe-vesting/react/useIsRecipient.d.ts +10 -0
  302. package/dist/fhe-vesting/react/useManagerBatchDiscloseHandlesToParty.d.ts +15 -0
  303. package/dist/fhe-vesting/react/useManagerDeploymentBlockNumber.d.ts +7 -0
  304. package/dist/fhe-vesting/react/useManagerDiscloseHandleToParty.d.ts +16 -0
  305. package/dist/fhe-vesting/react/useManagerFactoryCustomFee.d.ts +17 -0
  306. package/dist/fhe-vesting/react/useManagerFactoryDefaultGasFee.d.ts +10 -0
  307. package/dist/fhe-vesting/react/useManagerFactoryDisableCustomFee.d.ts +15 -0
  308. package/dist/fhe-vesting/react/useManagerFactoryFeeCollector.d.ts +10 -0
  309. package/dist/fhe-vesting/react/useManagerFactoryInitCodeHash.d.ts +18 -0
  310. package/dist/fhe-vesting/react/useManagerFactorySetCustomFee.d.ts +19 -0
  311. package/dist/fhe-vesting/react/useManagerFactorySetDefaultGasFee.d.ts +13 -0
  312. package/dist/fhe-vesting/react/useManagerFactorySetFeeCollector.d.ts +14 -0
  313. package/dist/fhe-vesting/react/useManagerFee.d.ts +7 -0
  314. package/dist/fhe-vesting/react/useManagerFeeInfo.d.ts +18 -0
  315. package/dist/fhe-vesting/react/useManagerFeeType.d.ts +7 -0
  316. package/dist/fhe-vesting/react/useManagerGrantRole.d.ts +17 -0
  317. package/dist/fhe-vesting/react/useManagerHasRole.d.ts +15 -0
  318. package/dist/fhe-vesting/react/useManagerIsPausable.d.ts +6 -0
  319. package/dist/fhe-vesting/react/useManagerIsSplitEnabled.d.ts +6 -0
  320. package/dist/fhe-vesting/react/useManagerMaxBatchSize.d.ts +6 -0
  321. package/dist/fhe-vesting/react/useManagerMaxRevokeBatchSize.d.ts +6 -0
  322. package/dist/fhe-vesting/react/useManagerPause.d.ts +13 -0
  323. package/dist/fhe-vesting/react/useManagerPaused.d.ts +6 -0
  324. package/dist/fhe-vesting/react/useManagerRevokeRole.d.ts +17 -0
  325. package/dist/fhe-vesting/react/useManagerToken.d.ts +11 -0
  326. package/dist/fhe-vesting/react/useManagerUnpause.d.ts +12 -0
  327. package/dist/fhe-vesting/react/useManagerWithdrawGasFee.d.ts +14 -0
  328. package/dist/fhe-vesting/react/useManagerWithdrawOtherConfidentialToken.d.ts +14 -0
  329. package/dist/fhe-vesting/react/useManagerWithdrawOtherToken.d.ts +14 -0
  330. package/dist/fhe-vesting/react/useManagerWithdrawTokenFee.d.ts +11 -0
  331. package/dist/fhe-vesting/react/usePartialClaim.d.ts +15 -0
  332. package/dist/fhe-vesting/react/usePause.d.ts +12 -0
  333. package/dist/fhe-vesting/react/usePendingVestingTransfer.d.ts +20 -0
  334. package/dist/fhe-vesting/react/useRecipientVestings.d.ts +11 -0
  335. package/dist/fhe-vesting/react/useRecipientVestingsLength.d.ts +10 -0
  336. package/dist/fhe-vesting/react/useRecipientVestingsSliced.d.ts +12 -0
  337. package/dist/fhe-vesting/react/useRenounceRole.d.ts +16 -0
  338. package/dist/fhe-vesting/react/useResetGasFee.d.ts +10 -0
  339. package/dist/fhe-vesting/react/useResetTokenFee.d.ts +10 -0
  340. package/dist/fhe-vesting/react/useRevokeRole.d.ts +15 -0
  341. package/dist/fhe-vesting/react/useRevokeVesting.d.ts +15 -0
  342. package/dist/fhe-vesting/react/useRoleConstants.d.ts +19 -0
  343. package/dist/fhe-vesting/react/useSetCustomFee.d.ts +18 -0
  344. package/dist/fhe-vesting/react/useSetDefaultFeeType.d.ts +14 -0
  345. package/dist/fhe-vesting/react/useSetDefaultGasFee.d.ts +12 -0
  346. package/dist/fhe-vesting/react/useSetDefaultTokenFee.d.ts +13 -0
  347. package/dist/fhe-vesting/react/useSetFeeCollector.d.ts +13 -0
  348. package/dist/fhe-vesting/react/useSetMaxBatchSize.d.ts +12 -0
  349. package/dist/fhe-vesting/react/useSetMaxRevokeBatchSize.d.ts +12 -0
  350. package/dist/fhe-vesting/react/useSplitVesting.d.ts +28 -0
  351. package/dist/fhe-vesting/react/useTransferFeeCollectorRole.d.ts +12 -0
  352. package/dist/fhe-vesting/react/useUnpause.d.ts +11 -0
  353. package/dist/fhe-vesting/react/useVestingClaim.d.ts +19 -0
  354. package/dist/fhe-vesting/react/useVestingInfo.d.ts +25 -0
  355. package/dist/fhe-vesting/react/useWithdrawAdmin.d.ts +17 -0
  356. package/dist/fhe-vesting/react/useWithdrawGasFee.d.ts +13 -0
  357. package/dist/fhe-vesting/react/useWithdrawOtherConfidentialToken.d.ts +13 -0
  358. package/dist/fhe-vesting/react/useWithdrawOtherToken.d.ts +13 -0
  359. package/dist/fhe-vesting/react/useWithdrawTokenFee.d.ts +18 -0
  360. package/dist/fhe-vesting/types.d.ts +72 -0
  361. package/dist/index.cjs +237 -0
  362. package/dist/index.d.cts +3 -0
  363. package/dist/index.d.ts +3 -0
  364. package/dist/index.js +14 -0
  365. package/dist/telemetry/console.d.ts +29 -0
  366. package/dist/telemetry/index.cjs +113 -0
  367. package/dist/telemetry/index.d.cts +3 -0
  368. package/dist/telemetry/index.d.ts +3 -0
  369. package/dist/telemetry/index.js +102 -0
  370. package/dist/telemetry/tokenops.d.ts +15 -0
  371. package/package.json +316 -0
@@ -0,0 +1,190 @@
1
+ import type { Account, Address, Hex, PublicClient, WalletClient } from "viem";
2
+ import { type SdkTelemetry } from "../core/telemetry.js";
3
+ /**
4
+ * Minimal `setOperator` ABI fragment. Embedded inline (rather than imported
5
+ * from a shared mock-token ABI) because every ERC-7984-conformant token —
6
+ * production or mock — exposes this exact 4-byte selector. No artifact
7
+ * dependency.
8
+ *
9
+ * The contract signature is:
10
+ *
11
+ * ```solidity
12
+ * function setOperator(address operator, uint48 until) external;
13
+ * ```
14
+ *
15
+ * `uint48` upper bound (`2**48 - 1 ≈ 8.9e+14`) is comfortably past year 9999
16
+ * in unix seconds, so a "far-future" deadline is structurally safe.
17
+ */
18
+ export declare const ERC7984_SET_OPERATOR_ABI: readonly [{
19
+ readonly type: "function";
20
+ readonly name: "setOperator";
21
+ readonly stateMutability: "nonpayable";
22
+ readonly inputs: readonly [{
23
+ readonly name: "operator";
24
+ readonly type: "address";
25
+ }, {
26
+ readonly name: "until";
27
+ readonly type: "uint48";
28
+ }];
29
+ readonly outputs: readonly [];
30
+ }];
31
+ /**
32
+ * Far-future `uint48` deadline. The on-chain `until` parameter is a `uint48`
33
+ * unix timestamp; this constant is the maximum value the type can hold
34
+ * (`2**48 - 1`). Use as the default deadline when a consumer doesn't care
35
+ * about expiry — typical for local-chain dev loops and end-to-end fixture
36
+ * setup. For production flows, scope the deadline to the expected operation
37
+ * window (e.g. `Date.now()/1000 + 3600`).
38
+ */
39
+ export declare const ERC7984_OPERATOR_MAX_DEADLINE: bigint;
40
+ export interface SetOperatorArgs {
41
+ /** Read-only viem client for receipt waiting. */
42
+ publicClient: PublicClient;
43
+ /** Wallet client used to send the `setOperator` call. */
44
+ walletClient: WalletClient;
45
+ /**
46
+ * Account that owns the tokens being authorized. Pass an `Address` (looked
47
+ * up on `walletClient`) when the wallet has multiple accounts, or omit and
48
+ * the wallet's default account is used.
49
+ */
50
+ /**
51
+ * Account that owns the tokens being authorized. Accepts either a full
52
+ * viem `Account` object (e.g. from `privateKeyToAccount`) or an `Address`
53
+ * string. Mirrors `CreateVestingArgsCommon.account` and viem's own
54
+ * `writeContract` flexibility.
55
+ *
56
+ * Fallback hierarchy when this arg is omitted:
57
+ * 1. `walletClient.account` — the full account object the wallet was
58
+ * built with (preferred — viem signs locally → `eth_sendRawTransaction`).
59
+ * 2. throws `TokenOpsContractError` — no signer available.
60
+ *
61
+ * **Why `Account | Address` and not just `Address`:**
62
+ * viem's `writeContract` calls `eth_sendTransaction` (custodial-wallet path,
63
+ * rejected by Alchemy / Infura / public RPCs) when handed a string address,
64
+ * and `eth_sendRawTransaction` (local-signing path) when handed an `Account`
65
+ * object with a `signTransaction` method. Pass the full object you got from
66
+ * `privateKeyToAccount` to get local signing; pass an address only when the
67
+ * wallet has multiple custodial accounts and you want to pick one by name.
68
+ */
69
+ account?: Account | Address;
70
+ /** ERC-7984 token contract address. */
71
+ token: Address;
72
+ /**
73
+ * Address being authorized to pull tokens — typically a manager clone
74
+ * (`/fhe-vesting`), an airdrop clone (`/fhe-airdrop`), or the disperse
75
+ * singleton (`/fhe-disperse`).
76
+ */
77
+ spender: Address;
78
+ /**
79
+ * `uint48` unix timestamp after which the operator authorization expires.
80
+ * Defaults to {@link ERC7984_OPERATOR_MAX_DEADLINE} ("forever" within
81
+ * `uint48`).
82
+ */
83
+ deadline?: bigint;
84
+ /**
85
+ * If `true` (default), waits for the transaction to be mined before
86
+ * returning. Set to `false` for fire-and-forget flows where the caller
87
+ * waits separately.
88
+ */
89
+ waitForReceipt?: boolean;
90
+ /** Optional telemetry sink — span emits as `fhe.setOperator`. */
91
+ telemetry?: SdkTelemetry;
92
+ }
93
+ /**
94
+ * Authorize `spender` to pull ERC-7984 tokens from `account` until
95
+ * `deadline`. Required pre-step before any `/fhe-vesting`, `/fhe-airdrop`,
96
+ * or `/fhe-disperse` flow that takes funds from the operator's balance.
97
+ *
98
+ * Resolves to the transaction hash. Waits for the transaction to be mined
99
+ * by default (`waitForReceipt: true`) — the receipt is the strongest
100
+ * "operator is now authorized" signal a consumer can build the next call on
101
+ * top of. Pass `waitForReceipt: false` if your call site manages receipt
102
+ * polling itself.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * import { setOperator, ERC7984_OPERATOR_MAX_DEADLINE } from "@tokenops/sdk/fhe";
107
+ *
108
+ * await setOperator({
109
+ * publicClient,
110
+ * walletClient,
111
+ * token: DEPLOYED_ADDRESSES.tokens.testConfidential[31337]!,
112
+ * spender: manager,
113
+ * // deadline defaults to ERC7984_OPERATOR_MAX_DEADLINE (forever).
114
+ * });
115
+ *
116
+ * // Now safe to call manager.createVesting / factory.fundConfidentialAirdrop / etc.
117
+ * ```
118
+ *
119
+ * @throws {@link TokenOpsContractError} if the writeContract or receipt-wait
120
+ * step throws. The original viem error is attached as the cause.
121
+ */
122
+ export declare function setOperator(args: SetOperatorArgs): Promise<Hex>;
123
+ /**
124
+ * Arguments for {@link revokeOperator}. Identical to {@link SetOperatorArgs}
125
+ * minus the `deadline` field — revoke is a fixed `until=0` call that cannot
126
+ * accept a non-zero deadline (the ERC-7984 contract treats `0` as the revoke
127
+ * convention; any non-zero `until` would be a re-grant, not a revoke).
128
+ */
129
+ export interface RevokeOperatorArgs {
130
+ /** Read-only viem client for receipt waiting. */
131
+ publicClient: PublicClient;
132
+ /** Wallet client used to send the `setOperator(..., 0)` call. */
133
+ walletClient: WalletClient;
134
+ /**
135
+ * Account that owns the tokens. Same fallback hierarchy as
136
+ * {@link SetOperatorArgs} — preserves the `Account` object when present so
137
+ * viem signs locally via `eth_sendRawTransaction` rather than the
138
+ * custodial `eth_sendTransaction` path that public RPCs reject.
139
+ */
140
+ account?: Account | Address;
141
+ /** ERC-7984 token contract address. */
142
+ token: Address;
143
+ /**
144
+ * Address whose operator authorization should be revoked — typically a
145
+ * stale manager clone (`/fhe-vesting`), a closed airdrop clone
146
+ * (`/fhe-airdrop`), or a singleton no longer in use (`/fhe-disperse`).
147
+ */
148
+ spender: Address;
149
+ /**
150
+ * If `true` (default), waits for the transaction to be mined before
151
+ * returning. Set to `false` for fire-and-forget flows where the caller
152
+ * waits separately.
153
+ */
154
+ waitForReceipt?: boolean;
155
+ /** Optional telemetry sink — span emits as `fhe.revokeOperator`. */
156
+ telemetry?: SdkTelemetry;
157
+ }
158
+ /**
159
+ * Revoke a previously granted ERC-7984 operator authorization. Calls
160
+ * `token.setOperator(spender, 0)` — the ERC-7984 convention where `until=0`
161
+ * means "no future authorization" (the on-chain timestamp check `until >=
162
+ * block.timestamp` fails immediately).
163
+ *
164
+ * **When to use this.** Any `setOperator` flow leaves the spender authorized
165
+ * for the deadline window. The default deadline is
166
+ * {@link ERC7984_OPERATOR_MAX_DEADLINE} (uint48 max ≈ year 8.9e+14) — useful
167
+ * for local-chain dev loops, hostile for production deployments where a
168
+ * stale manager clone (replaced by a new one) would otherwise keep operator
169
+ * rights forever. R19 evm-audit M-3: the original `setOperator` shipped
170
+ * without a revoke sibling, forcing consumers to hand-roll
171
+ * `walletClient.writeContract({ ..., args: [spender, 0] })`.
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * import { revokeOperator } from "@tokenops/sdk/fhe";
176
+ *
177
+ * await revokeOperator({
178
+ * publicClient,
179
+ * walletClient,
180
+ * token: DEPLOYED_ADDRESSES.tokens.testConfidential[31337]!,
181
+ * spender: staleManager, // old manager clone after deploying a new one
182
+ * });
183
+ * // `staleManager` can no longer call `confidentialTransferFrom` against
184
+ * // the caller's balance.
185
+ * ```
186
+ *
187
+ * @throws {@link TokenOpsContractError} if the writeContract or receipt-wait
188
+ * step throws. The original viem error is attached as the cause.
189
+ */
190
+ export declare function revokeOperator(args: RevokeOperatorArgs): Promise<Hex>;
@@ -0,0 +1,102 @@
1
+ 'use strict';
2
+
3
+ require('../../chunk-66IHPTOK.cjs');
4
+ var chunk56UI7LUR_cjs = require('../../chunk-56UI7LUR.cjs');
5
+ var react = require('react');
6
+
7
+ function resolveUserDecryptor(source) {
8
+ if (source === void 0) return void 0;
9
+ return typeof source === "function" ? source() : source;
10
+ }
11
+ function useDecryptedHandle(opts) {
12
+ const [state, setState] = react.useState({
13
+ status: "idle",
14
+ value: void 0,
15
+ error: void 0
16
+ });
17
+ const decryptorSourceRef = react.useRef(opts.userDecryptor);
18
+ decryptorSourceRef.current = opts.userDecryptor;
19
+ const { handle, contractAddress, relayerParams, enabled } = opts;
20
+ const enabledNorm = enabled !== false;
21
+ const handleStr = handle;
22
+ const contractStr = contractAddress;
23
+ const relayerKey = relayerParams ? JSON.stringify(serializableSlice(relayerParams)) : "";
24
+ react.useEffect(() => {
25
+ if (!enabledNorm) {
26
+ setState({ status: "idle", value: void 0, error: void 0 });
27
+ return;
28
+ }
29
+ if (!handleStr || !contractStr) {
30
+ setState({ status: "idle", value: void 0, error: void 0 });
31
+ return;
32
+ }
33
+ const userDecryptor = resolveUserDecryptor(decryptorSourceRef.current);
34
+ if (!userDecryptor) {
35
+ setState({
36
+ status: "error",
37
+ value: void 0,
38
+ error: new chunk56UI7LUR_cjs.TokenOpsValidationError(
39
+ "useDecryptedHandle: no `userDecryptor` resolved \u2014 pass `userDecryptor: () => useZamaSDK().relayer` (or an eager RelayerSDK / MockFhevmInstance).",
40
+ { method: "useDecryptedHandle" }
41
+ )
42
+ });
43
+ return;
44
+ }
45
+ let cancelled = false;
46
+ setState({ status: "loading", value: void 0, error: void 0 });
47
+ void (async () => {
48
+ try {
49
+ const result = await userDecryptor.userDecrypt({
50
+ handleContractPairs: [{ handle: handleStr, contractAddress: contractStr }],
51
+ ...relayerParams ?? {}
52
+ });
53
+ const plain = result[handleStr];
54
+ if (plain === void 0) {
55
+ throw new chunk56UI7LUR_cjs.TokenOpsValidationError(
56
+ `useDecryptedHandle: relayer returned no value for handle ${handleStr} on contract ${contractStr} \u2014 check ACL grant + (handle, contractAddress, userAddress) triple`,
57
+ { method: "useDecryptedHandle", contractAddress: contractStr }
58
+ );
59
+ }
60
+ const value = typeof plain === "bigint" ? plain : BigInt(plain);
61
+ if (!cancelled) setState({ status: "success", value, error: void 0 });
62
+ } catch (err) {
63
+ if (!cancelled) {
64
+ const error = err instanceof Error ? err : new Error(String(err));
65
+ setState({ status: "error", value: void 0, error });
66
+ }
67
+ }
68
+ })();
69
+ return () => {
70
+ cancelled = true;
71
+ };
72
+ }, [enabledNorm, handleStr, contractStr, relayerKey]);
73
+ return state;
74
+ }
75
+ function serializableSlice(v) {
76
+ const out = {};
77
+ for (const k of Object.keys(v)) {
78
+ const val = v[k];
79
+ if (val === void 0) continue;
80
+ if (typeof val === "function" || typeof val === "symbol") continue;
81
+ out[k] = typeof val === "bigint" ? val.toString() : val;
82
+ }
83
+ return out;
84
+ }
85
+
86
+ Object.defineProperty(exports, "TokenOpsContractError", {
87
+ enumerable: true,
88
+ get: function () { return chunk56UI7LUR_cjs.TokenOpsContractError; }
89
+ });
90
+ Object.defineProperty(exports, "TokenOpsSdkError", {
91
+ enumerable: true,
92
+ get: function () { return chunk56UI7LUR_cjs.TokenOpsSdkError; }
93
+ });
94
+ Object.defineProperty(exports, "TokenOpsValidationError", {
95
+ enumerable: true,
96
+ get: function () { return chunk56UI7LUR_cjs.TokenOpsValidationError; }
97
+ });
98
+ Object.defineProperty(exports, "isTokenOpsSdkError", {
99
+ enumerable: true,
100
+ get: function () { return chunk56UI7LUR_cjs.isTokenOpsSdkError; }
101
+ });
102
+ exports.useDecryptedHandle = useDecryptedHandle;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Cross-product React hooks living in the `@tokenops/sdk/fhe/react` subpath.
3
+ *
4
+ * Per-product React hooks (`useCreateVesting`, `useDisperse`, etc.) live in
5
+ * each product's `src/<product>/react/` barrel. This barrel hosts hooks that
6
+ * span products — e.g. `useDecryptedHandle` (works on any product's
7
+ * `EncryptedHandle` return value).
8
+ */
9
+ export { useDecryptedHandle, type UseDecryptedHandleOptions, type UseDecryptedHandleResult, type UserDecryptor, type UserDecryptorSource, } from "./use-decrypted-handle.js";
10
+ export { TokenOpsSdkError, isTokenOpsSdkError, TokenOpsValidationError, TokenOpsContractError, } from "../../core/errors.js";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Cross-product React hooks living in the `@tokenops/sdk/fhe/react` subpath.
3
+ *
4
+ * Per-product React hooks (`useCreateVesting`, `useDisperse`, etc.) live in
5
+ * each product's `src/<product>/react/` barrel. This barrel hosts hooks that
6
+ * span products — e.g. `useDecryptedHandle` (works on any product's
7
+ * `EncryptedHandle` return value).
8
+ */
9
+ export { useDecryptedHandle, type UseDecryptedHandleOptions, type UseDecryptedHandleResult, type UserDecryptor, type UserDecryptorSource, } from "./use-decrypted-handle.js";
10
+ export { TokenOpsSdkError, isTokenOpsSdkError, TokenOpsValidationError, TokenOpsContractError, } from "../../core/errors.js";
@@ -0,0 +1,85 @@
1
+ import '../../chunk-KWFFIJYX.js';
2
+ import { TokenOpsValidationError } from '../../chunk-IVE3QEGD.js';
3
+ export { TokenOpsContractError, TokenOpsSdkError, TokenOpsValidationError, isTokenOpsSdkError } from '../../chunk-IVE3QEGD.js';
4
+ import { useState, useRef, useEffect } from 'react';
5
+
6
+ function resolveUserDecryptor(source) {
7
+ if (source === void 0) return void 0;
8
+ return typeof source === "function" ? source() : source;
9
+ }
10
+ function useDecryptedHandle(opts) {
11
+ const [state, setState] = useState({
12
+ status: "idle",
13
+ value: void 0,
14
+ error: void 0
15
+ });
16
+ const decryptorSourceRef = useRef(opts.userDecryptor);
17
+ decryptorSourceRef.current = opts.userDecryptor;
18
+ const { handle, contractAddress, relayerParams, enabled } = opts;
19
+ const enabledNorm = enabled !== false;
20
+ const handleStr = handle;
21
+ const contractStr = contractAddress;
22
+ const relayerKey = relayerParams ? JSON.stringify(serializableSlice(relayerParams)) : "";
23
+ useEffect(() => {
24
+ if (!enabledNorm) {
25
+ setState({ status: "idle", value: void 0, error: void 0 });
26
+ return;
27
+ }
28
+ if (!handleStr || !contractStr) {
29
+ setState({ status: "idle", value: void 0, error: void 0 });
30
+ return;
31
+ }
32
+ const userDecryptor = resolveUserDecryptor(decryptorSourceRef.current);
33
+ if (!userDecryptor) {
34
+ setState({
35
+ status: "error",
36
+ value: void 0,
37
+ error: new TokenOpsValidationError(
38
+ "useDecryptedHandle: no `userDecryptor` resolved \u2014 pass `userDecryptor: () => useZamaSDK().relayer` (or an eager RelayerSDK / MockFhevmInstance).",
39
+ { method: "useDecryptedHandle" }
40
+ )
41
+ });
42
+ return;
43
+ }
44
+ let cancelled = false;
45
+ setState({ status: "loading", value: void 0, error: void 0 });
46
+ void (async () => {
47
+ try {
48
+ const result = await userDecryptor.userDecrypt({
49
+ handleContractPairs: [{ handle: handleStr, contractAddress: contractStr }],
50
+ ...relayerParams ?? {}
51
+ });
52
+ const plain = result[handleStr];
53
+ if (plain === void 0) {
54
+ throw new TokenOpsValidationError(
55
+ `useDecryptedHandle: relayer returned no value for handle ${handleStr} on contract ${contractStr} \u2014 check ACL grant + (handle, contractAddress, userAddress) triple`,
56
+ { method: "useDecryptedHandle", contractAddress: contractStr }
57
+ );
58
+ }
59
+ const value = typeof plain === "bigint" ? plain : BigInt(plain);
60
+ if (!cancelled) setState({ status: "success", value, error: void 0 });
61
+ } catch (err) {
62
+ if (!cancelled) {
63
+ const error = err instanceof Error ? err : new Error(String(err));
64
+ setState({ status: "error", value: void 0, error });
65
+ }
66
+ }
67
+ })();
68
+ return () => {
69
+ cancelled = true;
70
+ };
71
+ }, [enabledNorm, handleStr, contractStr, relayerKey]);
72
+ return state;
73
+ }
74
+ function serializableSlice(v) {
75
+ const out = {};
76
+ for (const k of Object.keys(v)) {
77
+ const val = v[k];
78
+ if (val === void 0) continue;
79
+ if (typeof val === "function" || typeof val === "symbol") continue;
80
+ out[k] = typeof val === "bigint" ? val.toString() : val;
81
+ }
82
+ return out;
83
+ }
84
+
85
+ export { useDecryptedHandle };
@@ -0,0 +1,102 @@
1
+ import type { Address } from "viem";
2
+ import { type EncryptedHandle } from "../../core/brands.js";
3
+ /**
4
+ * Subset of `@zama-fhe/sdk` `RelayerSDK` we depend on for user-decryption.
5
+ * Declared structurally so consumers can pass any v3 RelayerSDK
6
+ * (`RelayerWeb`, `RelayerNode`, or a mock like `MockFhevmInstance`) without
7
+ * us importing the optional peer dep.
8
+ */
9
+ export interface UserDecryptor {
10
+ userDecrypt(params: {
11
+ handleContractPairs: {
12
+ handle: string;
13
+ contractAddress: string;
14
+ }[];
15
+ privateKey?: unknown;
16
+ publicKey?: unknown;
17
+ signature?: unknown;
18
+ contractAddresses?: string[];
19
+ userAddress?: string;
20
+ requestValidity?: {
21
+ startTimestamp: bigint | number;
22
+ durationDays: bigint | number;
23
+ };
24
+ contractsChainId?: bigint | number;
25
+ }): Promise<Readonly<Record<string, unknown>>>;
26
+ }
27
+ /** Eager or lazy {@link UserDecryptor} reference — mirrors EncryptorSource. */
28
+ export type UserDecryptorSource = UserDecryptor | (() => UserDecryptor | undefined);
29
+ /** Options accepted by {@link useDecryptedHandle}. */
30
+ export interface UseDecryptedHandleOptions {
31
+ /**
32
+ * The encrypted handle to decrypt. `undefined` keeps the hook in `idle`
33
+ * state — useful when the handle comes from a downstream query that hasn't
34
+ * resolved yet.
35
+ */
36
+ handle?: EncryptedHandle | undefined;
37
+ /**
38
+ * The contract that granted ACL access to the handle. The relayer enforces
39
+ * `(handle, contractAddress, userAddress)` triples — passing the wrong
40
+ * contract here returns an empty result with no diagnostic.
41
+ */
42
+ contractAddress?: Address | undefined;
43
+ /**
44
+ * Lazy or eager Zama RelayerSDK / MockFhevmInstance / RelayerWeb / RelayerNode.
45
+ * Recommended in React: `userDecryptor: () => useZamaSDK().relayer` — the
46
+ * SDK calls this per-decryption so it picks up the live RelayerSDK instance
47
+ * rather than a stale capture (CLAUDE.md Pitfall #3).
48
+ */
49
+ userDecryptor?: UserDecryptorSource | undefined;
50
+ /**
51
+ * Extra params passed straight through to the relayer's `userDecrypt`. The
52
+ * Zama `RelayerWeb` / `RelayerNode` require `privateKey`, `publicKey`,
53
+ * `signature`, `requestValidity`, `contractsChainId`. `MockFhevmInstance`
54
+ * tolerates a partial shape. Hosts that wrap their own keypair management
55
+ * pass the full shape here.
56
+ */
57
+ relayerParams?: Omit<Parameters<UserDecryptor["userDecrypt"]>[0], "handleContractPairs"> | undefined;
58
+ /**
59
+ * Skip the decrypt — defaults to `false`. Useful when the consumer wants
60
+ * to render an "Encrypted" placeholder until the user opts in.
61
+ */
62
+ enabled?: boolean | undefined;
63
+ }
64
+ /** Discriminated state machine for the hook's return. */
65
+ export type UseDecryptedHandleResult = {
66
+ status: "idle";
67
+ value: undefined;
68
+ error: undefined;
69
+ } | {
70
+ status: "loading";
71
+ value: undefined;
72
+ error: undefined;
73
+ } | {
74
+ status: "success";
75
+ value: bigint;
76
+ error: undefined;
77
+ } | {
78
+ status: "error";
79
+ value: undefined;
80
+ error: Error;
81
+ };
82
+ /**
83
+ * Decrypt a single `EncryptedHandle` returned by an FHE-product encrypted
84
+ * view (e.g. `EncryptedViewResult.handle` from
85
+ * `ConfidentialVestingManagerClient.getTokenBalance()`).
86
+ *
87
+ * ```ts
88
+ * import { useDecryptedHandle } from "@tokenops/sdk/fhe/react";
89
+ *
90
+ * const { status, value } = useDecryptedHandle({
91
+ * handle: viewResult?.handle,
92
+ * contractAddress: managerAddress,
93
+ * userDecryptor: () => useZamaSDK().relayer,
94
+ * relayerParams: { ...keypair, requestValidity, contractsChainId },
95
+ * });
96
+ * ```
97
+ *
98
+ * The relayer source resolves lazily per decrypt — the hook does NOT
99
+ * memoize the SDK client across renders, because user-decrypt is a one-shot
100
+ * action (no benefit to client caching).
101
+ */
102
+ export declare function useDecryptedHandle(opts: UseDecryptedHandleOptions): UseDecryptedHandleResult;
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Fixed plaintext denominator used by every confidential split call.
3
+ *
4
+ * = LCM(1..16, 10_000) = 2⁴ × 3² × 5⁴ × 7 × 11 × 13 = 90,090,000.
5
+ *
6
+ * The denominator lives in plaintext (calldata or storage). Sizing it
7
+ * per-call to fit each specific split would leak the split's shape — a
8
+ * `1/2` split would use a different plaintext denominator than a `1/7`
9
+ * split, and observers could distinguish them without decrypting anything.
10
+ * Pinning every split to a single universal constant removes that side
11
+ * channel.
12
+ *
13
+ * `90_090_000` specifically is the smallest integer divisible by every
14
+ * common human split shape we support, in two flavours:
15
+ * - `n/m` with `m ∈ 1..16` (halves, thirds, …, sixteenths and their
16
+ * combinations) — produces an exact integer numerator because `m`
17
+ * divides `90_090_000`.
18
+ * - `o/10_000` (basis points, `o ∈ 0..10_000`) — produces an exact integer
19
+ * numerator because `90_090_000 = 10_000 × 9_009`, so `bps` maps to
20
+ * `bps × 9_009`.
21
+ *
22
+ * No rounding artifacts in either case — the denominator itself is the
23
+ * only signal an observer sees, and it never changes, so the leak surface
24
+ * is zero. Use the {@link share} builder to construct ratios from either
25
+ * shape ergonomically.
26
+ *
27
+ * Overflow is not a concern. The confidential-vesting contract upcasts
28
+ * the encrypted numerator to `euint128` before multiplying by the holder
29
+ * balance, so the intermediate `amount × numerator` math happens in
30
+ * `euint128` space (max ~3.4 × 10³⁸). For a 6-decimal ERC-7984 balance
31
+ * (max ~1.84 × 10¹⁹) and our denominator (~9 × 10⁷) the product tops out
32
+ * at ~1.7 × 10²⁷ — eleven orders of magnitude under the `euint128`
33
+ * ceiling. The plaintext denominator itself fits trivially in the
34
+ * contract's `uint128 denominator` parameter.
35
+ *
36
+ * Do NOT shrink this. All split-style SDK methods must use the same
37
+ * value — the leak surface is only zero when every product agrees on
38
+ * one constant. Today that's `fhe-vesting` `splitVesting`; future
39
+ * split-style surfaces (weighted disperses, weighted airdrops if added)
40
+ * must pin to this same constant.
41
+ */
42
+ export declare const FHE_SPLIT_DENOMINATOR = 90090000n;
43
+ /**
44
+ * Bit-width to validate the scaled numerator/denominator against.
45
+ *
46
+ * - `"uint64"` matches the encrypted-numerator width every confidential
47
+ * split path actually uses (the SDK routes through `encryptUint64`).
48
+ * Hit `splitVesting`-style call sites with this so the validator's
49
+ * bound matches the encryption path's bound — same `InvalidArgumentError`
50
+ * instead of a less specific `EncryptionFailedError` downstream.
51
+ * - `"uint128"` is the legacy default kept for non-split contract surfaces
52
+ * that the helper might also serve in the future.
53
+ */
54
+ export type ScaleRatioWidth = "uint64" | "uint128";
55
+ export interface ScaledRatio {
56
+ numerator: bigint;
57
+ denominator: bigint;
58
+ }
59
+ export interface ScaleRatioArgs {
60
+ numerator: bigint;
61
+ denominator: bigint;
62
+ /**
63
+ * Target denominator for the scaled output. Defaults to
64
+ * {@link FHE_SPLIT_DENOMINATOR} (`90_090_000`) — the privacy-preserving
65
+ * constant every confidential split must agree on. Override only for
66
+ * non-split contract surfaces that have a different precision floor.
67
+ */
68
+ minDenominator?: bigint;
69
+ /**
70
+ * Bit-width the scaled values are validated against. Defaults to
71
+ * `"uint128"`. Pass `"uint64"` for confidential split paths whose
72
+ * encrypted numerator goes through `encryptUint64`, so the bound the
73
+ * helper reports matches the bound the encryption call would enforce.
74
+ */
75
+ width?: ScaleRatioWidth;
76
+ }
77
+ /**
78
+ * Scale a plaintext ratio so the output denominator equals the
79
+ * privacy-preserving split constant ({@link FHE_SPLIT_DENOMINATOR},
80
+ * default `90_090_000`) while keeping both values within `uint128`.
81
+ *
82
+ * For arbitrary `numerator/denominator` inputs the output is the closest
83
+ * exact-integer numerator under that constant — i.e. `numerator ×
84
+ * (90_090_000 / denominator)` when `denominator` divides `90_090_000`
85
+ * (every `1..16` fraction and every basis-point amount), or
86
+ * `ceil(90_090_000 × numerator / denominator)` for general inputs (with
87
+ * the denominator still pinned to `90_090_000`).
88
+ *
89
+ * Pre-scaled inputs whose denominator already matches `minDenominator`
90
+ * are returned unchanged; pre-scaled inputs whose denominator exceeds
91
+ * `minDenominator` are also returned unchanged (the caller is asking for
92
+ * higher precision than the standard constant, e.g. for a non-split
93
+ * surface).
94
+ *
95
+ * Most consumers should use {@link share} instead — its builders express
96
+ * the two natural shapes (`n/m`, basis points) directly and produce
97
+ * `ScaledRatio` outputs that are exact-integer by construction.
98
+ *
99
+ * @example
100
+ * scaleRatio({ numerator: 1n, denominator: 2n });
101
+ * // → { numerator: 45_045_000n, denominator: 90_090_000n } // 50% of 90_090_000
102
+ *
103
+ * @example
104
+ * scaleRatio({ numerator: 2n, denominator: 3n });
105
+ * // → { numerator: 60_060_000n, denominator: 90_090_000n } // exact: 2/3 × 90_090_000
106
+ */
107
+ export declare function scaleRatio({ numerator, denominator, minDenominator, width, }: ScaleRatioArgs): ScaledRatio;
108
+ /**
109
+ * Guided builders for the two split shapes the SDK supports as
110
+ * exact-integer numerators over {@link FHE_SPLIT_DENOMINATOR}
111
+ * (`90_090_000` = LCM(1..16, 10_000)).
112
+ *
113
+ * Use these when you know your split as one of:
114
+ * - a simple fraction `n/m` with `m ∈ 1..16` (halves, thirds, …,
115
+ * sixteenths), or
116
+ * - a basis-point amount `bps/10_000` with `bps ∈ 0..10_000`
117
+ * (1 bp = 0.01%, 100 bp = 1%, 10_000 bp = 100%).
118
+ *
119
+ * Both shapes land on `90_090_000` with no rounding artifacts. The
120
+ * returned `ScaledRatio` is ready to pass to split-style SDK calls with
121
+ * `preScaled: true` — the auto-scaling path is skipped because the math
122
+ * has already been done exactly.
123
+ *
124
+ * @example
125
+ * share.fraction(1, 3) // → { numerator: 30_030_000n, denominator: 90_090_000n }
126
+ * share.basisPoints(250) // → { numerator: 2_252_250n, denominator: 90_090_000n } // 2.5%
127
+ *
128
+ * @example
129
+ * const ratio = share.basisPoints(50); // 0.5%
130
+ * await manager.splitVesting({
131
+ * vestingId,
132
+ * numerator: ratio.numerator,
133
+ * denominator: ratio.denominator,
134
+ * preScaled: true, // skip auto-scaling; share already did it
135
+ * newRecipient,
136
+ * });
137
+ */
138
+ export declare const share: {
139
+ /**
140
+ * Build a `ScaledRatio` from a simple fraction `n/m`.
141
+ *
142
+ * - `m` must be in `1..16` — every integer in this range divides
143
+ * {@link FHE_SPLIT_DENOMINATOR} cleanly, so the result is exact.
144
+ * - `n` must be in `0..m` — `0` is a zero-share (no-op split) and `m`
145
+ * itself is the whole position.
146
+ *
147
+ * Both arguments accept `number` (must be an integer) or `bigint` —
148
+ * use whichever is convenient at the call site.
149
+ *
150
+ * @throws InvalidArgumentError if `m` is outside `1..16` or `n` is
151
+ * outside `0..m`, or either input is a non-integer `number`.
152
+ */
153
+ readonly fraction: (numerator: number | bigint, denominator: number | bigint) => ScaledRatio;
154
+ /**
155
+ * Build a `ScaledRatio` from a basis-point amount.
156
+ *
157
+ * `bps` must be in `0..10_000` — `0` is a zero-share and `10_000` is
158
+ * the whole position (= 100%). `10_000` divides
159
+ * {@link FHE_SPLIT_DENOMINATOR} cleanly, so the result is exact:
160
+ * `bps × 9_009` over `90_090_000`.
161
+ *
162
+ * Accepts `number` (must be an integer) or `bigint`.
163
+ *
164
+ * @throws InvalidArgumentError if `bps` is outside `0..10_000`, or is
165
+ * a non-integer `number`.
166
+ */
167
+ readonly basisPoints: (bps: number | bigint) => ScaledRatio;
168
+ };