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