@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,1644 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkSYHNZSZZ_cjs = require('./chunk-SYHNZSZZ.cjs');
4
- var chunk43RFBQ73_cjs = require('./chunk-43RFBQ73.cjs');
5
- var chunk2RNW4MIJ_cjs = require('./chunk-2RNW4MIJ.cjs');
6
- var chunkVJKZWYYJ_cjs = require('./chunk-VJKZWYYJ.cjs');
7
- var viem = require('viem');
8
-
9
- // src/fhe-airdrop/abis/cloneable.ts
10
- var confidentialAirdropCloneableAbi = [
11
- {
12
- inputs: [],
13
- stateMutability: "nonpayable",
14
- type: "constructor"
15
- },
16
- {
17
- inputs: [],
18
- name: "AccessControlBadConfirmation",
19
- type: "error"
20
- },
21
- {
22
- inputs: [
23
- {
24
- internalType: "address",
25
- name: "account",
26
- type: "address"
27
- },
28
- {
29
- internalType: "bytes32",
30
- name: "neededRole",
31
- type: "bytes32"
32
- }
33
- ],
34
- name: "AccessControlUnauthorizedAccount",
35
- type: "error"
36
- },
37
- {
38
- inputs: [],
39
- name: "ClaimNotStarted",
40
- type: "error"
41
- },
42
- {
43
- inputs: [],
44
- name: "ClaimWindowFinished",
45
- type: "error"
46
- },
47
- {
48
- inputs: [],
49
- name: "ClaimsPaused",
50
- type: "error"
51
- },
52
- {
53
- inputs: [],
54
- name: "ECDSAInvalidSignature",
55
- type: "error"
56
- },
57
- {
58
- inputs: [
59
- {
60
- internalType: "uint256",
61
- name: "length",
62
- type: "uint256"
63
- }
64
- ],
65
- name: "ECDSAInvalidSignatureLength",
66
- type: "error"
67
- },
68
- {
69
- inputs: [
70
- {
71
- internalType: "bytes32",
72
- name: "s",
73
- type: "bytes32"
74
- }
75
- ],
76
- name: "ECDSAInvalidSignatureS",
77
- type: "error"
78
- },
79
- {
80
- inputs: [],
81
- name: "EndTimeInPast",
82
- type: "error"
83
- },
84
- {
85
- inputs: [],
86
- name: "ExtensionNotAllowed",
87
- type: "error"
88
- },
89
- {
90
- inputs: [],
91
- name: "InsufficientBalance",
92
- type: "error"
93
- },
94
- {
95
- inputs: [],
96
- name: "InsufficientFee",
97
- type: "error"
98
- },
99
- {
100
- inputs: [],
101
- name: "InvalidAddress",
102
- type: "error"
103
- },
104
- {
105
- inputs: [],
106
- name: "InvalidDuration",
107
- type: "error"
108
- },
109
- {
110
- inputs: [],
111
- name: "InvalidInitialization",
112
- type: "error"
113
- },
114
- {
115
- inputs: [],
116
- name: "InvalidSignature",
117
- type: "error"
118
- },
119
- {
120
- inputs: [],
121
- name: "InvalidStartTime",
122
- type: "error"
123
- },
124
- {
125
- inputs: [],
126
- name: "NotInitializing",
127
- type: "error"
128
- },
129
- {
130
- inputs: [
131
- {
132
- internalType: "bytes32",
133
- name: "handle",
134
- type: "bytes32"
135
- },
136
- {
137
- internalType: "address",
138
- name: "sender",
139
- type: "address"
140
- }
141
- ],
142
- name: "SenderNotAllowedToUseHandle",
143
- type: "error"
144
- },
145
- {
146
- inputs: [
147
- {
148
- internalType: "address",
149
- name: "sender",
150
- type: "address"
151
- }
152
- ],
153
- name: "SenderNotAllowed",
154
- type: "error"
155
- },
156
- {
157
- inputs: [],
158
- name: "SignatureAlreadyClaimed",
159
- type: "error"
160
- },
161
- {
162
- inputs: [],
163
- name: "TransferFailed",
164
- type: "error"
165
- },
166
- {
167
- inputs: [],
168
- name: "ZamaProtocolUnsupported",
169
- type: "error"
170
- },
171
- {
172
- inputs: [],
173
- name: "ZeroBalance",
174
- type: "error"
175
- },
176
- {
177
- anonymous: false,
178
- inputs: [
179
- {
180
- indexed: true,
181
- internalType: "address",
182
- name: "admin",
183
- type: "address"
184
- },
185
- {
186
- indexed: false,
187
- internalType: "uint32",
188
- name: "oldEndTime",
189
- type: "uint32"
190
- },
191
- {
192
- indexed: false,
193
- internalType: "uint32",
194
- name: "newEndTime",
195
- type: "uint32"
196
- }
197
- ],
198
- name: "ClaimWindowExtended",
199
- type: "event"
200
- },
201
- {
202
- anonymous: false,
203
- inputs: [
204
- {
205
- indexed: true,
206
- internalType: "address",
207
- name: "user",
208
- type: "address"
209
- },
210
- {
211
- indexed: false,
212
- internalType: "bytes32",
213
- name: "signatureHash",
214
- type: "bytes32"
215
- }
216
- ],
217
- name: "Claimed",
218
- type: "event"
219
- },
220
- {
221
- anonymous: false,
222
- inputs: [],
223
- name: "EIP712DomainChanged",
224
- type: "event"
225
- },
226
- {
227
- anonymous: false,
228
- inputs: [
229
- {
230
- indexed: true,
231
- internalType: "address",
232
- name: "recipient",
233
- type: "address"
234
- },
235
- {
236
- indexed: false,
237
- internalType: "uint256",
238
- name: "amount",
239
- type: "uint256"
240
- }
241
- ],
242
- name: "GasFeeWithdrawn",
243
- type: "event"
244
- },
245
- {
246
- anonymous: false,
247
- inputs: [
248
- {
249
- indexed: false,
250
- internalType: "uint64",
251
- name: "version",
252
- type: "uint64"
253
- }
254
- ],
255
- name: "Initialized",
256
- type: "event"
257
- },
258
- {
259
- anonymous: false,
260
- inputs: [
261
- {
262
- indexed: true,
263
- internalType: "address",
264
- name: "admin",
265
- type: "address"
266
- },
267
- {
268
- indexed: true,
269
- internalType: "address",
270
- name: "feeCollector",
271
- type: "address"
272
- },
273
- {
274
- indexed: false,
275
- internalType: "uint32",
276
- name: "endTime",
277
- type: "uint32"
278
- }
279
- ],
280
- name: "Initialized",
281
- type: "event"
282
- },
283
- {
284
- anonymous: false,
285
- inputs: [
286
- {
287
- indexed: true,
288
- internalType: "address",
289
- name: "admin",
290
- type: "address"
291
- },
292
- {
293
- indexed: true,
294
- internalType: "address",
295
- name: "token",
296
- type: "address"
297
- },
298
- {
299
- indexed: true,
300
- internalType: "address",
301
- name: "recipient",
302
- type: "address"
303
- }
304
- ],
305
- name: "OtherConfidentialTokenWithdrawn",
306
- type: "event"
307
- },
308
- {
309
- anonymous: false,
310
- inputs: [
311
- {
312
- indexed: true,
313
- internalType: "address",
314
- name: "admin",
315
- type: "address"
316
- },
317
- {
318
- indexed: true,
319
- internalType: "address",
320
- name: "token",
321
- type: "address"
322
- },
323
- {
324
- indexed: false,
325
- internalType: "uint256",
326
- name: "amount",
327
- type: "uint256"
328
- }
329
- ],
330
- name: "OtherTokenWithdrawn",
331
- type: "event"
332
- },
333
- {
334
- anonymous: false,
335
- inputs: [
336
- {
337
- indexed: false,
338
- internalType: "bool",
339
- name: "isPaused",
340
- type: "bool"
341
- }
342
- ],
343
- name: "PauseToggled",
344
- type: "event"
345
- },
346
- {
347
- anonymous: false,
348
- inputs: [
349
- {
350
- indexed: true,
351
- internalType: "bytes32",
352
- name: "role",
353
- type: "bytes32"
354
- },
355
- {
356
- indexed: true,
357
- internalType: "bytes32",
358
- name: "previousAdminRole",
359
- type: "bytes32"
360
- },
361
- {
362
- indexed: true,
363
- internalType: "bytes32",
364
- name: "newAdminRole",
365
- type: "bytes32"
366
- }
367
- ],
368
- name: "RoleAdminChanged",
369
- type: "event"
370
- },
371
- {
372
- anonymous: false,
373
- inputs: [
374
- {
375
- indexed: true,
376
- internalType: "bytes32",
377
- name: "role",
378
- type: "bytes32"
379
- },
380
- {
381
- indexed: true,
382
- internalType: "address",
383
- name: "account",
384
- type: "address"
385
- },
386
- {
387
- indexed: true,
388
- internalType: "address",
389
- name: "sender",
390
- type: "address"
391
- }
392
- ],
393
- name: "RoleGranted",
394
- type: "event"
395
- },
396
- {
397
- anonymous: false,
398
- inputs: [
399
- {
400
- indexed: true,
401
- internalType: "bytes32",
402
- name: "role",
403
- type: "bytes32"
404
- },
405
- {
406
- indexed: true,
407
- internalType: "address",
408
- name: "account",
409
- type: "address"
410
- },
411
- {
412
- indexed: true,
413
- internalType: "address",
414
- name: "sender",
415
- type: "address"
416
- }
417
- ],
418
- name: "RoleRevoked",
419
- type: "event"
420
- },
421
- {
422
- anonymous: false,
423
- inputs: [
424
- {
425
- indexed: true,
426
- internalType: "address",
427
- name: "admin",
428
- type: "address"
429
- },
430
- {
431
- indexed: true,
432
- internalType: "address",
433
- name: "recipient",
434
- type: "address"
435
- }
436
- ],
437
- name: "Withdrawn",
438
- type: "event"
439
- },
440
- {
441
- inputs: [],
442
- name: "CAN_EXTEND_CLAIM_WINDOW",
443
- outputs: [
444
- {
445
- internalType: "bool",
446
- name: "",
447
- type: "bool"
448
- }
449
- ],
450
- stateMutability: "view",
451
- type: "function"
452
- },
453
- {
454
- inputs: [],
455
- name: "CLAIM_TYPEHASH",
456
- outputs: [
457
- {
458
- internalType: "bytes32",
459
- name: "",
460
- type: "bytes32"
461
- }
462
- ],
463
- stateMutability: "view",
464
- type: "function"
465
- },
466
- {
467
- inputs: [],
468
- name: "DEFAULT_ADMIN_ROLE",
469
- outputs: [
470
- {
471
- internalType: "bytes32",
472
- name: "",
473
- type: "bytes32"
474
- }
475
- ],
476
- stateMutability: "view",
477
- type: "function"
478
- },
479
- {
480
- inputs: [],
481
- name: "DOMAIN_SEPARATOR",
482
- outputs: [
483
- {
484
- internalType: "bytes32",
485
- name: "",
486
- type: "bytes32"
487
- }
488
- ],
489
- stateMutability: "view",
490
- type: "function"
491
- },
492
- {
493
- inputs: [],
494
- name: "FEE_COLLECTOR_ROLE",
495
- outputs: [
496
- {
497
- internalType: "bytes32",
498
- name: "",
499
- type: "bytes32"
500
- }
501
- ],
502
- stateMutability: "view",
503
- type: "function"
504
- },
505
- {
506
- inputs: [],
507
- name: "GAS_FEE",
508
- outputs: [
509
- {
510
- internalType: "uint256",
511
- name: "",
512
- type: "uint256"
513
- }
514
- ],
515
- stateMutability: "view",
516
- type: "function"
517
- },
518
- {
519
- inputs: [],
520
- name: "START_TIME",
521
- outputs: [
522
- {
523
- internalType: "uint32",
524
- name: "",
525
- type: "uint32"
526
- }
527
- ],
528
- stateMutability: "view",
529
- type: "function"
530
- },
531
- {
532
- inputs: [],
533
- name: "TOKEN",
534
- outputs: [
535
- {
536
- internalType: "contract IERC7984",
537
- name: "",
538
- type: "address"
539
- }
540
- ],
541
- stateMutability: "view",
542
- type: "function"
543
- },
544
- {
545
- inputs: [
546
- {
547
- internalType: "externalEuint64",
548
- name: "inputAmount",
549
- type: "bytes32"
550
- },
551
- {
552
- internalType: "bytes",
553
- name: "inputProof",
554
- type: "bytes"
555
- },
556
- {
557
- internalType: "bytes",
558
- name: "signature",
559
- type: "bytes"
560
- }
561
- ],
562
- name: "claim",
563
- outputs: [],
564
- stateMutability: "payable",
565
- type: "function"
566
- },
567
- {
568
- inputs: [
569
- {
570
- internalType: "bytes32",
571
- name: "signatureHash",
572
- type: "bytes32"
573
- }
574
- ],
575
- name: "claimedSignatures",
576
- outputs: [
577
- {
578
- internalType: "bool",
579
- name: "isClaimed",
580
- type: "bool"
581
- }
582
- ],
583
- stateMutability: "view",
584
- type: "function"
585
- },
586
- {
587
- inputs: [],
588
- name: "deploymentBlockNumber",
589
- outputs: [
590
- {
591
- internalType: "uint256",
592
- name: "",
593
- type: "uint256"
594
- }
595
- ],
596
- stateMutability: "view",
597
- type: "function"
598
- },
599
- {
600
- inputs: [],
601
- name: "eip712Domain",
602
- outputs: [
603
- {
604
- internalType: "bytes1",
605
- name: "fields",
606
- type: "bytes1"
607
- },
608
- {
609
- internalType: "string",
610
- name: "name",
611
- type: "string"
612
- },
613
- {
614
- internalType: "string",
615
- name: "version",
616
- type: "string"
617
- },
618
- {
619
- internalType: "uint256",
620
- name: "chainId",
621
- type: "uint256"
622
- },
623
- {
624
- internalType: "address",
625
- name: "verifyingContract",
626
- type: "address"
627
- },
628
- {
629
- internalType: "bytes32",
630
- name: "salt",
631
- type: "bytes32"
632
- },
633
- {
634
- internalType: "uint256[]",
635
- name: "extensions",
636
- type: "uint256[]"
637
- }
638
- ],
639
- stateMutability: "view",
640
- type: "function"
641
- },
642
- {
643
- inputs: [],
644
- name: "endTime",
645
- outputs: [
646
- {
647
- internalType: "uint32",
648
- name: "",
649
- type: "uint32"
650
- }
651
- ],
652
- stateMutability: "view",
653
- type: "function"
654
- },
655
- {
656
- inputs: [
657
- {
658
- internalType: "uint32",
659
- name: "newEndTime",
660
- type: "uint32"
661
- }
662
- ],
663
- name: "extendClaimWindow",
664
- outputs: [],
665
- stateMutability: "nonpayable",
666
- type: "function"
667
- },
668
- {
669
- inputs: [
670
- {
671
- internalType: "externalEuint64",
672
- name: "inputAmount",
673
- type: "bytes32"
674
- },
675
- {
676
- internalType: "bytes",
677
- name: "inputProof",
678
- type: "bytes"
679
- },
680
- {
681
- internalType: "bytes",
682
- name: "signature",
683
- type: "bytes"
684
- }
685
- ],
686
- name: "getClaimAmount",
687
- outputs: [
688
- {
689
- internalType: "euint64",
690
- name: "encryptedAmount",
691
- type: "bytes32"
692
- }
693
- ],
694
- stateMutability: "nonpayable",
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
- name: "hasClaimEnded",
737
- outputs: [
738
- {
739
- internalType: "bool",
740
- name: "",
741
- type: "bool"
742
- }
743
- ],
744
- stateMutability: "view",
745
- type: "function"
746
- },
747
- {
748
- inputs: [],
749
- name: "hasClaimStarted",
750
- outputs: [
751
- {
752
- internalType: "bool",
753
- name: "",
754
- type: "bool"
755
- }
756
- ],
757
- stateMutability: "view",
758
- type: "function"
759
- },
760
- {
761
- inputs: [
762
- {
763
- internalType: "bytes32",
764
- name: "role",
765
- type: "bytes32"
766
- },
767
- {
768
- internalType: "address",
769
- name: "account",
770
- type: "address"
771
- }
772
- ],
773
- name: "hasRole",
774
- outputs: [
775
- {
776
- internalType: "bool",
777
- name: "",
778
- type: "bool"
779
- }
780
- ],
781
- stateMutability: "view",
782
- type: "function"
783
- },
784
- {
785
- inputs: [
786
- {
787
- internalType: "address",
788
- name: "_admin",
789
- type: "address"
790
- },
791
- {
792
- internalType: "address",
793
- name: "_feeCollector",
794
- type: "address"
795
- },
796
- {
797
- internalType: "uint32",
798
- name: "_endTime",
799
- type: "uint32"
800
- }
801
- ],
802
- name: "initialize",
803
- outputs: [],
804
- stateMutability: "nonpayable",
805
- type: "function"
806
- },
807
- {
808
- inputs: [],
809
- name: "isClaimWindowActive",
810
- outputs: [
811
- {
812
- internalType: "bool",
813
- name: "",
814
- type: "bool"
815
- }
816
- ],
817
- stateMutability: "view",
818
- type: "function"
819
- },
820
- {
821
- inputs: [],
822
- name: "isPaused",
823
- outputs: [
824
- {
825
- internalType: "bool",
826
- name: "",
827
- type: "bool"
828
- }
829
- ],
830
- stateMutability: "view",
831
- type: "function"
832
- },
833
- {
834
- inputs: [
835
- {
836
- internalType: "address",
837
- name: "user",
838
- type: "address"
839
- },
840
- {
841
- internalType: "externalEuint64",
842
- name: "encryptedAmount",
843
- type: "bytes32"
844
- }
845
- ],
846
- name: "isSignatureClaimed",
847
- outputs: [
848
- {
849
- internalType: "bool",
850
- name: "",
851
- type: "bool"
852
- }
853
- ],
854
- stateMutability: "view",
855
- type: "function"
856
- },
857
- {
858
- inputs: [
859
- {
860
- internalType: "externalEuint64",
861
- name: "inputAmount",
862
- type: "bytes32"
863
- },
864
- {
865
- internalType: "bytes",
866
- name: "signature",
867
- type: "bytes"
868
- }
869
- ],
870
- name: "isSignatureValid",
871
- outputs: [
872
- {
873
- internalType: "bool",
874
- name: "",
875
- type: "bool"
876
- }
877
- ],
878
- stateMutability: "view",
879
- type: "function"
880
- },
881
- {
882
- inputs: [
883
- {
884
- internalType: "bytes32",
885
- name: "role",
886
- type: "bytes32"
887
- },
888
- {
889
- internalType: "address",
890
- name: "callerConfirmation",
891
- type: "address"
892
- }
893
- ],
894
- name: "renounceRole",
895
- outputs: [],
896
- stateMutability: "nonpayable",
897
- type: "function"
898
- },
899
- {
900
- inputs: [
901
- {
902
- internalType: "bytes32",
903
- name: "role",
904
- type: "bytes32"
905
- },
906
- {
907
- internalType: "address",
908
- name: "account",
909
- type: "address"
910
- }
911
- ],
912
- name: "revokeRole",
913
- outputs: [],
914
- stateMutability: "nonpayable",
915
- type: "function"
916
- },
917
- {
918
- inputs: [
919
- {
920
- internalType: "bool",
921
- name: "paused",
922
- type: "bool"
923
- }
924
- ],
925
- name: "setPaused",
926
- outputs: [],
927
- stateMutability: "nonpayable",
928
- type: "function"
929
- },
930
- {
931
- inputs: [
932
- {
933
- internalType: "bytes4",
934
- name: "interfaceId",
935
- type: "bytes4"
936
- }
937
- ],
938
- name: "supportsInterface",
939
- outputs: [
940
- {
941
- internalType: "bool",
942
- name: "",
943
- type: "bool"
944
- }
945
- ],
946
- stateMutability: "view",
947
- type: "function"
948
- },
949
- {
950
- inputs: [
951
- {
952
- internalType: "address",
953
- name: "recipient",
954
- type: "address"
955
- }
956
- ],
957
- name: "withdraw",
958
- outputs: [],
959
- stateMutability: "nonpayable",
960
- type: "function"
961
- },
962
- {
963
- inputs: [
964
- {
965
- internalType: "address",
966
- name: "recipient",
967
- type: "address"
968
- },
969
- {
970
- internalType: "uint256",
971
- name: "amount",
972
- type: "uint256"
973
- }
974
- ],
975
- name: "withdrawGasFee",
976
- outputs: [],
977
- stateMutability: "nonpayable",
978
- type: "function"
979
- },
980
- {
981
- inputs: [
982
- {
983
- internalType: "address",
984
- name: "tokenAddress",
985
- type: "address"
986
- },
987
- {
988
- internalType: "address",
989
- name: "recipient",
990
- type: "address"
991
- }
992
- ],
993
- name: "withdrawOtherConfidentialToken",
994
- outputs: [],
995
- stateMutability: "nonpayable",
996
- type: "function"
997
- },
998
- {
999
- inputs: [
1000
- {
1001
- internalType: "address",
1002
- name: "tokenAddress",
1003
- type: "address"
1004
- },
1005
- {
1006
- internalType: "address",
1007
- name: "recipient",
1008
- type: "address"
1009
- }
1010
- ],
1011
- name: "withdrawOtherToken",
1012
- outputs: [],
1013
- stateMutability: "nonpayable",
1014
- type: "function"
1015
- }
1016
- ];
1017
-
1018
- // src/fhe-airdrop/errors.ts
1019
- var AlreadyClaimedError = class extends chunk2RNW4MIJ_cjs.TokenOpsSdkError {
1020
- name = "AlreadyClaimedError";
1021
- constructor(args) {
1022
- const who = args.caller ? `${args.caller}: ` : "";
1023
- super(`${args.method}: ${who}this airdrop claim has already been redeemed.`, {
1024
- code: "TOKENOPS_ALREADY_CLAIMED",
1025
- cause: args.cause,
1026
- context: {
1027
- method: args.method,
1028
- contractAddress: args.contractAddress,
1029
- caller: args.caller
1030
- }
1031
- });
1032
- }
1033
- };
1034
- var ClaimNotStartedError = class extends chunk2RNW4MIJ_cjs.TokenOpsSdkError {
1035
- name = "ClaimNotStartedError";
1036
- constructor(args) {
1037
- const detail = args.startsAt !== void 0 ? ` Opens at unix timestamp ${args.startsAt}.` : "";
1038
- super(`${args.method}: airdrop claim window has not started.${detail}`, {
1039
- code: "TOKENOPS_CLAIM_NOT_STARTED",
1040
- cause: args.cause,
1041
- context: {
1042
- method: args.method,
1043
- contractAddress: args.contractAddress,
1044
- startsAt: args.startsAt
1045
- }
1046
- });
1047
- }
1048
- };
1049
- var ClaimWindowClosedError = class extends chunk2RNW4MIJ_cjs.TokenOpsSdkError {
1050
- name = "ClaimWindowClosedError";
1051
- constructor(args) {
1052
- const detail = args.endedAt !== void 0 ? ` Closed at unix timestamp ${args.endedAt}.` : "";
1053
- super(`${args.method}: airdrop claim window has closed.${detail}`, {
1054
- code: "TOKENOPS_CLAIM_WINDOW_CLOSED",
1055
- cause: args.cause,
1056
- context: {
1057
- method: args.method,
1058
- contractAddress: args.contractAddress,
1059
- endedAt: args.endedAt
1060
- }
1061
- });
1062
- }
1063
- };
1064
- var CONFIDENTIAL_POOL_BALANCE_METHODS = /* @__PURE__ */ new Set([
1065
- "claim",
1066
- "withdraw",
1067
- "withdrawOtherConfidentialToken"
1068
- ]);
1069
- var airdropProductMapper = (name, _args, ctx) => {
1070
- switch (name) {
1071
- case "SignatureAlreadyClaimed":
1072
- return new AlreadyClaimedError(ctx);
1073
- case "ClaimNotStarted":
1074
- return new ClaimNotStartedError(ctx);
1075
- case "ClaimWindowFinished":
1076
- return new ClaimWindowClosedError(ctx);
1077
- // OZ ECDSA reverts surface from `isSignatureValid` when the signature
1078
- // bytes are structurally malformed (e.g. `s`-value out of range,
1079
- // 0-length, wrong length). Map to a single typed error so consumers
1080
- // can branch on `error.code === "TOKENOPS_INVALID_SIGNATURE"`.
1081
- case "ECDSAInvalidSignature":
1082
- case "ECDSAInvalidSignatureS":
1083
- case "ECDSAInvalidSignatureLength":
1084
- return new chunk2RNW4MIJ_cjs.InvalidSignatureError(ctx);
1085
- case "ZeroBalance":
1086
- case "InsufficientBalance":
1087
- return CONFIDENTIAL_POOL_BALANCE_METHODS.has(ctx.method) ? new chunk2RNW4MIJ_cjs.InsufficientBalanceError({ ...ctx, balanceKind: "confidential" }) : void 0;
1088
- default:
1089
- return void 0;
1090
- }
1091
- };
1092
- var ConfidentialAirdropClient = class {
1093
- publicClient;
1094
- walletClient;
1095
- address;
1096
- #aclAddressOverride;
1097
- #telemetry;
1098
- #cachedAclAddress;
1099
- constructor(config) {
1100
- this.publicClient = config.publicClient;
1101
- this.walletClient = config.walletClient;
1102
- this.address = config.address;
1103
- this.#telemetry = config.telemetry;
1104
- this.#aclAddressOverride = config.aclAddress;
1105
- const chainIdForInit = config.publicClient.chain?.id;
1106
- this.#telemetry?.event("fhe-airdrop.client.init", {
1107
- surface: "client",
1108
- chainId: chainIdForInit ?? null,
1109
- hasWallet: !!this.walletClient,
1110
- aclResolved: !!config.aclAddress || chainIdForInit !== void 0 && !!chunkSYHNZSZZ_cjs.getFhevmAclAddress(chainIdForInit),
1111
- sdkVersion: chunk43RFBQ73_cjs.SDK_VERSION
1112
- });
1113
- }
1114
- /**
1115
- * The FHEVM ACL contract address used by encrypted-view methods to parse
1116
- * `ACL.Allowed` events. Resolved lazily on first access; throws
1117
- * `DeploymentAddressUnavailableError` if no override was passed and the
1118
- * SDK does not have an ACL deployed for the connected chain.
1119
- */
1120
- get aclAddress() {
1121
- if (this.#cachedAclAddress) return this.#cachedAclAddress;
1122
- this.#cachedAclAddress = this.#aclAddressOverride ?? chunkSYHNZSZZ_cjs.requireFhevmAclAddress(this.publicClient.chain?.id, "ConfidentialAirdropClient");
1123
- return this.#cachedAclAddress;
1124
- }
1125
- // ============================================================
1126
- // IMMUTABLE READS
1127
- // ============================================================
1128
- /** ERC-7984 confidential token this airdrop was deployed for. Immutable arg. */
1129
- async token() {
1130
- return this.#read("TOKEN");
1131
- }
1132
- /** Per-claim gas fee in wei. Immutable arg. Attached as `msg.value` by `claim()` automatically. */
1133
- async gasFee() {
1134
- return this.#read("GAS_FEE");
1135
- }
1136
- /** Unix timestamp when claims become available. Immutable arg. */
1137
- async startTime() {
1138
- return this.#read("START_TIME");
1139
- }
1140
- /** Whether the admin can extend the claim window past `endTime`. Immutable arg. */
1141
- async canExtendClaimWindow() {
1142
- return this.#read("CAN_EXTEND_CLAIM_WINDOW");
1143
- }
1144
- // ============================================================
1145
- // STORAGE READS
1146
- // ============================================================
1147
- /** Unix timestamp when claims end. Mutable — can be extended by admin if `canExtendClaimWindow`. */
1148
- async endTime() {
1149
- return this.#read("endTime");
1150
- }
1151
- /** Whether claims are currently paused by the admin. */
1152
- async isPaused() {
1153
- return this.#read("isPaused");
1154
- }
1155
- /** Block number at which this clone was deployed. */
1156
- async deploymentBlockNumber() {
1157
- return this.#read("deploymentBlockNumber");
1158
- }
1159
- /**
1160
- * Check whether a pre-computed signature hash has been consumed.
1161
- *
1162
- * The contract keys claim replay-protection on
1163
- * `keccak256(abi.encode(CLAIM_TYPEHASH, recipient, bytes32(encryptedAmountHandle)))`.
1164
- * Use this when you already hold the struct hash (e.g. you computed it server-side
1165
- * while building the claim payload). For the more common case where you hold the
1166
- * user address and the encrypted handle, use {@link isSignatureClaimed} instead —
1167
- * it computes the hash for you.
1168
- *
1169
- * @param signatureHash `bytes32` storage key — the EIP-712 struct hash of the Claim.
1170
- */
1171
- async claimedSignatures(signatureHash) {
1172
- return this.#read("claimedSignatures", [signatureHash]);
1173
- }
1174
- // ============================================================
1175
- // VIEW FUNCTIONS
1176
- // ============================================================
1177
- /** `true` if within the claim time window and not paused. Free read — no gas. */
1178
- async isClaimWindowActive() {
1179
- return this.#read("isClaimWindowActive");
1180
- }
1181
- /** `true` if the current timestamp is past `START_TIME`. */
1182
- async hasClaimStarted() {
1183
- return this.#read("hasClaimStarted");
1184
- }
1185
- /** `true` if the current timestamp is past `endTime`. */
1186
- async hasClaimEnded() {
1187
- return this.#read("hasClaimEnded");
1188
- }
1189
- /** EIP-712 domain separator for the clone. Useful for off-chain signing tools. */
1190
- async domainSeparator() {
1191
- return this.#read("DOMAIN_SEPARATOR");
1192
- }
1193
- /**
1194
- * EIP-712 type hash for the `Claim(address recipient, bytes32 encryptedAmount)`
1195
- * struct. Off-chain signers that don't use {@link signClaimAuthorization}
1196
- * (e.g. custom HSM-backed signers, ledger flows) need this to assemble the
1197
- * typed-data payload manually.
1198
- */
1199
- async claimTypehash() {
1200
- return this.#read("CLAIM_TYPEHASH");
1201
- }
1202
- /**
1203
- * Check whether a claim has been consumed, given the user address and encrypted amount handle.
1204
- *
1205
- * This is the method most frontend developers want. Pass the same `user` and
1206
- * `encryptedAmountHandle` that appear in the admin-issued claim payload; the contract
1207
- * recomputes the struct hash internally and looks it up in storage.
1208
- *
1209
- * Prefer this over {@link claimedSignatures} unless you already hold the pre-computed
1210
- * `bytes32` struct hash (e.g. from a server-side indexer).
1211
- *
1212
- * @param user Recipient address from the claim authorization.
1213
- * @param encryptedAmountHandle The `externalEuint64` handle (as `Hex`) from the claim payload.
1214
- */
1215
- async isSignatureClaimed(user, encryptedAmountHandle) {
1216
- return this.#read("isSignatureClaimed", [user, encryptedAmountHandle]);
1217
- }
1218
- /**
1219
- * Check whether an admin-issued claim authorization is valid for a specific caller,
1220
- * without consuming it.
1221
- *
1222
- * Returns `false` (not a revert) when the signature is **structurally valid** but
1223
- * fails one of the on-chain checks: already-claimed, claim window inactive, or the
1224
- * signer lacks `DEFAULT_ADMIN_ROLE`. The on-chain implementation recomputes the
1225
- * EIP-712 struct hash over `(msg.sender, encryptedAmount)`, so the result is
1226
- * caller-specific: a signature issued for recipient A is invalid when checked
1227
- * against caller B. Pass the address that will actually submit the claim.
1228
- *
1229
- * **Throws** {@link InvalidSignatureError} (code `TOKENOPS_INVALID_SIGNATURE`)
1230
- * when the signature bytes are **structurally malformed** — wrong length, invalid
1231
- * `s`-value range, or unparseable. The on-chain `ECDSA.recover` reverts before
1232
- * the boolean logic runs in that case, so consumer code must catch this
1233
- * separately from the `false` return:
1234
- *
1235
- * ```ts
1236
- * try {
1237
- * const ok = await airdrop.isSignatureValid({ encryptedAmountHandle, signature, caller });
1238
- * if (!ok) { /* signed by non-admin, window closed, or already claimed *\/ }
1239
- * } catch (err) {
1240
- * if (err instanceof InvalidSignatureError) { /* malformed signature bytes *\/ }
1241
- * }
1242
- * ```
1243
- *
1244
- * Use this to show a pre-claim validation state in the UI before asking the user to
1245
- * pay gas.
1246
- */
1247
- async isSignatureValid(args) {
1248
- try {
1249
- return await this.publicClient.readContract({
1250
- address: this.address,
1251
- abi: confidentialAirdropCloneableAbi,
1252
- functionName: "isSignatureValid",
1253
- args: [args.encryptedAmountHandle, args.signature],
1254
- account: args.caller
1255
- });
1256
- } catch (err) {
1257
- throw chunk43RFBQ73_cjs.mapContractRevert(err, {
1258
- method: "isSignatureValid",
1259
- contractAddress: this.address,
1260
- abi: confidentialAirdropCloneableAbi,
1261
- productMapper: airdropProductMapper,
1262
- account: args.caller
1263
- });
1264
- }
1265
- }
1266
- // ============================================================
1267
- // PREFLIGHT
1268
- // ============================================================
1269
- /**
1270
- * Read-only preflight for {@link claim}. Runs the deterministic-from-off-chain
1271
- * checks in parallel and reports any blockers as typed {@link TokenOpsSdkError}s.
1272
- * Returns `{ ready: true, blockers: [] }` when the claim is safe to submit.
1273
- *
1274
- * Preflight is **opt-in**. Consumers who have already validated state can
1275
- * skip this call and invoke `claim` directly — they'll receive the same
1276
- * typed errors at write time via the revert mapper.
1277
- *
1278
- * Checks performed (all read-only, no gas):
1279
- * - Claim window started (`block.timestamp ≥ START_TIME`).
1280
- * - Claim window not closed (`block.timestamp ≤ endTime`).
1281
- * - Claims not paused.
1282
- * - Signature not already redeemed by this caller.
1283
- * - ETH balance covers `GAS_FEE()` (the `msg.value` the claim must attach).
1284
- *
1285
- * The EIP-712 admin-signature check is **not** preflight-detectable — the
1286
- * SDK cannot verify the signer's role without the contract round-trip — and
1287
- * will still surface as {@link InvalidSignatureError} at write time.
1288
- *
1289
- * Pool balance is also **not** preflight-detectable: the clone's confidential
1290
- * balance is an encrypted `euint64` handle that the SDK cannot read in
1291
- * plaintext. An unfunded clone will pass preflight and revert on-chain with
1292
- * {@link FheHandleNotAllowedError} (the FHEVM ACL rejects `FHE.allowTransient`
1293
- * on an uninitialized handle). Confirm the pool has been funded before
1294
- * showing `ready: true`.
1295
- *
1296
- * @returns `{ ready, blockers }` — same `code` shape the write would throw.
1297
- */
1298
- async preflightClaim(args) {
1299
- const blockers = [];
1300
- const [startTime, endTime, isPaused, isClaimed, block, gasFee, callerBalance] = await Promise.all([
1301
- this.startTime(),
1302
- this.endTime(),
1303
- this.isPaused(),
1304
- this.isSignatureClaimed(args.caller, args.encryptedAmountHandle),
1305
- this.publicClient.getBlock(),
1306
- this.gasFee(),
1307
- this.publicClient.getBalance({ address: args.caller })
1308
- ]);
1309
- const now = Number(block.timestamp);
1310
- if (isPaused) {
1311
- blockers.push(new chunk2RNW4MIJ_cjs.PausedError({ method: "claim", contractAddress: this.address }));
1312
- }
1313
- if (now < startTime) {
1314
- blockers.push(
1315
- new ClaimNotStartedError({
1316
- method: "claim",
1317
- contractAddress: this.address,
1318
- startsAt: startTime
1319
- })
1320
- );
1321
- }
1322
- if (now > endTime) {
1323
- blockers.push(
1324
- new ClaimWindowClosedError({
1325
- method: "claim",
1326
- contractAddress: this.address,
1327
- endedAt: endTime
1328
- })
1329
- );
1330
- }
1331
- if (isClaimed) {
1332
- blockers.push(
1333
- new AlreadyClaimedError({
1334
- method: "claim",
1335
- contractAddress: this.address,
1336
- caller: args.caller
1337
- })
1338
- );
1339
- }
1340
- if (callerBalance < gasFee) {
1341
- blockers.push(
1342
- new chunk2RNW4MIJ_cjs.InsufficientFeeError({
1343
- method: "claim",
1344
- contractAddress: this.address,
1345
- feeKind: "gas",
1346
- required: gasFee,
1347
- provided: callerBalance
1348
- })
1349
- );
1350
- }
1351
- return { ready: blockers.length === 0, blockers };
1352
- }
1353
- // ============================================================
1354
- // CLAIM (USER OP)
1355
- // ============================================================
1356
- /**
1357
- * Claim tokens using an EIP-712 admin signature. Sends `GAS_FEE()` ETH with the tx.
1358
- *
1359
- * The `encryptedInput` must be the exact handle the admin signed in
1360
- * {@link signClaimAuthorization}. The signature commits to that handle, so the SDK
1361
- * does NOT re-encrypt — submit the admin-issued payload as-is.
1362
- *
1363
- * **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.
1364
- *
1365
- * **An unfunded pool is the opposite case — it reverts loudly.** Do not
1366
- * generalize the silent-zero rule above to a clone whose pool was never
1367
- * funded: that claim throws {@link FheHandleNotAllowedError} (the FHEVM ACL
1368
- * rejects `FHE.allowTransient` on an uninitialized handle), and
1369
- * {@link preflightClaim} cannot detect it because the pool balance is an
1370
- * encrypted `euint64` the SDK cannot read in plaintext.
1371
- *
1372
- * @returns Transaction hash.
1373
- * @example
1374
- * const fee = await airdrop.gasFee();
1375
- * const hash = await airdrop.claim({ encryptedInput, signature });
1376
- */
1377
- async claim(args) {
1378
- const wallet = this.#requireWallet("claim");
1379
- const account = this.#resolveAccount(wallet, args.account, "claim");
1380
- const fee = args.value ?? await this.gasFee();
1381
- const writeArgs = [
1382
- args.encryptedInput.handle,
1383
- args.encryptedInput.inputProof,
1384
- args.signature
1385
- ];
1386
- await this.#preflightWrite("claim", "claim", writeArgs, account, fee);
1387
- try {
1388
- return await wallet.writeContract({
1389
- address: this.address,
1390
- abi: confidentialAirdropCloneableAbi,
1391
- functionName: "claim",
1392
- args: writeArgs,
1393
- account,
1394
- chain: wallet.chain,
1395
- value: fee
1396
- });
1397
- } catch (err) {
1398
- throw this.#mapRevert("claim", err, accountAddress(account));
1399
- }
1400
- }
1401
- /**
1402
- * **This is a write transaction, not a free view. It costs gas.**
1403
- *
1404
- * Verify the admin-signed claim allocation and grant the caller decrypt access
1405
- * to the encrypted amount. Budget gas and `await` the receipt before calling
1406
- * the Zama relayer's `userDecrypt` — the handle is only valid after the tx lands.
1407
- *
1408
- * Internally the contract calls `FHE.allow(handle, msg.sender)`, which persists
1409
- * the ACL grant on-chain. The handle is extracted from the receipt's ACL `Allowed`
1410
- * event — `simulateContract` would return a divergent handle and break decryption.
1411
- *
1412
- * Does **not** consume the claim (the `claimedSignatures` bit is not set). Call
1413
- * {@link claim} when the user is ready to transfer tokens.
1414
- *
1415
- * @returns `{ handle, hash }` — `handle` is a `euint64` granted to the caller;
1416
- * pass it to the Zama relayer's `userDecrypt` to obtain the plaintext amount.
1417
- */
1418
- async getClaimAmount(args) {
1419
- const wallet = this.#requireWallet("getClaimAmount");
1420
- const account = this.#resolveAccount(wallet, args.account, "getClaimAmount");
1421
- const writeArgs = [
1422
- args.encryptedInput.handle,
1423
- args.encryptedInput.inputProof,
1424
- args.signature
1425
- ];
1426
- await this.#preflightWrite("getClaimAmount", "getClaimAmount", writeArgs, account);
1427
- let hash;
1428
- try {
1429
- hash = await wallet.writeContract({
1430
- address: this.address,
1431
- abi: confidentialAirdropCloneableAbi,
1432
- functionName: "getClaimAmount",
1433
- args: writeArgs,
1434
- account,
1435
- chain: wallet.chain
1436
- });
1437
- } catch (err) {
1438
- throw this.#mapRevert("getClaimAmount", err, accountAddress(account));
1439
- }
1440
- const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
1441
- const callerAddress = accountAddress(account).toLowerCase();
1442
- const aclLogs = receipt.logs.filter(
1443
- (log) => log.address.toLowerCase() === this.aclAddress.toLowerCase()
1444
- );
1445
- const events = viem.parseEventLogs({ abi: [chunkSYHNZSZZ_cjs.ACL_ALLOWED_EVENT], logs: aclLogs });
1446
- const granted = events.filter(
1447
- (ev) => ev.args.account.toLowerCase() === callerAddress && ev.args.caller.toLowerCase() === this.address.toLowerCase()
1448
- );
1449
- if (granted.length === 0) {
1450
- throw new chunk2RNW4MIJ_cjs.ReceiptEventNotFoundError({
1451
- method: "getClaimAmount",
1452
- eventName: "Allowed",
1453
- contractAddress: this.aclAddress,
1454
- txHash: hash,
1455
- hint: `Expected ACL grant from airdrop ${this.address} to caller ${callerAddress}; the contract did not grant decrypt access.`
1456
- });
1457
- }
1458
- if (granted.length > 1) {
1459
- throw new chunk2RNW4MIJ_cjs.ReceiptEventAmbiguousError({
1460
- method: "getClaimAmount",
1461
- eventName: "Allowed",
1462
- contractAddress: this.aclAddress,
1463
- txHash: hash,
1464
- count: granted.length
1465
- });
1466
- }
1467
- const handle = granted[0].args.handle;
1468
- return { handle, hash };
1469
- }
1470
- // ============================================================
1471
- // ADMIN WRITES
1472
- // ============================================================
1473
- /**
1474
- * Withdraw all confidential tokens to `recipient`. `DEFAULT_ADMIN_ROLE` only.
1475
- *
1476
- * Calling on a clone whose pool was **never funded** throws
1477
- * {@link FheHandleNotAllowedError} (code `TOKENOPS_FHE_HANDLE_NOT_ALLOWED`).
1478
- * The contract calls `FHE.allowTransient` on the confidential balance handle;
1479
- * when the handle is uninitialized, the FHEVM ACL contract reverts with
1480
- * `SenderNotAllowed(address)`. Confirm the pool has been funded (e.g. via the
1481
- * factory's `createAndFund...` variant or a follow-up `confidentialTransfer`)
1482
- * before calling.
1483
- */
1484
- async withdraw(recipient, account) {
1485
- this.#requireChecksumAddress("withdraw", "recipient", recipient);
1486
- return this.#simpleWrite("withdraw", [recipient], account);
1487
- }
1488
- /** Pause or unpause claims. DEFAULT_ADMIN_ROLE only. */
1489
- async setPaused(paused, account) {
1490
- return chunkVJKZWYYJ_cjs.withTelemetry(this.#telemetry, "fhe-airdrop.client.setPaused", async () => {
1491
- return this.#simpleWrite("setPaused", [paused], account);
1492
- });
1493
- }
1494
- /**
1495
- * Extend the claim window end time. DEFAULT_ADMIN_ROLE only.
1496
- * Requires `CAN_EXTEND_CLAIM_WINDOW == true` or the contract reverts.
1497
- */
1498
- async extendClaimWindow(newEndTime, account) {
1499
- return chunkVJKZWYYJ_cjs.withTelemetry(this.#telemetry, "fhe-airdrop.client.extendClaimWindow", async () => {
1500
- return this.#simpleWrite("extendClaimWindow", [newEndTime], account);
1501
- });
1502
- }
1503
- /** Rescue accidentally sent ERC20 tokens. DEFAULT_ADMIN_ROLE only. */
1504
- async withdrawOtherToken(tokenAddress, recipient, account) {
1505
- this.#requireChecksumAddress("withdrawOtherToken", "tokenAddress", tokenAddress);
1506
- this.#requireChecksumAddress("withdrawOtherToken", "recipient", recipient);
1507
- return this.#simpleWrite("withdrawOtherToken", [tokenAddress, recipient], account);
1508
- }
1509
- /** Rescue accidentally sent ERC7984 confidential tokens. DEFAULT_ADMIN_ROLE only. */
1510
- async withdrawOtherConfidentialToken(tokenAddress, recipient, account) {
1511
- this.#requireChecksumAddress("withdrawOtherConfidentialToken", "tokenAddress", tokenAddress);
1512
- this.#requireChecksumAddress("withdrawOtherConfidentialToken", "recipient", recipient);
1513
- return this.#simpleWrite("withdrawOtherConfidentialToken", [tokenAddress, recipient], account);
1514
- }
1515
- // ============================================================
1516
- // FEE COLLECTOR WRITES
1517
- // ============================================================
1518
- /**
1519
- * Withdraw collected ETH gas fees. FEE_COLLECTOR_ROLE only.
1520
- * Pass `amount = 0n` to withdraw the entire balance.
1521
- */
1522
- async withdrawGasFee(recipient, amount, account) {
1523
- this.#requireChecksumAddress("withdrawGasFee", "recipient", recipient);
1524
- return this.#simpleWrite("withdrawGasFee", [recipient, amount], account);
1525
- }
1526
- // ============================================================
1527
- // ROLE MANAGEMENT
1528
- // ============================================================
1529
- async hasRole(role, account) {
1530
- return this.#read("hasRole", [role, account]);
1531
- }
1532
- async grantRole(role, accountTarget, account) {
1533
- return chunkVJKZWYYJ_cjs.withTelemetry(this.#telemetry, "fhe-airdrop.client.grantRole", async () => {
1534
- return this.#simpleWrite("grantRole", [role, accountTarget], account);
1535
- });
1536
- }
1537
- async revokeRole(role, accountTarget, account) {
1538
- return chunkVJKZWYYJ_cjs.withTelemetry(this.#telemetry, "fhe-airdrop.client.revokeRole", async () => {
1539
- return this.#simpleWrite("revokeRole", [role, accountTarget], account);
1540
- });
1541
- }
1542
- // ============================================================
1543
- // INTERNALS
1544
- // ============================================================
1545
- #requireChecksumAddress(method, argument, value) {
1546
- if (!viem.isAddress(value, { strict: true })) {
1547
- throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
1548
- method,
1549
- argument,
1550
- reason: "must be a valid EIP-55 checksummed address",
1551
- value
1552
- });
1553
- }
1554
- }
1555
- #requireWallet(method) {
1556
- if (!this.walletClient) {
1557
- throw new chunk2RNW4MIJ_cjs.MissingWalletClientError(method);
1558
- }
1559
- return this.walletClient;
1560
- }
1561
- #resolveAccount(wallet, override, method) {
1562
- const acct = override ?? wallet.account;
1563
- if (!acct) {
1564
- throw new chunk2RNW4MIJ_cjs.MissingAccountError(method);
1565
- }
1566
- if (typeof acct === "string") {
1567
- this.#requireChecksumAddress(method, "account", acct);
1568
- }
1569
- return acct;
1570
- }
1571
- #mapRevert(method, err, account) {
1572
- return chunk43RFBQ73_cjs.mapContractRevert(err, {
1573
- method,
1574
- contractAddress: this.address,
1575
- abi: confidentialAirdropCloneableAbi,
1576
- productMapper: airdropProductMapper,
1577
- account
1578
- });
1579
- }
1580
- async #simpleWrite(functionName, args, account) {
1581
- const wallet = this.#requireWallet(functionName);
1582
- const acct = this.#resolveAccount(wallet, account, functionName);
1583
- await this.#preflightWrite(functionName, functionName, args, acct);
1584
- try {
1585
- return await wallet.writeContract({
1586
- address: this.address,
1587
- abi: confidentialAirdropCloneableAbi,
1588
- functionName,
1589
- args,
1590
- account: acct,
1591
- chain: wallet.chain
1592
- });
1593
- } catch (err) {
1594
- throw this.#mapRevert(functionName, err, accountAddress(acct));
1595
- }
1596
- }
1597
- /**
1598
- * Pre-flight a write via `simulateContract` purely to surface typed reverts.
1599
- *
1600
- * The simulate's *return value* is discarded — FHE writes still need
1601
- * `writeContract` + receipt parsing because simulated FHE op handles diverge
1602
- * from the executed-tx handles (CLAUDE.md Pitfall #1). The only purpose of
1603
- * this call is to let viem decode any revert against the ABI and produce a
1604
- * `ContractFunctionRevertedError` frame the revert-mapper can classify.
1605
- */
1606
- async #preflightWrite(method, functionName, args, account, value) {
1607
- try {
1608
- await this.publicClient.simulateContract({
1609
- address: this.address,
1610
- abi: confidentialAirdropCloneableAbi,
1611
- functionName,
1612
- args,
1613
- account,
1614
- ...value !== void 0 ? { value } : {}
1615
- });
1616
- } catch (err) {
1617
- if (chunk43RFBQ73_cjs.isContractRevert(err)) {
1618
- throw this.#mapRevert(method, err, accountAddress(account));
1619
- }
1620
- }
1621
- }
1622
- async #read(functionName, args = []) {
1623
- const result = await this.publicClient.readContract({
1624
- address: this.address,
1625
- abi: confidentialAirdropCloneableAbi,
1626
- functionName,
1627
- args
1628
- });
1629
- return result;
1630
- }
1631
- };
1632
- function createConfidentialAirdropClient(config) {
1633
- return new ConfidentialAirdropClient(config);
1634
- }
1635
- function accountAddress(account) {
1636
- return typeof account === "string" ? account : account.address;
1637
- }
1638
-
1639
- exports.AlreadyClaimedError = AlreadyClaimedError;
1640
- exports.ClaimNotStartedError = ClaimNotStartedError;
1641
- exports.ClaimWindowClosedError = ClaimWindowClosedError;
1642
- exports.ConfidentialAirdropClient = ConfidentialAirdropClient;
1643
- exports.confidentialAirdropCloneableAbi = confidentialAirdropCloneableAbi;
1644
- exports.createConfidentialAirdropClient = createConfidentialAirdropClient;