@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
@@ -0,0 +1,263 @@
1
+ import type { Address, Hex } from "viem";
2
+ import type { EncryptedInput, EncryptedViewResult } from "../fhe/types.js";
3
+ import { AirdropBaseClient, type AirdropBaseClientConfig, type WriteAccountOverride } from "./airdrop-base.js";
4
+ import type { DedupMode } from "./constants.js";
5
+ /**
6
+ * EIP-712 domain name every `ECDSAConfidentialAirdrop` instance shares. Set once, at `initialize`.
7
+ *
8
+ * @alpha
9
+ */
10
+ export declare const EIP712_DOMAIN_NAME = "ConfidentialAirdrop";
11
+ /**
12
+ * EIP-712 domain version every `ECDSAConfidentialAirdrop` instance shares.
13
+ *
14
+ * @alpha
15
+ */
16
+ export declare const EIP712_DOMAIN_VERSION = "1";
17
+ /**
18
+ * The `Claim` struct's EIP-712 type declaration, field-for-field in the
19
+ * contract's declared order. v2 adds `dedupId` and `deadline` to v1's
20
+ * two-field struct.
21
+ *
22
+ * @alpha
23
+ */
24
+ export declare const CLAIM_TYPES: {
25
+ readonly Claim: readonly [{
26
+ readonly name: "recipient";
27
+ readonly type: "address";
28
+ }, {
29
+ readonly name: "encryptedAmount";
30
+ readonly type: "bytes32";
31
+ }, {
32
+ readonly name: "dedupId";
33
+ readonly type: "bytes32";
34
+ }, {
35
+ readonly name: "deadline";
36
+ readonly type: "uint256";
37
+ }];
38
+ };
39
+ /**
40
+ * `CLAIM_TYPEHASH`, computed client-side from {@link CLAIM_TYPES} exactly as
41
+ * Solidity computes its `bytes32 public constant CLAIM_TYPEHASH`. Exported so
42
+ * a caller can sanity-check the binding without an RPC round trip;
43
+ * {@link EcdsaAirdropClient.claimTypehash} reads the live on-chain value for
44
+ * the paranoid case where an instance was deployed off a diverged contract
45
+ * build.
46
+ *
47
+ * @alpha
48
+ */
49
+ export declare const CLAIM_TYPEHASH: `0x${string}`;
50
+ /** @alpha */
51
+ export interface EcdsaAirdropClientConfig extends AirdropBaseClientConfig {
52
+ /**
53
+ * The replay-protection policy this instance was deployed with
54
+ * (`perAddress` / `perDedupId` / `both` / `none`).
55
+ *
56
+ * Required at construction because the contract exposes **no on-chain
57
+ * getter** for it: `ECDSADedupStorage.dedupMode`
58
+ * (`ConfidentialAirdropECDSAStorage.sol`) is a private field inside an
59
+ * ERC-7201 namespaced storage struct, unreachable through any ABI-visible
60
+ * read — every other constant this client exposes (`SIGNER_ROLE`,
61
+ * `CLAIM_TYPEHASH`, `DOMAIN_SEPARATOR`) has a public getter; this one does
62
+ * not. Pass the same value used at
63
+ * `factory.createEcdsaAirdrop({ params: { dedupMode } })` time.
64
+ */
65
+ dedupMode: DedupMode;
66
+ }
67
+ /**
68
+ * Inputs shared by {@link EcdsaAirdropClient.claim} and {@link EcdsaAirdropClient.claimAndUnwrap}.
69
+ *
70
+ * @alpha
71
+ */
72
+ export interface EcdsaClaimArgs extends WriteAccountOverride {
73
+ /**
74
+ * Payout destination. Omit (or pass the zero address) to default to the
75
+ * sending account — mirrors the contract's own `to == address(0)` redirect
76
+ * rule. Authorization (the signature), replay dedup and the FHE input
77
+ * proof all stay bound to the sending account regardless of `to`; this
78
+ * field only redirects where the tokens (and the recipient ACL) land.
79
+ */
80
+ to?: Address;
81
+ /** The claimant's encrypted allocation, bound to `(airdrop, sendingAccount)` at encryption time. */
82
+ encryptedInput: EncryptedInput;
83
+ /** The off-chain claim id bound into the signature. */
84
+ dedupId: Hex;
85
+ /** Unix seconds the signature expires at. Past this, the contract reverts `SignatureExpired`. */
86
+ deadline: bigint;
87
+ /** The `SIGNER_ROLE` holder that authorized this claim. */
88
+ signer: Address;
89
+ /** The EIP-712 signature from `signClaimAuthorization` (`./encryption.js`). */
90
+ signature: Hex;
91
+ }
92
+ /**
93
+ * Inputs for {@link EcdsaAirdropClient.getClaimAmount}.
94
+ *
95
+ * @alpha
96
+ */
97
+ export interface GetClaimAmountArgs extends WriteAccountOverride {
98
+ encryptedInput: EncryptedInput;
99
+ dedupId: Hex;
100
+ deadline: bigint;
101
+ signer: Address;
102
+ signature: Hex;
103
+ }
104
+ /**
105
+ * Inputs for {@link EcdsaAirdropClient.isSignatureValid}.
106
+ *
107
+ * @alpha
108
+ */
109
+ export interface IsSignatureValidArgs {
110
+ /**
111
+ * The address the signature was made out to — the contract's digest binds
112
+ * `msg.sender`, so this read is simulated as an `eth_call` from
113
+ * `recipient`, not from whatever account the SDK happens to be configured
114
+ * with. Passing the wrong address always returns `false` for a signature
115
+ * that would otherwise succeed.
116
+ */
117
+ recipient: Address;
118
+ /** The external encrypted allocation handle — no input proof: this is a view, it never calls `FHE.fromExternal`. */
119
+ encryptedAmountHandle: Hex;
120
+ dedupId: Hex;
121
+ deadline: bigint;
122
+ signer: Address;
123
+ signature: Hex;
124
+ }
125
+ /**
126
+ * Client for one `ECDSAConfidentialAirdrop` instance — the variant whose
127
+ * claims are authorised by an off-chain EIP-712 signature from a
128
+ * `SIGNER_ROLE` holder, rather than a Merkle proof.
129
+ *
130
+ * Adds the claim surface on top of {@link AirdropBaseClient}'s shared
131
+ * lifecycle/treasury/rescue/role/disclosure methods: `claim` /
132
+ * `claimAndUnwrap` submit a signed allocation, `getClaimAmount` previews it
133
+ * as a decryptable handle without consuming replay state, and
134
+ * `isSignatureValid` gas-optimistically checks all of the above without
135
+ * spending an FHE op.
136
+ *
137
+ * Every claim entrypoint here takes the exact-equality gas fee
138
+ * ({@link AirdropBaseClient.gasFee}) automatically — read fresh on every
139
+ * `claim`/`claimAndUnwrap` call and attached as the transaction's `value`, so
140
+ * a caller never has to source it themselves or risk sending the wrong
141
+ * amount against the contract's `msg.value != gasFee()` revert.
142
+ *
143
+ * @example
144
+ * const airdrop = new EcdsaAirdropClient({ publicClient, walletClient, address, dedupMode: "perAddress" });
145
+ * const hash = await airdrop.claim({ encryptedInput, dedupId, deadline, signer, signature });
146
+ *
147
+ * @alpha
148
+ */
149
+ export declare class EcdsaAirdropClient extends AirdropBaseClient {
150
+ /** @see EcdsaAirdropClientConfig.dedupMode */
151
+ readonly dedupMode: DedupMode;
152
+ constructor(config: EcdsaAirdropClientConfig);
153
+ /**
154
+ * Claim a signed encrypted allocation, delivering the tokens to `to`
155
+ * (defaults to the sending account).
156
+ *
157
+ * Consumes this instance's `dedupMode` replay guard(s) and the defense-in-
158
+ * depth EIP-712 digest guard. Requires `msg.value == gasFee()` exactly —
159
+ * handled for you; see the class TSDoc.
160
+ *
161
+ * @throws {@link ClaimNotStartedError} before `startTime`.
162
+ * @throws {@link ClaimWindowClosedError} after `endTime`.
163
+ * @throws {@link SignatureExpiredError} after `args.deadline` has passed.
164
+ * @throws {@link InvalidSignatureError} when `signer` lacks `SIGNER_ROLE` or the signature does not verify.
165
+ * @throws {@link AlreadyClaimedError} on an address or digest replay.
166
+ * @throws {@link DedupIdConsumedError} on a `dedupId` replay under `perDedupId`/`both`.
167
+ * @returns The transaction hash.
168
+ */
169
+ claim(args: EcdsaClaimArgs): Promise<Hex>;
170
+ /**
171
+ * Claim then route the allocation straight into the wrapper's unwrap
172
+ * (`to` becomes the underlying ERC-20 beneficiary). Reverts
173
+ * `TokenNotUnwrappable` (surfaced as `FeatureDisabledError`) on a
174
+ * non-unwrappable campaign.
175
+ *
176
+ * Same replay consumption and `msg.value == gasFee()` requirement as
177
+ * {@link claim}.
178
+ *
179
+ * @returns The transaction hash. The underlying ERC-20 is released later by
180
+ * a separate, permissionless `finalizeUnwrap` — this hash is only the
181
+ * unwrap request.
182
+ */
183
+ claimAndUnwrap(args: EcdsaClaimArgs): Promise<Hex>;
184
+ /**
185
+ * Preview a signed allocation as a handle the caller can decrypt, without
186
+ * consuming either replay guard — the same input can still be claimed for
187
+ * real afterwards. No fee.
188
+ *
189
+ * An encrypted view: the contract calls `FHE.allow(amount, msg.sender)`, so
190
+ * the result is recovered from the receipt's ACL `Allowed` event, never
191
+ * from a simulation. See {@link AirdropBaseClient}'s class TSDoc.
192
+ *
193
+ * @returns `{ handle, hash }` — pass `handle` to the Zama relayer's `userDecrypt`.
194
+ */
195
+ getClaimAmount(args: GetClaimAmountArgs): Promise<EncryptedViewResult>;
196
+ /**
197
+ * Gas-optimised validity check: would `claim`/`claimAndUnwrap` succeed
198
+ * right now for `args.recipient`, without spending an FHE op or a
199
+ * transaction.
200
+ *
201
+ * Never reverts — returns `false` for every failure mode (paused, outside
202
+ * the claim window, past `deadline`, `signer` lacking `SIGNER_ROLE`, an
203
+ * invalid signature, an already-consumed digest, or an already-deduped
204
+ * claim per this instance's `dedupMode`).
205
+ *
206
+ * @returns Whether the signature is currently valid and unconsumed for `args.recipient`.
207
+ */
208
+ isSignatureValid(args: IsSignatureValidArgs): Promise<boolean>;
209
+ /** `bytes32` identifier for the role that must authorize a claim signature. */
210
+ SIGNER_ROLE(): Promise<Hex>;
211
+ /**
212
+ * The live on-chain `CLAIM_TYPEHASH`. Prefer the module-level
213
+ * {@link CLAIM_TYPEHASH} constant to avoid an RPC round trip; use this read
214
+ * only to confirm a specific deployed instance was built off the expected
215
+ * contract source.
216
+ */
217
+ claimTypehash(): Promise<Hex>;
218
+ /**
219
+ * The EIP-712 domain separator this instance signs against
220
+ * (`_domainSeparatorV4()`), bound to `(chainId, address(this))`. Useful for
221
+ * verifying a signature independently of `walletClient.signTypedData`.
222
+ */
223
+ domainSeparator(): Promise<Hex>;
224
+ /**
225
+ * The instance's ERC-5267 domain description - the same domain
226
+ * {@link domainSeparator} hashes, but field by field.
227
+ *
228
+ * Use it when something else has to reconstruct the domain rather than
229
+ * compare a hash: a wallet rendering a typed-data prompt, an independent
230
+ * verifier, or a cross-check that a deployed instance really was initialized
231
+ * with {@link EIP712_DOMAIN_NAME} / {@link EIP712_DOMAIN_VERSION} on the
232
+ * chain you think it is on. `salt` is `bytes32(0)` and `extensions` is empty
233
+ * - this contract uses OpenZeppelin's plain `EIP712` domain.
234
+ *
235
+ * @returns The seven ERC-5267 fields, named. `fields` is the standard's
236
+ * bitmap of which of them are actually in use.
237
+ */
238
+ eip712Domain(): Promise<Eip712Domain>;
239
+ }
240
+ /**
241
+ * The ERC-5267 `eip712Domain()` tuple, as named fields.
242
+ *
243
+ * @alpha
244
+ */
245
+ export interface Eip712Domain {
246
+ /** Bitmap of which of the six domain fields below the contract populates. */
247
+ fields: Hex;
248
+ name: string;
249
+ version: string;
250
+ chainId: bigint;
251
+ verifyingContract: Address;
252
+ salt: Hex;
253
+ extensions: readonly bigint[];
254
+ }
255
+ /**
256
+ * Create an {@link EcdsaAirdropClient}. Mirrors viem's `create*` convention.
257
+ *
258
+ * @example
259
+ * const airdrop = createEcdsaAirdropClient({ publicClient, walletClient, address, dedupMode: "perAddress" });
260
+ *
261
+ * @alpha
262
+ */
263
+ export declare function createEcdsaAirdropClient(config: EcdsaAirdropClientConfig): EcdsaAirdropClient;
@@ -1,11 +1,13 @@
1
- import type { Address, WalletClient } from "viem";
2
- import { type EncryptedHandle, type Signature } from "../core/brands.js";
3
- import type { EncryptedInput, EncryptedInputs } from "./types.js";
1
+ import type { Account, Address, Hex, WalletClient } from "viem";
2
+ import { type Signature } from "../core/brands.js";
3
+ import type { EncryptedInput, EncryptedInputs } from "../fhe/types.js";
4
4
  /**
5
5
  * FHE input values, discriminated by ciphertext type. Mirrors the shape of
6
6
  * `EncryptInput` from `@zama-fhe/sdk` so that a `RelayerWeb` / `RelayerNode`
7
7
  * / `MockFhevmInstance` instance is structurally assignable to {@link Encryptor}
8
8
  * without casting.
9
+ *
10
+ * @alpha
9
11
  */
