@tokenops/sdk 1.6.0 → 2.0.0-alpha.2

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 (263) hide show
  1. package/CHANGELOG.md +77 -8
  2. package/CONTRIBUTING.md +4 -2
  3. package/README.md +146 -90
  4. package/SUPPORT.md +47 -0
  5. package/dist/{chunk-BD4LZBVF.cjs → chunk-3QHNYEQD.cjs} +18 -17
  6. package/dist/{chunk-YFIWCYHC.cjs → chunk-3YHBO2DL.cjs} +56 -54
  7. package/dist/{chunk-QET3Q4JP.js → chunk-44YJPMQC.js} +8 -6
  8. package/dist/{chunk-6WSNS3UV.js → chunk-4RAAATVY.js} +2 -4
  9. package/dist/{chunk-4KJ66YRH.js → chunk-4TSDNZQ3.js} +2 -2
  10. package/dist/chunk-66IHPTOK.cjs +20 -0
  11. package/dist/{chunk-2RNW4MIJ.cjs → chunk-67OV5CX2.cjs} +0 -18
  12. package/dist/{chunk-PD7ME2BT.js → chunk-6GNR22OV.js} +2 -1
  13. package/dist/{chunk-WOEETTH7.cjs → chunk-7AFPOE7N.cjs} +6 -6
  14. package/dist/{chunk-QKKBBH7I.js → chunk-A4DCEE33.js} +34 -7
  15. package/dist/chunk-AREQJHKA.cjs +713 -0
  16. package/dist/{chunk-U57COLUE.js → chunk-AXIPOR3C.js} +2 -2
  17. package/dist/chunk-EBLBPUPI.cjs +255 -0
  18. package/dist/chunk-EYDA6Q6C.js +245 -0
  19. package/dist/{chunk-SYHNZSZZ.cjs → chunk-FAXIIH5R.cjs} +3 -3
  20. package/dist/{chunk-AYGRYDBX.cjs → chunk-FEDX7B6T.cjs} +37 -35
  21. package/dist/{chunk-CBRL2PJA.cjs → chunk-FHWSBGWE.cjs} +12 -12
  22. package/dist/{chunk-WUXUWTFW.cjs → chunk-FT5H2Q7Y.cjs} +37 -7
  23. package/dist/chunk-GADGBQJO.js +423 -0
  24. package/dist/{chunk-VHSNYUYV.js → chunk-IGO5XSPS.js} +5 -5
  25. package/dist/chunk-IUKKNJ2R.cjs +433 -0
  26. package/dist/{chunk-VR3FREBX.cjs → chunk-JK4XMMKM.cjs} +3 -3
  27. package/dist/{chunk-4ZCXK4VI.cjs → chunk-KFRDLKMA.cjs} +14 -14
  28. package/dist/chunk-KWFFIJYX.js +11 -0
  29. package/dist/{chunk-7G7UOQV4.cjs → chunk-MM5BV5CS.cjs} +4 -4
  30. package/dist/{chunk-43RFBQ73.cjs → chunk-MVDQMV25.cjs} +29 -32
  31. package/dist/chunk-NWFMBLSQ.js +4 -0
  32. package/dist/{chunk-HETNKZEE.js → chunk-PYYSB5ZN.js} +1 -1
  33. package/dist/chunk-PZZK3O3S.cjs +9843 -0
  34. package/dist/{chunk-DRSPMIZ7.js → chunk-QBJ7O2B4.js} +1 -11
  35. package/dist/{chunk-WTK6JDSI.js → chunk-SPLNGUFF.js} +6 -4
  36. package/dist/{chunk-UJS4N2XM.cjs → chunk-TEBM66WA.cjs} +12 -12
  37. package/dist/{chunk-TN65XNTI.js → chunk-TWT3STIX.js} +8 -6
  38. package/dist/chunk-UG5RKLU2.cjs +6 -0
  39. package/dist/{chunk-EUKPOXWR.cjs → chunk-UHHMVBLU.cjs} +17 -15
  40. package/dist/chunk-VW356KR3.js +688 -0
  41. package/dist/{chunk-BK7YIVLK.cjs → chunk-WJLECC22.cjs} +75 -73
  42. package/dist/{chunk-V5D7BHW3.js → chunk-WJMEBBU7.js} +6 -4
  43. package/dist/{chunk-NFW7AUEX.js → chunk-WMACINXO.js} +1 -1
  44. package/dist/chunk-X7WBPCEU.js +9817 -0
  45. package/dist/{chunk-46T67CE2.js → chunk-ZA673I3O.js} +1 -1
  46. package/dist/{chunk-YPYCWLYP.js → chunk-ZWXJTBZO.js} +1 -1
  47. package/dist/core/addresses.d.ts +14 -2
  48. package/dist/core/brands.d.ts +8 -2
  49. package/dist/core/errors.d.ts +71 -10
  50. package/dist/core/preflight.d.ts +1 -0
  51. package/dist/fhe/erc7984-abi.d.ts +1 -0
  52. package/dist/fhe/index.cjs +64 -63
  53. package/dist/fhe/index.js +7 -6
  54. package/dist/fhe/operators.d.ts +22 -5
  55. package/dist/fhe/react/index.cjs +13 -12
  56. package/dist/fhe/react/index.js +6 -5
  57. package/dist/fhe/types.d.ts +8 -2
  58. package/dist/fhe-airdrop/abis/{cloneable.d.ts → airdrop-base.d.ts} +254 -396
  59. package/dist/fhe-airdrop/abis/compliance.d.ts +422 -0
  60. package/dist/fhe-airdrop/abis/ecdsa.d.ts +1316 -0
  61. package/dist/fhe-airdrop/abis/factory.d.ts +1319 -190
  62. package/dist/fhe-airdrop/abis/index.d.ts +5 -2
  63. package/dist/fhe-airdrop/abis/merkle.d.ts +1250 -0
  64. package/dist/fhe-airdrop/advanced/index.cjs +11 -12
  65. package/dist/fhe-airdrop/advanced/index.d.cts +34 -11
  66. package/dist/fhe-airdrop/advanced/index.d.ts +34 -11
  67. package/dist/fhe-airdrop/advanced/index.js +3 -8
  68. package/dist/fhe-airdrop/advanced/react/index.cjs +619 -51
  69. package/dist/fhe-airdrop/advanced/react/index.d.cts +43 -3
  70. package/dist/fhe-airdrop/advanced/react/index.d.ts +43 -3
  71. package/dist/fhe-airdrop/advanced/react/index.js +592 -52
  72. package/dist/fhe-airdrop/advanced/react/useClearCompliancePolicy.d.ts +28 -0
  73. package/dist/fhe-airdrop/advanced/react/useClearUpgradeabilityPolicy.d.ts +26 -0
  74. package/dist/fhe-airdrop/advanced/react/useDisableCustomFee.d.ts +25 -0
  75. package/dist/fhe-airdrop/advanced/react/useEcdsaInitCodeHash.d.ts +30 -0
  76. package/dist/fhe-airdrop/advanced/react/useFactoryComplianceDelegate.d.ts +25 -0
  77. package/dist/fhe-airdrop/advanced/react/useFactoryCompliancePolicy.d.ts +38 -0
  78. package/dist/fhe-airdrop/advanced/react/useFactoryCustomFee.d.ts +24 -0
  79. package/dist/fhe-airdrop/advanced/react/useFactoryGrantRole.d.ts +32 -0
  80. package/dist/fhe-airdrop/advanced/react/useFactoryHasRole.d.ts +27 -0
  81. package/dist/fhe-airdrop/advanced/react/useFactoryImplementations.d.ts +33 -0
  82. package/dist/fhe-airdrop/advanced/react/useFactoryRenounceRole.d.ts +36 -0
  83. package/dist/fhe-airdrop/advanced/react/useFactoryRevokeRole.d.ts +35 -0
  84. package/dist/fhe-airdrop/advanced/react/useFactoryRoleConstants.d.ts +46 -0
  85. package/dist/fhe-airdrop/advanced/react/useFactoryRoleMembers.d.ts +47 -0
  86. package/dist/fhe-airdrop/advanced/react/useFactoryUpgradeabilityPolicy.d.ts +39 -0
  87. package/dist/fhe-airdrop/advanced/react/useMerkleInitCodeHash.d.ts +24 -0
  88. package/dist/fhe-airdrop/advanced/react/usePredictEcdsaAirdropAddress.d.ts +33 -0
  89. package/dist/fhe-airdrop/advanced/react/usePredictMerkleAirdropAddress.d.ts +27 -0
  90. package/dist/fhe-airdrop/advanced/react/useSetComplianceDelegate.d.ts +33 -0
  91. package/dist/fhe-airdrop/advanced/react/useSetComplianceManagerImpl.d.ts +27 -0
  92. package/dist/fhe-airdrop/advanced/react/useSetCompliancePolicy.d.ts +28 -0
  93. package/dist/fhe-airdrop/advanced/react/useSetCustomFee.d.ts +28 -0
  94. package/dist/fhe-airdrop/advanced/react/useSetDefaultDelegateToCompliance.d.ts +31 -0
  95. package/dist/fhe-airdrop/advanced/react/useSetDefaultGasFee.d.ts +28 -0
  96. package/dist/fhe-airdrop/advanced/react/useSetDefaultUpgradeable.d.ts +27 -0
  97. package/dist/fhe-airdrop/advanced/react/useSetEcdsaImplementation.d.ts +34 -0
  98. package/dist/fhe-airdrop/advanced/react/useSetFeeCollector.d.ts +27 -0
  99. package/dist/fhe-airdrop/advanced/react/useSetMerkleImplementation.d.ts +30 -0
  100. package/dist/fhe-airdrop/advanced/react/useSetUpgradeabilityPolicy.d.ts +31 -0
  101. package/dist/fhe-airdrop/airdrop-base.d.ts +608 -0
  102. package/dist/fhe-airdrop/campaign.d.ts +338 -0
  103. package/dist/fhe-airdrop/compliance.d.ts +302 -0
  104. package/dist/fhe-airdrop/constants.d.ts +33 -0
  105. package/dist/fhe-airdrop/ecdsa.d.ts +263 -0
  106. package/dist/fhe-airdrop/encryption.d.ts +92 -14
  107. package/dist/fhe-airdrop/errors.d.ts +273 -15
  108. package/dist/fhe-airdrop/factory.d.ts +533 -274
  109. package/dist/fhe-airdrop/guards.d.ts +317 -0
  110. package/dist/fhe-airdrop/index.cjs +233 -73
  111. package/dist/fhe-airdrop/index.d.cts +46 -8
  112. package/dist/fhe-airdrop/index.d.ts +46 -8
  113. package/dist/fhe-airdrop/index.js +11 -7
  114. package/dist/fhe-airdrop/merkle-tree.d.ts +97 -0
  115. package/dist/fhe-airdrop/merkle.d.ts +201 -0
  116. package/dist/fhe-airdrop/react/_shared.d.ts +156 -70
  117. package/dist/fhe-airdrop/react/index.cjs +1174 -384
  118. package/dist/fhe-airdrop/react/index.d.cts +99 -74
  119. package/dist/fhe-airdrop/react/index.d.ts +99 -74
  120. package/dist/fhe-airdrop/react/index.js +993 -303
  121. package/dist/fhe-airdrop/react/keys.d.ts +90 -0
  122. package/dist/fhe-airdrop/react/useAccessEcdsaClaimAmount.d.ts +26 -0
  123. package/dist/fhe-airdrop/react/useAccessMerkleClaimAmount.d.ts +27 -0
  124. package/dist/fhe-airdrop/react/useAddComplianceDelegate.d.ts +37 -0
  125. package/dist/fhe-airdrop/react/useAdminBatchDiscloseBalanceToParties.d.ts +36 -0
  126. package/dist/fhe-airdrop/react/useAdminDiscloseBalanceToParty.d.ts +31 -0
  127. package/dist/fhe-airdrop/react/useAdminGetCurrentBalance.d.ts +27 -0
  128. package/dist/fhe-airdrop/react/useAirdropConfig.d.ts +49 -0
  129. package/dist/fhe-airdrop/react/useAirdropDeploymentMode.d.ts +28 -0
  130. package/dist/fhe-airdrop/react/useAirdropGasFee.d.ts +10 -5
  131. package/dist/fhe-airdrop/react/useAirdropGrantRole.d.ts +29 -10
  132. package/dist/fhe-airdrop/react/useAirdropHasRole.d.ts +15 -6
  133. package/dist/fhe-airdrop/react/useAirdropPause.d.ts +30 -0
  134. package/dist/fhe-airdrop/react/useAirdropPaused.d.ts +17 -0
  135. package/dist/fhe-airdrop/react/useAirdropRenounceRole.d.ts +36 -0
  136. package/dist/fhe-airdrop/react/useAirdropRevokeRole.d.ts +27 -9
  137. package/dist/fhe-airdrop/react/useAirdropRoleAdmin.d.ts +28 -0
  138. package/dist/fhe-airdrop/react/useAirdropRoleConstants.d.ts +67 -0
  139. package/dist/fhe-airdrop/react/useAirdropRoleMembers.d.ts +49 -0
  140. package/dist/fhe-airdrop/react/useAirdropToken.d.ts +11 -4
  141. package/dist/fhe-airdrop/react/useAirdropUpgradeToAndCall.d.ts +45 -0
  142. package/dist/fhe-airdrop/react/useAirdropWindow.d.ts +37 -0
  143. package/dist/fhe-airdrop/react/useBatchDiscloseHandlesToParty.d.ts +32 -0
  144. package/dist/fhe-airdrop/react/useBuildMerkleCampaign.d.ts +68 -0
  145. package/dist/fhe-airdrop/react/useClaimedAmount.d.ts +29 -0
  146. package/dist/fhe-airdrop/react/useComplianceGrantRole.d.ts +32 -0
  147. package/dist/fhe-airdrop/react/useComplianceHasRole.d.ts +37 -0
  148. package/dist/fhe-airdrop/react/useComplianceInfo.d.ts +50 -0
  149. package/dist/fhe-airdrop/react/useComplianceManager.d.ts +16 -0
  150. package/dist/fhe-airdrop/react/useComplianceManagerOf.d.ts +32 -0
  151. package/dist/fhe-airdrop/react/useComplianceRenounceRole.d.ts +38 -0
  152. package/dist/fhe-airdrop/react/useComplianceRevokeRole.d.ts +36 -0
  153. package/dist/fhe-airdrop/react/useComplianceRoleConstants.d.ts +41 -0
  154. package/dist/fhe-airdrop/react/useComplianceRoleMembers.d.ts +45 -0
  155. package/dist/fhe-airdrop/react/useCreateAndFundEcdsaAirdrop.d.ts +55 -0
  156. package/dist/fhe-airdrop/react/useCreateAndFundMerkleAirdrop.d.ts +52 -0
  157. package/dist/fhe-airdrop/react/useCreateEcdsaAirdrop.d.ts +28 -0
  158. package/dist/fhe-airdrop/react/useCreateMerkleAirdrop.d.ts +25 -0
  159. package/dist/fhe-airdrop/react/useDiscloseHandleToParty.d.ts +35 -0
  160. package/dist/fhe-airdrop/react/useEcdsaClaim.d.ts +24 -0
  161. package/dist/fhe-airdrop/react/useEcdsaClaimAndUnwrap.d.ts +27 -0
  162. package/dist/fhe-airdrop/react/useEcdsaDomain.d.ts +41 -0
  163. package/dist/fhe-airdrop/react/useEffectiveDelegateToCompliance.d.ts +26 -0
  164. package/dist/fhe-airdrop/react/useEffectiveUpgradeable.d.ts +20 -0
  165. package/dist/fhe-airdrop/react/useEncryptCampaignAmounts.d.ts +59 -0
  166. package/dist/fhe-airdrop/react/useExtendClaimWindow.d.ts +17 -12
  167. package/dist/fhe-airdrop/react/useFactoryFees.d.ts +28 -0
  168. package/dist/fhe-airdrop/react/useFactoryRegistry.d.ts +35 -0
  169. package/dist/fhe-airdrop/react/useFundAirdrop.d.ts +35 -0
  170. package/dist/fhe-airdrop/react/useGrantInstanceRoles.d.ts +35 -0
  171. package/dist/fhe-airdrop/react/useIsActiveDelegate.d.ts +29 -0
  172. package/dist/fhe-airdrop/react/useIsMerkleRootMutable.d.ts +21 -0
  173. package/dist/fhe-airdrop/react/useIsSignatureValid.d.ts +46 -0
  174. package/dist/fhe-airdrop/react/useMerkleClaim.d.ts +22 -0
  175. package/dist/fhe-airdrop/react/useMerkleClaimAndUnwrap.d.ts +29 -0
  176. package/dist/fhe-airdrop/react/useMerkleRoot.d.ts +15 -0
  177. package/dist/fhe-airdrop/react/usePlanMerkleCampaign.d.ts +53 -0
  178. package/dist/fhe-airdrop/react/usePreflightClaim.d.ts +46 -0
  179. package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +51 -35
  180. package/dist/fhe-airdrop/react/useRescueERC20.d.ts +30 -0
  181. package/dist/fhe-airdrop/react/useRescueOtherConfidentialToken.d.ts +34 -0
  182. package/dist/fhe-airdrop/react/useRevokeComplianceDelegate.d.ts +37 -0
  183. package/dist/fhe-airdrop/react/useRotateMerkleRoot.d.ts +52 -0
  184. package/dist/fhe-airdrop/react/useSetMerkleRoot.d.ts +22 -0
  185. package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +32 -21
  186. package/dist/fhe-airdrop/react/useWithdrawConfidential.d.ts +23 -0
  187. package/dist/fhe-airdrop/react/useWithdrawGasFee.d.ts +37 -0
  188. package/dist/fhe-airdrop/roles.d.ts +147 -0
  189. package/dist/fhe-airdrop/types.d.ts +78 -63
  190. package/dist/fhe-disperse/index.cjs +70 -68
  191. package/dist/fhe-disperse/index.js +10 -8
  192. package/dist/fhe-disperse/react/index.cjs +94 -92
  193. package/dist/fhe-disperse/react/index.js +13 -11
  194. package/dist/fhe-vesting/advanced/index.cjs +10 -8
  195. package/dist/fhe-vesting/advanced/index.js +8 -6
  196. package/dist/fhe-vesting/advanced/react/index.cjs +16 -14
  197. package/dist/fhe-vesting/advanced/react/index.js +13 -11
  198. package/dist/fhe-vesting/index.cjs +74 -72
  199. package/dist/fhe-vesting/index.js +11 -9
  200. package/dist/fhe-vesting/react/index.cjs +228 -226
  201. package/dist/fhe-vesting/react/index.js +15 -13
  202. package/dist/index.cjs +100 -87
  203. package/dist/index.js +3 -2
  204. package/dist/testnet-faucet/index.cjs +57 -55
  205. package/dist/testnet-faucet/index.js +7 -5
  206. package/dist/testnet-faucet/react/index.cjs +55 -53
  207. package/dist/testnet-faucet/react/index.js +9 -7
  208. package/package.json +6 -2
  209. package/dist/chunk-CNP4L3GF.js +0 -105
  210. package/dist/chunk-KSDSXJ34.js +0 -41
  211. package/dist/chunk-LBWRFZR3.cjs +0 -1681
  212. package/dist/chunk-OL6SHN3D.cjs +0 -44
  213. package/dist/chunk-S2XD75JM.js +0 -1637
  214. package/dist/chunk-SPGSO5SO.cjs +0 -1644
  215. package/dist/chunk-UE5XK2SY.js +0 -1673
  216. package/dist/chunk-WO72UBQD.cjs +0 -109
  217. package/dist/fhe-airdrop/advanced/factory-advanced.d.ts +0 -53
  218. package/dist/fhe-airdrop/advanced/react/usePredictAirdropAddress.d.ts +0 -49
  219. package/dist/fhe-airdrop/airdrop.d.ts +0 -317
  220. package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +0 -37
  221. package/dist/fhe-airdrop/react/useAirdropCanExtendClaimWindow.d.ts +0 -7
  222. package/dist/fhe-airdrop/react/useAirdropClaimTypehash.d.ts +0 -10
  223. package/dist/fhe-airdrop/react/useAirdropClaimedSignatures.d.ts +0 -16
  224. package/dist/fhe-airdrop/react/useAirdropDeploymentBlockNumber.d.ts +0 -6
  225. package/dist/fhe-airdrop/react/useAirdropDomainSeparator.d.ts +0 -8
  226. package/dist/fhe-airdrop/react/useAirdropEndTime.d.ts +0 -10
  227. package/dist/fhe-airdrop/react/useAirdropFactoryCustomFee.d.ts +0 -17
  228. package/dist/fhe-airdrop/react/useAirdropFactoryDefaultGasFee.d.ts +0 -10
  229. package/dist/fhe-airdrop/react/useAirdropFactoryDisableCustomFee.d.ts +0 -15
  230. package/dist/fhe-airdrop/react/useAirdropFactoryFeeCollector.d.ts +0 -11
  231. package/dist/fhe-airdrop/react/useAirdropFactoryInitCodeHash.d.ts +0 -17
  232. package/dist/fhe-airdrop/react/useAirdropFactorySetCustomFee.d.ts +0 -17
  233. package/dist/fhe-airdrop/react/useAirdropFactorySetDefaultGasFee.d.ts +0 -16
  234. package/dist/fhe-airdrop/react/useAirdropFactorySetFeeCollector.d.ts +0 -15
  235. package/dist/fhe-airdrop/react/useAirdropHasClaimEnded.d.ts +0 -7
  236. package/dist/fhe-airdrop/react/useAirdropHasClaimStarted.d.ts +0 -7
  237. package/dist/fhe-airdrop/react/useAirdropIsClaimWindowActive.d.ts +0 -9
  238. package/dist/fhe-airdrop/react/useAirdropIsPaused.d.ts +0 -8
  239. package/dist/fhe-airdrop/react/useAirdropIsSignatureClaimed.d.ts +0 -22
  240. package/dist/fhe-airdrop/react/useAirdropIsSignatureValid.d.ts +0 -51
  241. package/dist/fhe-airdrop/react/useAirdropStartTime.d.ts +0 -10
  242. package/dist/fhe-airdrop/react/useAirdropWithdrawGasFee.d.ts +0 -15
  243. package/dist/fhe-airdrop/react/useAirdropWithdrawOtherConfidentialToken.d.ts +0 -14
  244. package/dist/fhe-airdrop/react/useAirdropWithdrawOtherToken.d.ts +0 -14
  245. package/dist/fhe-airdrop/react/useClaim.d.ts +0 -39
  246. package/dist/fhe-airdrop/react/useConfidentialAirdropFactoryImplementation.d.ts +0 -11
  247. package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +0 -41
  248. package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +0 -48
  249. package/dist/fhe-airdrop/react/useCreateConfidentialAirdrop.d.ts +0 -29
  250. package/dist/fhe-airdrop/react/useCreateConfidentialAirdropAndGetAddress.d.ts +0 -31
  251. package/dist/fhe-airdrop/react/useDisableCustomFee.d.ts +0 -14
  252. package/dist/fhe-airdrop/react/useFactoryCustomFee.d.ts +0 -17
  253. package/dist/fhe-airdrop/react/useFactoryDefaultGasFee.d.ts +0 -10
  254. package/dist/fhe-airdrop/react/useFactoryFeeCollector.d.ts +0 -11
  255. package/dist/fhe-airdrop/react/useFactoryInitCodeHash.d.ts +0 -17
  256. package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +0 -33
  257. package/dist/fhe-airdrop/react/useSetCustomFee.d.ts +0 -16
  258. package/dist/fhe-airdrop/react/useSetDefaultGasFee.d.ts +0 -15
  259. package/dist/fhe-airdrop/react/useSetFeeCollector.d.ts +0 -14
  260. package/dist/fhe-airdrop/react/useSetPaused.d.ts +0 -14
  261. package/dist/fhe-airdrop/react/useWithdraw.d.ts +0 -12
  262. package/dist/fhe-airdrop/react/useWithdrawOtherConfidentialToken.d.ts +0 -13
  263. package/dist/fhe-airdrop/react/useWithdrawOtherToken.d.ts +0 -13
