@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.
- package/CHANGELOG.md +48 -8
- package/CONTRIBUTING.md +4 -2
- package/README.md +146 -90
- package/SUPPORT.md +47 -0
- package/dist/{chunk-HETNKZEE.js → chunk-335Z2W67.js} +1 -1
- package/dist/{chunk-BD4LZBVF.cjs → chunk-3QHNYEQD.cjs} +18 -17
- package/dist/chunk-456VDDA3.js +370 -0
- package/dist/{chunk-6WSNS3UV.js → chunk-4RAAATVY.js} +2 -4
- package/dist/{chunk-4KJ66YRH.js → chunk-4TSDNZQ3.js} +2 -2
- package/dist/{chunk-WUXUWTFW.cjs → chunk-5576FRT3.cjs} +31 -7
- package/dist/chunk-66IHPTOK.cjs +20 -0
- package/dist/{chunk-2RNW4MIJ.cjs → chunk-67OV5CX2.cjs} +0 -18
- package/dist/{chunk-PD7ME2BT.js → chunk-6GNR22OV.js} +2 -1
- package/dist/{chunk-VHSNYUYV.js → chunk-6NAVMWZQ.js} +5 -5
- package/dist/{chunk-EUKPOXWR.cjs → chunk-6PXXGACR.cjs} +17 -15
- package/dist/{chunk-WTK6JDSI.js → chunk-74QFZ5MK.js} +6 -4
- package/dist/{chunk-WOEETTH7.cjs → chunk-7AFPOE7N.cjs} +6 -6
- package/dist/{chunk-U57COLUE.js → chunk-AXIPOR3C.js} +2 -2
- package/dist/chunk-CTED3MTR.cjs +380 -0
- package/dist/{chunk-QKKBBH7I.js → chunk-DZHYSUGY.js} +28 -7
- package/dist/{chunk-V5D7BHW3.js → chunk-EAJ7SYHE.js} +6 -4
- package/dist/{chunk-SYHNZSZZ.cjs → chunk-FAXIIH5R.cjs} +3 -3
- package/dist/{chunk-7G7UOQV4.cjs → chunk-FGEB7RMY.cjs} +4 -4
- package/dist/chunk-GKKDAW44.js +8823 -0
- package/dist/{chunk-QET3Q4JP.js → chunk-H5POPGOZ.js} +8 -6
- package/dist/{chunk-VR3FREBX.cjs → chunk-JK4XMMKM.cjs} +3 -3
- package/dist/{chunk-CBRL2PJA.cjs → chunk-JQYC66TO.cjs} +12 -12
- package/dist/{chunk-YFIWCYHC.cjs → chunk-JZLGCTGK.cjs} +56 -54
- package/dist/{chunk-4ZCXK4VI.cjs → chunk-KFRDLKMA.cjs} +14 -14
- package/dist/chunk-KWFFIJYX.js +11 -0
- package/dist/chunk-M4IT6DNJ.cjs +608 -0
- package/dist/{chunk-43RFBQ73.cjs → chunk-MVDQMV25.cjs} +29 -32
- package/dist/chunk-NCVX3K2N.cjs +161 -0
- package/dist/chunk-NWFMBLSQ.js +4 -0
- package/dist/chunk-O5676ZWY.js +585 -0
- package/dist/chunk-PUX5VXDB.cjs +8845 -0
- package/dist/{chunk-DRSPMIZ7.js → chunk-QBJ7O2B4.js} +1 -11
- package/dist/{chunk-UJS4N2XM.cjs → chunk-TEBM66WA.cjs} +12 -12
- package/dist/{chunk-TN65XNTI.js → chunk-TWT3STIX.js} +8 -6
- package/dist/chunk-UG5RKLU2.cjs +6 -0
- package/dist/chunk-VP2B4WM2.js +154 -0
- package/dist/{chunk-BK7YIVLK.cjs → chunk-WJLECC22.cjs} +75 -73
- package/dist/{chunk-NFW7AUEX.js → chunk-WMACINXO.js} +1 -1
- package/dist/{chunk-AYGRYDBX.cjs → chunk-XAYGD4E4.cjs} +37 -35
- package/dist/{chunk-46T67CE2.js → chunk-ZA673I3O.js} +1 -1
- package/dist/{chunk-YPYCWLYP.js → chunk-ZWXJTBZO.js} +1 -1
- package/dist/core/addresses.d.ts +14 -2
- package/dist/core/brands.d.ts +8 -2
- package/dist/core/errors.d.ts +71 -10
- package/dist/core/preflight.d.ts +1 -0
- package/dist/fhe/erc7984-abi.d.ts +1 -0
- package/dist/fhe/index.cjs +64 -63
- package/dist/fhe/index.js +7 -6
- package/dist/fhe/operators.d.ts +22 -5
- package/dist/fhe/react/index.cjs +13 -12
- package/dist/fhe/react/index.js +6 -5
- package/dist/fhe/types.d.ts +6 -0
- package/dist/fhe-airdrop/abis/{cloneable.d.ts → airdrop-base.d.ts} +254 -396
- package/dist/fhe-airdrop/abis/compliance.d.ts +422 -0
- package/dist/fhe-airdrop/abis/ecdsa.d.ts +1316 -0
- package/dist/fhe-airdrop/abis/factory.d.ts +1319 -190
- package/dist/fhe-airdrop/abis/index.d.ts +5 -2
- package/dist/fhe-airdrop/abis/merkle.d.ts +1238 -0
- package/dist/fhe-airdrop/advanced/index.cjs +11 -12
- package/dist/fhe-airdrop/advanced/index.d.cts +34 -11
- package/dist/fhe-airdrop/advanced/index.d.ts +34 -11
- package/dist/fhe-airdrop/advanced/index.js +3 -8
- package/dist/fhe-airdrop/advanced/react/index.cjs +37 -50
- package/dist/fhe-airdrop/advanced/react/index.d.cts +9 -3
- package/dist/fhe-airdrop/advanced/react/index.d.ts +9 -3
- package/dist/fhe-airdrop/advanced/react/index.js +36 -50
- package/dist/fhe-airdrop/advanced/react/usePredictEcdsaAirdropAddress.d.ts +33 -0
- package/dist/fhe-airdrop/advanced/react/usePredictMerkleAirdropAddress.d.ts +27 -0
- package/dist/fhe-airdrop/airdrop-base.d.ts +600 -0
- package/dist/fhe-airdrop/campaign.d.ts +297 -0
- package/dist/fhe-airdrop/compliance.d.ts +302 -0
- package/dist/fhe-airdrop/constants.d.ts +33 -0
- package/dist/fhe-airdrop/ecdsa.d.ts +263 -0
- package/dist/fhe-airdrop/encryption.d.ts +92 -14
- package/dist/fhe-airdrop/errors.d.ts +245 -15
- package/dist/fhe-airdrop/factory.d.ts +533 -274
- package/dist/fhe-airdrop/guards.d.ts +273 -0
- package/dist/fhe-airdrop/index.cjs +1131 -74
- package/dist/fhe-airdrop/index.d.cts +46 -8
- package/dist/fhe-airdrop/index.d.ts +46 -8
- package/dist/fhe-airdrop/index.js +931 -8
- package/dist/fhe-airdrop/merkle-tree.d.ts +103 -0
- package/dist/fhe-airdrop/merkle.d.ts +180 -0
- package/dist/fhe-airdrop/react/_shared.d.ts +144 -71
- package/dist/fhe-airdrop/react/index.cjs +399 -459
- package/dist/fhe-airdrop/react/index.d.cts +53 -74
- package/dist/fhe-airdrop/react/index.d.ts +53 -74
- package/dist/fhe-airdrop/react/index.js +261 -374
- package/dist/fhe-airdrop/react/useAirdropGasFee.d.ts +10 -5
- package/dist/fhe-airdrop/react/useAirdropHasRole.d.ts +15 -6
- package/dist/fhe-airdrop/react/useAirdropPause.d.ts +30 -0
- package/dist/fhe-airdrop/react/useAirdropPaused.d.ts +17 -0
- package/dist/fhe-airdrop/react/useAirdropToken.d.ts +11 -4
- package/dist/fhe-airdrop/react/useAirdropWindow.d.ts +37 -0
- package/dist/fhe-airdrop/react/useClaimedAmount.d.ts +29 -0
- package/dist/fhe-airdrop/react/useComplianceManager.d.ts +16 -0
- package/dist/fhe-airdrop/react/useCreateEcdsaAirdrop.d.ts +28 -0
- package/dist/fhe-airdrop/react/useCreateMerkleAirdrop.d.ts +25 -0
- package/dist/fhe-airdrop/react/useEcdsaClaim.d.ts +23 -0
- package/dist/fhe-airdrop/react/useEffectiveUpgradeable.d.ts +20 -0
- package/dist/fhe-airdrop/react/useExtendClaimWindow.d.ts +17 -12
- package/dist/fhe-airdrop/react/useFactoryFees.d.ts +28 -0
- package/dist/fhe-airdrop/react/useFactoryRegistry.d.ts +35 -0
- package/dist/fhe-airdrop/react/useFundAirdrop.d.ts +35 -0
- package/dist/fhe-airdrop/react/useGrantInstanceRoles.d.ts +35 -0
- package/dist/fhe-airdrop/react/useMerkleClaim.d.ts +34 -0
- package/dist/fhe-airdrop/react/useMerkleRoot.d.ts +15 -0
- package/dist/fhe-airdrop/react/useSetMerkleRoot.d.ts +22 -0
- package/dist/fhe-airdrop/react/useWithdrawConfidential.d.ts +23 -0
- package/dist/fhe-airdrop/roles.d.ts +147 -0
- package/dist/fhe-airdrop/types.d.ts +67 -65
- package/dist/fhe-disperse/index.cjs +70 -68
- package/dist/fhe-disperse/index.js +10 -8
- package/dist/fhe-disperse/react/index.cjs +94 -92
- package/dist/fhe-disperse/react/index.js +13 -11
- package/dist/fhe-vesting/advanced/index.cjs +10 -8
- package/dist/fhe-vesting/advanced/index.js +8 -6
- package/dist/fhe-vesting/advanced/react/index.cjs +16 -14
- package/dist/fhe-vesting/advanced/react/index.js +13 -11
- package/dist/fhe-vesting/index.cjs +74 -72
- package/dist/fhe-vesting/index.js +11 -9
- package/dist/fhe-vesting/react/index.cjs +228 -226
- package/dist/fhe-vesting/react/index.js +15 -13
- package/dist/index.cjs +100 -87
- package/dist/index.js +3 -2
- package/dist/testnet-faucet/index.cjs +57 -55
- package/dist/testnet-faucet/index.js +7 -5
- package/dist/testnet-faucet/react/index.cjs +55 -53
- package/dist/testnet-faucet/react/index.js +9 -7
- package/package.json +6 -2
- package/dist/chunk-CNP4L3GF.js +0 -105
- package/dist/chunk-KSDSXJ34.js +0 -41
- package/dist/chunk-LBWRFZR3.cjs +0 -1681
- package/dist/chunk-OL6SHN3D.cjs +0 -44
- package/dist/chunk-S2XD75JM.js +0 -1637
- package/dist/chunk-SPGSO5SO.cjs +0 -1644
- package/dist/chunk-UE5XK2SY.js +0 -1673
- package/dist/chunk-WO72UBQD.cjs +0 -109
- package/dist/fhe-airdrop/advanced/factory-advanced.d.ts +0 -53
- package/dist/fhe-airdrop/advanced/react/usePredictAirdropAddress.d.ts +0 -49
- package/dist/fhe-airdrop/airdrop.d.ts +0 -317
- package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +0 -37
- package/dist/fhe-airdrop/react/useAirdropCanExtendClaimWindow.d.ts +0 -7
- package/dist/fhe-airdrop/react/useAirdropClaimTypehash.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropClaimedSignatures.d.ts +0 -16
- package/dist/fhe-airdrop/react/useAirdropDeploymentBlockNumber.d.ts +0 -6
- package/dist/fhe-airdrop/react/useAirdropDomainSeparator.d.ts +0 -8
- package/dist/fhe-airdrop/react/useAirdropEndTime.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropFactoryCustomFee.d.ts +0 -17
- package/dist/fhe-airdrop/react/useAirdropFactoryDefaultGasFee.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropFactoryDisableCustomFee.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropFactoryFeeCollector.d.ts +0 -11
- package/dist/fhe-airdrop/react/useAirdropFactoryInitCodeHash.d.ts +0 -17
- package/dist/fhe-airdrop/react/useAirdropFactorySetCustomFee.d.ts +0 -17
- package/dist/fhe-airdrop/react/useAirdropFactorySetDefaultGasFee.d.ts +0 -16
- package/dist/fhe-airdrop/react/useAirdropFactorySetFeeCollector.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropGrantRole.d.ts +0 -16
- package/dist/fhe-airdrop/react/useAirdropHasClaimEnded.d.ts +0 -7
- package/dist/fhe-airdrop/react/useAirdropHasClaimStarted.d.ts +0 -7
- package/dist/fhe-airdrop/react/useAirdropIsClaimWindowActive.d.ts +0 -9
- package/dist/fhe-airdrop/react/useAirdropIsPaused.d.ts +0 -8
- package/dist/fhe-airdrop/react/useAirdropIsSignatureClaimed.d.ts +0 -22
- package/dist/fhe-airdrop/react/useAirdropIsSignatureValid.d.ts +0 -51
- package/dist/fhe-airdrop/react/useAirdropRevokeRole.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropStartTime.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropWithdrawGasFee.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropWithdrawOtherConfidentialToken.d.ts +0 -14
- package/dist/fhe-airdrop/react/useAirdropWithdrawOtherToken.d.ts +0 -14
- package/dist/fhe-airdrop/react/useClaim.d.ts +0 -39
- package/dist/fhe-airdrop/react/useConfidentialAirdropFactoryImplementation.d.ts +0 -11
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +0 -41
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +0 -48
- package/dist/fhe-airdrop/react/useCreateConfidentialAirdrop.d.ts +0 -29
- package/dist/fhe-airdrop/react/useCreateConfidentialAirdropAndGetAddress.d.ts +0 -31
- package/dist/fhe-airdrop/react/useDisableCustomFee.d.ts +0 -14
- package/dist/fhe-airdrop/react/useFactoryCustomFee.d.ts +0 -17
- package/dist/fhe-airdrop/react/useFactoryDefaultGasFee.d.ts +0 -10
- package/dist/fhe-airdrop/react/useFactoryFeeCollector.d.ts +0 -11
- package/dist/fhe-airdrop/react/useFactoryInitCodeHash.d.ts +0 -17
- package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +0 -33
- package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +0 -51
- package/dist/fhe-airdrop/react/useSetCustomFee.d.ts +0 -16
- package/dist/fhe-airdrop/react/useSetDefaultGasFee.d.ts +0 -15
- package/dist/fhe-airdrop/react/useSetFeeCollector.d.ts +0 -14
- package/dist/fhe-airdrop/react/useSetPaused.d.ts +0 -14
- package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +0 -31
- package/dist/fhe-airdrop/react/useWithdraw.d.ts +0 -12
- package/dist/fhe-airdrop/react/useWithdrawOtherConfidentialToken.d.ts +0 -13
- package/dist/fhe-airdrop/react/useWithdrawOtherToken.d.ts +0 -13
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import type { Address, Hex, PublicClient } from "viem";
|
|
2
|
+
import type { PreflightResult } from "../core/preflight.js";
|
|
3
|
+
import type { DeploymentMode } from "./constants.js";
|
|
4
|
+
import { type AirdropVariant } from "./errors.js";
|
|
5
|
+
import type { ConfidentialAirdropFactoryClient } from "./factory.js";
|
|
6
|
+
import type { EcdsaAirdropParams, MerkleAirdropParams } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Chains the airdrop v2 contracts are reachable on.
|
|
9
|
+
*
|
|
10
|
+
* Beyond the address registry this encodes an FHEVM constraint: every instance
|
|
11
|
+
* reads `ZamaConfig` at initialize time and reverts with
|
|
12
|
+
* `ZamaProtocolUnsupported` (declared by `@fhevm/solidity`, reached through
|
|
13
|
+
* `FHE.setCoprocessor`) anywhere the protocol is absent. An out-of-list chain
|
|
14
|
+
* can therefore only ever produce a wasted transaction.
|
|
15
|
+
*/
|
|
16
|
+
export declare const SUPPORTED_CHAIN_IDS: readonly number[];
|
|
17
|
+
/**
|
|
18
|
+
* Refuse a chain the airdrop v2 contracts are not reachable on.
|
|
19
|
+
*
|
|
20
|
+
* Every client in this module calls it from its constructor, before resolving
|
|
21
|
+
* an address: an unsupported chain is a hard "no", whereas a missing registry
|
|
22
|
+
* entry is a "not deployed there yet", and the two deserve different errors.
|
|
23
|
+
*
|
|
24
|
+
* @throws {@link UnsupportedChainError} for anything outside {@link SUPPORTED_CHAIN_IDS}.
|
|
25
|
+
*/
|
|
26
|
+
export declare function assertSupportedChain(chainId: number): void;
|
|
27
|
+
/**
|
|
28
|
+
* Refuse `mode: "uups"` for a Merkle campaign.
|
|
29
|
+
*
|
|
30
|
+
* The Merkle implementation's per-account `claimedAmount` mapping occupies an
|
|
31
|
+
* ERC-7201 namespaced slot that an earlier revision typed differently, so an
|
|
32
|
+
* in-place upgrade across that change reinterprets live storage - see
|
|
33
|
+
* {@link MerkleUupsUnsupportedError} for the full mechanism. Refusing at
|
|
34
|
+
* create time is what guarantees no SDK-created Merkle instance can ever be
|
|
35
|
+
* upgraded across it.
|
|
36
|
+
*
|
|
37
|
+
* Static: no RPC, so it runs before anything else on the Merkle create paths.
|
|
38
|
+
* The factory's `defaultUpgradeable == false` currently makes a UUPS create
|
|
39
|
+
* revert on-chain anyway, but that is a mutable policy owned by an admin key -
|
|
40
|
+
* this guard does not depend on it.
|
|
41
|
+
*
|
|
42
|
+
* @throws {@link MerkleUupsUnsupportedError} when `mode` is `"uups"`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function assertMerkleModeSupported(mode: DeploymentMode): void;
|
|
45
|
+
/** Inputs for {@link assertStockWrapper}. */
|
|
46
|
+
export interface AssertStockWrapperArgs {
|
|
47
|
+
publicClient: PublicClient;
|
|
48
|
+
/** The campaign's ERC-7984 token. */
|
|
49
|
+
token: Address;
|
|
50
|
+
/** The create-time flag. A `false` here makes this guard a no-op, by design. */
|
|
51
|
+
unwrappable: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Refuse `unwrappable: true` on a token that does not probe as a stock
|
|
55
|
+
* `ERC7984ERC20Wrapper` — see {@link NonStockWrapperError} for why a
|
|
56
|
+
* non-stock wrapper breaks `claimAndUnwrap`'s accounting.
|
|
57
|
+
*
|
|
58
|
+
* Needs one read, so it runs before the send rather than before the RPC. A
|
|
59
|
+
* CONTRACT REVERT, a zero-data return, or a zero-address answer from
|
|
60
|
+
* `underlying()` is taken as "not a stock wrapper": the probe cannot prove a
|
|
61
|
+
* wrapper is unhooked, only that it presents the stock interface, which is the
|
|
62
|
+
* strongest statement available off-chain and strictly better than discovering
|
|
63
|
+
* it at claim time.
|
|
64
|
+
*
|
|
65
|
+
* Anything that is not one of those — an RPC timeout, a rate limit, a client
|
|
66
|
+
* pointed at the wrong chain — is rethrown as itself. Reporting a transport
|
|
67
|
+
* failure as `NonStockWrapperError` would block a legitimate
|
|
68
|
+
* `unwrappable: true` create with a diagnosis the caller cannot act on;
|
|
69
|
+
* `isContractRevert` is the same discriminator the module's `#preflightWrite`
|
|
70
|
+
* implementations use for exactly this distinction.
|
|
71
|
+
*
|
|
72
|
+
* @throws {@link NonStockWrapperError} when `unwrappable` is set and the probe reverts, returns no data, or answers zero.
|
|
73
|
+
* @throws The underlying transport error, unchanged, when the probe fails for any other reason.
|
|
74
|
+
*/
|
|
75
|
+
export declare function assertStockWrapper(args: AssertStockWrapperArgs): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Inputs for {@link assertSaltAvailable}.
|
|
78
|
+
*
|
|
79
|
+
* @alpha
|
|
80
|
+
*/
|
|
81
|
+
export interface AssertSaltAvailableArgs {
|
|
82
|
+
publicClient: PublicClient;
|
|
83
|
+
/** The address the factory's prediction oracle returned for this tuple. */
|
|
84
|
+
predictedAddress: Address;
|
|
85
|
+
variant: AirdropVariant;
|
|
86
|
+
mode: DeploymentMode;
|
|
87
|
+
deployer: Address;
|
|
88
|
+
userSalt: Hex;
|
|
89
|
+
/** Label for the thrown error. */
|
|
90
|
+
method: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Refuse a create whose predicted address is already occupied.
|
|
94
|
+
*
|
|
95
|
+
* A predicted address commits to `(implementation, mode, deployer, userSalt)`
|
|
96
|
+
* and nothing else, so reusing a salt collides regardless of how different the
|
|
97
|
+
* two campaigns' params are - and the contracts' own default salt label
|
|
98
|
+
* (`airdrop.<type>.<token>.<caller>`) collides on the second campaign a caller
|
|
99
|
+
* runs against one token. One `eth_getCode` turns that into a named error
|
|
100
|
+
* instead of a revert the caller has to decode.
|
|
101
|
+
*
|
|
102
|
+
* @throws {@link SaltCollisionError} when the predicted address holds code.
|
|
103
|
+
*
|
|
104
|
+
* @alpha
|
|
105
|
+
*/
|
|
106
|
+
export declare function assertSaltAvailable(args: AssertSaltAvailableArgs): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Inputs for {@link assertPredictionFresh}.
|
|
109
|
+
*
|
|
110
|
+
* @alpha
|
|
111
|
+
*/
|
|
112
|
+
export interface AssertPredictionFreshArgs {
|
|
113
|
+
variant: AirdropVariant;
|
|
114
|
+
/** Init-code hash read before the prediction was put to use. */
|
|
115
|
+
initCodeHashBefore: Hex;
|
|
116
|
+
/** The same hash read after. */
|
|
117
|
+
initCodeHashAfter: Hex;
|
|
118
|
+
predictedAddress?: Address | undefined;
|
|
119
|
+
/** Label for the thrown error. */
|
|
120
|
+
method: string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Judge the two init-code-hash observations a prediction-consuming flow takes
|
|
124
|
+
* on either side of its work.
|
|
125
|
+
*
|
|
126
|
+
* Equal hashes mean the factory's implementation pointer for the variant did
|
|
127
|
+
* not move, so the predicted address still stands. Different hashes mean it
|
|
128
|
+
* did, and everything derived from the prediction is stale.
|
|
129
|
+
*
|
|
130
|
+
* @throws {@link PredictionDriftError} when the two hashes differ.
|
|
131
|
+
*
|
|
132
|
+
* @alpha
|
|
133
|
+
*/
|
|
134
|
+
export declare function assertPredictionFresh(args: AssertPredictionFreshArgs): void;
|
|
135
|
+
/** Fields shared by both variants of {@link PreflightCreateArgs}. */
|
|
136
|
+
interface PreflightCreateCommon {
|
|
137
|
+
factory: ConfidentialAirdropFactoryClient;
|
|
138
|
+
mode: DeploymentMode;
|
|
139
|
+
/** The account that will send `create*`. CREATE2 salts are per-deployer. */
|
|
140
|
+
creator: Address;
|
|
141
|
+
userSalt: Hex;
|
|
142
|
+
/**
|
|
143
|
+
* The variant's init-code hash observed when the address was predicted -
|
|
144
|
+
* e.g. `PlannedCampaign.initCodeHashAfter`. Supplying it turns on the
|
|
145
|
+
* drift check; omitting it skips that one check only.
|
|
146
|
+
*/
|
|
147
|
+
expectedInitCodeHash?: Hex | undefined;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Inputs for {@link preflightCreate}.
|
|
151
|
+
*
|
|
152
|
+
* @alpha
|
|
153
|
+
*/
|
|
154
|
+
export type PreflightCreateArgs = PreflightCreateCommon & ({
|
|
155
|
+
variant: "ecdsa";
|
|
156
|
+
params: EcdsaAirdropParams;
|
|
157
|
+
} | {
|
|
158
|
+
variant: "merkle";
|
|
159
|
+
params: MerkleAirdropParams;
|
|
160
|
+
});
|
|
161
|
+
/**
|
|
162
|
+
* Run every create-time guardrail read-only and report what would block the
|
|
163
|
+
* transaction, instead of throwing on the first problem.
|
|
164
|
+
*
|
|
165
|
+
* Same checks and the same typed errors the write path enforces: chain
|
|
166
|
+
* support, the Merkle/UUPS refusal, the creator's effective
|
|
167
|
+
* upgradeability policy when `mode: "uups"` is requested, the stock-wrapper
|
|
168
|
+
* probe when `unwrappable` is set, a salt collision on the predicted
|
|
169
|
+
* address, and - when `expectedInitCodeHash` is supplied - implementation
|
|
170
|
+
* drift since the prediction was taken.
|
|
171
|
+
*
|
|
172
|
+
* @returns `{ ready, blockers }`. `blockers` carries the errors `create*`
|
|
173
|
+
* would have thrown, so a UI can branch on `error.code` exactly as it does
|
|
174
|
+
* in `onError`.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* const { ready, blockers } = await preflightCreate({
|
|
178
|
+
* factory, variant: "merkle", params, mode: "clone", creator, userSalt,
|
|
179
|
+
* expectedInitCodeHash: plan.initCodeHashAfter,
|
|
180
|
+
* });
|
|
181
|
+
* if (!ready) return blockers.map((b) => b.code);
|
|
182
|
+
*
|
|
183
|
+
* @alpha
|
|
184
|
+
*/
|
|
185
|
+
export declare function preflightCreate(args: PreflightCreateArgs): Promise<PreflightResult>;
|
|
186
|
+
/**
|
|
187
|
+
* The subset of an instance client {@link preflightClaim} reads.
|
|
188
|
+
*
|
|
189
|
+
* Declared structurally rather than as `AirdropBaseClient` so this module
|
|
190
|
+
* stays free of a runtime import of the client it guards; `AirdropBaseClient`
|
|
191
|
+
* and both variant subclasses satisfy it as-is.
|
|
192
|
+
*
|
|
193
|
+
* @alpha
|
|
194
|
+
*/
|
|
195
|
+
export interface ClaimPreflightTarget {
|
|
196
|
+
readonly address: Address;
|
|
197
|
+
readonly chainId: number;
|
|
198
|
+
readonly publicClient: PublicClient;
|
|
199
|
+
hasClaimStarted(): Promise<boolean>;
|
|
200
|
+
hasClaimEnded(): Promise<boolean>;
|
|
201
|
+
startTime(): Promise<number>;
|
|
202
|
+
endTime(): Promise<number>;
|
|
203
|
+
gasFee(): Promise<bigint>;
|
|
204
|
+
/**
|
|
205
|
+
* The raw `PausableUpgradeable` flag, NOT `isClaimWindowActive()` — the
|
|
206
|
+
* latter ANDs the pause and the window together, which cannot say which of
|
|
207
|
+
* the two blocked the claim.
|
|
208
|
+
*/
|
|
209
|
+
paused(): Promise<boolean>;
|
|
210
|
+
/** Present on `EcdsaAirdropClient` only. */
|
|
211
|
+
isSignatureValid?: (args: {
|
|
212
|
+
recipient: Address;
|
|
213
|
+
encryptedAmountHandle: Hex;
|
|
214
|
+
dedupId: Hex;
|
|
215
|
+
deadline: bigint;
|
|
216
|
+
signer: Address;
|
|
217
|
+
signature: Hex;
|
|
218
|
+
}) => Promise<boolean>;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* The signature material {@link preflightClaim} needs to check an ECDSA claim.
|
|
222
|
+
*
|
|
223
|
+
* @alpha
|
|
224
|
+
*/
|
|
225
|
+
export interface EcdsaClaimPreflightSignature {
|
|
226
|
+
/** The external handle only - a view never calls `FHE.fromExternal`, so no input proof. */
|
|
227
|
+
encryptedAmountHandle: Hex;
|
|
228
|
+
dedupId: Hex;
|
|
229
|
+
deadline: bigint;
|
|
230
|
+
signer: Address;
|
|
231
|
+
signature: Hex;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Inputs for {@link preflightClaim}.
|
|
235
|
+
*
|
|
236
|
+
* @alpha
|
|
237
|
+
*/
|
|
238
|
+
export interface PreflightClaimArgs {
|
|
239
|
+
airdrop: ClaimPreflightTarget;
|
|
240
|
+
/** The account that will send the claim - not the payout destination. */
|
|
241
|
+
claimant: Address;
|
|
242
|
+
/**
|
|
243
|
+
* ECDSA campaigns only. Supplied together with a client that exposes
|
|
244
|
+
* `isSignatureValid`, it adds the authorisation check to the report.
|
|
245
|
+
*/
|
|
246
|
+
signature?: EcdsaClaimPreflightSignature | undefined;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Report what would stop `claim` / `claimAndUnwrap` right now, without sending
|
|
250
|
+
* anything.
|
|
251
|
+
*
|
|
252
|
+
* Checks the chain, the pause flag, the claim window on both ends, whether the
|
|
253
|
+
* claimant can cover the instance's exact-equality gas fee, and - for an ECDSA
|
|
254
|
+
* campaign given `signature` - whether the authorisation is currently valid and
|
|
255
|
+
* unconsumed.
|
|
256
|
+
*
|
|
257
|
+
* The pause is read on its own rather than through `isClaimWindowActive()`:
|
|
258
|
+
* that read ANDs the pause and the window together, so a `false` from it
|
|
259
|
+
* cannot say which of the two blocked the claim, whereas the window is already
|
|
260
|
+
* reported here as two distinct blockers. A paused campaign therefore appears
|
|
261
|
+
* as its own `PausedError` — the likeliest reason a claim reverts while the
|
|
262
|
+
* window is open.
|
|
263
|
+
*
|
|
264
|
+
* It deliberately does NOT check the claimant's allocation:
|
|
265
|
+
* that value is encrypted, and an SDK-side "you have nothing to claim" would
|
|
266
|
+
* require decrypting it.
|
|
267
|
+
*
|
|
268
|
+
* @returns `{ ready, blockers }` with the same typed errors the claim would throw.
|
|
269
|
+
*
|
|
270
|
+
* @alpha
|
|
271
|
+
*/
|
|
272
|
+
export declare function preflightClaim(args: PreflightClaimArgs): Promise<PreflightResult>;
|
|
273
|
+
export {};
|