10
12
  export type FheValueInput = {
11
13
  value: boolean | bigint;
@@ -20,6 +22,8 @@ export type FheValueInput = {
20
22
  /**
21
23
  * Subset of `@zama-fhe/sdk` `RelayerSDK` we depend on. Declared structurally so
22
24
  * consumers can pass any v3 RelayerSDK without us importing the optional peer dep.
25
+ *
26
+ * @alpha
23
27
  */
24
28
  export interface Encryptor {
25
29
  encrypt(params: {
@@ -34,6 +38,8 @@ export interface Encryptor {
34
38
  /**
35
39
  * Eager or lazy {@link Encryptor} reference. Lazy form for React/Vue/signals
36
40
  * hosts where the encryptor lifetime doesn't match the client's.
41
+ *
42
+ * @alpha
37
43
  */
38
44
  export type EncryptorSource = Encryptor | (() => Encryptor | undefined);
39
45
  /**
@@ -49,14 +55,18 @@ export type EncryptorSource = Encryptor | (() => Encryptor | undefined);
49
55
  * // React — lazy factory picks up the live ZamaSDK context
50
56
  * const zamaSDK = useZamaSDK();
51
57
  * const resolved = resolveEncryptor(() => zamaSDK.relayer);
58
+ *
59
+ * @alpha
52
60
  */
53
61
  export declare function resolveEncryptor(source: EncryptorSource | undefined): Encryptor | undefined;
62
+ /** @alpha */
54
63
  export interface EncryptUint64Args {
55
64
  encryptor: Encryptor;
56
65
  contractAddress: Address;
57
66
  userAddress: Address;
58
67
  value: bigint;
59
68
  }
69
+ /** @alpha */
60
70
  export interface EncryptUint64BatchArgs {
61
71
  encryptor: Encryptor;
62
72
  contractAddress: Address;
@@ -67,9 +77,22 @@ export interface EncryptUint64BatchArgs {
67
77
  * Encrypt a single `uint64` value into an `externalEuint64` handle + KMS input proof.
68
78
  *
69
79
  * The handle and proof are bound to `contractAddress` and `userAddress` — they
70
- * cannot be replayed against a different contract or sender. For airdrops the
71
- * `userAddress` MUST be the **recipient** (not the admin), because the contract's
72
- * `FHE.fromExternal` rejects proofs bound to any other address.
80
+ * cannot be replayed against a different contract or sender. The binding must
81
+ * name whichever contract calls `FHE.fromExternal` and whichever account sends
82
+ * that transaction, and for airdrops those differ between the two flows:
83
+ *
84
+ * - **Claiming** (`EcdsaAirdropClient.claim` / `claimAndUnwrap`): bind to
85
+ * `(airdropInstanceAddress, recipientAddress)`. The `userAddress` MUST be
86
+ * the **recipient** — the account that sends the claim — not the admin.
87
+ * - **Funding** (`ConfidentialAirdropFactoryClient.fundAirdrop` /
88
+ * `createAndFund*`, i.e. a hand-built `FundInput.encryptedInput`):
89
+ * bind to `(factoryAddress, funderAddress)`. The factory, not the instance,
90
+ * is what calls `FHE.fromExternal` on the pool amount, and the funder is the
91
+ * admin sending the create/fund transaction. A proof bound to the instance
92
+ * reverts inside `FHE.fromExternal`.
93
+ *
94
+ * Either way `FHE.fromExternal` rejects a proof bound to any other pair, so
95
+ * the binding is a hard requirement, not a convention.
73
96
  *
74
97
  * **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
75
98
  * convention (1 token = 1_000_000 base units), not the 18 decimals typical of
@@ -82,36 +105,91 @@ export interface EncryptUint64BatchArgs {
82
105
  * @param args Encryption request; `value` must fit in `uint64` (0 to 2^64-1).
83
106
  * @returns `{ handle: Hex, inputProof: Hex }` — pass both to the contract.
84
107
  * @example
108
+ * // Claim side: bound to (instance, recipient).
85
109
  * const encrypted = await encryptUint64({
86
110
  * encryptor,
87
- * contractAddress: airdropAddress,
111
+ * contractAddress: airdrop,
88
112
  * userAddress: recipientAddress, // must be the recipient, not the admin
89
113
  * value: 1_000_000n, // raw token units; ERC-7984 uses 6 decimals
90
114
  * });
91
115
  * const signature = await signClaimAuthorization({
92
116
  * walletClient,
93
- * airdropAddress,
117
+ * airdrop,
118
+ * chainId,
94
119
  * recipient: recipientAddress,
95
120
  * encryptedAmountHandle: encrypted.handle,
121
+ * dedupId,
122
+ * deadline,
96
123
  * });
124
+ * @example
125
+ * // Funding side: bound to (factory, funder) — NOT to the instance.
126
+ * const pool = await encryptUint64({
127
+ * encryptor,
128
+ * contractAddress: factory.address,
129
+ * userAddress: funderAddress,
130
+ * value: 100_000_000n,
131
+ * });
132
+ * await factory.fundAirdrop({ airdrop, encryptedInput: pool });
133
+ *
134
+ * @alpha
97
135
  */
98
136
  export declare function encryptUint64({ encryptor, contractAddress, userAddress, value, }: EncryptUint64Args): Promise<EncryptedInput>;
99
137
  /**
100
138
  * Encrypt N `uint64` values into N handles bound by a single input proof.
139
+ *
140
+ * @alpha
101
141
  */
102
142
  export declare function encryptUint64Batch({ encryptor, contractAddress, userAddress, values, }: EncryptUint64BatchArgs): Promise<EncryptedInputs>;
103
143
  /**
104
- * Build an EIP712 signature for a `Claim(address recipient, bytes32 encryptedAmount)` struct.
144
+ * Build the v2 EIP-712 signature over a `Claim(address recipient, bytes32
145
+ * encryptedAmount, bytes32 dedupId, uint256 deadline)` struct — the
146
+ * four-field digest `ECDSAConfidentialAirdrop` verifies (see `CLAIM_TYPEHASH`
147
+ * / `CLAIM_TYPES` in `./ecdsa.js`).
148
+ *
149
+ * A `SIGNER_ROLE` holder calls this off-chain; the recipient later presents
150
+ * the returned signature (together with the matching encrypted input) to
151
+ * `claim` / `claimAndUnwrap` / `getClaimAmount` / `isSignatureValid`. The
152
+ * signer is **not** bound into the digest — every claim entrypoint takes
153
+ * `signer` as an explicit parameter and verifies the signature against it,
154
+ * so the signature alone proves who signed.
105
155
  *
106
- * The admin calls this to sign a claim authorisation. The resulting `signature`
107
- * is passed by the recipient to `claim()` or `getClaimAmount()`.
156
+ * **Replay is bounded by the instance's `dedupMode`, not by this function.**
157
+ * Every mode consumes the EIP-712 digest, so the exact same signature bytes
158
+ * can never be replayed once used — but that is only ONE of two possible
159
+ * replay dimensions, and which second dimension applies depends entirely on
160
+ * the deploy-time `dedupMode` (`perAddress` / `perDedupId` / `both` /
161
+ * `none`, ordinals 0–3 in `./constants.js`):
108
162
  *
109
- * @param args Claim signing request. `walletClient` must sign with DEFAULT_ADMIN_ROLE on the airdrop clone.
163
+ * - `perAddress` — a recipient is capped at one claim, however many valid
164
+ * signatures they hold for that address.
165
+ * - `perDedupId` — signing the **same** encrypted amount for two
166
+ * **different** `dedupId`s lets it be claimed **twice** — a 2x drain. Never
167
+ * reuse the ciphertext across `dedupId`s that should not both be honoured.
168
+ * - `both` — both guards apply; either an address or a `dedupId` replay is
169
+ * blocked.
170
+ * - `none` — **neither** dedup map is written. Every distinct signature (any
171
+ * new `dedupId` or `deadline` produces a new digest) is independently
172
+ * claimable, with no per-address or per-allocation ceiling on-chain at all.
173
+ *
174
+ * **The consequence:** under `perDedupId` and `none`, the on-chain contract
175
+ * enforces no upper bound on total payout to a given recipient or
176
+ * allocation — the **signing service** is the only thing bounding it, by
177
+ * never issuing two signatures that should not both be honoured. That
178
+ * constraint lives in the service that calls this function, not in the
179
+ * contract.
180
+ *
181
+ * @param args Claim signing request. `walletClient` (or `args.account`) must sign with `SIGNER_ROLE` on the airdrop instance.
110
182
  * @returns `0x`-prefixed ECDSA signature bytes.
183
+ *
184
+ * @alpha
111
185
  */
112
186
  export declare function signClaimAuthorization(args: {
113
187
  walletClient: WalletClient;
114
- airdropAddress: Address;
188
+ airdrop: Address;
189
+ chainId: number;
115
190
  recipient: Address;
116
- encryptedAmountHandle: EncryptedHandle;
191
+ encryptedAmountHandle: Hex;
192
+ dedupId: Hex;
193
+ deadline: bigint;
194
+ account?: Account | Address | undefined;
117
195
  }): Promise<Signature>;