@@ -1,1673 +0,0 @@
1
- import { erc7984OperatorAbi } from './chunk-7VELUOMI.js';
2
- import { SDK_VERSION, mapContractRevert, isContractRevert } from './chunk-6WSNS3UV.js';
3
- import { getFheAirdropFactoryAddress } from './chunk-QKKBBH7I.js';
4
- import { normaliseAddress } from './chunk-46T67CE2.js';
5
- import { InvalidArgumentError, asExternalInputProof, asEncryptedHandle, TokenOpsSdkError, MissingAccountError, asSignature, DeploymentAddressUnavailableError, OperatorNotApprovedError, AlreadyInitializedError, asTxHash, MissingWalletClientError, MissingEncryptorError } from './chunk-DRSPMIZ7.js';
6
- import { withTelemetry } from './chunk-Q2GP5UDC.js';
7
- import { bytesToHex, isAddress, parseEventLogs, BaseError, ContractFunctionZeroDataError } from 'viem';
8
-
9
- // src/fhe-airdrop/abis/factory.ts
10
- var confidentialAirdropFactoryAbi = [
11
- {
12
- inputs: [
13
- {
14
- internalType: "address",
15
- name: "implementation_",
16
- type: "address"
17
- },
18
- {
19
- internalType: "address",
20
- name: "feeCollector_",
21
- type: "address"
22
- },
23
- {
24
- internalType: "uint256",
25
- name: "defaultGasFee_",
26
- type: "uint256"
27
- },
28
- {
29
- internalType: "address",
30
- name: "admin",
31
- type: "address"
32
- }
33
- ],
34
- stateMutability: "nonpayable",
35
- type: "constructor"
36
- },
37
- {
38
- inputs: [],
39
- name: "AccessControlBadConfirmation",
40
- type: "error"
41
- },
42
- {
43
- inputs: [
44
- {
45
- internalType: "address",
46
- name: "account",
47
- type: "address"
48
- },
49
- {
50
- internalType: "bytes32",
51
- name: "neededRole",
52
- type: "bytes32"
53
- }
54
- ],
55
- name: "AccessControlUnauthorizedAccount",
56
- type: "error"
57
- },
58
- {
59
- inputs: [],
60
- name: "EndTimeInPast",
61
- type: "error"
62
- },
63
- {
64
- inputs: [],
65
- name: "InvalidAddress",
66
- type: "error"
67
- },
68
- {
69
- inputs: [],
70
- name: "InvalidDuration",
71
- type: "error"
72
- },
73
- {
74
- inputs: [],
75
- name: "InvalidStartTime",
76
- type: "error"
77
- },
78
- {
79
- inputs: [
80
- {
81
- internalType: "bytes32",
82
- name: "handle",
83
- type: "bytes32"
84
- },
85
- {
86
- internalType: "address",
87
- name: "sender",
88
- type: "address"
89
- }
90
- ],
91
- name: "SenderNotAllowedToUseHandle",
92
- type: "error"
93
- },
94
- {
95
- inputs: [
96
- {
97
- internalType: "address",
98
- name: "sender",
99
- type: "address"
100
- }
101
- ],
102
- name: "SenderNotAllowed",
103
- type: "error"
104
- },
105
- {
106
- inputs: [],
107
- name: "ZamaProtocolUnsupported",
108
- type: "error"
109
- },
110
- {
111
- anonymous: false,
112
- inputs: [
113
- {
114
- indexed: true,
115
- internalType: "address",
116
- name: "airdrop",
117
- type: "address"
118
- },
119
- {
120
- indexed: true,
121
- internalType: "address",
122
- name: "token",
123
- type: "address"
124
- },
125
- {
126
- indexed: true,
127
- internalType: "address",
128
- name: "admin",
129
- type: "address"
130
- },
131
- {
132
- indexed: false,
133
- internalType: "address",
134
- name: "feeCollector",
135
- type: "address"
136
- },
137
- {
138
- indexed: false,
139
- internalType: "uint256",
140
- name: "gasFee",
141
- type: "uint256"
142
- },
143
- {
144
- indexed: false,
145
- internalType: "uint32",
146
- name: "startTime",
147
- type: "uint32"
148
- },
149
- {
150
- indexed: false,
151
- internalType: "uint32",
152
- name: "endTime",
153
- type: "uint32"
154
- },
155
- {
156
- indexed: false,
157
- internalType: "bool",
158
- name: "canExtendClaimWindow",
159
- type: "bool"
160
- },
161
- {
162
- indexed: false,
163
- internalType: "address",
164
- name: "creator",
165
- type: "address"
166
- },
167
- {
168
- indexed: false,
169
- internalType: "bytes32",
170
- name: "userSalt",
171
- type: "bytes32"
172
- }
173
- ],
174
- name: "ConfidentialAirdropCreated",
175
- type: "event"
176
- },
177
- {
178
- anonymous: false,
179
- inputs: [
180
- {
181
- indexed: true,
182
- internalType: "address",
183
- name: "airdrop",
184
- type: "address"
185
- },
186
- {
187
- indexed: true,
188
- internalType: "address",
189
- name: "token",
190
- type: "address"
191
- },
192
- {
193
- indexed: false,
194
- internalType: "euint64",
195
- name: "transferredAmount",
196
- type: "bytes32"
197
- }
198
- ],
199
- name: "ConfidentialAirdropFunded",
200
- type: "event"
201
- },
202
- {
203
- anonymous: false,
204
- inputs: [
205
- {
206
- indexed: true,
207
- internalType: "address",
208
- name: "admin",
209
- type: "address"
210
- },
211
- {
212
- indexed: true,
213
- internalType: "address",
214
- name: "newFeeCollector",
215
- type: "address"
216
- }
217
- ],
218
- name: "FeeCollectorSet",
219
- type: "event"
220
- },
221
- {
222
- anonymous: false,
223
- inputs: [
224
- {
225
- indexed: true,
226
- internalType: "bytes32",
227
- name: "role",
228
- type: "bytes32"
229
- },
230
- {
231
- indexed: true,
232
- internalType: "bytes32",
233
- name: "previousAdminRole",
234
- type: "bytes32"
235
- },
236
- {
237
- indexed: true,
238
- internalType: "bytes32",
239
- name: "newAdminRole",
240
- type: "bytes32"
241
- }
242
- ],
243
- name: "RoleAdminChanged",
244
- type: "event"
245
- },
246
- {
247
- anonymous: false,
248
- inputs: [
249
- {
250
- indexed: true,
251
- internalType: "bytes32",
252
- name: "role",
253
- type: "bytes32"
254
- },
255
- {
256
- indexed: true,
257
- internalType: "address",
258
- name: "account",
259
- type: "address"
260
- },
261
- {
262
- indexed: true,
263
- internalType: "address",
264
- name: "sender",
265
- type: "address"
266
- }
267
- ],
268
- name: "RoleGranted",
269
- type: "event"
270
- },
271
- {
272
- anonymous: false,
273
- inputs: [
274
- {
275
- indexed: true,
276
- internalType: "bytes32",
277
- name: "role",
278
- type: "bytes32"
279
- },
280
- {
281
- indexed: true,
282
- internalType: "address",
283
- name: "account",
284
- type: "address"
285
- },
286
- {
287
- indexed: true,
288
- internalType: "address",
289
- name: "sender",
290
- type: "address"
291
- }
292
- ],
293
- name: "RoleRevoked",
294
- type: "event"
295
- },
296
- {
297
- anonymous: false,
298
- inputs: [
299
- {
300
- indexed: true,
301
- internalType: "address",
302
- name: "admin",
303
- type: "address"
304
- },
305
- {
306
- indexed: false,
307
- internalType: "bool",
308
- name: "enabled",
309
- type: "bool"
310
- },
311
- {
312
- indexed: true,
313
- internalType: "address",
314
- name: "campaignCreator",
315
- type: "address"
316
- },
317
- {
318
- indexed: false,
319
- internalType: "uint256",
320
- name: "gasFee",
321
- type: "uint256"
322
- }
323
- ],
324
- name: "SetCustomFee",
325
- type: "event"
326
- },
327
- {
328
- anonymous: false,
329
- inputs: [
330
- {
331
- indexed: true,
332
- internalType: "address",
333
- name: "admin",
334
- type: "address"
335
- },
336
- {
337
- indexed: false,
338
- internalType: "uint256",
339
- name: "oldGasFee",
340
- type: "uint256"
341
- },
342
- {
343
- indexed: false,
344
- internalType: "uint256",
345
- name: "newGasFee",
346
- type: "uint256"
347
- }
348
- ],
349
- name: "SetDefaultGasFee",
350
- type: "event"
351
- },
352
- {
353
- inputs: [],
354
- name: "DEFAULT_ADMIN_ROLE",
355
- outputs: [
356
- {
357
- internalType: "bytes32",
358
- name: "",
359
- type: "bytes32"
360
- }
361
- ],
362
- stateMutability: "view",
363
- type: "function"
364
- },
365
- {
366
- inputs: [],
367
- name: "FEE_MANAGER_ROLE",
368
- outputs: [
369
- {
370
- internalType: "bytes32",
371
- name: "",
372
- type: "bytes32"
373
- }
374
- ],
375
- stateMutability: "view",
376
- type: "function"
377
- },
378
- {
379
- inputs: [],
380
- name: "confidentialProtocolId",
381
- outputs: [
382
- {
383
- internalType: "uint256",
384
- name: "",
385
- type: "uint256"
386
- }
387
- ],
388
- stateMutability: "view",
389
- type: "function"
390
- },
391
- {
392
- inputs: [
393
- {
394
- components: [
395
- {
396
- internalType: "address",
397
- name: "token",
398
- type: "address"
399
- },
400
- {
401
- internalType: "uint32",
402
- name: "startTime",
403
- type: "uint32"
404
- },
405
- {
406
- internalType: "uint32",
407
- name: "endTime",
408
- type: "uint32"
409
- },
410
- {
411
- internalType: "bool",
412
- name: "canExtendClaimWindow",
413
- type: "bool"
414
- },
415
- {
416
- internalType: "address",
417
- name: "admin",
418
- type: "address"
419
- }
420
- ],
421
- internalType: "struct IConfidentialAirdropFactory.AirdropParams",
422
- name: "params",
423
- type: "tuple"
424
- },
425
- {
426
- internalType: "bytes32",
427
- name: "userSalt",
428
- type: "bytes32"
429
- },
430
- {
431
- internalType: "externalEuint64",
432
- name: "encryptedAmount",
433
- type: "bytes32"
434
- },
435
- {
436
- internalType: "bytes",
437
- name: "inputProof",
438
- type: "bytes"
439
- }
440
- ],
441
- name: "createAndFundConfidentialAirdrop",
442
- outputs: [
443
- {
444
- internalType: "address",
445
- name: "airdrop",
446
- type: "address"
447
- }
448
- ],
449
- stateMutability: "nonpayable",
450
- type: "function"
451
- },
452
- {
453
- inputs: [
454
- {
455
- components: [
456
- {
457
- internalType: "address",
458
- name: "token",
459
- type: "address"
460
- },
461
- {
462
- internalType: "uint32",
463
- name: "startTime",
464
- type: "uint32"
465
- },
466
- {
467
- internalType: "uint32",
468
- name: "endTime",
469
- type: "uint32"
470
- },
471
- {
472
- internalType: "bool",
473
- name: "canExtendClaimWindow",
474
- type: "bool"
475
- },
476
- {
477
- internalType: "address",
478
- name: "admin",
479
- type: "address"
480
- }
481
- ],
482
- internalType: "struct IConfidentialAirdropFactory.AirdropParams",
483
- name: "params",
484
- type: "tuple"
485
- },
486
- {
487
- internalType: "bytes32",
488
- name: "userSalt",
489
- type: "bytes32"
490
- }
491
- ],
492
- name: "createConfidentialAirdrop",
493
- outputs: [
494
- {
495
- internalType: "address",
496
- name: "airdrop",
497
- type: "address"
498
- }
499
- ],
500
- stateMutability: "nonpayable",
501
- type: "function"
502
- },
503
- {
504
- inputs: [],
505
- name: "defaultGasFee",
506
- outputs: [
507
- {
508
- internalType: "uint256",
509
- name: "",
510
- type: "uint256"
511
- }
512
- ],
513
- stateMutability: "view",
514
- type: "function"
515
- },
516
- {
517
- inputs: [
518
- {
519
- internalType: "address",
520
- name: "campaignCreator",
521
- type: "address"
522
- }
523
- ],
524
- name: "disableCustomFee",
525
- outputs: [],
526
- stateMutability: "nonpayable",
527
- type: "function"
528
- },
529
- {
530
- inputs: [],
531
- name: "feeCollector",
532
- outputs: [
533
- {
534
- internalType: "address",
535
- name: "",
536
- type: "address"
537
- }
538
- ],
539
- stateMutability: "view",
540
- type: "function"
541
- },
542
- {
543
- inputs: [
544
- {
545
- internalType: "address",
546
- name: "token",
547
- type: "address"
548
- },
549
- {
550
- components: [
551
- {
552
- internalType: "address",
553
- name: "token",
554
- type: "address"
555
- },
556
- {
557
- internalType: "uint32",
558
- name: "startTime",
559
- type: "uint32"
560
- },
561
- {
562
- internalType: "uint32",
563
- name: "endTime",
564
- type: "uint32"
565
- },
566
- {
567
- internalType: "bool",
568
- name: "canExtendClaimWindow",
569
- type: "bool"
570
- },
571
- {
572
- internalType: "address",
573
- name: "admin",
574
- type: "address"
575
- }
576
- ],
577
- internalType: "struct IConfidentialAirdropFactory.AirdropParams",
578
- name: "params",
579
- type: "tuple"
580
- },
581
- {
582
- internalType: "bytes32",
583
- name: "userSalt",
584
- type: "bytes32"
585
- },
586
- {
587
- internalType: "address",
588
- name: "deployer",
589
- type: "address"
590
- },
591
- {
592
- internalType: "uint256",
593
- name: "gasFee",
594
- type: "uint256"
595
- },
596
- {
597
- internalType: "externalEuint64",
598
- name: "encryptedAmount",
599
- type: "bytes32"
600
- },
601
- {
602
- internalType: "bytes",
603
- name: "inputProof",
604
- type: "bytes"
605
- }
606
- ],
607
- name: "fundConfidentialAirdrop",
608
- outputs: [],
609
- stateMutability: "nonpayable",
610
- type: "function"
611
- },
612
- {
613
- inputs: [
614
- {
615
- internalType: "address",
616
- name: "campaignCreator",
617
- type: "address"
618
- }
619
- ],
620
- name: "getCustomFee",
621
- outputs: [
622
- {
623
- components: [
624
- {
625
- internalType: "bool",
626
- name: "enabled",
627
- type: "bool"
628
- },
629
- {
630
- internalType: "uint256",
631
- name: "gasFee",
632
- type: "uint256"
633
- }
634
- ],
635
- internalType: "struct IConfidentialAirdropFactory.CustomFee",
636
- name: "",
637
- type: "tuple"
638
- }
639
- ],
640
- stateMutability: "view",
641
- type: "function"
642
- },
643
- {
644
- inputs: [
645
- {
646
- components: [
647
- {
648
- internalType: "address",
649
- name: "token",
650
- type: "address"
651
- },
652
- {
653
- internalType: "uint32",
654
- name: "startTime",
655
- type: "uint32"
656
- },
657
- {
658
- internalType: "uint32",
659
- name: "endTime",
660
- type: "uint32"
661
- },
662
- {
663
- internalType: "bool",
664
- name: "canExtendClaimWindow",
665
- type: "bool"
666
- },
667
- {
668
- internalType: "address",
669
- name: "admin",
670
- type: "address"
671
- }
672
- ],
673
- internalType: "struct IConfidentialAirdropFactory.AirdropParams",
674
- name: "params",
675
- type: "tuple"
676
- },
677
- {
678
- internalType: "uint256",
679
- name: "gasFee",
680
- type: "uint256"
681
- }
682
- ],
683
- name: "getInitCodeHash",
684
- outputs: [
685
- {
686
- internalType: "bytes32",
687
- name: "hash",
688
- type: "bytes32"
689
- }
690
- ],
691
- stateMutability: "view",
692
- type: "function"
693
- },
694
- {
695
- inputs: [
696
- {
697
- internalType: "bytes32",
698
- name: "role",
699
- type: "bytes32"
700
- }
701
- ],
702
- name: "getRoleAdmin",
703
- outputs: [
704
- {
705
- internalType: "bytes32",
706
- name: "",
707
- type: "bytes32"
708
- }
709
- ],
710
- stateMutability: "view",
711
- type: "function"
712
- },
713
- {
714
- inputs: [
715
- {
716
- internalType: "bytes32",
717
- name: "role",
718
- type: "bytes32"
719
- },
720
- {
721
- internalType: "address",
722
- name: "account",
723
- type: "address"
724
- }
725
- ],
726
- name: "grantRole",
727
- outputs: [],
728
- stateMutability: "nonpayable",
729
- type: "function"
730
- },
731
- {
732
- inputs: [
733
- {
734
- internalType: "bytes32",
735
- name: "role",
736
- type: "bytes32"
737
- },
738
- {
739
- internalType: "address",
740
- name: "account",
741
- type: "address"
742
- }
743
- ],
744
- name: "hasRole",
745
- outputs: [
746
- {
747
- internalType: "bool",
748
- name: "",
749
- type: "bool"
750
- }
751
- ],
752
- stateMutability: "view",
753
- type: "function"
754
- },
755
- {
756
- inputs: [],
757
- name: "implementation",
758
- outputs: [
759
- {
760
- internalType: "address",
761
- name: "",
762
- type: "address"
763
- }
764
- ],
765
- stateMutability: "view",
766
- type: "function"
767
- },
768
- {
769
- inputs: [
770
- {
771
- components: [
772
- {
773
- internalType: "address",
774
- name: "token",
775
- type: "address"
776
- },
777
- {
778
- internalType: "uint32",
779
- name: "startTime",
780
- type: "uint32"
781
- },
782
- {
783
- internalType: "uint32",
784
- name: "endTime",
785
- type: "uint32"
786
- },
787
- {
788
- internalType: "bool",
789
- name: "canExtendClaimWindow",
790
- type: "bool"
791
- },
792
- {
793
- internalType: "address",
794
- name: "admin",
795
- type: "address"
796
- }
797
- ],
798
- internalType: "struct IConfidentialAirdropFactory.AirdropParams",
799
- name: "params",
800
- type: "tuple"
801
- },
802
- {
803
- internalType: "bytes32",
804
- name: "userSalt",
805
- type: "bytes32"
806
- },
807
- {
808
- internalType: "address",
809
- name: "deployer",
810
- type: "address"
811
- },
812
- {
813
- internalType: "uint256",
814
- name: "gasFee",
815
- type: "uint256"
816
- }
817
- ],
818
- name: "predictAirdropAddress",
819
- outputs: [
820
- {
821
- internalType: "address",
822
- name: "predicted",
823
- type: "address"
824
- }
825
- ],
826
- stateMutability: "view",
827
- type: "function"
828
- },
829
- {
830
- inputs: [
831
- {
832
- internalType: "bytes32",
833
- name: "role",
834
- type: "bytes32"
835
- },
836
- {
837
- internalType: "address",
838
- name: "callerConfirmation",
839
- type: "address"
840
- }
841
- ],
842
- name: "renounceRole",
843
- outputs: [],
844
- stateMutability: "nonpayable",
845
- type: "function"
846
- },
847
- {
848
- inputs: [
849
- {
850
- internalType: "bytes32",
851
- name: "role",
852
- type: "bytes32"
853
- },
854
- {
855
- internalType: "address",
856
- name: "account",
857
- type: "address"
858
- }
859
- ],
860
- name: "revokeRole",
861
- outputs: [],
862
- stateMutability: "nonpayable",
863
- type: "function"
864
- },
865
- {
866
- inputs: [
867
- {
868
- internalType: "address",
869
- name: "campaignCreator",
870
- type: "address"
871
- },
872
- {
873
- internalType: "uint256",
874
- name: "gasFee",
875
- type: "uint256"
876
- }
877
- ],
878
- name: "setCustomFee",
879
- outputs: [],
880
- stateMutability: "nonpayable",
881
- type: "function"
882
- },
883
- {
884
- inputs: [
885
- {
886
- internalType: "uint256",
887
- name: "newGasFee",
888
- type: "uint256"
889
- }
890
- ],
891
- name: "setDefaultGasFee",
892
- outputs: [],
893
- stateMutability: "nonpayable",
894
- type: "function"
895
- },
896
- {
897
- inputs: [
898
- {
899
- internalType: "address",
900
- name: "newFeeCollector",
901
- type: "address"
902
- }
903
- ],
904
- name: "setFeeCollector",
905
- outputs: [],
906
- stateMutability: "nonpayable",
907
- type: "function"
908
- },
909
- {
910
- inputs: [
911
- {
912
- internalType: "bytes4",
913
- name: "interfaceId",
914
- type: "bytes4"
915
- }
916
- ],
917
- name: "supportsInterface",
918
- outputs: [
919
- {
920
- internalType: "bool",
921
- name: "",
922
- type: "bool"
923
- }
924
- ],
925
- stateMutability: "view",
926
- type: "function"
927
- }
928
- ];
929
- function resolveEncryptor(source) {
930
- if (source === void 0) return void 0;
931
- return typeof source === "function" ? source() : source;
932
- }
933
- var MAX_UINT64 = (1n << 64n) - 1n;
934
- function assertUint64(value, label) {
935
- if (value < 0n || value > MAX_UINT64) {
936
- throw new InvalidArgumentError({
937
- method: "encryptUint64",
938
- argument: label,
939
- reason: "exceeds uint64 range (0..2^64-1)",
940
- value
941
- });
942
- }
943
- }
944
- async function encryptUint64({
945
- encryptor,
946
- contractAddress,
947
- userAddress,
948
- value
949
- }) {
950
- assertUint64(value, "value");
951
- const { handles, inputProof } = await encryptor.encrypt({
952
- values: [{ value, type: "euint64" }],
953
- contractAddress,
954
- userAddress
955
- });
956
- if (handles.length !== 1) {
957
- throw new InvalidArgumentError({
958
- method: "encryptUint64",
959
- argument: "handles",
960
- reason: `expected 1 handle, got ${handles.length}`,
961
- value: handles.length
962
- });
963
- }
964
- return {
965
- handle: asEncryptedHandle(bytesToHex(handles[0])),
966
- inputProof: asExternalInputProof(bytesToHex(inputProof))
967
- };
968
- }
969
- async function encryptUint64Batch({
970
- encryptor,
971
- contractAddress,
972
- userAddress,
973
- values
974
- }) {
975
- if (values.length === 0) {
976
- throw new InvalidArgumentError({
977
- method: "encryptUint64Batch",
978
- argument: "values",
979
- reason: "must be non-empty"
980
- });
981
- }
982
- values.forEach((v, i) => assertUint64(v, `values[${i}]`));
983
- const { handles, inputProof } = await encryptor.encrypt({
984
- values: values.map((value) => ({ value, type: "euint64" })),
985
- contractAddress,
986
- userAddress
987
- });
988
- if (handles.length !== values.length) {
989
- throw new InvalidArgumentError({
990
- method: "encryptUint64Batch",
991
- argument: "handles",
992
- reason: `expected ${values.length} handles, got ${handles.length}`,
993
- value: handles.length
994
- });
995
- }
996
- return {
997
- handles: handles.map((h) => asEncryptedHandle(bytesToHex(h))),
998
- inputProof: asExternalInputProof(bytesToHex(inputProof))
999
- };
1000
- }
1001
- async function signClaimAuthorization(args) {
1002
- if (args.encryptedAmountHandle.length !== 66) {
1003
- throw new TokenOpsSdkError(
1004
- `signClaimAuthorization: encryptedAmountHandle must be a 32-byte hex string (0x + 64 chars), got length ${args.encryptedAmountHandle.length}`
1005
- );
1006
- }
1007
- const account = args.walletClient.account;
1008
- if (!account) {
1009
- throw new MissingAccountError("signClaimAuthorization");
1010
- }
1011
- const chainId = args.walletClient.chain?.id;
1012
- if (!chainId) {
1013
- throw new InvalidArgumentError({
1014
- method: "signClaimAuthorization",
1015
- argument: "walletClient.chain.id",
1016
- reason: "required for EIP712 chainId binding; pass a walletClient constructed with a known chain (e.g. `createWalletClient({ chain: sepolia, ... })`)."
1017
- });
1018
- }
1019
- const sig = await args.walletClient.signTypedData({
1020
- account,
1021
- domain: {
1022
- name: "ConfidentialAirdrop",
1023
- version: "1",
1024
- chainId,
1025
- verifyingContract: args.airdropAddress
1026
- },
1027
- types: {
1028
- Claim: [
1029
- { name: "recipient", type: "address" },
1030
- { name: "encryptedAmount", type: "bytes32" }
1031
- ]
1032
- },
1033
- primaryType: "Claim",
1034
- message: {
1035
- recipient: args.recipient,
1036
- encryptedAmount: args.encryptedAmountHandle
1037
- }
1038
- });
1039
- return asSignature(sig);
1040
- }
1041
- var airdropFactoryProductMapper = () => void 0;
1042
- var ConfidentialAirdropFactoryClient = class {
1043
- publicClient;
1044
- walletClient;
1045
- address;
1046
- encryptor;
1047
- #telemetry;
1048
- constructor(config) {
1049
- this.publicClient = config.publicClient;
1050
- this.walletClient = config.walletClient;
1051
- this.encryptor = config.encryptor;
1052
- const chainId = config.chainId ?? config.publicClient.chain?.id;
1053
- const addressOverride = config.address ? normaliseAddress(config.address) : void 0;
1054
- const resolved = addressOverride ?? (chainId === void 0 ? void 0 : getFheAirdropFactoryAddress(chainId));
1055
- if (!resolved) {
1056
- throw new DeploymentAddressUnavailableError({
1057
- reason: chainId === void 0 ? "chain-id-missing" : "registry-not-deployed",
1058
- product: "fheAirdrop",
1059
- contract: "confidentialAirdropFactory",
1060
- chainId,
1061
- clientLabel: "ConfidentialAirdropFactoryClient"
1062
- });
1063
- }
1064
- this.address = resolved;
1065
- this.#telemetry = config.telemetry;
1066
- this.#telemetry?.event("fhe-airdrop.client.init", {
1067
- surface: "factory",
1068
- chainId: chainId ?? null,
1069
- hasWallet: !!this.walletClient,
1070
- aclResolved: true,
1071
- // factory has no ACL dependency; constant for funnel-shape parity with client.
1072
- sdkVersion: SDK_VERSION
1073
- });
1074
- }
1075
- // ----------------------- writes -----------------------
1076
- /**
1077
- * Deploy a new airdrop clone via the factory and return its address, parsed
1078
- * from the `ConfidentialAirdropCreated` event in the tx receipt.
1079
- *
1080
- * **This is the headline factory entry point.** It returns one rich-return
1081
- * shape: most consumers want the deployed address back, and the SDK already
1082
- * waits for and parses the event, so there's no reason to make consumers do
1083
- * it themselves.
1084
- *
1085
- * Internally: `writeContract` → {@link PublicClient.waitForTransactionReceipt} →
1086
- * `parseEventLogs({ eventName: "ConfidentialAirdropCreated" })`.
1087
- *
1088
- * For genuine pre-mine prediction (rare), import
1089
- * `ConfidentialAirdropFactoryAdvancedClient` from
1090
- * `@tokenops/sdk/fhe-airdrop/advanced` and call `predictAirdropAddress`.
1091
- *
1092
- * @example
1093
- * const { hash, airdrop } = await factory.createConfidentialAirdrop({
1094
- * params, userSalt,
1095
- * });
1096
- */
1097
- async createConfidentialAirdrop(args) {
1098
- return withTelemetry(
1099
- this.#telemetry,
1100
- "fhe-airdrop.factory.createConfidentialAirdrop",
1101
- async () => {
1102
- const hash = await this.#write(
1103
- "createConfidentialAirdrop",
1104
- [toAbiParams(args.params), args.userSalt],
1105
- args.account
1106
- );
1107
- return this.#resolveAirdropFromReceipt(hash, "createConfidentialAirdrop");
1108
- }
1109
- );
1110
- }
1111
- /**
1112
- * Deploy and fund a new airdrop in a single transaction, and return its
1113
- * address. The SDK encrypts `amount` into an `externalEuint64` before
1114
- * passing to the contract.
1115
- *
1116
- * Prerequisites: caller must have set this factory as an operator on the
1117
- * token: `token.setOperator(factoryAddress, deadline)`.
1118
- *
1119
- * **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.
1120
- *
1121
- * **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
1122
- * convention (1 token = 1_000_000 base units), not the 18 decimals typical of
1123
- * ERC-20. Amount parameters are base units of the token's actual decimals:
1124
- * for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
1125
- * transparent TTT test token uses 18 decimals.
1126
- *
1127
- * Symmetric with {@link ConfidentialAirdropFactoryClient.createConfidentialAirdrop}
1128
- * — both return `{ hash, airdrop }` parsed from the
1129
- * `ConfidentialAirdropCreated` event.
1130
- *
1131
- * @example
1132
- * const { hash, airdrop } = await factory.createAndFundConfidentialAirdrop({
1133
- * params, userSalt, amount: 1_000_000n,
1134
- * });
1135
- */
1136
- async createAndFundConfidentialAirdrop(args) {
1137
- return withTelemetry(
1138
- this.#telemetry,
1139
- "fhe-airdrop.factory.createAndFundConfidentialAirdrop",
1140
- async () => {
1141
- const wallet = this.#requireWallet("createAndFundConfidentialAirdrop");
1142
- const account = this.#resolveAccount(
1143
- wallet,
1144
- args.account,
1145
- "createAndFundConfidentialAirdrop"
1146
- );
1147
- const encrypted = await this.#encryptAmount(
1148
- args.amount,
1149
- args.encryptor,
1150
- args.encryptedInput,
1151
- account,
1152
- "createAndFundConfidentialAirdrop"
1153
- );
1154
- const writeArgs = [
1155
- toAbiParams(args.params),
1156
- args.userSalt,
1157
- encrypted.handle,
1158
- encrypted.inputProof
1159
- ];
1160
- await this.#preflightWrite(
1161
- "createAndFundConfidentialAirdrop",
1162
- "createAndFundConfidentialAirdrop",
1163
- writeArgs,
1164
- account
1165
- );
1166
- let hash;
1167
- try {
1168
- hash = await wallet.writeContract({
1169
- address: this.address,
1170
- abi: confidentialAirdropFactoryAbi,
1171
- functionName: "createAndFundConfidentialAirdrop",
1172
- args: writeArgs,
1173
- account,
1174
- chain: wallet.chain
1175
- });
1176
- } catch (err) {
1177
- throw this.#mapRevert("createAndFundConfidentialAirdrop", err, accountAddress(account));
1178
- }
1179
- return this.#resolveAirdropFromReceipt(hash, "createAndFundConfidentialAirdrop");
1180
- }
1181
- );
1182
- }
1183
- /**
1184
- * Fund an existing (or not-yet-deployed) airdrop with encrypted tokens.
1185
- *
1186
- * Prerequisites: caller must have set this factory as an operator on the token:
1187
- * `token.setOperator(factoryAddress, deadline)`
1188
- *
1189
- * **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.
1190
- *
1191
- * **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
1192
- * convention (1 token = 1_000_000 base units), not the 18 decimals typical of
1193
- * ERC-20. Amount parameters are base units of the token's actual decimals:
1194
- * for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
1195
- * transparent TTT test token uses 18 decimals.
1196
- *
1197
- * @returns Transaction hash.
1198
- */
1199
- async fundConfidentialAirdrop(args) {
1200
- const wallet = this.#requireWallet("fundConfidentialAirdrop");
1201
- const account = this.#resolveAccount(wallet, args.account, "fundConfidentialAirdrop");
1202
- const encrypted = await this.#encryptAmount(
1203
- args.amount,
1204
- args.encryptor,
1205
- args.encryptedInput,
1206
- account,
1207
- "fundConfidentialAirdrop"
1208
- );
1209
- const writeArgs = [
1210
- args.token,
1211
- toAbiParams(args.params),
1212
- args.userSalt,
1213
- args.deployer,
1214
- args.gasFee,
1215
- encrypted.handle,
1216
- encrypted.inputProof
1217
- ];
1218
- await this.#preflightWrite(
1219
- "fundConfidentialAirdrop",
1220
- "fundConfidentialAirdrop",
1221
- writeArgs,
1222
- account
1223
- );
1224
- try {
1225
- return await wallet.writeContract({
1226
- address: this.address,
1227
- abi: confidentialAirdropFactoryAbi,
1228
- functionName: "fundConfidentialAirdrop",
1229
- args: writeArgs,
1230
- account,
1231
- chain: wallet.chain
1232
- });
1233
- } catch (err) {
1234
- throw this.#mapRevert("fundConfidentialAirdrop", err, accountAddress(account));
1235
- }
1236
- }
1237
- /**
1238
- * Deploy a new airdrop clone and return its address, parsed from the
1239
- * `ConfidentialAirdropCreated` event in the tx receipt.
1240
- *
1241
- * Symmetry helper with the fhe-vesting client. Use this when you want a
1242
- * one-call "deploy and use" shape; otherwise call
1243
- * {@link ConfidentialAirdropFactoryClient.createConfidentialAirdrop} and parse
1244
- * the receipt yourself, or call
1245
- * {@link ConfidentialAirdropFactoryClient.predictAirdropAddress} before mining.
1246
- *
1247
- * Internally: {@link ConfidentialAirdropFactoryClient.createConfidentialAirdrop} →
1248
- * {@link PublicClient.waitForTransactionReceipt} →
1249
- * `parseEventLogs({ eventName: "ConfidentialAirdropCreated" })`.
1250
- *
1251
- * @example
1252
- * const { hash, airdrop } = await factory.createConfidentialAirdropAndGetAddress({
1253
- * params, userSalt,
1254
- * });
1255
- */
1256
- async createConfidentialAirdropAndGetAddress(args) {
1257
- return this.createConfidentialAirdrop(args);
1258
- }
1259
- /**
1260
- * Deploy AND fund a new airdrop clone in one tx, returning its address parsed
1261
- * from the `ConfidentialAirdropCreated` event in the receipt.
1262
- *
1263
- * Symmetry with {@link ConfidentialAirdropFactoryClient.createConfidentialAirdropAndGetAddress}
1264
- * — use this when you also need to seed the pool in the same transaction.
1265
- *
1266
- * **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.
1267
- *
1268
- * **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
1269
- * convention (1 token = 1_000_000 base units), not the 18 decimals typical of
1270
- * ERC-20. Amount parameters are base units of the token's actual decimals:
1271
- * for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
1272
- * transparent TTT test token uses 18 decimals.
1273
- *
1274
- * Internally: {@link ConfidentialAirdropFactoryClient.createAndFundConfidentialAirdrop} →
1275
- * {@link PublicClient.waitForTransactionReceipt} →
1276
- * `parseEventLogs({ eventName: "ConfidentialAirdropCreated" })`.
1277
- *
1278
- * @example
1279
- * const { hash, airdrop } = await factory.createAndFundConfidentialAirdropAndGetAddress({
1280
- * params, userSalt, amount, encryptor,
1281
- * });
1282
- */
1283
- async createAndFundConfidentialAirdropAndGetAddress(args) {
1284
- return this.createAndFundConfidentialAirdrop(args);
1285
- }
1286
- // ----------------------- fee management (FEE_MANAGER_ROLE) -----------------------
1287
- /** Change the fee collector address. FEE_MANAGER_ROLE only. */
1288
- async setFeeCollector(newFeeCollector, account) {
1289
- return withTelemetry(this.#telemetry, "fhe-airdrop.factory.setFeeCollector", async () => {
1290
- return this.#write("setFeeCollector", [newFeeCollector], account);
1291
- });
1292
- }
1293
- /** Change the default per-claim gas fee in wei. FEE_MANAGER_ROLE only. */
1294
- async setDefaultGasFee(newGasFee, account) {
1295
- return withTelemetry(this.#telemetry, "fhe-airdrop.factory.setDefaultGasFee", async () => {
1296
- return this.#write("setDefaultGasFee", [newGasFee], account);
1297
- });
1298
- }
1299
- /** Set a per-creator gas fee override. FEE_MANAGER_ROLE only. */
1300
- async setCustomFee(campaignCreator, gasFee, account) {
1301
- return withTelemetry(this.#telemetry, "fhe-airdrop.factory.setCustomFee", async () => {
1302
- return this.#write("setCustomFee", [campaignCreator, gasFee], account);
1303
- });
1304
- }
1305
- /** Remove a per-creator fee override, reverting to `defaultGasFee`. FEE_MANAGER_ROLE only. */
1306
- async disableCustomFee(campaignCreator, account) {
1307
- return withTelemetry(this.#telemetry, "fhe-airdrop.factory.disableCustomFee", async () => {
1308
- return this.#write("disableCustomFee", [campaignCreator], account);
1309
- });
1310
- }
1311
- // ----------------------- reads -----------------------
1312
- /** Current LibClone implementation address. */
1313
- async implementation() {
1314
- return this.#read("implementation");
1315
- }
1316
- /**
1317
- * Alias for {@link ConfidentialAirdropFactoryClient.implementation} that matches
1318
- * the contract's storage field name (`_airdropImplementation`).
1319
- *
1320
- * Provided for parity with `fhe-vesting`'s `managerImplementation()` alias.
1321
- * The airdrop factory has the same
1322
- * LibClone shape mirroring `_airdropImplementation` storage, so server
1323
- * devs reading the Solidity first reach for `factory.airdropImplementation()`
1324
- * via autocomplete and would otherwise hit a TS2551 on the SDK's
1325
- * `implementation()` shape. The canonical `implementation()` method is
1326
- * retained for backwards-compat and cross-factory uniformity.
1327
- */
1328
- async airdropImplementation() {
1329
- return this.implementation();
1330
- }
1331
- /** Default per-claim gas fee in wei. Used when no custom fee is set for the campaign creator. */
1332
- async defaultGasFee() {
1333
- return this.#read("defaultGasFee");
1334
- }
1335
- /** Address authorized to collect gas fees from airdrop clones. */
1336
- async feeCollector() {
1337
- return this.#read("feeCollector");
1338
- }
1339
- /** Per-creator custom fee override. `enabled` is `false` when no override is set. */
1340
- async getCustomFee(campaignCreator) {
1341
- const raw = await this.#read("getCustomFee", [
1342
- campaignCreator
1343
- ]);
1344
- return { enabled: raw.enabled, gasFee: raw.gasFee };
1345
- }
1346
- /**
1347
- * Compute the CREATE2 init-code hash for a given set of params and gas fee.
1348
- * Useful for deriving the clone address off-chain. Use `predictAirdropAddress` from
1349
- * `@tokenops/sdk/fhe-airdrop/advanced` for the full address derivation.
1350
- * @param args `{ params, gasFee }` — must match the values used at deploy time.
1351
- * @returns `bytes32` init-code hash.
1352
- */
1353
- async getInitCodeHash(args) {
1354
- return this.#read("getInitCodeHash", [toAbiParams(args.params), args.gasFee]);
1355
- }
1356
- // ----------------------- preflight -----------------------
1357
- /**
1358
- * Read-only preflight for {@link createConfidentialAirdrop} /
1359
- * {@link createAndFundConfidentialAirdrop}. Runs the
1360
- * deterministic-from-off-chain checks and reports blockers both as
1361
- * human-readable strings (`blockers`) and as typed {@link TokenOpsSdkError}s
1362
- * (`blockerErrors`), index-aligned.
1363
- *
1364
- * Preflight is **opt-in**. Consumers who have already validated state can
1365
- * skip this call and invoke the write directly — they'll receive the same
1366
- * typed errors at write time via the revert mapper.
1367
- *
1368
- * Report fields: `isFactoryOperator`, `gasFee`, `predictedAirdrop`,
1369
- * `alreadyDeployed`, `ready`, `blockers`, `blockerErrors` — see
1370
- * {@link CreateAirdropPreflightReport} for the meaning of each.
1371
- *
1372
- * Checks performed (all read-only, no gas):
1373
- * - Structural `params` validation mirroring the factory + clone
1374
- * `initialize` requirements (`InvalidArgumentError` blockers): `token` and
1375
- * `admin` are checksummed non-zero addresses,
1376
- * `startTimestamp < endTimestamp`, and `endTimestamp` is in the future
1377
- * (the clone's `initialize` reverts with `EndTimeInPast`).
1378
- * - Operator: creator has approved this factory as an ERC-7984 operator on
1379
- * `params.token` — a blocker only when `funding: true`
1380
- * ({@link OperatorNotApprovedError}); otherwise informational via
1381
- * `isFactoryOperator`.
1382
- * - Collision (only when `userSalt` is supplied): bytecode already at the
1383
- * predicted CREATE2 address means a repeat create with the same
1384
- * `(params, userSalt, gasFee)` would revert
1385
- * ({@link AlreadyInitializedError} blocker).
1386
- *
1387
- * **Not preflight-detectable — read before trusting `ready: true`:** the
1388
- * creator's confidential token balance is an encrypted `euint64` the SDK
1389
- * cannot read in plaintext, and an underfunded `createAndFund` does **not**
1390
- * revert — the ERC-7984 transfer silently moves an encrypted zero. Confirm
1391
- * the creator's balance covers the pool before submitting.
1392
- *
1393
- * @param args See {@link PreflightCreateAirdropArgs}.
1394
- * @returns A {@link CreateAirdropPreflightReport}.
1395
- */
1396
- async preflightCreateAirdrop(args) {
1397
- const { params, creator, userSalt, funding } = args;
1398
- const blockers = [];
1399
- const blockerErrors = [];
1400
- const pushBlocker = (err) => {
1401
- blockerErrors.push(err);
1402
- blockers.push(err.message);
1403
- };
1404
- const tokenOk = isAddress(params.token, { strict: true }) && params.token !== ZERO_ADDRESS;
1405
- if (!tokenOk) {
1406
- pushBlocker(
1407
- new InvalidArgumentError({
1408
- method: "createConfidentialAirdrop",
1409
- argument: "params.token",
1410
- reason: "must be a valid, non-zero EIP-55 checksummed address",
1411
- value: params.token
1412
- })
1413
- );
1414
- }
1415
- const adminOk = isAddress(params.admin, { strict: true }) && params.admin !== ZERO_ADDRESS;
1416
- if (!adminOk) {
1417
- pushBlocker(
1418
- new InvalidArgumentError({
1419
- method: "createConfidentialAirdrop",
1420
- argument: "params.admin",
1421
- reason: "must be a valid, non-zero EIP-55 checksummed address",
1422
- value: params.admin
1423
- })
1424
- );
1425
- }
1426
- if (params.startTimestamp >= params.endTimestamp) {
1427
- pushBlocker(
1428
- new InvalidArgumentError({
1429
- method: "createConfidentialAirdrop",
1430
- argument: "params.startTimestamp/params.endTimestamp",
1431
- reason: "startTimestamp must be strictly less than endTimestamp",
1432
- value: { startTimestamp: params.startTimestamp, endTimestamp: params.endTimestamp }
1433
- })
1434
- );
1435
- }
1436
- const [block, customFee, defaultFee, operatorRead] = await Promise.all([
1437
- this.publicClient.getBlock(),
1438
- this.getCustomFee(creator),
1439
- this.defaultGasFee(),
1440
- tokenOk ? this.publicClient.readContract({
1441
- address: params.token,
1442
- abi: erc7984OperatorAbi,
1443
- functionName: "isOperator",
1444
- args: [creator, this.address]
1445
- }).then((v) => ({ ok: true, value: v })).catch((err) => {
1446
- if (isNotErc7984Failure(err)) return { ok: false, err };
1447
- throw err;
1448
- }) : Promise.resolve({ ok: true, value: false })
1449
- ]);
1450
- const isFactoryOperator = operatorRead.ok ? operatorRead.value : false;
1451
- if (!operatorRead.ok) {
1452
- pushBlocker(
1453
- new InvalidArgumentError({
1454
- method: "createConfidentialAirdrop",
1455
- argument: "params.token",
1456
- reason: "does not implement the ERC-7984 `isOperator(address,address)` view \u2014 it is not a confidential token (or the address holds no contract on this chain)",
1457
- value: params.token
1458
- })
1459
- );
1460
- }
1461
- const gasFee = customFee.enabled ? customFee.gasFee : defaultFee;
1462
- if (params.endTimestamp <= Number(block.timestamp)) {
1463
- pushBlocker(
1464
- new InvalidArgumentError({
1465
- method: "createConfidentialAirdrop",
1466
- argument: "params.endTimestamp",
1467
- reason: "must be in the future (the clone's initialize reverts with EndTimeInPast)",
1468
- value: params.endTimestamp
1469
- })
1470
- );
1471
- }
1472
- if (funding === true && tokenOk && operatorRead.ok && !isFactoryOperator) {
1473
- pushBlocker(
1474
- new OperatorNotApprovedError({
1475
- method: "createAndFundConfidentialAirdrop",
1476
- contractAddress: this.address,
1477
- tokenAddress: params.token,
1478
- holder: creator,
1479
- spender: this.address
1480
- })
1481
- );
1482
- }
1483
- let predictedAirdrop;
1484
- let alreadyDeployed;
1485
- if (userSalt !== void 0 && tokenOk && adminOk) {
1486
- predictedAirdrop = await this.#read("predictAirdropAddress", [
1487
- toAbiParams(params),
1488
- userSalt,
1489
- creator,
1490
- gasFee
1491
- ]);
1492
- const bytecode = await this.publicClient.getCode({ address: predictedAirdrop });
1493
- alreadyDeployed = bytecode !== void 0 && bytecode !== "0x";
1494
- if (alreadyDeployed) {
1495
- pushBlocker(
1496
- new AlreadyInitializedError({
1497
- method: "createConfidentialAirdrop",
1498
- contractAddress: predictedAirdrop
1499
- })
1500
- );
1501
- }
1502
- }
1503
- return {
1504
- isFactoryOperator,
1505
- gasFee,
1506
- predictedAirdrop,
1507
- alreadyDeployed,
1508
- ready: blockers.length === 0,
1509
- blockers,
1510
- blockerErrors
1511
- };
1512
- }
1513
- // ----------------------- internals -----------------------
1514
- /**
1515
- * Wait for the receipt of a clone-deploy tx and parse the
1516
- * `ConfidentialAirdropCreated` event to extract the deployed airdrop
1517
- * address. Branded result; throws `TokenOpsSdkError` if zero or >1 events
1518
- * match this factory address.
1519
- */
1520
- async #resolveAirdropFromReceipt(hash, method) {
1521
- const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
1522
- const events = parseEventLogs({
1523
- abi: confidentialAirdropFactoryAbi,
1524
- eventName: "ConfidentialAirdropCreated",
1525
- logs: receipt.logs
1526
- });
1527
- const ours = events.filter((ev) => ev.address.toLowerCase() === this.address.toLowerCase());
1528
- if (ours.length === 0) {
1529
- throw new TokenOpsSdkError(
1530
- `${method}: no ConfidentialAirdropCreated event from factory ${this.address} in tx ${hash}`
1531
- );
1532
- }
1533
- if (ours.length > 1) {
1534
- throw new TokenOpsSdkError(
1535
- `${method}: ${ours.length} ConfidentialAirdropCreated events from factory ${this.address} in tx ${hash}; ambiguous result`
1536
- );
1537
- }
1538
- return { hash: asTxHash(hash), airdrop: ours[0].args.airdrop };
1539
- }
1540
- #requireWallet(method) {
1541
- if (!this.walletClient) {
1542
- throw new MissingWalletClientError(method);
1543
- }
1544
- return this.walletClient;
1545
- }
1546
- #resolveAccount(wallet, override, method) {
1547
- const acct = override ?? wallet.account;
1548
- if (!acct) {
1549
- throw new MissingAccountError(method);
1550
- }
1551
- return acct;
1552
- }
1553
- /**
1554
- * Resolve the encrypted-amount payload for a fund-style write. Enforces
1555
- * **exactly one** of `amount` / `encryptedInput` so a caller who hands the
1556
- * SDK a pre-encrypted handle cannot also pass a stale plaintext that drifts
1557
- * from the on-chain ciphertext.
1558
- */
1559
- async #encryptAmount(amount, encryptor, preEncrypted, account, method) {
1560
- const hasAmount = amount !== void 0;
1561
- const hasInput = preEncrypted !== void 0;
1562
- if (hasAmount && hasInput) {
1563
- throw new InvalidArgumentError({
1564
- method,
1565
- argument: "amount/encryptedInput",
1566
- reason: "exactly one of `amount` (plaintext, SDK encrypts) or `encryptedInput` (pre-encrypted) must be supplied \u2014 got both"
1567
- });
1568
- }
1569
- if (!hasAmount && !hasInput) {
1570
- throw new InvalidArgumentError({
1571
- method,
1572
- argument: "amount/encryptedInput",
1573
- reason: "exactly one of `amount` (plaintext, SDK encrypts) or `encryptedInput` (pre-encrypted) must be supplied \u2014 got neither"
1574
- });
1575
- }
1576
- if (hasInput) return preEncrypted;
1577
- const enc = encryptor ?? resolveEncryptor(this.encryptor);
1578
- if (!enc) {
1579
- throw new MissingEncryptorError("encryptAmount", {
1580
- hint: "Pass `encryptor` to the call or the client config (eager or lazy factory)."
1581
- });
1582
- }
1583
- return encryptUint64({
1584
- encryptor: enc,
1585
- contractAddress: this.address,
1586
- userAddress: accountAddress(account),
1587
- value: amount
1588
- });
1589
- }
1590
- async #write(functionName, args, account) {
1591
- const wallet = this.#requireWallet(functionName);
1592
- const acct = this.#resolveAccount(wallet, account, functionName);
1593
- await this.#preflightWrite(functionName, functionName, args, acct);
1594
- try {
1595
- return await wallet.writeContract({
1596
- address: this.address,
1597
- abi: confidentialAirdropFactoryAbi,
1598
- functionName,
1599
- args,
1600
- account: acct,
1601
- chain: wallet.chain
1602
- });
1603
- } catch (err) {
1604
- throw this.#mapRevert(functionName, err, accountAddress(acct));
1605
- }
1606
- }
1607
- #mapRevert(method, err, account) {
1608
- return mapContractRevert(err, {
1609
- method,
1610
- contractAddress: this.address,
1611
- abi: confidentialAirdropFactoryAbi,
1612
- productMapper: airdropFactoryProductMapper,
1613
- account
1614
- });
1615
- }
1616
- /**
1617
- * Pre-flight a write via `simulateContract` purely to surface typed reverts.
1618
- *
1619
- * The simulate's *return value* is discarded — FHE writes still need
1620
- * `writeContract` + receipt parsing because simulated FHE op handles diverge
1621
- * from the executed-tx handles (CLAUDE.md Pitfall #1). The only purpose of
1622
- * this call is to let viem decode any revert against the ABI and produce a
1623
- * `ContractFunctionRevertedError` frame the revert-mapper can classify.
1624
- */
1625
- async #preflightWrite(method, functionName, args, account, value) {
1626
- try {
1627
- await this.publicClient.simulateContract({
1628
- address: this.address,
1629
- abi: confidentialAirdropFactoryAbi,
1630
- functionName,
1631
- args,
1632
- account,
1633
- ...value !== void 0 ? { value } : {}
1634
- });
1635
- } catch (err) {
1636
- if (isContractRevert(err)) {
1637
- throw this.#mapRevert(method, err, accountAddress(account));
1638
- }
1639
- }
1640
- }
1641
- async #read(functionName, args = []) {
1642
- const result = await this.publicClient.readContract({
1643
- address: this.address,
1644
- abi: confidentialAirdropFactoryAbi,
1645
- functionName,
1646
- args
1647
- });
1648
- return result;
1649
- }
1650
- };
1651
- function createConfidentialAirdropFactoryClient(config) {
1652
- return new ConfidentialAirdropFactoryClient(config);
1653
- }
1654
- function isNotErc7984Failure(err) {
1655
- if (isContractRevert(err)) return true;
1656
- if (!(err instanceof BaseError)) return false;
1657
- return err.walk((e) => e instanceof ContractFunctionZeroDataError) instanceof ContractFunctionZeroDataError;
1658
- }
1659
- var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
1660
- function accountAddress(account) {
1661
- return typeof account === "string" ? account : account.address;
1662
- }
1663
- function toAbiParams(params) {
1664
- return {
1665
- token: params.token,
1666
- startTime: params.startTimestamp,
1667
- endTime: params.endTimestamp,
1668
- canExtendClaimWindow: params.canExtendClaimWindow,
1669
- admin: params.admin
1670
- };
1671
- }
1672
-
1673
- export { ConfidentialAirdropFactoryClient, confidentialAirdropFactoryAbi, createConfidentialAirdropFactoryClient, encryptUint64, encryptUint64Batch, resolveEncryptor, signClaimAuthorization };