@tokenops/sdk 2.0.0-alpha.3 → 2.0.0-alpha.4

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 (151) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +71 -35
  3. package/SUPPORT.md +1 -1
  4. package/dist/{chunk-NGU4JYIR.js → chunk-2ND7US2I.js} +1 -1
  5. package/dist/{chunk-U3TBQRT7.js → chunk-3ZSPRHR3.js} +55 -12
  6. package/dist/{chunk-BXX5TETM.js → chunk-67Q6KSVV.js} +4114 -3267
  7. package/dist/{chunk-JVNJSDQ4.cjs → chunk-6AYJRUGP.cjs} +7 -50
  8. package/dist/{chunk-AHU2HMNE.cjs → chunk-6FUHF73F.cjs} +5 -5
  9. package/dist/{chunk-NWFMBLSQ.js → chunk-7KY4K4PH.js} +1 -1
  10. package/dist/{chunk-YABHXJNH.cjs → chunk-ARZ5C3FS.cjs} +7 -7
  11. package/dist/{chunk-4IB4IY5Y.js → chunk-AX6MQAWU.js} +2 -2
  12. package/dist/{chunk-BPIVVCSQ.js → chunk-BSXEX2SH.js} +3 -3
  13. package/dist/{chunk-PK6Q6J5F.js → chunk-CHGY6B7L.js} +34 -81
  14. package/dist/{chunk-GKYZQJGP.cjs → chunk-DFK5GCJP.cjs} +55 -72
  15. package/dist/{chunk-4AWQJQXY.cjs → chunk-E4IV4M4E.cjs} +4126 -3279
  16. package/dist/{chunk-6HCT4QIX.js → chunk-GHGF65LN.js} +16 -13
  17. package/dist/{chunk-TWT3STIX.js → chunk-K3R27WX4.js} +8 -46
  18. package/dist/{chunk-GCJFAY4X.js → chunk-KJUNBOJQ.js} +52 -71
  19. package/dist/{chunk-6XOAYDC6.cjs → chunk-PO3A2AQX.cjs} +4 -4
  20. package/dist/{chunk-TND5NDV7.cjs → chunk-QHDMPT7I.cjs} +64 -19
  21. package/dist/{chunk-IEKTGJ4J.cjs → chunk-S47IBDTA.cjs} +36 -83
  22. package/dist/{chunk-UG5RKLU2.cjs → chunk-SUYBAF27.cjs} +1 -1
  23. package/dist/{chunk-WRWRA4TN.js → chunk-TWU7L5H7.js} +5 -48
  24. package/dist/{chunk-WJLECC22.cjs → chunk-UUSSWOPR.cjs} +9 -47
  25. package/dist/{chunk-YTIYTV4K.cjs → chunk-VHKMWWBA.cjs} +319 -40
  26. package/dist/{chunk-PG3WXT3K.cjs → chunk-YAL6JSAZ.cjs} +16 -13
  27. package/dist/{chunk-LEYYG4RF.js → chunk-YMWMIWBP.js} +315 -42
  28. package/dist/core/addresses.d.ts +4 -4
  29. package/dist/core/errors.d.ts +1 -1
  30. package/dist/core/index.d.ts +1 -0
  31. package/dist/core/pending.d.ts +57 -0
  32. package/dist/core/version.d.ts +1 -1
  33. package/dist/fhe/operators.d.ts +6 -5
  34. package/dist/fhe/types.d.ts +1 -1
  35. package/dist/fhe-airdrop/abis/airdrop-base.d.ts +81 -4
  36. package/dist/fhe-airdrop/abis/ecdsa.d.ts +101 -4
  37. package/dist/fhe-airdrop/abis/factory.d.ts +222 -4
  38. package/dist/fhe-airdrop/abis/merkle.d.ts +100 -4
  39. package/dist/fhe-airdrop/advanced/index.cjs +8 -4
  40. package/dist/fhe-airdrop/advanced/index.d.cts +1 -0
  41. package/dist/fhe-airdrop/advanced/index.d.ts +1 -0
  42. package/dist/fhe-airdrop/advanced/index.js +1 -1
  43. package/dist/fhe-airdrop/advanced/react/index.cjs +121 -143
  44. package/dist/fhe-airdrop/advanced/react/index.js +55 -77
  45. package/dist/fhe-airdrop/advanced/react/useClearCompliancePolicy.d.ts +3 -1
  46. package/dist/fhe-airdrop/advanced/react/useDisableCustomFee.d.ts +3 -1
  47. package/dist/fhe-airdrop/advanced/react/useFactoryComplianceDelegate.d.ts +2 -4
  48. package/dist/fhe-airdrop/advanced/react/useSetComplianceDelegate.d.ts +7 -7
  49. package/dist/fhe-airdrop/advanced/react/useSetComplianceManagerImpl.d.ts +3 -1
  50. package/dist/fhe-airdrop/advanced/react/useSetCompliancePolicy.d.ts +2 -1
  51. package/dist/fhe-airdrop/advanced/react/useSetCustomFee.d.ts +3 -1
  52. package/dist/fhe-airdrop/advanced/react/useSetDefaultDelegateToCompliance.d.ts +5 -4
  53. package/dist/fhe-airdrop/advanced/react/useSetDefaultGasFee.d.ts +3 -1
  54. package/dist/fhe-airdrop/advanced/react/useSetMaxGasFee.d.ts +7 -3
  55. package/dist/fhe-airdrop/airdrop-base.d.ts +95 -10
  56. package/dist/fhe-airdrop/campaign.d.ts +37 -73
  57. package/dist/fhe-airdrop/compliance-clone.d.ts +21 -0
  58. package/dist/fhe-airdrop/constants.d.ts +3 -1
  59. package/dist/fhe-airdrop/ecdsa.d.ts +67 -27
  60. package/dist/fhe-airdrop/encryption.d.ts +19 -6
  61. package/dist/fhe-airdrop/errors.d.ts +77 -2
  62. package/dist/fhe-airdrop/factory-params.d.ts +2361 -0
  63. package/dist/fhe-airdrop/factory.d.ts +142 -68
  64. package/dist/fhe-airdrop/guards.d.ts +110 -31
  65. package/dist/fhe-airdrop/index.cjs +79 -59
  66. package/dist/fhe-airdrop/index.d.cts +11 -9
  67. package/dist/fhe-airdrop/index.d.ts +11 -9
  68. package/dist/fhe-airdrop/index.js +5 -5
  69. package/dist/fhe-airdrop/merkle-tree.d.ts +9 -9
  70. package/dist/fhe-airdrop/merkle.d.ts +32 -11
  71. package/dist/fhe-airdrop/react/_shared.d.ts +12 -6
  72. package/dist/fhe-airdrop/react/index.cjs +294 -258
  73. package/dist/fhe-airdrop/react/index.d.cts +16 -9
  74. package/dist/fhe-airdrop/react/index.d.ts +16 -9
  75. package/dist/fhe-airdrop/react/index.js +114 -110
  76. package/dist/fhe-airdrop/react/keys.d.ts +46 -7
  77. package/dist/fhe-airdrop/react/useAccessEcdsaClaimAmount.d.ts +6 -3
  78. package/dist/fhe-airdrop/react/useAccessMerkleClaimAmount.d.ts +2 -2
  79. package/dist/fhe-airdrop/react/useAirdropConfig.d.ts +8 -3
  80. package/dist/fhe-airdrop/react/useAirdropPause.d.ts +5 -0
  81. package/dist/fhe-airdrop/react/useBuildMerkleCampaign.d.ts +4 -6
  82. package/dist/fhe-airdrop/react/useComplianceManager.d.ts +2 -2
  83. package/dist/fhe-airdrop/react/useComplianceManagerOf.d.ts +1 -2
  84. package/dist/fhe-airdrop/react/useCreateAndFundEcdsaAirdrop.d.ts +16 -11
  85. package/dist/fhe-airdrop/react/useCreateAndFundMerkleAirdrop.d.ts +23 -7
  86. package/dist/fhe-airdrop/react/useCreateEcdsaAirdrop.d.ts +13 -8
  87. package/dist/fhe-airdrop/react/useCreateMerkleAirdrop.d.ts +27 -7
  88. package/dist/fhe-airdrop/react/useDedupMode.d.ts +16 -0
  89. package/dist/fhe-airdrop/react/useDiscloseHandleToParty.d.ts +4 -3
  90. package/dist/fhe-airdrop/react/useEcdsaClaim.d.ts +6 -4
  91. package/dist/fhe-airdrop/react/useEcdsaClaimAndUnwrap.d.ts +15 -8
  92. package/dist/fhe-airdrop/react/useEcdsaDomain.d.ts +1 -1
  93. package/dist/fhe-airdrop/react/useEncryptCampaignAmounts.d.ts +5 -7
  94. package/dist/fhe-airdrop/react/useExtendClaimWindow.d.ts +4 -1
  95. package/dist/fhe-airdrop/react/useFundAirdrop.d.ts +3 -4
  96. package/dist/fhe-airdrop/react/useGrantInstanceRoles.d.ts +2 -1
  97. package/dist/fhe-airdrop/react/useIsSignatureValid.d.ts +5 -4
  98. package/dist/fhe-airdrop/react/useMerkleClaim.d.ts +4 -1
  99. package/dist/fhe-airdrop/react/useMerkleClaimAndUnwrap.d.ts +14 -3
  100. package/dist/fhe-airdrop/react/usePlanMerkleCampaign.d.ts +18 -3
  101. package/dist/fhe-airdrop/react/usePreflightClaim.d.ts +1 -1
  102. package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +34 -13
  103. package/dist/fhe-airdrop/react/useRescueERC20.d.ts +3 -3
  104. package/dist/fhe-airdrop/react/useRescueNativeToken.d.ts +23 -0
  105. package/dist/fhe-airdrop/react/useRotateMerkleRoot.d.ts +5 -2
  106. package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +4 -0
  107. package/dist/fhe-airdrop/react/useTokenOf.d.ts +29 -0
  108. package/dist/fhe-airdrop/react/useUnwrapRequest.d.ts +25 -0
  109. package/dist/fhe-airdrop/react/useWithdrawConfidential.d.ts +4 -0
  110. package/dist/fhe-airdrop/roles.d.ts +82 -7
  111. package/dist/fhe-airdrop/types.d.ts +109 -14
  112. package/dist/fhe-disperse/errors.d.ts +3 -3
  113. package/dist/fhe-disperse/index.cjs +22 -22
  114. package/dist/fhe-disperse/index.d.cts +2 -1
  115. package/dist/fhe-disperse/index.d.ts +2 -1
  116. package/dist/fhe-disperse/index.js +3 -3
  117. package/dist/fhe-disperse/react/index.cjs +27 -25
  118. package/dist/fhe-disperse/react/index.d.cts +2 -1
  119. package/dist/fhe-disperse/react/index.d.ts +2 -1
  120. package/dist/fhe-disperse/react/index.js +8 -6
  121. package/dist/fhe-disperse/react/useDisperse.d.ts +6 -2
  122. package/dist/fhe-disperse/react/useRegister.d.ts +9 -3
  123. package/dist/fhe-disperse/react/useSingletonWithdrawTokenFee.d.ts +7 -2
  124. package/dist/fhe-disperse/react/useWithdrawTokenFee.d.ts +7 -2
  125. package/dist/fhe-disperse/singleton.d.ts +33 -19
  126. package/dist/fhe-disperse/types.d.ts +48 -8
  127. package/dist/fhe-vesting/advanced/index.cjs +6 -6
  128. package/dist/fhe-vesting/advanced/index.js +4 -4
  129. package/dist/fhe-vesting/advanced/react/index.cjs +9 -9
  130. package/dist/fhe-vesting/advanced/react/index.js +6 -6
  131. package/dist/fhe-vesting/factory.d.ts +31 -8
  132. package/dist/fhe-vesting/index.cjs +23 -23
  133. package/dist/fhe-vesting/index.d.cts +3 -2
  134. package/dist/fhe-vesting/index.d.ts +3 -2
  135. package/dist/fhe-vesting/index.js +4 -4
  136. package/dist/fhe-vesting/manager.d.ts +27 -2
  137. package/dist/fhe-vesting/react/index.cjs +126 -126
  138. package/dist/fhe-vesting/react/index.d.cts +3 -2
  139. package/dist/fhe-vesting/react/index.d.ts +3 -2
  140. package/dist/fhe-vesting/react/index.js +5 -5
  141. package/dist/fhe-vesting/react/useCreateManager.d.ts +16 -9
  142. package/dist/fhe-vesting/react/useCreateManagerAndGetAddress.d.ts +9 -5
  143. package/dist/fhe-vesting/react/useSplitVesting.d.ts +9 -3
  144. package/dist/index.cjs +18 -18
  145. package/dist/index.js +1 -1
  146. package/dist/testnet-faucet/faucet.d.ts +3 -0
  147. package/dist/testnet-faucet/index.cjs +15 -15
  148. package/dist/testnet-faucet/index.js +3 -3
  149. package/dist/testnet-faucet/react/index.cjs +9 -9
  150. package/dist/testnet-faucet/react/index.js +4 -4
  151. package/package.json +1 -1
