@tokenops/sdk 1.5.1 → 2.0.0-alpha.1

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