@tokenops/sdk 1.5.1 → 2.0.0-alpha.1

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