@@ -5,8 +5,19 @@ import type { ConfidentialAirdropFactoryClient } from "./factory.js";
5
5
  import type { MerkleAirdropClient } from "./merkle.js";
6
6
  import { type MerkleLeafInput } from "./merkle-tree.js";
7
7
  import type { DeploymentMode } from "./constants.js";
8
- import type { BuiltCampaign, CampaignRecipient, MerkleAirdropParams } from "./types.js";
9
- export type { BuiltCampaign, CampaignEntry, CampaignRecipient } from "./types.js";
8
+ import type { BuiltCampaign, CampaignRecipient, MerkleAirdropParams, PlannedCampaign } from "./types.js";
9
+ export type { BuiltCampaign, CampaignEntry, CampaignRecipient, PlannedCampaign } from "./types.js";
10
+ /**
11
+ * Recipients per relayer request: an input ciphertext packs at most 2048 bits, so 2048 / 64
12
+ * euint64 values share one proof.
13
+ *
14
+ * `@zama-fhe/sdk` does not check this client-side, so the campaign builders chunk every
15
+ * roster to this size. Each entry carries its own chunk's proof, so a claim is identical
16
+ * whichever chunk its leaf came from.
17
+ *
18
+ * @alpha
19
+ */
20
+ export declare const MERKLE_BATCH_LIMIT: number;
10
21
  /**
11
22
  * Reject the campaign shapes that produce an unusable or misleading tree,
12
23
  * before any encryption work is done.
@@ -46,45 +57,12 @@ export declare function validateCampaignRecipients(recipients: readonly Campaign
46
57
  * pattern as `buildMerkleTreeInternal` in `./merkle-tree.js`.
47
58
  */
