@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.
- package/CHANGELOG.md +53 -0
- package/README.md +71 -35
- package/SUPPORT.md +1 -1
- package/dist/{chunk-NGU4JYIR.js → chunk-2ND7US2I.js} +1 -1
- package/dist/{chunk-U3TBQRT7.js → chunk-3ZSPRHR3.js} +55 -12
- package/dist/{chunk-BXX5TETM.js → chunk-67Q6KSVV.js} +4114 -3267
- package/dist/{chunk-JVNJSDQ4.cjs → chunk-6AYJRUGP.cjs} +7 -50
- package/dist/{chunk-AHU2HMNE.cjs → chunk-6FUHF73F.cjs} +5 -5
- package/dist/{chunk-NWFMBLSQ.js → chunk-7KY4K4PH.js} +1 -1
- package/dist/{chunk-YABHXJNH.cjs → chunk-ARZ5C3FS.cjs} +7 -7
- package/dist/{chunk-4IB4IY5Y.js → chunk-AX6MQAWU.js} +2 -2
- package/dist/{chunk-BPIVVCSQ.js → chunk-BSXEX2SH.js} +3 -3
- package/dist/{chunk-PK6Q6J5F.js → chunk-CHGY6B7L.js} +34 -81
- package/dist/{chunk-GKYZQJGP.cjs → chunk-DFK5GCJP.cjs} +55 -72
- package/dist/{chunk-4AWQJQXY.cjs → chunk-E4IV4M4E.cjs} +4126 -3279
- package/dist/{chunk-6HCT4QIX.js → chunk-GHGF65LN.js} +16 -13
- package/dist/{chunk-TWT3STIX.js → chunk-K3R27WX4.js} +8 -46
- package/dist/{chunk-GCJFAY4X.js → chunk-KJUNBOJQ.js} +52 -71
- package/dist/{chunk-6XOAYDC6.cjs → chunk-PO3A2AQX.cjs} +4 -4
- package/dist/{chunk-TND5NDV7.cjs → chunk-QHDMPT7I.cjs} +64 -19
- package/dist/{chunk-IEKTGJ4J.cjs → chunk-S47IBDTA.cjs} +36 -83
- package/dist/{chunk-UG5RKLU2.cjs → chunk-SUYBAF27.cjs} +1 -1
- package/dist/{chunk-WRWRA4TN.js → chunk-TWU7L5H7.js} +5 -48
- package/dist/{chunk-WJLECC22.cjs → chunk-UUSSWOPR.cjs} +9 -47
- package/dist/{chunk-YTIYTV4K.cjs → chunk-VHKMWWBA.cjs} +319 -40
- package/dist/{chunk-PG3WXT3K.cjs → chunk-YAL6JSAZ.cjs} +16 -13
- package/dist/{chunk-LEYYG4RF.js → chunk-YMWMIWBP.js} +315 -42
- package/dist/core/addresses.d.ts +4 -4
- package/dist/core/errors.d.ts +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/pending.d.ts +57 -0
- package/dist/core/version.d.ts +1 -1
- package/dist/fhe/operators.d.ts +6 -5
- package/dist/fhe/types.d.ts +1 -1
- package/dist/fhe-airdrop/abis/airdrop-base.d.ts +81 -4
- package/dist/fhe-airdrop/abis/ecdsa.d.ts +101 -4
- package/dist/fhe-airdrop/abis/factory.d.ts +222 -4
- package/dist/fhe-airdrop/abis/merkle.d.ts +100 -4
- package/dist/fhe-airdrop/advanced/index.cjs +8 -4
- package/dist/fhe-airdrop/advanced/index.d.cts +1 -0
- package/dist/fhe-airdrop/advanced/index.d.ts +1 -0
- package/dist/fhe-airdrop/advanced/index.js +1 -1
- package/dist/fhe-airdrop/advanced/react/index.cjs +121 -143
- package/dist/fhe-airdrop/advanced/react/index.js +55 -77
- package/dist/fhe-airdrop/advanced/react/useClearCompliancePolicy.d.ts +3 -1
- package/dist/fhe-airdrop/advanced/react/useDisableCustomFee.d.ts +3 -1
- package/dist/fhe-airdrop/advanced/react/useFactoryComplianceDelegate.d.ts +2 -4
- package/dist/fhe-airdrop/advanced/react/useSetComplianceDelegate.d.ts +7 -7
- package/dist/fhe-airdrop/advanced/react/useSetComplianceManagerImpl.d.ts +3 -1
- package/dist/fhe-airdrop/advanced/react/useSetCompliancePolicy.d.ts +2 -1
- package/dist/fhe-airdrop/advanced/react/useSetCustomFee.d.ts +3 -1
- package/dist/fhe-airdrop/advanced/react/useSetDefaultDelegateToCompliance.d.ts +5 -4
- package/dist/fhe-airdrop/advanced/react/useSetDefaultGasFee.d.ts +3 -1
- package/dist/fhe-airdrop/advanced/react/useSetMaxGasFee.d.ts +7 -3
- package/dist/fhe-airdrop/airdrop-base.d.ts +95 -10
- package/dist/fhe-airdrop/campaign.d.ts +37 -73
- package/dist/fhe-airdrop/compliance-clone.d.ts +21 -0
- package/dist/fhe-airdrop/constants.d.ts +3 -1
- package/dist/fhe-airdrop/ecdsa.d.ts +67 -27
- package/dist/fhe-airdrop/encryption.d.ts +19 -6
- package/dist/fhe-airdrop/errors.d.ts +77 -2
- package/dist/fhe-airdrop/factory-params.d.ts +2361 -0
- package/dist/fhe-airdrop/factory.d.ts +142 -68
- package/dist/fhe-airdrop/guards.d.ts +110 -31
- package/dist/fhe-airdrop/index.cjs +79 -59
- package/dist/fhe-airdrop/index.d.cts +11 -9
- package/dist/fhe-airdrop/index.d.ts +11 -9
- package/dist/fhe-airdrop/index.js +5 -5
- package/dist/fhe-airdrop/merkle-tree.d.ts +9 -9
- package/dist/fhe-airdrop/merkle.d.ts +32 -11
- package/dist/fhe-airdrop/react/_shared.d.ts +12 -6
- package/dist/fhe-airdrop/react/index.cjs +294 -258
- package/dist/fhe-airdrop/react/index.d.cts +16 -9
- package/dist/fhe-airdrop/react/index.d.ts +16 -9
- package/dist/fhe-airdrop/react/index.js +114 -110
- package/dist/fhe-airdrop/react/keys.d.ts +46 -7
- package/dist/fhe-airdrop/react/useAccessEcdsaClaimAmount.d.ts +6 -3
- package/dist/fhe-airdrop/react/useAccessMerkleClaimAmount.d.ts +2 -2
- package/dist/fhe-airdrop/react/useAirdropConfig.d.ts +8 -3
- package/dist/fhe-airdrop/react/useAirdropPause.d.ts +5 -0
- package/dist/fhe-airdrop/react/useBuildMerkleCampaign.d.ts +4 -6
- package/dist/fhe-airdrop/react/useComplianceManager.d.ts +2 -2
- package/dist/fhe-airdrop/react/useComplianceManagerOf.d.ts +1 -2
- package/dist/fhe-airdrop/react/useCreateAndFundEcdsaAirdrop.d.ts +16 -11
- package/dist/fhe-airdrop/react/useCreateAndFundMerkleAirdrop.d.ts +23 -7
- package/dist/fhe-airdrop/react/useCreateEcdsaAirdrop.d.ts +13 -8
- package/dist/fhe-airdrop/react/useCreateMerkleAirdrop.d.ts +27 -7
- package/dist/fhe-airdrop/react/useDedupMode.d.ts +16 -0
- package/dist/fhe-airdrop/react/useDiscloseHandleToParty.d.ts +4 -3
- package/dist/fhe-airdrop/react/useEcdsaClaim.d.ts +6 -4
- package/dist/fhe-airdrop/react/useEcdsaClaimAndUnwrap.d.ts +15 -8
- package/dist/fhe-airdrop/react/useEcdsaDomain.d.ts +1 -1
- package/dist/fhe-airdrop/react/useEncryptCampaignAmounts.d.ts +5 -7
- package/dist/fhe-airdrop/react/useExtendClaimWindow.d.ts +4 -1
- package/dist/fhe-airdrop/react/useFundAirdrop.d.ts +3 -4
- package/dist/fhe-airdrop/react/useGrantInstanceRoles.d.ts +2 -1
- package/dist/fhe-airdrop/react/useIsSignatureValid.d.ts +5 -4
- package/dist/fhe-airdrop/react/useMerkleClaim.d.ts +4 -1
- package/dist/fhe-airdrop/react/useMerkleClaimAndUnwrap.d.ts +14 -3
- package/dist/fhe-airdrop/react/usePlanMerkleCampaign.d.ts +18 -3
- package/dist/fhe-airdrop/react/usePreflightClaim.d.ts +1 -1
- package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +34 -13
- package/dist/fhe-airdrop/react/useRescueERC20.d.ts +3 -3
- package/dist/fhe-airdrop/react/useRescueNativeToken.d.ts +23 -0
- package/dist/fhe-airdrop/react/useRotateMerkleRoot.d.ts +5 -2
- package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +4 -0
- package/dist/fhe-airdrop/react/useTokenOf.d.ts +29 -0
- package/dist/fhe-airdrop/react/useUnwrapRequest.d.ts +25 -0
- package/dist/fhe-airdrop/react/useWithdrawConfidential.d.ts +4 -0
- package/dist/fhe-airdrop/roles.d.ts +82 -7
- package/dist/fhe-airdrop/types.d.ts +109 -14
- package/dist/fhe-disperse/errors.d.ts +3 -3
- package/dist/fhe-disperse/index.cjs +22 -22
- package/dist/fhe-disperse/index.d.cts +2 -1
- package/dist/fhe-disperse/index.d.ts +2 -1
- package/dist/fhe-disperse/index.js +3 -3
- package/dist/fhe-disperse/react/index.cjs +27 -25
- package/dist/fhe-disperse/react/index.d.cts +2 -1
- package/dist/fhe-disperse/react/index.d.ts +2 -1
- package/dist/fhe-disperse/react/index.js +8 -6
- package/dist/fhe-disperse/react/useDisperse.d.ts +6 -2
- package/dist/fhe-disperse/react/useRegister.d.ts +9 -3
- package/dist/fhe-disperse/react/useSingletonWithdrawTokenFee.d.ts +7 -2
- package/dist/fhe-disperse/react/useWithdrawTokenFee.d.ts +7 -2
- package/dist/fhe-disperse/singleton.d.ts +33 -19
- package/dist/fhe-disperse/types.d.ts +48 -8
- package/dist/fhe-vesting/advanced/index.cjs +6 -6
- package/dist/fhe-vesting/advanced/index.js +4 -4
- package/dist/fhe-vesting/advanced/react/index.cjs +9 -9
- package/dist/fhe-vesting/advanced/react/index.js +6 -6
- package/dist/fhe-vesting/factory.d.ts +31 -8
- package/dist/fhe-vesting/index.cjs +23 -23
- package/dist/fhe-vesting/index.d.cts +3 -2
- package/dist/fhe-vesting/index.d.ts +3 -2
- package/dist/fhe-vesting/index.js +4 -4
- package/dist/fhe-vesting/manager.d.ts +27 -2
- package/dist/fhe-vesting/react/index.cjs +126 -126
- package/dist/fhe-vesting/react/index.d.cts +3 -2
- package/dist/fhe-vesting/react/index.d.ts +3 -2
- package/dist/fhe-vesting/react/index.js +5 -5
- package/dist/fhe-vesting/react/useCreateManager.d.ts +16 -9
- package/dist/fhe-vesting/react/useCreateManagerAndGetAddress.d.ts +9 -5
- package/dist/fhe-vesting/react/useSplitVesting.d.ts +9 -3
- package/dist/index.cjs +18 -18
- package/dist/index.js +1 -1
- package/dist/testnet-faucet/faucet.d.ts +3 -0
- package/dist/testnet-faucet/index.cjs +15 -15
- package/dist/testnet-faucet/index.js +3 -3
- package/dist/testnet-faucet/react/index.cjs +9 -9
- package/dist/testnet-faucet/react/index.js +4 -4
- package/package.json +1 -1
|
@@ -1,40 +1,11 @@
|
|
|
1
|
-
import type { AbiParameterToPrimitiveType, ExtractAbiFunction } from "abitype";
|
|
2
1
|
import type { Account, Address, Hex, PublicClient, WalletClient } from "viem";
|
|
3
2
|
import { type SdkTelemetry } from "../core/telemetry.js";
|
|
3
|
+
import type { ReceiptMode } from "../core/pending.js";
|
|
4
4
|
import type { EncryptedInput } from "../fhe/types.js";
|
|
5
|
-
import { airdropFactoryAbi as factoryAbi } from "./abis/factory.js";
|
|
6
5
|
import type { WriteAccountOverride } from "./airdrop-base.js";
|
|
7
|
-
import {
|
|
6
|
+
import type { DeploymentMode } from "./constants.js";
|
|
8
7
|
import { type EncryptorSource } from "./encryption.js";
|
|
9
|
-
import type {
|
|
10
|
-
type ContractMerkleParams = AbiParameterToPrimitiveType<ExtractAbiFunction<typeof factoryAbi, "createMerkleConfidentialAirdrop">["inputs"][0]>;
|
|
11
|
-
/** The on-chain `CommonAirdropParams` struct, field-for-field, straight off the ABI. */
|
|
12
|
-
type ContractCommonParams = ContractMerkleParams["common"];
|
|
13
|
-
/**
|
|
14
|
-
* Convert the SDK's `"clone"` / `"uups"` name to the contract's
|
|
15
|
-
* `DeploymentMode` ordinal.
|
|
16
|
-
*
|
|
17
|
-
* The string union is the SDK's currency everywhere else; the ordinal exists
|
|
18
|
-
* only at the ABI edge. Keeping the conversion in one exported function makes
|
|
19
|
-
* an inverted mapping a one-line test failure rather than a silently
|
|
20
|
-
* upgradeable instance.
|
|
21
|
-
*
|
|
22
|
-
* @param mode Deployment shell to select.
|
|
23
|
-
* @returns The `uint8` the factory expects.
|
|
24
|
-
*/
|
|
25
|
-
export declare function toDeploymentModeOrdinal(mode: DeploymentMode): number;
|
|
26
|
-
/**
|
|
27
|
-
* Project {@link CommonAirdropParams} onto the contract's struct.
|
|
28
|
-
*
|
|
29
|
-
* The two shapes are already identical, so this is a re-assembly rather than a
|
|
30
|
-
* translation — and that is the point: it pins the field set and their order to
|
|
31
|
-
* the vendored ABI, so a struct change in a future contract commit surfaces
|
|
32
|
-
* here instead of as a silently mis-encoded tuple.
|
|
33
|
-
*
|
|
34
|
-
* @param common Create-time fields shared by both airdrop variants.
|
|
35
|
-
* @returns The struct in the ABI's declared field order.
|
|
36
|
-
*/
|
|
37
|
-
export declare function toContractCommonParams(common: CommonAirdropParams): ContractCommonParams;
|
|
8
|
+
import type { AirdropVariantParams, CreateAirdropArgs, CreateAirdropResult, CreateCommitments, CreateMerkleAirdropArgs, EcdsaAirdropParams, MerkleAirdropParams, PendingCreateAirdropResult } from "./types.js";
|
|
38
9
|
/** @alpha */
|
|
39
10
|
export interface ConfidentialAirdropFactoryClientConfig {
|
|
40
11
|
publicClient: PublicClient;
|
|
@@ -184,6 +155,14 @@ export declare const FACTORY_ROLE_CONCENTRATION_NOTE = "The live factory holds a
|
|
|
184
155
|
* exists; splitting roles is a contracts-repo decision, not something this
|
|
185
156
|
* client can arrange.
|
|
186
157
|
*
|
|
158
|
+
* **Safe / multisig signers.** The four creates take `waitForReceipt: false`
|
|
159
|
+
* and return the committed addresses with `pending: true` (see
|
|
160
|
+
* {@link PendingCreateAirdropResult}). `fundAirdrop` and the admin
|
|
161
|
+
* writes already return a bare hash; the operator approval they need
|
|
162
|
+
* (`setOperator`, `@tokenops/sdk/fhe`) takes `waitForReceipt: false` as well. A post-create role split goes through
|
|
163
|
+
* {@link planInstanceRoleSplit} plus {@link encodeInstanceRoleSplit} as one
|
|
164
|
+
* MultiSend batch, not `grantInstanceRoles`.
|
|
165
|
+
*
|
|
187
166
|
* @example
|
|
188
167
|
* const factory = createConfidentialAirdropFactoryClient({ publicClient, walletClient });
|
|
189
168
|
* const { airdrop, complianceManager } = await factory.createMerkleAirdrop({
|
|
@@ -212,9 +191,14 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
212
191
|
* read-only form of the same checks.
|
|
213
192
|
*
|
|
214
193
|
* @param args Instance parameters, deployment shell and the caller's salt.
|
|
215
|
-
* @returns The tx hash, the deployed instance
|
|
194
|
+
* @returns The tx hash, the deployed instance, its compliance-manager clone, the clone's
|
|
195
|
+
* implementation and the platform delegate it was wired with. With `waitForReceipt: false`,
|
|
196
|
+
* a {@link PendingCreateAirdropResult}.
|
|
197
|
+
* @throws {@link InvalidArgumentError} on `gasFee` when the resolved fee exceeds the factory's `maxGasFee` ceiling, checked before the creator's bound.
|
|
198
|
+
* @throws {@link GasFeeNotAcceptedError} when the factory resolves a fee above `common.maxAcceptedGasFee`.
|
|
216
199
|
* @throws {@link NonStockWrapperError} when `unwrappable` is set on a token that is not a stock wrapper.
|
|
217
200
|
* @throws {@link SaltCollisionError} when this `(mode, deployer, userSalt)` tuple already deployed an instance.
|
|
201
|
+
* @throws {@link CreateCommitmentMismatchError} when a quoted or pinned commitment no longer matches what the factory would deploy.
|
|
218
202
|
* @throws {@link UpgradeabilityNotAllowedError} when `mode: "uups"` is not permitted for the creator.
|
|
219
203
|
* @throws {@link InvalidArgumentError} when `userSalt` was already consumed by this creator and mode.
|
|
220
204
|
*
|
|
@@ -225,7 +209,11 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
225
209
|
* userSalt: keccak256(toBytes("campaign-42")),
|
|
226
210
|
* });
|
|
227
211
|
*/
|
|
228
|
-
createEcdsaAirdrop(args: CreateAirdropArgs<EcdsaAirdropParams> & WriteAccountOverride): Promise<CreateAirdropResult>;
|
|
212
|
+
createEcdsaAirdrop(args: CreateAirdropArgs<EcdsaAirdropParams> & WriteAccountOverride & ReceiptMode<true>): Promise<CreateAirdropResult>;
|
|
213
|
+
/** With `waitForReceipt: false`: returns on submission, before the receipt exists. */
|
|
214
|
+
createEcdsaAirdrop(args: CreateAirdropArgs<EcdsaAirdropParams> & WriteAccountOverride & ReceiptMode<false>): Promise<PendingCreateAirdropResult>;
|
|
215
|
+
/** With a runtime `boolean`: either result, narrowed by `pending`. */
|
|
216
|
+
createEcdsaAirdrop(args: CreateAirdropArgs<EcdsaAirdropParams> & WriteAccountOverride & ReceiptMode): Promise<CreateAirdropResult | PendingCreateAirdropResult>;
|
|
229
217
|
/**
|
|
230
218
|
* Deploy a Merkle-proof airdrop instance.
|
|
231
219
|
*
|
|
@@ -235,14 +223,43 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
235
223
|
* across that change reinterprets live storage. See
|
|
236
224
|
* {@link MerkleUupsUnsupportedError}.
|
|
237
225
|
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
226
|
+
* **Creating from a plan.** Pass the {@link PlannedCampaign} as `plan`, with
|
|
227
|
+
* `merkleRoot: plan.root`. The plan's leaves are bound to `plan.predictedAddress`, so the
|
|
228
|
+
* create pins it, refuses a root that differs from `plan.root`, and refuses to send once
|
|
229
|
+
* the factory's Merkle implementation has moved since the plan was taken
|
|
230
|
+
* ({@link PredictionDriftError}). A rotation landing after that check is still refused by
|
|
231
|
+
* the contract ({@link CreateCommitmentMismatchError}). `expected: { airdrop: plan.predictedAddress }`
|
|
232
|
+
* is the lower-level equivalent of the pin alone.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* const plan = await planMerkleCampaign({
|
|
236
|
+
* factory, params, mode, creator, userSalt, recipients, encryptor,
|
|
237
|
+
* });
|
|
238
|
+
* await factory.createMerkleAirdrop({
|
|
239
|
+
* params: { ...params, merkleRoot: plan.root, isMerkleRootMutable: false },
|
|
240
|
+
* mode,
|
|
241
|
+
* userSalt,
|
|
242
|
+
* plan,
|
|
243
|
+
* });
|
|
244
|
+
*
|
|
245
|
+
* @param args Instance parameters, deployment shell, the caller's salt and, optionally, the plan being realised.
|
|
246
|
+
* @returns The tx hash, the deployed instance, its compliance-manager clone, the clone's
|
|
247
|
+
* implementation and the platform delegate it was wired with. With `waitForReceipt: false`,
|
|
248
|
+
* a {@link PendingCreateAirdropResult}.
|
|
249
|
+
* @throws {@link InvalidArgumentError} on `gasFee` when the resolved fee exceeds the factory's `maxGasFee` ceiling, checked before the creator's bound.
|
|
250
|
+
* @throws {@link GasFeeNotAcceptedError} when the factory resolves a fee above `common.maxAcceptedGasFee`.
|
|
240
251
|
* @throws {@link MerkleUupsUnsupportedError} when `mode` is `"uups"`.
|
|
241
252
|
* @throws {@link NonStockWrapperError} when `unwrappable` is set on a token that is not a stock wrapper.
|
|
242
253
|
* @throws {@link SaltCollisionError} when this `(mode, deployer, userSalt)` tuple already deployed an instance.
|
|
243
|
-
* @throws {@link
|
|
254
|
+
* @throws {@link CreateCommitmentMismatchError} when a quoted or pinned commitment no longer matches what the factory would deploy.
|
|
255
|
+
* @throws {@link PredictionDriftError} when `plan` is given and the factory's Merkle implementation moved since it was taken.
|
|
256
|
+
* @throws {@link InvalidArgumentError} when the root is zero and `isMerkleRootMutable` is false, the salt was already used, or `params.merkleRoot` / `expected.airdrop` disagrees with `plan`.
|
|
244
257
|
*/
|
|
245
|
-
createMerkleAirdrop(args:
|
|
258
|
+
createMerkleAirdrop(args: CreateMerkleAirdropArgs & WriteAccountOverride & ReceiptMode<true>): Promise<CreateAirdropResult>;
|
|
259
|
+
/** With `waitForReceipt: false`: returns on submission, before the receipt exists. */
|
|
260
|
+
createMerkleAirdrop(args: CreateMerkleAirdropArgs & WriteAccountOverride & ReceiptMode<false>): Promise<PendingCreateAirdropResult>;
|
|
261
|
+
/** With a runtime `boolean`: either result, narrowed by `pending`. */
|
|
262
|
+
createMerkleAirdrop(args: CreateMerkleAirdropArgs & WriteAccountOverride & ReceiptMode): Promise<CreateAirdropResult | PendingCreateAirdropResult>;
|
|
246
263
|
/**
|
|
247
264
|
* Deploy an ECDSA airdrop and seed its pool in the same transaction.
|
|
248
265
|
*
|
|
@@ -256,12 +273,21 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
256
273
|
* does not prove the pool was funded — confirm the funder's balance first.
|
|
257
274
|
*
|
|
258
275
|
* @param args Create arguments plus exactly one of `amount` / `encryptedInput`.
|
|
259
|
-
* @returns The tx hash, the deployed instance
|
|
276
|
+
* @returns The tx hash, the deployed instance, its compliance-manager clone, the clone's
|
|
277
|
+
* implementation and the platform delegate it was wired with. With `waitForReceipt: false`,
|
|
278
|
+
* a {@link PendingCreateAirdropResult}.
|
|
279
|
+
* @throws {@link InvalidArgumentError} on `gasFee` when the resolved fee exceeds the factory's `maxGasFee` ceiling, checked before the creator's bound.
|
|
280
|
+
* @throws {@link GasFeeNotAcceptedError} when the factory resolves a fee above `common.maxAcceptedGasFee`.
|
|
260
281
|
* @throws {@link NonStockWrapperError} when `unwrappable` is set on a token that is not a stock wrapper.
|
|
261
282
|
* @throws {@link SaltCollisionError} when this `(mode, deployer, userSalt)` tuple already deployed an instance.
|
|
283
|
+
* @throws {@link CreateCommitmentMismatchError} when a quoted or pinned commitment no longer matches what the factory would deploy.
|
|
262
284
|
* @throws {@link MissingEncryptorError} when `amount` is given and no encryptor is resolvable.
|
|
263
285
|
*/
|
|
264
|
-
createAndFundEcdsaAirdrop(args: CreateAirdropArgs<EcdsaAirdropParams> & FundInput & WriteAccountOverride): Promise<CreateAirdropResult>;
|
|
286
|
+
createAndFundEcdsaAirdrop(args: CreateAirdropArgs<EcdsaAirdropParams> & FundInput & WriteAccountOverride & ReceiptMode<true>): Promise<CreateAirdropResult>;
|
|
287
|
+
/** With `waitForReceipt: false`: returns on submission, before the receipt exists. */
|
|
288
|
+
createAndFundEcdsaAirdrop(args: CreateAirdropArgs<EcdsaAirdropParams> & FundInput & WriteAccountOverride & ReceiptMode<false>): Promise<PendingCreateAirdropResult>;
|
|
289
|
+
/** With a runtime `boolean`: either result, narrowed by `pending`. */
|
|
290
|
+
createAndFundEcdsaAirdrop(args: CreateAirdropArgs<EcdsaAirdropParams> & FundInput & WriteAccountOverride & ReceiptMode): Promise<CreateAirdropResult | PendingCreateAirdropResult>;
|
|
265
291
|
/**
|
|
266
292
|
* Deploy a Merkle airdrop and seed its pool in the same transaction.
|
|
267
293
|
*
|
|
@@ -273,14 +299,31 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
273
299
|
* because reverting would leak the balance. A successful receipt therefore
|
|
274
300
|
* does not prove the pool was funded.
|
|
275
301
|
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
302
|
+
* **Creating from a plan.** Pass the {@link PlannedCampaign} as `plan`, with
|
|
303
|
+
* `merkleRoot: plan.root`, exactly as for {@link createMerkleAirdrop}: the address is pinned,
|
|
304
|
+
* the root and the Merkle init-code hash are checked, and both checks run before anything is
|
|
305
|
+
* encrypted. `expected: { airdrop: plan.predictedAddress }` is the lower-level equivalent of
|
|
306
|
+
* the pin alone.
|
|
307
|
+
*
|
|
308
|
+
* @param args Create arguments plus exactly one of `amount` / `encryptedInput`, and optionally the plan being realised.
|
|
309
|
+
* @returns The tx hash, the deployed instance, its compliance-manager clone, the clone's
|
|
310
|
+
* implementation and the platform delegate it was wired with. With `waitForReceipt: false`,
|
|
311
|
+
* a {@link PendingCreateAirdropResult}.
|
|
312
|
+
* @throws {@link InvalidArgumentError} on `gasFee` when the resolved fee exceeds the factory's `maxGasFee` ceiling, checked before the creator's bound.
|
|
313
|
+
* @throws {@link GasFeeNotAcceptedError} when the factory resolves a fee above `common.maxAcceptedGasFee`.
|
|
278
314
|
* @throws {@link MerkleUupsUnsupportedError} when `mode` is `"uups"`.
|
|
279
315
|
* @throws {@link NonStockWrapperError} when `unwrappable` is set on a token that is not a stock wrapper.
|
|
280
316
|
* @throws {@link SaltCollisionError} when this `(mode, deployer, userSalt)` tuple already deployed an instance.
|
|
317
|
+
* @throws {@link CreateCommitmentMismatchError} when a quoted or pinned commitment no longer matches what the factory would deploy.
|
|
281
318
|
* @throws {@link MissingEncryptorError} when `amount` is given and no encryptor is resolvable.
|
|
319
|
+
* @throws {@link PredictionDriftError} when `plan` is given and the factory's Merkle implementation moved since it was taken.
|
|
320
|
+
* @throws {@link InvalidArgumentError} when `params.merkleRoot` or `expected.airdrop` disagrees with `plan`.
|
|
282
321
|
*/
|
|
283
|
-
createAndFundMerkleAirdrop(args:
|
|
322
|
+
createAndFundMerkleAirdrop(args: CreateMerkleAirdropArgs & FundInput & WriteAccountOverride & ReceiptMode<true>): Promise<CreateAirdropResult>;
|
|
323
|
+
/** With `waitForReceipt: false`: returns on submission, before the receipt exists. */
|
|
324
|
+
createAndFundMerkleAirdrop(args: CreateMerkleAirdropArgs & FundInput & WriteAccountOverride & ReceiptMode<false>): Promise<PendingCreateAirdropResult>;
|
|
325
|
+
/** With a runtime `boolean`: either result, narrowed by `pending`. */
|
|
326
|
+
createAndFundMerkleAirdrop(args: CreateMerkleAirdropArgs & FundInput & WriteAccountOverride & ReceiptMode): Promise<CreateAirdropResult | PendingCreateAirdropResult>;
|
|
284
327
|
/**
|
|
285
328
|
* Top up the pool of an instance this factory already deployed.
|
|
286
329
|
*
|
|
@@ -289,12 +332,22 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
289
332
|
* grants the compliance-manager clone its ACL on the amount. Sending tokens
|
|
290
333
|
* to the instance directly leaves the pool unusable for compliance reads.
|
|
291
334
|
*
|
|
335
|
+
* The token pulled is the one the factory recorded at create ({@link tokenOf}), not
|
|
336
|
+
* whatever the instance reports today.
|
|
337
|
+
*
|
|
338
|
+
* Prerequisite: the funder approved the factory as an ERC-7984 operator on that token
|
|
339
|
+
* (`setOperator` / `ensureOperator` from `@tokenops/sdk/fhe`). Those wait for their receipt
|
|
340
|
+
* by default, so a Safe passes `waitForReceipt: false` there too and lets the approval
|
|
341
|
+
* execute before this transaction does.
|
|
342
|
+
*
|
|
292
343
|
* **Silent-zero transfers.** A short encrypted balance moves an encrypted
|
|
293
344
|
* zero instead of reverting — the receipt cannot tell you value arrived.
|
|
294
345
|
*
|
|
295
346
|
* @param args The instance address plus exactly one of `amount` / `encryptedInput`.
|
|
296
347
|
* @returns The transaction hash.
|
|
297
348
|
* @throws {@link InvalidArgumentError} when `airdrop` was not created by this factory (`UnknownAirdrop`).
|
|
349
|
+
* @throws {@link InvalidArgumentError} when both or neither of `amount` / `encryptedInput` is supplied.
|
|
350
|
+
* @throws {@link MissingEncryptorError} when `amount` is given and no encryptor is resolvable.
|
|
298
351
|
*/
|
|
299
352
|
fundAirdrop(args: {
|
|
300
353
|
airdrop: Address;
|
|
@@ -359,7 +412,7 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
359
412
|
*/
|
|
360
413
|
airdrops(offset: bigint, limit: bigint): Promise<readonly Address[]>;
|
|
361
414
|
/**
|
|
362
|
-
* Whether THIS factory created `candidate` - the genuineness check
|
|
415
|
+
* Whether THIS factory created `candidate` - the genuineness check.
|
|
363
416
|
*
|
|
364
417
|
* Nothing observable at an instance proves which factory, if any, deployed
|
|
365
418
|
* it: an attacker can deploy a contract with the same ABI, the same events
|
|
@@ -383,6 +436,14 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
383
436
|
* @returns The clone address, or the zero address when unknown to this factory.
|
|
384
437
|
*/
|
|
385
438
|
complianceManagerOf(airdrop: Address): Promise<Address>;
|
|
439
|
+
/**
|
|
440
|
+
* The token recorded for `airdrop` at create - what {@link fundAirdrop} pulls, regardless
|
|
441
|
+
* of what the instance reports today.
|
|
442
|
+
*
|
|
443
|
+
* @param airdrop Instance address.
|
|
444
|
+
* @returns The token address, or the zero address when unknown to this factory.
|
|
445
|
+
*/
|
|
446
|
+
tokenOf(airdrop: Address): Promise<Address>;
|
|
386
447
|
/**
|
|
387
448
|
* Redirect where accrued claim-fee ETH withdraws to. Requires
|
|
388
449
|
* `FEE_MANAGER_ROLE`.
|
|
@@ -426,9 +487,8 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
426
487
|
*
|
|
427
488
|
* Lowering it below an already-configured fee does not rewrite that fee - the
|
|
428
489
|
* stale value stays in storage and reverts `GasFeeExceedsMaximum` at the next
|
|
429
|
-
* create until it is lowered too.
|
|
430
|
-
*
|
|
431
|
-
* @throws {@link InvalidArgumentError} when `maxGasFee` is below a currently configured fee (`GasFeeExceedsMaximum`).
|
|
490
|
+
* create until it is lowered too. The contract sets no lower bound, so this call
|
|
491
|
+
* itself does not revert on that account.
|
|
432
492
|
*/
|
|
433
493
|
setMaxGasFee(maxGasFee: bigint, account?: Account | Address): Promise<Hex>;
|
|
434
494
|
/**
|
|
@@ -451,6 +511,7 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
451
511
|
* clones point at the implementation live when they were created.
|
|
452
512
|
*
|
|
453
513
|
* @throws {@link InvalidArgumentError} when `implementation` is the zero address (`ZeroImplementation`).
|
|
514
|
+
* @throws {@link InvalidArgumentError} when `implementation` has no code or is an EIP-7702 delegation designator (`InvalidImplementation`).
|
|
454
515
|
*/
|
|
455
516
|
setEcdsaImplementation(implementation: Address, account?: Account | Address): Promise<Hex>;
|
|
456
517
|
/**
|
|
@@ -458,6 +519,7 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
458
519
|
* Requires `IMPL_MANAGER_ROLE`. Does not affect already-deployed instances.
|
|
459
520
|
*
|
|
460
521
|
* @throws {@link InvalidArgumentError} when `implementation` is the zero address (`ZeroImplementation`).
|
|
522
|
+
* @throws {@link InvalidArgumentError} when `implementation` has no code or is an EIP-7702 delegation designator (`InvalidImplementation`).
|
|
461
523
|
*/
|
|
462
524
|
setMerkleImplementation(implementation: Address, account?: Account | Address): Promise<Hex>;
|
|
463
525
|
/** The implementation address `createEcdsaAirdrop*` currently clones. */
|
|
@@ -469,16 +531,17 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
469
531
|
* `COMPLIANCE_WIRING_ROLE`. Does not affect already-deployed clones.
|
|
470
532
|
*
|
|
471
533
|
* @throws {@link InvalidArgumentError} when `implementation` is the zero address (`ZeroComplianceManagerImpl`).
|
|
534
|
+
* @throws {@link InvalidArgumentError} when `implementation` has no code or is an EIP-7702 delegation designator (`InvalidImplementation`).
|
|
472
535
|
*/
|
|
473
536
|
setComplianceManagerImpl(implementation: Address, account?: Account | Address): Promise<Hex>;
|
|
474
537
|
/**
|
|
475
538
|
* Set the platform-designated compliance delegate every compliance-manager
|
|
476
539
|
* clone wires in. Requires `COMPLIANCE_WIRING_ROLE`.
|
|
477
540
|
*
|
|
478
|
-
*
|
|
479
|
-
*
|
|
480
|
-
*
|
|
481
|
-
*
|
|
541
|
+
* The factory's constructor already seeded a non-zero delegate with delegation ON, so
|
|
542
|
+
* this only rotates it: it can never be cleared, and the zero address always reverts.
|
|
543
|
+
* Applies to clones created after it lands; existing clones keep the delegate they were
|
|
544
|
+
* initialized with.
|
|
482
545
|
*
|
|
483
546
|
* @throws {@link InvalidArgumentError} when `delegate` is the zero address (`ZeroComplianceDelegate`).
|
|
484
547
|
*/
|
|
@@ -487,10 +550,8 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
487
550
|
* Set whether new instances default to delegating compliance disclosure to
|
|
488
551
|
* {@link complianceDelegate}. Requires `COMPLIANCE_WIRING_ROLE`.
|
|
489
552
|
*
|
|
490
|
-
*
|
|
491
|
-
*
|
|
492
|
-
*
|
|
493
|
-
* @throws {@link InvalidArgumentError} when `on` is `true` and no delegate is set yet (`ZeroComplianceDelegate`).
|
|
553
|
+
* The default starts ON at construction (no post-deploy wiring); passing `false` is the
|
|
554
|
+
* deliberate opt-out. A per-creator {@link setCompliancePolicy} override still wins.
|
|
494
555
|
*/
|
|
495
556
|
setDefaultDelegateToCompliance(on: boolean, account?: Account | Address): Promise<Hex>;
|
|
496
557
|
/**
|
|
@@ -507,6 +568,24 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
507
568
|
complianceManagerImpl(): Promise<Address>;
|
|
508
569
|
/** The platform-designated compliance delegate wired into new compliance-manager clones. */
|
|
509
570
|
complianceDelegate(): Promise<Address>;
|
|
571
|
+
/**
|
|
572
|
+
* The platform delegate a create from `creator` would wire into its compliance clone:
|
|
573
|
+
* `complianceDelegate()` while the creator's effective policy is ON, the zero address
|
|
574
|
+
* while it is OFF. This is the value the factory checks `expectedComplianceDelegate`
|
|
575
|
+
* against.
|
|
576
|
+
*/
|
|
577
|
+
resolveComplianceDelegate(creator: Address): Promise<Address>;
|
|
578
|
+
/**
|
|
579
|
+
* Quote the {@link CreateCommitments} a create from `deployer` will be checked against,
|
|
580
|
+
* honouring anything already pinned in `expected`. The predicted address comes from the
|
|
581
|
+
* variant's prediction oracle, the other two from the factory's live configuration.
|
|
582
|
+
*/
|
|
583
|
+
quoteCreateCommitments(args: AirdropVariantParams & {
|
|
584
|
+
mode: DeploymentMode;
|
|
585
|
+
deployer: Address;
|
|
586
|
+
userSalt: Hex;
|
|
587
|
+
expected?: Partial<CreateCommitments> | undefined;
|
|
588
|
+
}): Promise<CreateCommitments>;
|
|
510
589
|
/** A creator's delegate-to-compliance override, if any — `overridden: false` means the factory default applies instead. */
|
|
511
590
|
getCompliancePolicy(creator: Address): Promise<CompliancePolicy>;
|
|
512
591
|
/**
|
|
@@ -613,12 +692,11 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
613
692
|
/**
|
|
614
693
|
* Revoke `role` from `holder`. Requires the role's admin role.
|
|
615
694
|
*
|
|
616
|
-
* **The factory floors `DEFAULT_ADMIN_ROLE` at one live member
|
|
617
|
-
*
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
*
|
|
621
|
-
* administration permanently; it no longer does.
|
|
695
|
+
* **The factory floors `DEFAULT_ADMIN_ROLE` at one live member**, matching
|
|
696
|
+
* the instances. Renouncing or revoking the sole holder reverts `LastAdmin`,
|
|
697
|
+
* and granting the role to the zero address reverts `ZeroAdminGrant`, so the
|
|
698
|
+
* set can neither be emptied (which would freeze role administration
|
|
699
|
+
* permanently) nor satisfied by a member nobody controls.
|
|
622
700
|
*
|
|
623
701
|
* A handover is still available and is the supported way out: grant the
|
|
624
702
|
* successor first, then renounce.
|
|
@@ -638,12 +716,9 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
638
716
|
* the resolved sending account. Renouncing for somebody else is not a call
|
|
639
717
|
* that can succeed; use {@link revokeRole} to remove another account's role.
|
|
640
718
|
*
|
|
641
|
-
* The same
|
|
642
|
-
*
|
|
643
|
-
*
|
|
644
|
-
* actually stops working: role grants and revokes, permanently; not the
|
|
645
|
-
* operational setters, which keep answering to whoever already holds the
|
|
646
|
-
* role that gates them.
|
|
719
|
+
* The same `DEFAULT_ADMIN_ROLE` floor as {@link revokeRole} applies: the sole admin
|
|
720
|
+
* cannot renounce, the call reverts `LastAdmin`. Grant a successor first, then
|
|
721
|
+
* renounce.
|
|
647
722
|
*
|
|
648
723
|
* @returns The transaction hash.
|
|
649
724
|
*/
|
|
@@ -660,4 +735,3 @@ export declare class ConfidentialAirdropFactoryClient {
|
|
|
660
735
|
* @alpha
|
|
661
736
|
*/
|
|
662
737
|
export declare function createConfidentialAirdropFactoryClient(config: ConfidentialAirdropFactoryClientConfig): ConfidentialAirdropFactoryClient;
|
|
663
|
-
export {};
|
|
@@ -3,7 +3,7 @@ import type { PreflightResult } from "../core/preflight.js";
|
|
|
3
3
|
import { type DeploymentMode } from "./constants.js";
|
|
4
4
|
import { type AirdropVariant } from "./errors.js";
|
|
5
5
|
import type { ConfidentialAirdropFactoryClient } from "./factory.js";
|
|
6
|
-
import type { EcdsaAirdropParams, MerkleAirdropParams } from "./types.js";
|
|
6
|
+
import type { CreateCommitments, EcdsaAirdropParams, MerkleAirdropParams, PlannedCampaign } from "./types.js";
|
|
7
7
|
/**
|
|
8
8
|
* Chains the airdrop v2 contracts are reachable on.
|
|
9
9
|
*
|
|
@@ -105,8 +105,8 @@ export interface AssertSaltAvailableArgs {
|
|
|
105
105
|
*/
|
|
106
106
|
export declare function assertSaltAvailable(args: AssertSaltAvailableArgs): Promise<void>;
|
|
107
107
|
/**
|
|
108
|
-
* The slice of {@link ConfidentialAirdropFactoryClient}
|
|
109
|
-
*
|
|
108
|
+
* The slice of {@link ConfidentialAirdropFactoryClient} the create fee checks
|
|
109
|
+
* read. Structural so this module keeps its runtime-import-free shape; the real
|
|
110
110
|
* client satisfies it as-is.
|
|
111
111
|
*
|
|
112
112
|
* @alpha
|
|
@@ -116,7 +116,7 @@ export interface GasFeeResolver {
|
|
|
116
116
|
resolveGasFee(creator: Address): Promise<bigint>;
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
|
-
* Inputs for {@link
|
|
119
|
+
* Inputs for {@link assertCreateGasFee}.
|
|
120
120
|
*
|
|
121
121
|
* @alpha
|
|
122
122
|
*/
|
|
@@ -130,23 +130,31 @@ export interface AssertGasFeeAcceptedArgs {
|
|
|
130
130
|
method: string;
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
|
-
*
|
|
133
|
+
* Both create-time fee checks, in the order the factory's `_create` runs them:
|
|
134
|
+
* the resolved fee against the factory's own `maxGasFee` ceiling first
|
|
135
|
+
* (`GasFeeExceedsMaximum`), then against the creator's `maxAcceptedGasFee`
|
|
136
|
+
* (`GasFeeNotAccepted`). Reporting the bound first would tell a creator to
|
|
137
|
+
* raise it when the ceiling would refuse the create anyway.
|
|
134
138
|
*
|
|
135
|
-
* The contract enforces
|
|
136
|
-
* carries the
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
+
* The contract enforces both. Doing it here buys the reason: the revert
|
|
140
|
+
* carries the numbers but not which factory knob produced them, and a creator
|
|
141
|
+
* who sees `resolvedFee` next to their own bound can tell a raised default from
|
|
142
|
+
* a custom override they did not know they had.
|
|
139
143
|
*
|
|
140
144
|
* The range check is not redundant with the comparison - a bound outside
|
|
141
145
|
* `uint96` silently wraps at the ABI edge and could encode as a SMALLER number
|
|
142
146
|
* than intended, turning "accept anything" into "accept almost nothing".
|
|
143
147
|
*
|
|
144
|
-
* @throws {@link InvalidArgumentError} when `maxAcceptedGasFee` is
|
|
145
|
-
* @throws {@link GasFeeNotAcceptedError} when the
|
|
148
|
+
* @throws {@link InvalidArgumentError} when `maxAcceptedGasFee` is outside `uint96`, or on `gasFee` when the resolved fee exceeds the ceiling.
|
|
149
|
+
* @throws {@link GasFeeNotAcceptedError} when the resolved fee is within the ceiling but above the bound.
|
|
146
150
|
*
|
|
147
|
-
* @
|
|
151
|
+
* @internal
|
|
148
152
|
*/
|
|
149
|
-
export declare function
|
|
153
|
+
export declare function assertCreateGasFee(args: AssertGasFeeAcceptedArgs & {
|
|
154
|
+
factory: GasFeeResolver & {
|
|
155
|
+
maxGasFee(): Promise<bigint>;
|
|
156
|
+
};
|
|
157
|
+
}): Promise<void>;
|
|
150
158
|
/**
|
|
151
159
|
* Inputs for {@link assertPredictionFresh}.
|
|
152
160
|
*
|
|
@@ -175,6 +183,38 @@ export interface AssertPredictionFreshArgs {
|
|
|
175
183
|
* @alpha
|
|
176
184
|
*/
|
|
177
185
|
export declare function assertPredictionFresh(args: AssertPredictionFreshArgs): void;
|
|
186
|
+
/**
|
|
187
|
+
* Inputs for {@link resolvePlannedCreate}.
|
|
188
|
+
*
|
|
189
|
+
* @internal
|
|
190
|
+
*/
|
|
191
|
+
export interface ResolvePlannedCreateArgs {
|
|
192
|
+
/** Label for the thrown error. */
|
|
193
|
+
method: string;
|
|
194
|
+
params: MerkleAirdropParams;
|
|
195
|
+
expected?: Partial<CreateCommitments> | undefined;
|
|
196
|
+
/** Preflight only; the write path reads the live hash itself. */
|
|
197
|
+
expectedInitCodeHash?: Hex | undefined;
|
|
198
|
+
plan?: PlannedCampaign | undefined;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Fold a {@link PlannedCampaign} into the pins a Merkle create is sent with.
|
|
202
|
+
*
|
|
203
|
+
* Without a plan the caller's `expected` and `expectedInitCodeHash` come back
|
|
204
|
+
* untouched. With one, `expected.airdrop` becomes `plan.predictedAddress` and
|
|
205
|
+
* the drift check is judged against `plan.initCodeHashAfter`. A caller-supplied
|
|
206
|
+
* value that disagrees with the plan is refused rather than overridden, so the
|
|
207
|
+
* plan never silently wins over something the caller wrote down. Static: no RPC.
|
|
208
|
+
*
|
|
209
|
+
* @throws {@link InvalidArgumentError} when `params.merkleRoot`, `expected.airdrop`
|
|
210
|
+
* or `expectedInitCodeHash` disagrees with the plan.
|
|
211
|
+
*
|
|
212
|
+
* @internal
|
|
213
|
+
*/
|
|
214
|
+
export declare function resolvePlannedCreate(args: ResolvePlannedCreateArgs): {
|
|
215
|
+
expected: Partial<CreateCommitments> | undefined;
|
|
216
|
+
expectedInitCodeHash: Hex | undefined;
|
|
217
|
+
};
|
|
178
218
|
/** Fields shared by both variants of {@link PreflightCreateArgs}. */
|
|
179
219
|
interface PreflightCreateCommon {
|
|
180
220
|
factory: ConfidentialAirdropFactoryClient;
|
|
@@ -183,11 +223,35 @@ interface PreflightCreateCommon {
|
|
|
183
223
|
creator: Address;
|
|
184
224
|
userSalt: Hex;
|
|
185
225
|
/**
|
|
186
|
-
* The variant's init-code hash observed when the address was predicted
|
|
187
|
-
*
|
|
188
|
-
*
|
|
226
|
+
* The variant's init-code hash observed when the address was predicted.
|
|
227
|
+
* Supplying it turns on the drift check; omitting it skips that one check
|
|
228
|
+
* only. A Merkle `plan` supplies `plan.initCodeHashAfter` for you.
|
|
189
229
|
*/
|
|
190
230
|
expectedInitCodeHash?: Hex | undefined;
|
|
231
|
+
/**
|
|
232
|
+
* Commitments to pin instead of quoting fresh at send time. Anything omitted is read
|
|
233
|
+
* from the factory just before the transaction. For a {@link PlannedCampaign}, pass
|
|
234
|
+
* `plan` on the Merkle arm instead; `{ airdrop: plan.predictedAddress }` here is the
|
|
235
|
+
* lower-level equivalent of its pin.
|
|
236
|
+
*
|
|
237
|
+
* The preflight compares each pinned field with the factory's fresh quote and reports a
|
|
238
|
+
* `CreateCommitmentMismatchError` blocker (with that `field`) when they differ, since the
|
|
239
|
+
* factory would revert the create on it.
|
|
240
|
+
*/
|
|
241
|
+
expected?: Partial<CreateCommitments> | undefined;
|
|
242
|
+
}
|
|
243
|
+
/** @alpha */
|
|
244
|
+
export interface PreflightCreateResult extends PreflightResult {
|
|
245
|
+
/**
|
|
246
|
+
* The commitments the create would be sent with - the fresh quote with any pinned
|
|
247
|
+
* `expected` field taking precedence - what an app shows the creator and compares with a
|
|
248
|
+
* published record. A pinned field that differs from the fresh quote is reported here as
|
|
249
|
+
* pinned and also as a `CreateCommitmentMismatchError` blocker. Absent when a read
|
|
250
|
+
* producing the quote failed: with nothing pinned no blocker is added, and with a pin
|
|
251
|
+
* the failure is a blocker (a typed SDK error) or is rethrown (anything else), so the
|
|
252
|
+
* mismatch check is never skipped silently.
|
|
253
|
+
*/
|
|
254
|
+
commitments?: CreateCommitments;
|
|
191
255
|
}
|
|
192
256
|
/**
|
|
193
257
|
* Inputs for {@link preflightCreate}.
|
|
@@ -200,33 +264,49 @@ export type PreflightCreateArgs = PreflightCreateCommon & ({
|
|
|
200
264
|
} | {
|
|
201
265
|
variant: "merkle";
|
|
202
266
|
params: MerkleAirdropParams;
|
|
267
|
+
/**
|
|
268
|
+
* The {@link PlannedCampaign} the create will realise. Pins
|
|
269
|
+
* `expected.airdrop` to `plan.predictedAddress` and turns the drift check
|
|
270
|
+
* on against `plan.initCodeHashAfter`. A `params.merkleRoot`,
|
|
271
|
+
* `expected.airdrop` or `expectedInitCodeHash` that disagrees with the
|
|
272
|
+
* plan is reported as an `InvalidArgumentError` blocker.
|
|
273
|
+
*/
|
|
274
|
+
plan?: PlannedCampaign | undefined;
|
|
203
275
|
});
|
|
204
276
|
/**
|
|
205
277
|
* Run every create-time guardrail read-only and report what would block the
|
|
206
278
|
* transaction, instead of throwing on the first problem.
|
|
207
279
|
*
|
|
208
280
|
* Same checks and the same typed errors the write path enforces: chain
|
|
209
|
-
* support, the Merkle/UUPS refusal, the
|
|
210
|
-
* `
|
|
281
|
+
* support, the Merkle/UUPS refusal, params the instance initializer would
|
|
282
|
+
* revert on (a zero token, an `endTime` less than a minute away, a window
|
|
283
|
+
* that does not open before it closes, a zero immutable Merkle root, a zero
|
|
284
|
+
* ECDSA signer; `InvalidArgumentError` naming the field), the creator's resolved gas fee against
|
|
285
|
+
* `common.maxAcceptedGasFee` and against the factory's `maxGasFee` ceiling
|
|
286
|
+
* (an `InvalidArgumentError` on `gasFee`, the same error the create's
|
|
287
|
+
* `GasFeeExceedsMaximum` revert maps to), the creator's effective
|
|
211
288
|
* upgradeability policy when `mode: "uups"` is requested, the stock-wrapper
|
|
212
289
|
* probe when `unwrappable` is set, a salt collision on the predicted
|
|
213
|
-
* address
|
|
214
|
-
*
|
|
290
|
+
* address (the pinned `expected.airdrop` when given), a pinned commitment
|
|
291
|
+
* that no longer matches the factory's fresh quote, and - when
|
|
292
|
+
* `expectedInitCodeHash` or a Merkle `plan` is supplied - implementation
|
|
293
|
+
* drift since the prediction was taken. A `plan` that disagrees with
|
|
294
|
+
* `params.merkleRoot`, `expected.airdrop` or `expectedInitCodeHash` is an
|
|
295
|
+
* `InvalidArgumentError` blocker.
|
|
215
296
|
*
|
|
216
|
-
* @returns `{ ready, blockers }`. `blockers` carries the errors
|
|
217
|
-
* would have thrown, so a UI can branch on `error.code` exactly as
|
|
218
|
-
* in `onError
|
|
297
|
+
* @returns `{ ready, blockers, commitments }`. `blockers` carries the errors
|
|
298
|
+
* `create*` would have thrown, so a UI can branch on `error.code` exactly as
|
|
299
|
+
* it does in `onError`; `commitments` is what the create would be sent with.
|
|
219
300
|
*
|
|
220
301
|
* @example
|
|
221
302
|
* const { ready, blockers } = await preflightCreate({
|
|
222
|
-
* factory, variant: "merkle", params, mode: "clone", creator, userSalt,
|
|
223
|
-
* expectedInitCodeHash: plan.initCodeHashAfter,
|
|
303
|
+
* factory, variant: "merkle", params, mode: "clone", creator, userSalt, plan,
|
|
224
304
|
* });
|
|
225
305
|
* if (!ready) return blockers.map((b) => b.code);
|
|
226
306
|
*
|
|
227
307
|
* @alpha
|
|
228
308
|
*/
|
|
229
|
-
export declare function preflightCreate(args: PreflightCreateArgs): Promise<
|
|
309
|
+
export declare function preflightCreate(args: PreflightCreateArgs): Promise<PreflightCreateResult>;
|
|
230
310
|
/**
|
|
231
311
|
* The subset of an instance client {@link preflightClaim} reads.
|
|
232
312
|
*
|
|
@@ -353,22 +433,21 @@ export interface PreflightClaimArgs {
|
|
|
353
433
|
}
|
|
354
434
|
/**
|
|
355
435
|
* The three argument-relation rules the Merkle claim path enforces before it touches the
|
|
356
|
-
* coprocessor
|
|
357
|
-
*
|
|
436
|
+
* coprocessor: non-zero account, `claimAndUnwrap` is self-only, and only the account itself
|
|
437
|
+
* may redirect payout. All are decidable from the arguments alone, so both `preflightClaim`
|
|
438
|
+
* and the client's own write path run them - no RPC, no chance of a wasted fee.
|
|
358
439
|
*
|
|
359
440
|
* @param account The claim identity (`claim`'s leading argument).
|
|
360
441
|
* @param submitter The address that will send the transaction.
|
|
361
|
-
* @param boundTo The address the entry's input proof is bound to, when known.
|
|
362
442
|
* @param to The payout destination, if one will be passed.
|
|
363
443
|
* @param entrypoint `claimAndUnwrap` is self-only; `claim` accepts a third-party submitter.
|
|
364
|
-
* @throws {@link InvalidArgumentError} on a zero `account
|
|
444
|
+
* @throws {@link InvalidArgumentError} on a zero `account` or a third-party `claimAndUnwrap`.
|
|
365
445
|
* @throws {@link UnauthorizedRedirectError} when a third party tries to redirect payout.
|
|
366
446
|
*/
|
|
367
447
|
export declare function assertMerkleClaimIdentity(args: {
|
|
368
448
|
method: string;
|
|
369
449
|
account: Address;
|
|
370
450
|
submitter: Address;
|
|
371
|
-
boundTo?: Address | undefined;
|
|
372
451
|
to?: Address | undefined;
|
|
373
452
|
entrypoint?: "claim" | "claimAndUnwrap" | undefined;
|
|
374
453
|
}): void;
|