@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
@@ -0,0 +1,688 @@
1
+ import { isContractRevert } from './chunk-4RAAATVY.js';
2
+ import { TokenOpsSdkError, InvalidArgumentError, FeatureDisabledError, UnsupportedChainError, FheHandleNotAllowedError, TransferFailedError, InsufficientBalanceError, InsufficientFeeError, PausedError, InvalidSignatureError, isTokenOpsSdkError } from './chunk-QBJ7O2B4.js';
3
+ import { isAddressEqual, zeroAddress, isAddress, BaseError, ContractFunctionZeroDataError } from 'viem';
4
+
5
+ // src/fhe-airdrop/constants.ts
6
+ var AIRDROP_CONTRACTS_COMMIT = "7175ac82f467f0f88c05aba1a4536892999b4251";
7
+ var DEPLOYMENT_MODE = { clone: 0, uups: 1 };
8
+ var DEDUP_MODE = { perAddress: 0, perDedupId: 1, both: 2, none: 3 };
9
+
10
+ // src/fhe-airdrop/errors.ts
11
+ var MerkleUupsUnsupportedError = class extends TokenOpsSdkError {
12
+ name = "MerkleUupsUnsupportedError";
13
+ constructor(options) {
14
+ super(
15
+ 'Merkle campaigns cannot use `mode: "uups"`: the per-account `claimedAmount` mapping occupies an ERC-7201 namespaced slot that an earlier revision typed differently, so an in-place upgrade across that change reinterprets existing storage and can re-open claims that were already settled. Use `mode: "clone"`.',
16
+ {
17
+ code: "TOKENOPS_MERKLE_UUPS_UNSUPPORTED",
18
+ cause: options?.cause,
19
+ context: { constraint: "merkle-uups-storage-retype" }
20
+ }
21
+ );
22
+ }
23
+ };
24
+ var NonStockWrapperError = class extends TokenOpsSdkError {
25
+ name = "NonStockWrapperError";
26
+ constructor(args) {
27
+ const detail = args?.token ? ` (token: ${args.token})` : "";
28
+ super(
29
+ `\`claimAndUnwrap\` is only exact for a stock ERC7984ERC20Wrapper${detail}: it burns from the airdrop instance's pooled wrapper balance, not from a per-claimant sub-balance, so the delivered amount is bounded by the pool's balance rather than by the claimant's own outstanding amount. A hooked or fee-taking wrapper can throw that accounting off, so a claimant can be credited against tokens that are not theirs.`,
30
+ {
31
+ code: "TOKENOPS_NON_STOCK_WRAPPER",
32
+ cause: args?.cause,
33
+ context: { constraint: "wrapper-unwrap-pool-bound", token: args?.token }
34
+ }
35
+ );
36
+ }
37
+ };
38
+ var UnauthorizedRedirectError = class extends TokenOpsSdkError {
39
+ name = "UnauthorizedRedirectError";
40
+ constructor(args) {
41
+ const who = args?.submitter ? ` (submitter: ${args.submitter})` : "";
42
+ super(
43
+ `Only the claim identity may redirect its own payout${who}: \`to\` (${args?.to ?? "unknown"}) differs from \`account\` (${args?.account ?? "unknown"}) and the submitter is not that account. Leave \`to\` unset (or equal to \`account\`) when submitting on someone else's behalf.`,
44
+ {
45
+ code: "TOKENOPS_UNAUTHORIZED_REDIRECT",
46
+ cause: args?.cause,
47
+ context: {
48
+ constraint: "merkle-third-party-redirect",
49
+ account: args?.account,
50
+ to: args?.to,
51
+ submitter: args?.submitter
52
+ }
53
+ }
54
+ );
55
+ }
56
+ };
57
+ var SaltCollisionError = class extends TokenOpsSdkError {
58
+ name = "SaltCollisionError";
59
+ constructor(args) {
60
+ super(
61
+ `${args.method}: the predicted address ${args.predictedAddress} already holds code. A ${args.variant} instance address commits only to (implementation, mode, deployer, userSalt) - the params struct is ignored - so this (mode, deployer, userSalt) tuple has already been deployed. Pick a fresh \`userSalt\` for each campaign.`,
62
+ {
63
+ code: "TOKENOPS_SALT_COLLISION",
64
+ cause: args.cause,
65
+ context: {
66
+ method: args.method,
67
+ variant: args.variant,
68
+ mode: args.mode,
69
+ deployer: args.deployer,
70
+ userSalt: args.userSalt,
71
+ predictedAddress: args.predictedAddress
72
+ }
73
+ }
74
+ );
75
+ }
76
+ };
77
+ var PredictionDriftError = class extends TokenOpsSdkError {
78
+ name = "PredictionDriftError";
79
+ constructor(args) {
80
+ const where = args.predictedAddress ? ` ${args.predictedAddress}` : "";
81
+ super(
82
+ `${args.method}: the factory's ${args.variant} init-code hash changed from ${args.initCodeHashBefore} to ${args.initCodeHashAfter} mid-flight. An implementation rotation landed while the prediction was in use, so the predicted address${where} is stale and anything bound to it (a Merkle campaign's ciphertexts above all) will not match the instance the create produces. Re-predict and rebuild.`,
83
+ {
84
+ code: "TOKENOPS_PREDICTION_DRIFT",
85
+ cause: args.cause,
86
+ context: {
87
+ method: args.method,
88
+ variant: args.variant,
89
+ initCodeHashBefore: args.initCodeHashBefore,
90
+ initCodeHashAfter: args.initCodeHashAfter,
91
+ predictedAddress: args.predictedAddress
92
+ }
93
+ }
94
+ );
95
+ }
96
+ };
97
+ var UpgradeabilityNotAllowedError = class extends TokenOpsSdkError {
98
+ name = "UpgradeabilityNotAllowedError";
99
+ constructor(args) {
100
+ const label = args.method ? `${args.method}: ` : "";
101
+ const who = args.creator ? ` for creator ${args.creator}` : "";
102
+ super(
103
+ `${label}\`mode: "uups"\` is not permitted${who} \u2014 call \`setDefaultUpgradeable(true)\` or \`setUpgradeabilityPolicy(creator, true)\` (UPGRADE_MANAGER_ROLE), or use \`mode: "clone"\`.`,
104
+ {
105
+ code: "TOKENOPS_UPGRADEABILITY_NOT_ALLOWED",
106
+ cause: args.cause,
107
+ context: {
108
+ method: args.method,
109
+ contractAddress: args.contractAddress,
110
+ creator: args.creator
111
+ }
112
+ }
113
+ );
114
+ }
115
+ };
116
+ var FeeCollectorSelfAdministeredError = class extends TokenOpsSdkError {
117
+ name = "FeeCollectorSelfAdministeredError";
118
+ constructor(args) {
119
+ super(
120
+ "FEE_COLLECTOR_ROLE is self-administered (its own role admin, not DEFAULT_ADMIN_ROLE) \u2014 grantInstanceRoles cannot grant it from the caller's admin role. Have an existing FEE_COLLECTOR_ROLE holder call `grantRole` directly.",
121
+ {
122
+ code: "TOKENOPS_FEE_COLLECTOR_SELF_ADMINISTERED",
123
+ cause: args?.cause,
124
+ context: { requestedGrantee: args?.requestedGrantee }
125
+ }
126
+ );
127
+ }
128
+ };
129
+ var DedupIdConsumedError = class extends TokenOpsSdkError {
130
+ name = "DedupIdConsumedError";
131
+ constructor(args) {
132
+ const which = args.dedupId ? ` ${args.dedupId}` : "";
133
+ super(`${args.method}: dedupId${which} has already been claimed.`, {
134
+ code: "TOKENOPS_DEDUP_ID_CONSUMED",
135
+ cause: args.cause,
136
+ context: {
137
+ method: args.method,
138
+ contractAddress: args.contractAddress,
139
+ dedupId: args.dedupId
140
+ }
141
+ });
142
+ }
143
+ };
144
+ var AlreadyClaimedError = class extends TokenOpsSdkError {
145
+ name = "AlreadyClaimedError";
146
+ constructor(args) {
147
+ super(`${args.method}: already claimed (${args.replayGuard} replay guard).`, {
148
+ code: "TOKENOPS_ALREADY_CLAIMED",
149
+ cause: args.cause,
150
+ context: {
151
+ method: args.method,
152
+ contractAddress: args.contractAddress,
153
+ replayGuard: args.replayGuard
154
+ }
155
+ });
156
+ }
157
+ };
158
+ var ClaimNotStartedError = class extends TokenOpsSdkError {
159
+ name = "ClaimNotStartedError";
160
+ constructor(args) {
161
+ const detail = args.startTime !== void 0 ? ` Opens at unix timestamp ${args.startTime}.` : "";
162
+ super(`${args.method}: the claim window has not opened yet.${detail}`, {
163
+ code: "TOKENOPS_CLAIM_NOT_STARTED",
164
+ cause: args.cause,
165
+ context: {
166
+ method: args.method,
167
+ contractAddress: args.contractAddress,
168
+ startTime: args.startTime,
169
+ currentTime: args.currentTime
170
+ }
171
+ });
172
+ }
173
+ };
174
+ var SignatureExpiredError = class extends TokenOpsSdkError {
175
+ name = "SignatureExpiredError";
176
+ constructor(args) {
177
+ const detail = args.deadline !== void 0 && args.currentTime !== void 0 ? ` The signature's deadline (unix timestamp ${args.deadline}) has passed; current time is ${args.currentTime}.` : "";
178
+ super(`${args.method}: signature has expired.${detail} Re-sign with a later deadline.`, {
179
+ code: "TOKENOPS_SIGNATURE_EXPIRED",
180
+ cause: args.cause,
181
+ context: {
182
+ method: args.method,
183
+ contractAddress: args.contractAddress,
184
+ deadline: args.deadline,
185
+ currentTime: args.currentTime
186
+ }
187
+ });
188
+ }
189
+ };
190
+ var ClaimWindowClosedError = class extends TokenOpsSdkError {
191
+ name = "ClaimWindowClosedError";
192
+ constructor(args) {
193
+ const detail = args.endTime !== void 0 ? ` Closed at unix timestamp ${args.endTime}.` : "";
194
+ super(`${args.method}: the claim window has closed.${detail}`, {
195
+ code: "TOKENOPS_CLAIM_WINDOW_CLOSED",
196
+ cause: args.cause,
197
+ context: {
198
+ method: args.method,
199
+ contractAddress: args.contractAddress,
200
+ endTime: args.endTime,
201
+ currentTime: args.currentTime
202
+ }
203
+ });
204
+ }
205
+ };
206
+ var airdropProductMapper = (name, errArgs, ctx) => {
207
+ switch (name) {
208
+ // ---- guarded conditions, caught on-chain instead of pre-flight -------
209
+ case "TokenNotAWrapper": {
210
+ const token = ctx.productContext?.["token"];
211
+ return new NonStockWrapperError({ token });
212
+ }
213
+ case "UpgradeabilityNotAllowed": {
214
+ const creator = ctx.productContext?.["creator"];
215
+ return new UpgradeabilityNotAllowedError({ ...ctx, creator });
216
+ }
217
+ // ---- claim lifecycle --------------------------------------------------
218
+ case "ClaimNotStarted": {
219
+ const startTime = numberArg(errArgs?.[0]);
220
+ const currentTime = numberArg(errArgs?.[1]);
221
+ return new ClaimNotStartedError({ ...ctx, startTime, currentTime });
222
+ }
223
+ case "ClaimWindowFinished": {
224
+ const endTime = numberArg(errArgs?.[0]);
225
+ const currentTime = numberArg(errArgs?.[1]);
226
+ return new ClaimWindowClosedError({ ...ctx, endTime, currentTime });
227
+ }
228
+ case "AddressAlreadyClaimed":
229
+ return new AlreadyClaimedError({ ...ctx, replayGuard: "address" });
230
+ case "SignatureAlreadyUsed":
231
+ return new AlreadyClaimedError({ ...ctx, replayGuard: "signature" });
232
+ case "DedupIdAlreadyClaimed": {
233
+ const dedupId = ctx.productContext?.["dedupId"];
234
+ return new DedupIdConsumedError({ ...ctx, dedupId });
235
+ }
236
+ case "InsufficientFee": {
237
+ const provided = errArgs?.[0];
238
+ const required = errArgs?.[1];
239
+ return new InsufficientFeeError({ ...ctx, feeKind: "gas", provided, required });
240
+ }
241
+ case "InsufficientFeeBalance": {
242
+ const requested = errArgs?.[0];
243
+ const available = errArgs?.[1];
244
+ return new InsufficientBalanceError({ ...ctx, balanceKind: "eth", requested, available });
245
+ }
246
+ case "EthTransferFailed":
247
+ return new TransferFailedError({ ...ctx, asset: "eth" });
248
+ case "HandleNotAllowed": {
249
+ const handle = errArgs?.[0];
250
+ return new FheHandleNotAllowedError({ ...ctx, handle });
251
+ }
252
+ // ---- Merkle-specific ----------------------------------------------
253
+ case "InvalidMerkleProof":
254
+ return new InvalidArgumentError({
255
+ method: ctx.method,
256
+ argument: "merkleProof",
257
+ reason: "the contract reverted with `InvalidMerkleProof` \u2014 the proof does not verify against the current on-chain root. If the root was recently rotated, rebuild the proof against the new root."
258
+ });
259
+ case "RootImmutable":
260
+ return new FeatureDisabledError({ ...ctx, feature: "merkleRootRotation" });
261
+ case "ZeroAccount":
262
+ return invalidArg(
263
+ ctx,
264
+ "account",
265
+ name,
266
+ "the claim identity is mandatory and is never defaulted from the caller"
267
+ );
268
+ case "UnauthorizedRedirect": {
269
+ const account = errArgs?.[0];
270
+ const to = errArgs?.[1];
271
+ return new UnauthorizedRedirectError({
272
+ account,
273
+ to,
274
+ submitter: ctx.productContext?.["creator"]
275
+ });
276
+ }
277
+ // ---- FHEVM chain config ---------------------------------------------
278
+ case "ZamaProtocolUnsupported": {
279
+ const chainId = ctx.productContext?.["chainId"] ?? 0;
280
+ return new UnsupportedChainError(chainId);
281
+ }
282
+ // ---- ECDSA-specific signature reverts --------------------------------
283
+ case "SignatureExpired": {
284
+ const deadline = errArgs?.[0];
285
+ const currentTime = errArgs?.[1];
286
+ return new SignatureExpiredError({ ...ctx, deadline, currentTime });
287
+ }
288
+ // ---- argument-validation bucket: reverts not already covered by the
289
+ // cross-product default mapper's `Zero*`/`Invalid*` list ---------------
290
+ case "ZeroToken":
291
+ return invalidArg(ctx, "token", name);
292
+ case "ZeroFeeCollector":
293
+ return invalidArg(
294
+ ctx,
295
+ "feeCollector",
296
+ name,
297
+ "validates the factory-injected fee-collector init parameter"
298
+ );
299
+ case "ZeroComplianceManager":
300
+ return invalidArg(ctx, "complianceManager", name);
301
+ case "ZeroRecipient":
302
+ return invalidArg(ctx, "recipient", name);
303
+ case "ZeroAdminGrant":
304
+ return invalidArg(
305
+ ctx,
306
+ "admin",
307
+ name,
308
+ "granting DEFAULT_ADMIN_ROLE to the zero address is never valid"
309
+ );
310
+ case "ZeroFeeCollectorGrant":
311
+ return invalidArg(
312
+ ctx,
313
+ "feeCollector",
314
+ name,
315
+ "granting FEE_COLLECTOR_ROLE to the zero address is never valid on a fee-charging campaign"
316
+ );
317
+ case "LastAdmin":
318
+ return invalidArg(
319
+ ctx,
320
+ "admin",
321
+ name,
322
+ "revoking or renouncing the sole DEFAULT_ADMIN_ROLE member would leave the instance permanently ungovernable"
323
+ );
324
+ case "LastFeeCollector":
325
+ return invalidArg(
326
+ ctx,
327
+ "feeCollector",
328
+ name,
329
+ "revoking the sole FEE_COLLECTOR_ROLE member would strand accrued claim-fee ETH on a fee-charging campaign"
330
+ );
331
+ case "CannotRescueAirdropToken":
332
+ return invalidArg(ctx, "token", name, "the rescue target cannot be the airdrop's own token");
333
+ case "TokenNotUnwrappable":
334
+ return new FeatureDisabledError({ ...ctx, feature: "claimAndUnwrap" });
335
+ case "ZeroAdmin":
336
+ return invalidArg(ctx, "admin", name);
337
+ case "ZeroImplementation":
338
+ return invalidArg(ctx, "implementation", name);
339
+ case "ZeroComplianceManagerImpl":
340
+ return invalidArg(ctx, "complianceManagerImpl", name);
341
+ case "ZeroComplianceDelegate":
342
+ return invalidArg(
343
+ ctx,
344
+ "complianceDelegate",
345
+ name,
346
+ "required while the default compliance-delegate policy is on"
347
+ );
348
+ case "IndexOutOfBounds": {
349
+ const index = errArgs?.[0];
350
+ const count = errArgs?.[1];
351
+ return invalidArg(
352
+ ctx,
353
+ "index",
354
+ name,
355
+ `requested index ${index?.toString() ?? "?"}, but only ${count?.toString() ?? "?"} airdrops exist`
356
+ );
357
+ }
358
+ case "UnknownAirdrop":
359
+ return invalidArg(ctx, "airdrop", name, "was not created by this factory");
360
+ case "SaltAlreadyUsed": {
361
+ const existingAirdrop = errArgs?.[0];
362
+ return new InvalidArgumentError({
363
+ method: ctx.method,
364
+ argument: "userSalt",
365
+ reason: `this (creator, mode, userSalt) tuple already predicts an existing instance${existingAirdrop ? ` at ${existingAirdrop}` : ""}.`,
366
+ value: existingAirdrop
367
+ });
368
+ }
369
+ case "ZeroSigner":
370
+ return invalidArg(ctx, "signer", name);
371
+ case "ZeroMerkleRoot":
372
+ return invalidArg(
373
+ ctx,
374
+ "merkleRoot",
375
+ name,
376
+ "a zero root is only permitted when `isMerkleRootMutable` is true"
377
+ );
378
+ // ---- compliance manager clone (`ComplianceRoleManager`) --------------
379
+ case "ZeroAirdrop":
380
+ return invalidArg(ctx, "airdrop", name);
381
+ case "ZeroClientAdmin":
382
+ return invalidArg(ctx, "clientAdmin", name);
383
+ case "ZeroDelegate":
384
+ return invalidArg(ctx, "delegate", name);
385
+ case "AirdropAndManagerAreSameAddress":
386
+ return invalidArg(
387
+ ctx,
388
+ "airdrop",
389
+ name,
390
+ "cannot equal this compliance manager clone's own address"
391
+ );
392
+ case "DelegateAndManagerAreSameAddress":
393
+ return invalidArg(
394
+ ctx,
395
+ "delegate",
396
+ name,
397
+ "cannot equal this compliance manager clone's own address"
398
+ );
399
+ case "DelegateAndAirdropAreSameAddress":
400
+ return invalidArg(ctx, "delegate", name, "cannot equal the airdrop instance's address");
401
+ case "DelegateAlreadyAdded":
402
+ return invalidArg(ctx, "delegate", name, "already an active client delegate");
403
+ case "DelegateNotFound":
404
+ return invalidArg(ctx, "delegate", name, "not an active client delegate");
405
+ case "CannotManageComplianceDelegate":
406
+ return invalidArg(
407
+ ctx,
408
+ "delegate",
409
+ name,
410
+ "targets the factory-designated platform compliance delegate, which cannot be managed this way"
411
+ );
412
+ default:
413
+ return void 0;
414
+ }
415
+ };
416
+ function invalidArg(ctx, argument, revertName, detail) {
417
+ const suffix = detail ? ` ${detail}.` : "";
418
+ return new InvalidArgumentError({
419
+ method: ctx.method,
420
+ argument,
421
+ reason: `the contract reverted with \`${revertName}\`.${suffix}`
422
+ });
423
+ }
424
+ function numberArg(value) {
425
+ return typeof value === "bigint" ? Number(value) : void 0;
426
+ }
427
+ var SUPPORTED_CHAIN_IDS = [1, 11155111, 31337];
428
+ function assertSupportedChain(chainId) {
429
+ if (!SUPPORTED_CHAIN_IDS.includes(chainId)) {
430
+ throw new UnsupportedChainError(chainId);
431
+ }
432
+ }
433
+ function assertMerkleModeSupported(mode) {
434
+ if (mode === "uups") {
435
+ throw new MerkleUupsUnsupportedError();
436
+ }
437
+ }
438
+ var WRAPPER_PROBE_ABI = [
439
+ {
440
+ inputs: [],
441
+ name: "underlying",
442
+ outputs: [{ internalType: "address", name: "", type: "address" }],
443
+ stateMutability: "view",
444
+ type: "function"
445
+ }
446
+ ];
447
+ function isProbeAnswer(error) {
448
+ if (isContractRevert(error)) return true;
449
+ if (!(error instanceof BaseError)) return false;
450
+ return error.walk((e) => e instanceof ContractFunctionZeroDataError) !== null;
451
+ }
452
+ async function assertStockWrapper(args) {
453
+ if (!args.unwrappable) return;
454
+ let underlying;
455
+ try {
456
+ underlying = await args.publicClient.readContract({
457
+ address: args.token,
458
+ abi: WRAPPER_PROBE_ABI,
459
+ functionName: "underlying"
460
+ });
461
+ } catch (cause) {
462
+ if (!isProbeAnswer(cause)) throw cause;
463
+ throw new NonStockWrapperError({ token: args.token, cause });
464
+ }
465
+ if (isAddressEqual(underlying, zeroAddress)) {
466
+ throw new NonStockWrapperError({ token: args.token });
467
+ }
468
+ }
469
+ async function assertSaltAvailable(args) {
470
+ const code = await args.publicClient.getCode({ address: args.predictedAddress });
471
+ if (code === void 0 || code === "0x") return;
472
+ throw new SaltCollisionError({
473
+ method: args.method,
474
+ variant: args.variant,
475
+ mode: args.mode,
476
+ deployer: args.deployer,
477
+ userSalt: args.userSalt,
478
+ predictedAddress: args.predictedAddress
479
+ });
480
+ }
481
+ function assertPredictionFresh(args) {
482
+ if (args.initCodeHashBefore.toLowerCase() === args.initCodeHashAfter.toLowerCase()) return;
483
+ throw new PredictionDriftError({
484
+ method: args.method,
485
+ variant: args.variant,
486
+ initCodeHashBefore: args.initCodeHashBefore,
487
+ initCodeHashAfter: args.initCodeHashAfter,
488
+ predictedAddress: args.predictedAddress
489
+ });
490
+ }
491
+ async function preflightCreate(args) {
492
+ const method = args.variant === "merkle" ? "createMerkleAirdrop" : "createEcdsaAirdrop";
493
+ const blockers = [];
494
+ collect(blockers, () => assertSupportedChain(args.factory.chainId));
495
+ if (args.variant === "merkle") {
496
+ collect(blockers, () => assertMerkleModeSupported(args.mode));
497
+ }
498
+ const predictArgs = {
499
+ mode: args.mode,
500
+ deployer: args.creator,
501
+ userSalt: args.userSalt
502
+ };
503
+ const predictedAddress = args.variant === "merkle" ? await args.factory.predictMerkleAirdropAddress({ params: args.params, ...predictArgs }) : await args.factory.predictEcdsaAirdropAddress({ params: args.params, ...predictArgs });
504
+ const liveInitCodeHash = args.variant === "merkle" ? await args.factory.getMerkleInitCodeHash({ params: args.params, mode: args.mode }) : await args.factory.getEcdsaInitCodeHash({ params: args.params, mode: args.mode });
505
+ if (args.mode === "uups") {
506
+ const allowed = await args.factory.effectiveUpgradeable(args.creator);
507
+ if (!allowed) {
508
+ blockers.push(
509
+ new UpgradeabilityNotAllowedError({
510
+ method,
511
+ contractAddress: args.factory.address,
512
+ creator: args.creator
513
+ })
514
+ );
515
+ }
516
+ }
517
+ await collectAsync(
518
+ blockers,
519
+ () => assertStockWrapper({
520
+ publicClient: args.factory.publicClient,
521
+ token: args.params.common.token,
522
+ unwrappable: args.params.common.unwrappable
523
+ })
524
+ );
525
+ await collectAsync(
526
+ blockers,
527
+ () => assertSaltAvailable({
528
+ publicClient: args.factory.publicClient,
529
+ predictedAddress,
530
+ variant: args.variant,
531
+ mode: args.mode,
532
+ deployer: args.creator,
533
+ userSalt: args.userSalt,
534
+ method
535
+ })
536
+ );
537
+ if (args.expectedInitCodeHash !== void 0) {
538
+ collect(
539
+ blockers,
540
+ () => assertPredictionFresh({
541
+ variant: args.variant,
542
+ initCodeHashBefore: args.expectedInitCodeHash,
543
+ initCodeHashAfter: liveInitCodeHash,
544
+ predictedAddress,
545
+ method
546
+ })
547
+ );
548
+ }
549
+ return { ready: blockers.length === 0, blockers };
550
+ }
551
+ function assertMerkleClaimIdentity(args) {
552
+ const { method, account, submitter, boundTo, to, entrypoint = "claim" } = args;
553
+ for (const [argument, value] of [
554
+ ["account", account],
555
+ ["entry.boundTo", boundTo],
556
+ ["to", to],
557
+ ["submitter", submitter]
558
+ ]) {
559
+ if (value !== void 0 && !isAddress(value, { strict: false })) {
560
+ throw new InvalidArgumentError({
561
+ method,
562
+ argument,
563
+ reason: "is not a 20-byte hex address",
564
+ value
565
+ });
566
+ }
567
+ }
568
+ if (isAddressEqual(account, zeroAddress)) {
569
+ throw new InvalidArgumentError({
570
+ method,
571
+ argument: "account",
572
+ reason: "is the zero address; the claim identity is mandatory and is never defaulted from the caller"
573
+ });
574
+ }
575
+ if (boundTo !== void 0 && !isAddressEqual(boundTo, submitter)) {
576
+ throw new InvalidArgumentError({
577
+ method,
578
+ argument: "entry.boundTo",
579
+ reason: `is ${boundTo}, but this transaction is sent from ${submitter}; the FHE input proof is bound to the sender, so only ${boundTo} can submit this entry`
580
+ });
581
+ }
582
+ if (entrypoint === "claimAndUnwrap") {
583
+ if (!isAddressEqual(account, submitter)) {
584
+ throw new InvalidArgumentError({
585
+ method,
586
+ argument: "entry.account",
587
+ reason: `is ${account}, but \`claimAndUnwrap\` is always submitted for the caller (${submitter}); use \`claim\` to settle on someone else's behalf`
588
+ });
589
+ }
590
+ return;
591
+ }
592
+ const beneficiary = to === void 0 || isAddressEqual(to, zeroAddress) ? account : to;
593
+ if (!isAddressEqual(beneficiary, account) && !isAddressEqual(submitter, account)) {
594
+ throw new UnauthorizedRedirectError({ account, to: beneficiary, submitter });
595
+ }
596
+ }
597
+ async function preflightClaim(args) {
598
+ const { airdrop, claimant } = args;
599
+ const method = "preflightClaim";
600
+ const blockers = [];
601
+ collect(blockers, () => assertSupportedChain(airdrop.chainId));
602
+ if (args.account !== void 0 || args.entrypoint !== void 0) {
603
+ collect(
604
+ blockers,
605
+ () => assertMerkleClaimIdentity({
606
+ method,
607
+ account: args.account ?? claimant,
608
+ submitter: claimant,
609
+ to: args.to,
610
+ entrypoint: args.entrypoint
611
+ })
612
+ );
613
+ }
614
+ const [started, ended, paused, fee, balance, unwrappable] = await Promise.all([
615
+ airdrop.hasClaimStarted(),
616
+ airdrop.hasClaimEnded(),
617
+ airdrop.paused(),
618
+ airdrop.gasFee(),
619
+ airdrop.publicClient.getBalance({ address: claimant }),
620
+ args.entrypoint === "claimAndUnwrap" && airdrop.unwrappable ? airdrop.unwrappable() : Promise.resolve(true)
621
+ ]);
622
+ if (!unwrappable) {
623
+ blockers.push(
624
+ new FeatureDisabledError({
625
+ method,
626
+ contractAddress: airdrop.address,
627
+ feature: "claimAndUnwrap"
628
+ })
629
+ );
630
+ }
631
+ if (paused) {
632
+ blockers.push(new PausedError({ method, contractAddress: airdrop.address }));
633
+ }
634
+ if (!started) {
635
+ blockers.push(
636
+ new ClaimNotStartedError({
637
+ method,
638
+ contractAddress: airdrop.address,
639
+ startTime: await airdrop.startTime()
640
+ })
641
+ );
642
+ }
643
+ if (ended) {
644
+ blockers.push(
645
+ new ClaimWindowClosedError({
646
+ method,
647
+ contractAddress: airdrop.address,
648
+ endTime: await airdrop.endTime()
649
+ })
650
+ );
651
+ }
652
+ if (balance < fee) {
653
+ blockers.push(
654
+ new InsufficientFeeError({
655
+ method,
656
+ contractAddress: airdrop.address,
657
+ feeKind: "gas",
658
+ provided: balance,
659
+ required: fee
660
+ })
661
+ );
662
+ }
663
+ if (args.signature && airdrop.isSignatureValid) {
664
+ const valid = await airdrop.isSignatureValid({ recipient: claimant, ...args.signature });
665
+ if (!valid) {
666
+ blockers.push(new InvalidSignatureError({ method, contractAddress: airdrop.address }));
667
+ }
668
+ }
669
+ return { ready: blockers.length === 0, blockers };
670
+ }
671
+ function collect(blockers, run) {
672
+ try {
673
+ run();
674
+ } catch (err) {
675
+ if (!isTokenOpsSdkError(err)) throw err;
676
+ blockers.push(err);
677
+ }
678
+ }
679
+ async function collectAsync(blockers, run) {
680
+ try {
681
+ await run();
682
+ } catch (err) {
683
+ if (!isTokenOpsSdkError(err)) throw err;
684
+ blockers.push(err);
685
+ }
686
+ }
687
+
688
+ export { AIRDROP_CONTRACTS_COMMIT, AlreadyClaimedError, ClaimNotStartedError, ClaimWindowClosedError, DEDUP_MODE, DEPLOYMENT_MODE, DedupIdConsumedError, FeeCollectorSelfAdministeredError, MerkleUupsUnsupportedError, NonStockWrapperError, PredictionDriftError, SaltCollisionError, SignatureExpiredError, UnauthorizedRedirectError, UpgradeabilityNotAllowedError, airdropProductMapper, assertMerkleClaimIdentity, assertMerkleModeSupported, assertPredictionFresh, assertSaltAvailable, assertStockWrapper, assertSupportedChain, preflightClaim, preflightCreate };