48
59
  export declare function validateCampaignRecipientsInternal(recipients: readonly CampaignRecipient[], method: string): void;
49
- /**
50
- * Who will submit the claims, for every builder that encrypts a roster.
51
- *
52
- * Follows the same shared-option pattern as `WriteAccountOverride`, because the choice
53
- * applies identically to all four builders and is frozen once the root is published.
54
- *
55
- * @alpha
56
- */
57
- export interface CampaignSubmitterOption {
58
- /**
59
- * The single address that will send every `claim` in this campaign.
60
- *
61
- * Omit for a **self-claim** campaign: each recipient's input is bound to that
62
- * recipient, one relayer request each, and only they can claim.
63
- *
64
- * Set it for a **relayed** campaign: the whole roster is bound to this one address and
65
- * batched, so a single `inputProof` covers up to 32 recipients and only this address
66
- * can submit. That batching is the point — one proof cannot be bound to many
67
- * addresses, so per-recipient binding and batching are mutually exclusive.
68
- *
69
- * An input ciphertext packs at most 2048 bits, so a `euint64` roster is chunked at 32
70
- * recipients per request; a longer roster simply issues more requests. Nothing about a
71
- * claim changes, since every chunk's proof is bound to the same submitter.
72
- *
73
- * Either way the leaf still commits each recipient's own `account`, so payout and
74
- * accounting are unaffected by who submits.
75
- *
76
- * **Frozen at publication.** An FHEVM handle encodes its `(instance, userAddress)`
77
- * binding, so re-pointing a leaf at a different submitter means re-encrypting, which
78
- * changes the handle and therefore the root. Choose before publishing, not after.
79
- */
80
- submitter?: Address;
81
- }
82
60
  /**
83
61
  * Inputs for {@link buildMerkleCampaign}.
84
62
  *
85
63
  * @alpha
86
64
  */
87
- export interface BuildMerkleCampaignArgs extends CampaignSubmitterOption {
65
+ export interface BuildMerkleCampaignArgs {
88
66
  /** The LIVE `MerkleConfidentialAirdrop` instance every input is bound to. Not the factory, not the implementation. */
89
67
  instance: Address;
90
68
  recipients: readonly CampaignRecipient[];
@@ -96,9 +74,7 @@ export interface BuildMerkleCampaignArgs extends CampaignSubmitterOption {
96
74
  * @alpha
97
75
  */
98
76
  export interface EncryptedCampaignLeaf extends MerkleLeafInput {
99
- /** The only address that can submit this leaf — what `handle`/`inputProof` are bound to. */
100
- boundTo: Address;
101
- /** The KMS input proof binding `handle` to `(instance, boundTo)`. Required at claim time, unused by the tree. */
77
+ /** The KMS input proof binding `handle` to `(instance, instance)`. Required at claim time, unused by the tree. */
102
78
  inputProof: Hex;
103
79
  }
104
80
  /**
@@ -106,7 +82,7 @@ export interface EncryptedCampaignLeaf extends MerkleLeafInput {
106
82
  *
107
83
  * @alpha
108
84
  */
109
- export interface EncryptCampaignAmountsArgs extends CampaignSubmitterOption {
85
+ export interface EncryptCampaignAmountsArgs {
110
86
  /** The LIVE `MerkleConfidentialAirdrop` instance every input is bound to. Not the factory, not the implementation. */
111
87
  instance: Address;
112
88
  recipients: readonly CampaignRecipient[];
@@ -119,17 +95,15 @@ export interface EncryptCampaignAmountsArgs extends CampaignSubmitterOption {
119
95
  * publishing a root, or to hand them to something else that builds the tree.
120
96
  * If you just want a campaign, {@link buildMerkleCampaign} does both.
121
97
  *
122
- * **Request count follows `submitter`.** Omitted: one relayer request per recipient,
123
- * issued concurrently, each bound to that recipient. Set: one batched request per 32
124
- * recipients (the 2048-bit input-ciphertext limit), every leaf claimable only by that
125
- * submitter.
98
+ * One relayer request per 32 recipients, issued concurrently; every leaf is submittable
99
+ * by any address.
126
100
  *
127
101
  * **The output is not reproducible.** Encryption is randomised, so calling this
128
102
  * twice with the same roster yields different handles and therefore a different
129
103
  * root. Persist what you get back; you cannot regenerate it.
130
104
  *
131
105
  * @param args The live instance, the roster, and an eager or lazy encryptor.
132
- * @returns One `{ account, boundTo, handle, inputProof }` per roster entry, in roster order.
106
+ * @returns One `{ account, handle, inputProof }` per roster entry, in roster order.
133
107
  * @throws {@link InvalidArgumentError} on any roster problem {@link validateCampaignRecipients} rejects, or a zero `instance`.
134
108
  * @throws {@link MissingEncryptorError} when `encryptor` resolves to `undefined`.
135
109
  *
@@ -142,8 +116,7 @@ export interface EncryptCampaignAmountsArgs extends CampaignSubmitterOption {
142
116
  export declare function encryptCampaignAmounts(args: EncryptCampaignAmountsArgs): Promise<readonly EncryptedCampaignLeaf[]>;
143
117
  /**
144
118
  * Encrypt every recipient's cumulative total, then build the tree those ciphertexts
145
- * belong to. Binding follows `submitter`: omitted, each input is bound to its own
146
- * recipient; set, the whole roster is bound to that one submitter.
119
+ * belong to. Every input is bound to `(instance, instance)`.
147
120
  *
148
121
  * Use this on the **mutable-root** path: the instance already exists, so its
149
122
  * address is known and encryption can bind to it directly. Publish the returned
@@ -160,9 +133,8 @@ export declare function encryptCampaignAmounts(args: EncryptCampaignAmountsArgs)
160
133
  * claim, and no amount of on-chain data will reconstruct it. Persist the
161
134
  * entries when this resolves and serve each recipient theirs.
162
135
  *
163
- * **Relayer load follows `submitter`.** A self-claim roster fans out one request per
164
- * recipient; a relayed roster issues one per 32. Either way, split the roster across
165
- * calls yourself if your relayer rate-limits.
136
+ * One relayer request per 32 recipients, issued concurrently; every leaf is submittable
137
+ * by any address. Split the roster across calls yourself if your relayer rate-limits.
166
138
  *
167
139
  * **Already hold the handles?** This function encrypts unconditionally, and
168
140
  * encryption is randomised — so re-encrypting handles that exist elsewhere
@@ -185,13 +157,13 @@ export declare function encryptCampaignAmounts(args: EncryptCampaignAmountsArgs)
185
157
  *
186
158
  * @alpha
187
159
  */
188
- export declare function buildMerkleCampaign({ instance, recipients, encryptor, submitter, }: BuildMerkleCampaignArgs): Promise<BuiltCampaign>;
160
+ export declare function buildMerkleCampaign({ instance, recipients, encryptor, }: BuildMerkleCampaignArgs): Promise<BuiltCampaign>;
189
161
  /**
190
162
  * Inputs for {@link planMerkleCampaign}.
191
163
  *
192
164
  * @alpha
193
165
  */
194
- export interface PlanMerkleCampaignArgs extends CampaignSubmitterOption {
166
+ export interface PlanMerkleCampaignArgs {
195
167
  factory: ConfidentialAirdropFactoryClient;
196
168
  /** The exact params the subsequent `createMerkleAirdrop` will use, except `merkleRoot` — supply the planned root there. */
197
169
  params: MerkleAirdropParams;
@@ -202,19 +174,6 @@ export interface PlanMerkleCampaignArgs extends CampaignSubmitterOption {
202
174
  recipients: readonly CampaignRecipient[];
203
175
  encryptor: EncryptorSource;
204
176
  }
205
- /**
206
- * A campaign built against a not-yet-deployed instance, plus the evidence needed to trust the prediction.
207
- *
208
- * @alpha
209
- */
210
- export interface PlannedCampaign extends BuiltCampaign {
211
- /** Where `createMerkleAirdrop({ mode, userSalt })` from `creator` will land. Every entry is bound to this address. */
212
- predictedAddress: Address;
213
- /** The factory's Merkle init-code hash read BEFORE the address was predicted. */
214
- initCodeHashBefore: Hex;
215
- /** The same hash read AFTER. Always equal to `initCodeHashBefore` on a returned plan - a difference throws instead. */
216
- initCodeHashAfter: Hex;
217
- }
218
177
  /**
219
178
  * Build a campaign for an instance that does not exist yet, so its root can be
220
179
  * baked in at create time.
@@ -249,6 +208,13 @@ export interface PlannedCampaign extends BuiltCampaign {
249
208
  * `preflightCreate` (`./guards.js`) for those, or let `createMerkleAirdrop`
250
209
  * enforce them at send time.
251
210
  *
211
+ * **Create from the plan.** Pass the returned plan as `plan` to
212
+ * `createMerkleAirdrop` / `createAndFundMerkleAirdrop` (and to
213
+ * `preflightCreate`). That pins `predictedAddress`, checks the root, and
214
+ * re-judges drift against `initCodeHashAfter` just before the send, so an
215
+ * implementation rotation after planning is refused rather than deployed at an
216
+ * address the entries are not bound to.
217
+ *
252
218
  * **Distribution is yours** — same as {@link buildMerkleCampaign}: the chain
253
219
  * keeps only the root, so each recipient must be handed their own
254
220
  * `(handle, inputProof, merkleProof)` out of band or they cannot claim.
@@ -267,17 +233,18 @@ export interface PlannedCampaign extends BuiltCampaign {
267
233
  * params: { ...params, merkleRoot: plan.root, isMerkleRootMutable: false },
268
234
  * mode: "clone",
269
235
  * userSalt,
236
+ * plan,
270
237
  * });
271
238
  *
272
239
  * @alpha
273
240
  */
274
- export declare function planMerkleCampaign({ factory, params, mode, creator, userSalt, recipients, encryptor, submitter, }: PlanMerkleCampaignArgs): Promise<PlannedCampaign>;
241
+ export declare function planMerkleCampaign({ factory, params, mode, creator, userSalt, recipients, encryptor, }: PlanMerkleCampaignArgs): Promise<PlannedCampaign>;
275
242
  /**
276
243
  * Inputs for {@link rotateMerkleRoot}.
277
244
  *
278
245
  * @alpha
279
246
  */
280
- export interface RotateMerkleRootArgs extends WriteAccountOverride, CampaignSubmitterOption {
247
+ export interface RotateMerkleRootArgs extends WriteAccountOverride {
281
248
  /** The live instance. Its `address` is read off the client — nothing is predicted here. */
282
249
  airdrop: MerkleAirdropClient;
283
250
  /** The FULL updated roster: cumulative totals, not the deltas since the last root. */
@@ -311,11 +278,8 @@ export interface RotatedCampaign extends BuiltCampaign {
311
278
  * entries to every recipient**, including the ones whose total was unchanged —
312
279
  * the chain stores only the root, so an un-updated recipient is simply stuck.
313
280
  *
314
- * **`submitter` is not remembered across rotations.** It is read from THIS call, not from
315
- * the campaign being replaced, so omitting it on a rotation rebuilds a relayed campaign as
316
- * a self-claim one - every new entry becomes claimable only by its own recipient, and the
317
- * relayer that was settling for them can no longer submit anything. Pass the same
318
- * `submitter` again to keep a relayed campaign relayed.
281
+ * One relayer request per 32 recipients, issued concurrently; every leaf is submittable
282
+ * by any address.
319
283
  *
320
284
  * Requires `MERKLE_ADMIN_ROLE` on the instance and an instance created with
321
285
  * `isMerkleRootMutable: true`.
@@ -335,4 +299,4 @@ export interface RotatedCampaign extends BuiltCampaign {
335
299
  *
336
300
  * @alpha
337
301
  */
338
- export declare function rotateMerkleRoot({ airdrop, recipients, encryptor, submitter, account, }: RotateMerkleRootArgs): Promise<RotatedCampaign>;
302
+ export declare function rotateMerkleRoot({ airdrop, recipients, encryptor, account, }: RotateMerkleRootArgs): Promise<RotatedCampaign>;
@@ -0,0 +1,21 @@
1
+ import type { Address } from "viem";
2
+ /**
3
+ * Predict the compliance-manager clone the factory deploys for an instance.
4
+ *
5
+ * Mirrors `AirdropFactory`: `Clones.cloneDeterministic(managerImpl,
6
+ * keccak256(abi.encode(predictedInstance, "compliance")))`, sent from the
7
+ * factory. The salt derives from the instance address, so the clone moves in
8
+ * lockstep with it.
9
+ *
10
+ * @param args.factory The factory that performs the create (the CREATE2 deployer).
11
+ * @param args.managerImplementation The implementation the clone is made from.
12
+ * @param args.airdrop The instance address the create lands at.
13
+ * @returns The checksummed clone address.
14
+ *
15
+ * @alpha
16
+ */
17
+ export declare function predictComplianceManagerClone(args: {
18
+ factory: Address;
19
+ managerImplementation: Address;
20
+ airdrop: Address;
21
+ }): Address;
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @alpha
5
5
  */
6
- export declare const AIRDROP_CONTRACTS_COMMIT = "c5c12c2087f61bcd5bd1daa802563ed3cd68f002";
6
+ export declare const AIRDROP_CONTRACTS_COMMIT = "005980df194e0dc66053bd517e9759bd4d580047";
7
7
  /**
8
8
  * Deployment shell selected at create time. Mirrors the contract's `DeploymentMode` enum
9
9
  * (`IConfidentialAirdropTypes.sol`): `enum DeploymentMode { Clone, UUPS }`.
@@ -31,6 +31,8 @@ export declare const DEDUP_MODE: {
31
31
  };
32
32
  /** @alpha */
33
33
  export type DedupMode = keyof typeof DEDUP_MODE;
34
+ /** {@link DEDUP_MODE} inverted: the contract's ordinal to the SDK's name. */
35
+ export declare const DEDUP_MODE_BY_ORDINAL: ReadonlyMap<number, DedupMode>;
34
36
  /**
35
37
  * The largest value `CommonAirdropParams.maxAcceptedGasFee` can carry - the
36
38
  * `uint96` ceiling. Passing it accepts whatever fee the factory resolves, which
@@ -1,7 +1,7 @@
1
1
  import type { Address, Hex } from "viem";
2
2
  import type { EncryptedInput, EncryptedViewResult } from "../fhe/types.js";
3
3
  import { AirdropBaseClient, type AirdropBaseClientConfig, type WriteAccountOverride } from "./airdrop-base.js";
4
- import type { DedupMode } from "./constants.js";
4
+ import { type DedupMode } from "./constants.js";
5
5
  /**
6
6
  * EIP-712 domain name every `ECDSAConfidentialAirdrop` instance shares. Set once, at `initialize`.
7
7
  *
@@ -50,19 +50,12 @@ export declare const CLAIM_TYPEHASH: `0x${string}`;
50
50
  /** @alpha */
51
51
  export interface EcdsaAirdropClientConfig extends AirdropBaseClientConfig {
52
52
  /**
53
- * The replay-protection policy this instance was deployed with
54
- * (`perAddress` / `perDedupId` / `both` / `none`).
53
+ * The replay-protection policy this instance was created with, as configured on
54
+ * this client. Purely informational - no method branches on it.
55
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.
56
+ * @deprecated Read the policy from the chain with {@link EcdsaAirdropClient.readDedupMode}.
64
57
  */
65
- dedupMode: DedupMode;
58
+ dedupMode?: DedupMode | undefined;
66
59
  }
67
60
  /**
68
61
  * Inputs shared by {@link EcdsaAirdropClient.claim} and {@link EcdsaAirdropClient.claimAndUnwrap}.
@@ -73,12 +66,19 @@ export interface EcdsaClaimArgs extends WriteAccountOverride {
73
66
  /**
74
67
  * Payout destination. Omit (or pass the zero address) to default to the
75
68
  * 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.
69
+ * rule. Authorization (the signature), replay dedup and a non-empty FHE
70
+ * input proof all stay bound to the sending account regardless of `to`;
71
+ * this field only redirects where the tokens (and the recipient ACL) land.
79
72
  */
80
73
  to?: Address;
81
- /** The claimant's encrypted allocation, bound to `(airdrop, sendingAccount)` at encryption time. */
74
+ /**
75
+ * The claimant's encrypted allocation.
76
+ *
77
+ * A non-empty `inputProof` binds the handle to `(airdrop, sendingAccount)`. An empty one
78
+ * (`"0x"`) skips verification: a zero handle becomes an encrypted zero, and a nonzero handle
79
+ * is accepted only if the sender and the instance already hold ACL on it, else it reverts.
80
+ * See the guide's "Encryption binding differs by path".
81
+ */
82
82
  encryptedInput: EncryptedInput;
83
83
  /** The off-chain claim id bound into the signature. */
84
84
  dedupId: Hex;
@@ -95,6 +95,7 @@ export interface EcdsaClaimArgs extends WriteAccountOverride {
95
95
  * @alpha
96
96
  */
97
97
  export interface GetClaimAmountArgs extends WriteAccountOverride {
98
+ /** The claimant's encrypted allocation; the same empty-proof rule as {@link EcdsaClaimArgs.encryptedInput}. */
98
99
  encryptedInput: EncryptedInput;
99
100
  dedupId: Hex;
100
101
  deadline: bigint;
@@ -141,15 +142,21 @@ export interface IsSignatureValidArgs {
141
142
  * amount against the contract's `msg.value != gasFee()` revert.
142
143
  *
143
144
  * @example
144
- * const airdrop = new EcdsaAirdropClient({ publicClient, walletClient, address, dedupMode: "perAddress" });
145
+ * const airdrop = new EcdsaAirdropClient({ publicClient, walletClient, address });
145
146
  * const hash = await airdrop.claim({ encryptedInput, dedupId, deadline, signer, signature });
146
147
  *
147
148
  * @alpha
148
149
  */
149
150
  export declare class EcdsaAirdropClient extends AirdropBaseClient {
150
- /** @see EcdsaAirdropClientConfig.dedupMode */
151
- readonly dedupMode: DedupMode;
151
+ /** @deprecated Read the policy from the chain with {@link EcdsaAirdropClient.readDedupMode}. */
152
+ readonly dedupMode: DedupMode | undefined;
152
153
  constructor(config: EcdsaAirdropClientConfig);
154
+ /**
155
+ * Read the instance's frozen replay policy from the chain (`dedupMode()`).
156
+ *
157
+ * @throws {@link TokenOpsSdkError} when the contract returns an ordinal this SDK does not know.
158
+ */
159
+ readDedupMode(): Promise<DedupMode>;
153
160
  /**
154
161
  * Claim a signed encrypted allocation, delivering the tokens to `to`
155
162
  * (defaults to the sending account).
@@ -158,12 +165,18 @@ export declare class EcdsaAirdropClient extends AirdropBaseClient {
158
165
  * depth EIP-712 digest guard. Requires `msg.value == gasFee()` exactly —
159
166
  * handled for you; see the class TSDoc.
160
167
  *
168
+ * An empty `inputProof` is accepted only for a zero handle or one the sender and the
169
+ * instance already hold ACL on; see {@link EcdsaClaimArgs.encryptedInput}.
170
+ *
161
171
  * @throws {@link ClaimNotStartedError} before `startTime`.
162
172
  * @throws {@link ClaimWindowClosedError} after `endTime`.
163
173
  * @throws {@link SignatureExpiredError} after `args.deadline` has passed.
164
174
  * @throws {@link InvalidSignatureError} when `signer` lacks `SIGNER_ROLE` or the signature does not verify.
165
175
  * @throws {@link AlreadyClaimedError} on an address or digest replay.
166
176
  * @throws {@link DedupIdConsumedError} on a `dedupId` replay under `perDedupId`/`both`.
177
+ * @throws {@link FheHandleNotAllowedError} on an empty proof for a nonzero handle the sender
178
+ * holds no ACL on (`SenderNotAllowedToUseHandle`); the ACL's `SenderNotAllowed`, when only the
179
+ * instance lacks it, surfaces as a raw `ContractRevertError`.
167
180
  * @returns The transaction hash.
168
181
  */
169
182
  claim(args: EcdsaClaimArgs): Promise<Hex>;
@@ -173,12 +186,22 @@ export declare class EcdsaAirdropClient extends AirdropBaseClient {
173
186
  * `TokenNotUnwrappable` (surfaced as `FeatureDisabledError`) on a
174
187
  * non-unwrappable campaign.
175
188
  *
176
- * Same replay consumption and `msg.value == gasFee()` requirement as
177
- * {@link claim}.
189
+ * Same replay consumption, empty-proof rule and `msg.value == gasFee()`
190
+ * requirement as {@link claim}.
191
+ *
192
+ * **Discloses the amount immediately.** With the stock wrapper the unwrapped amount is
193
+ * publicly decryptable from this claim transaction (the emitted `unwrapRequestId` is its
194
+ * handle), so anyone can learn it at once; `finalizeUnwrap` only releases the ERC-20. Only
195
+ * {@link claim} keeps the amount confidential.
178
196
  *
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.
197
+ * @throws {@link FheHandleNotAllowedError} on an empty proof for a nonzero handle the sender
198
+ * holds no ACL on (`SenderNotAllowedToUseHandle`); the ACL's `SenderNotAllowed`, when only the
199
+ * instance lacks it, surfaces as a raw `ContractRevertError`.
200
+ * @returns The transaction hash. It is only the unwrap request: the underlying
201
+ * ERC-20 is released later by the wrapper's permissionless `finalizeUnwrap`. Read
202
+ * its `unwrapRequestId` with {@link AirdropBaseClient.readUnwrapRequest} (or
203
+ * {@link AirdropBaseClient.parseUnwrapRequest} over a receipt you hold), then
204
+ * finalize with Zama's `sdk.createToken(wrapper).finalizeUnwrap(unwrapRequestId)`.
182
205
  */
183
206
  claimAndUnwrap(args: EcdsaClaimArgs): Promise<Hex>;
184
207
  /**
@@ -201,9 +224,17 @@ export declare class EcdsaAirdropClient extends AirdropBaseClient {
201
224
  * the result is recovered from the receipt's ACL `Allowed` event, never
202
225
  * from a simulation. See {@link AirdropBaseClient}'s class TSDoc.
203
226
  *
227
+ * The same empty-proof rule as {@link claim} applies; see {@link EcdsaClaimArgs.encryptedInput}.
228
+ *
204
229
  * @returns `{ handle, hash }` — pass `handle` to the Zama relayer's `userDecrypt`.
205
- * @throws {@link AlreadyClaimedError} when this recipient's dedup slot is consumed.
230
+ * @throws {@link AlreadyClaimedError} when this recipient's dedup slot or this exact digest is consumed.
206
231
  * @throws {@link DedupIdConsumedError} when this `dedupId`'s slot is consumed.
232
+ * @throws {@link SignatureExpiredError} when `deadline` has passed.
233
+ * @throws {@link InvalidSignatureError} when the voucher was not signed by the instance's signer.
234
+ * @throws {@link PausedError} / {@link ClaimNotStartedError} / {@link ClaimWindowClosedError} when the campaign is paused or outside its claim window.
235
+ * @throws {@link FheHandleNotAllowedError} on an empty proof for a nonzero handle the sender
236
+ * holds no ACL on (`SenderNotAllowedToUseHandle`); the ACL's `SenderNotAllowed`, when only the
237
+ * instance lacks it, surfaces as a raw `ContractRevertError`.
207
238
  */
208
239
  getClaimAmount(args: GetClaimAmountArgs): Promise<EncryptedViewResult>;
209
240
  /**
@@ -216,10 +247,19 @@ export declare class EcdsaAirdropClient extends AirdropBaseClient {
216
247
  * invalid signature, an already-consumed digest, or an already-deduped
217
248
  * claim per this instance's `dedupMode`).
218
249
  *
250
+ * **Signer services should pre-check every voucher with this**, as an `eth_call` from the
251
+ * claimant while the window is open. It is `false` while paused, before `startTime` or past
252
+ * the deadline, so before the window opens verify off-chain with a `SignatureChecker`-equivalent
253
+ * check. It is also `false` for every voucher once the `SIGNER_ROLE` key is EIP-7702-delegated,
254
+ * although the key still holds the role; see the guide's "The ECDSA signer key".
255
+ *
219
256
  * @returns Whether the signature is currently valid and unconsumed for `args.recipient`.
220
257
  */
221
258
  isSignatureValid(args: IsSignatureValidArgs): Promise<boolean>;
222
- /** `bytes32` identifier for the role that must authorize a claim signature. */
259
+ /**
260
+ * `bytes32` identifier for the role that must authorize a claim signature. Hold it on a
261
+ * dedicated key that is never EIP-7702-delegated; see {@link isSignatureValid}.
262
+ */
223
263
  SIGNER_ROLE(): Promise<Hex>;
224
264
  /**
225
265
  * The live on-chain `CLAIM_TYPEHASH`. Prefer the module-level
@@ -269,7 +309,7 @@ export interface Eip712Domain {
269
309
  * Create an {@link EcdsaAirdropClient}. Mirrors viem's `create*` convention.
270
310
  *
271
311
  * @example
272
- * const airdrop = createEcdsaAirdropClient({ publicClient, walletClient, address, dedupMode: "perAddress" });
312
+ * const airdrop = createEcdsaAirdropClient({ publicClient, walletClient, address });
273
313
  *
274
314
  * @alpha
275
315
  */
@@ -79,20 +79,26 @@ export interface EncryptUint64BatchArgs {
79
79
  * The handle and proof are bound to `contractAddress` and `userAddress` — they
80
80
  * cannot be replayed against a different contract or sender. The binding must
81
81
  * name whichever contract calls `FHE.fromExternal` and whichever account sends
82
- * that transaction, and for airdrops those differ between the two flows:
82
+ * that transaction, and for airdrops those differ between the flows:
83
83
  *
84
84
  * - **Claiming** (`EcdsaAirdropClient.claim` / `claimAndUnwrap`): bind to
85
85
  * `(airdropInstanceAddress, recipientAddress)`. The `userAddress` MUST be
86
86
  * the **recipient** — the account that sends the claim — not the admin.
87
+ * This binding is checked only for a non-empty proof; an ECDSA claim with an
88
+ * empty proof (`"0x"`) skips verification and needs a zero handle or one the
89
+ * claimant and the instance already hold ACL on. Merkle claims always reject
90
+ * an empty proof.
87
91
  * - **Funding** (`ConfidentialAirdropFactoryClient.fundAirdrop` /
88
92
  * `createAndFund*`, i.e. a hand-built `FundInput.encryptedInput`):
89
93
  * 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`.
94
+ * is what calls `FHE.fromExternal` on the pool amount, and the funder is
95
+ * whoever sends the create-and-fund or fund transaction. A proof bound to the
96
+ * instance reverts inside `FHE.fromExternal`.
97
+ * - **Merkle leaves**: bind each Merkle leaf to `(instance, instance)`, never
98
+ * `(instance, recipient)`; the campaign builders do this for you.
93
99
  *
94
- * Either way `FHE.fromExternal` rejects a proof bound to any other pair, so
95
- * the binding is a hard requirement, not a convention.
100
+ * Either way a non-empty proof bound to any other pair is rejected, so the
101
+ * binding is a hard requirement, not a convention.
96
102
  *
97
103
  * **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
98
104
  * convention (1 token = 1_000_000 base units), not the 18 decimals typical of
@@ -153,6 +159,13 @@ export declare function encryptUint64Batch({ encryptor, contractAddress, userAdd
153
159
  * `signer` as an explicit parameter and verifies the signature against it,
154
160
  * so the signature alone proves who signed.
155
161
  *
162
+ * **`SIGNER_ROLE` must be a dedicated key that is never EIP-7702-delegated** (or an
163
+ * ERC-1271 contract signer over this digest). A delegation gives the key code, so
164
+ * `SignatureChecker` switches to ERC-1271 against the delegate and every outstanding
165
+ * voucher fails (`InvalidSignature`), although the key still holds the role. Pre-check
166
+ * each voucher with `EcdsaAirdropClient.isSignatureValid`; see the guide's "The ECDSA
167
+ * signer key".
168
+ *
156
169
  * **Replay is bounded by the instance's `dedupMode`, not by this function.**
157
170
  * Every mode consumes the EIP-712 digest, so the exact same signature bytes
158
171
  * can never be replayed once used — but that is only ONE of two possible
@@ -1,5 +1,5 @@
1
1
  import type { Address, Hex } from "viem";
2
- import { TokenOpsSdkError } from "../core/errors.js";
2
+ import { InvalidArgumentError, TokenOpsSdkError } from "../core/errors.js";
3
3
  import type { RevertNameMapper } from "../core/revert-mapper.js";
4
4
  /**
5
5
  * A Merkle campaign's per-account claim state (`claimedAmount`) sits at an
@@ -166,6 +166,70 @@ export declare class PredictionDriftError extends TokenOpsSdkError {
166
166
  cause?: unknown;
167
167
  });
168
168
  }
169
+ /**
170
+ * A create reverted because one of its {@link CreateCommitments} no longer matches what the
171
+ * factory would deploy: the airdrop implementation, the compliance-manager implementation
172
+ * or the creator's resolved platform delegate moved between quote and send. Nothing was
173
+ * deployed and the salt is unused. Re-quote; for `airdrop`, also rebuild anything bound to
174
+ * the old prediction (Merkle leaves, vouchers, encrypted inputs).
175
+ *
176
+ * @alpha
177
+ */
178
+ export declare class CreateCommitmentMismatchError extends TokenOpsSdkError {
179
+ readonly name = "CreateCommitmentMismatchError";
180
+ readonly context: {
181
+ method: string;
182
+ contractAddress: Address;
183
+ field: "airdrop" | "complianceManagerImpl" | "complianceDelegate";
184
+ expected?: Address;
185
+ actual?: Address;
186
+ };
187
+ constructor(args: {
188
+ method: string;
189
+ contractAddress: Address;
190
+ field: "airdrop" | "complianceManagerImpl" | "complianceDelegate";
191
+ expected?: Address;
192
+ actual?: Address;
193
+ cause?: unknown;
194
+ });
195
+ }
196
+ /**
197
+ * `withdrawConfidential` reverted with `ClawbackRequiresPause`: the campaign is unpaused and
198
+ * still inside its claim window, so the clawback is refused. Pause first (`PAUSER_ROLE`), or
199
+ * run it outside the window (before `startTime` or after `endTime`).
200
+ *
201
+ * @alpha
202
+ */
203
+ export declare class ClawbackRequiresPauseError extends TokenOpsSdkError {
204
+ readonly name = "ClawbackRequiresPauseError";
205
+ readonly context: {
206
+ method: string;
207
+ contractAddress: Address;
208
+ };
209
+ constructor(args: {
210
+ method: string;
211
+ contractAddress: Address;
212
+ cause?: unknown;
213
+ });
214
+ }
215
+ /**
216
+ * `rescueNativeToken` reverted with `NativeRescueRequiresZeroFee`: the instance charges a gas
217
+ * fee, so its ETH is fee revenue and belongs to `withdrawGasFee`.
218
+ *
219
+ * @alpha
220
+ */
221
+ export declare class NativeRescueRequiresZeroFeeError extends TokenOpsSdkError {
222
+ readonly name = "NativeRescueRequiresZeroFeeError";
223
+ readonly context: {
224
+ method: string;
225
+ contractAddress: Address;
226
+ };
227
+ constructor(args: {
228
+ method: string;
229
+ contractAddress: Address;
230
+ cause?: unknown;
231
+ });
232
+ }
169
233
  /**
170
234
  * Factory `create*` reverted with `UpgradeabilityNotAllowed`: the creator's effective upgradeability policy is off.
171
235
  *
@@ -186,7 +250,7 @@ export declare class UpgradeabilityNotAllowedError extends TokenOpsSdkError {
186
250
  });
187
251
  }
188
252
  /**
189
- * `planInstanceRoleSplit` (`roles.ts`, Task 13) refuses to plan a
253
+ * `planInstanceRoleSplit` (`roles.ts`) refuses to plan a
190
254
  * `FEE_COLLECTOR_ROLE` grant: the role is its own role-admin (not
191
255
  * `DEFAULT_ADMIN_ROLE`), so a grant issued from the caller's admin role would
192
256
  * simply fail on-chain with `AccessControlUnauthorizedAccount`. An existing
@@ -375,3 +439,14 @@ export declare class UnrecognisedAirdropError extends TokenOpsSdkError {
375
439
  });
376
440
  }
377
441
  export declare const airdropProductMapper: RevertNameMapper;
442
+ /**
443
+ * The typed form of the factory's `GasFeeExceedsMaximum(gasFee, maxGasFee)`, shared by the
444
+ * revert mapper and `preflightCreate` so both paths surface one error code.
445
+ *
446
+ * @internal
447
+ */
448
+ export declare function gasFeeExceedsMaximumError(args: {
449
+ method: string;
450
+ gasFee: bigint | undefined;
451
+ maxGasFee: bigint | undefined;
452
+ }): InvalidArgumentError;