@tokenops/sdk 1.5.1 → 2.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +198 -2
- package/CONTRIBUTING.md +4 -2
- package/README.md +146 -90
- package/SECURITY.md +7 -1
- package/SUPPORT.md +47 -0
- package/dist/{chunk-YQIBBEFJ.js → chunk-335Z2W67.js} +1 -1
- package/dist/{chunk-2NCLOQ56.cjs → chunk-3QHNYEQD.cjs} +77 -0
- package/dist/chunk-456VDDA3.js +370 -0
- package/dist/{chunk-SG65XWH7.js → chunk-4RAAATVY.js} +1 -3
- package/dist/{chunk-6BMP4ICG.js → chunk-4TSDNZQ3.js} +60 -2
- package/dist/{chunk-PUPKNW3R.cjs → chunk-5576FRT3.cjs} +30 -6
- package/dist/{chunk-AOP6HMPW.js → chunk-6GNR22OV.js} +75 -1
- package/dist/{chunk-NTZY6IB7.js → chunk-6NAVMWZQ.js} +4 -3
- package/dist/{chunk-C7BRZXJA.cjs → chunk-6PXXGACR.cjs} +8 -7
- package/dist/{chunk-IJFQ5L4I.js → chunk-74QFZ5MK.js} +4 -3
- package/dist/chunk-7AFPOE7N.cjs +59 -0
- package/dist/chunk-AXIPOR3C.js +56 -0
- package/dist/chunk-CTED3MTR.cjs +380 -0
- package/dist/{chunk-XGGTQQFH.js → chunk-DZHYSUGY.js} +28 -7
- package/dist/{chunk-OXTLPTO3.js → chunk-EAJ7SYHE.js} +4 -3
- package/dist/{chunk-V2PXZVBF.cjs → chunk-FGEB7RMY.cjs} +4 -4
- package/dist/chunk-GKKDAW44.js +8823 -0
- package/dist/{chunk-2PWNH3UE.js → chunk-H5POPGOZ.js} +63 -5
- package/dist/{chunk-W7IGCOVL.cjs → chunk-JQYC66TO.cjs} +9 -8
- package/dist/{chunk-PFXURMBZ.cjs → chunk-JZLGCTGK.cjs} +68 -8
- package/dist/{chunk-JYOTGRSO.cjs → chunk-KFRDLKMA.cjs} +61 -1
- package/dist/chunk-M4IT6DNJ.cjs +608 -0
- package/dist/{chunk-KLKI352M.cjs → chunk-MVDQMV25.cjs} +0 -3
- 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-IXLO7GO5.js → chunk-TWT3STIX.js} +46 -80
- package/dist/chunk-UG5RKLU2.cjs +6 -0
- package/dist/chunk-VP2B4WM2.js +154 -0
- package/dist/{chunk-5X5WL5CU.cjs → chunk-WJLECC22.cjs} +51 -88
- package/dist/{chunk-WENHUPZC.cjs → chunk-XAYGD4E4.cjs} +9 -8
- package/dist/core/addresses.d.ts +15 -3
- 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 +34 -13
- package/dist/fhe/index.d.cts +1 -0
- package/dist/fhe/index.d.ts +1 -0
- package/dist/fhe/index.js +19 -6
- package/dist/fhe/mock-erc7984.d.ts +4 -4
- package/dist/fhe/operators.d.ts +160 -3
- package/dist/fhe/react/index.cjs +14 -0
- package/dist/fhe/react/index.d.cts +2 -0
- package/dist/fhe/react/index.d.ts +2 -0
- package/dist/fhe/react/index.js +6 -0
- package/dist/fhe/react/useEnsureOperator.d.ts +56 -0
- package/dist/fhe/react/useIsOperator.d.ts +54 -0
- package/dist/fhe/sepolia-encryptor-web.d.ts +18 -3
- 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 +10 -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 +2 -8
- package/dist/fhe-airdrop/advanced/react/index.cjs +34 -48
- 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 +33 -48
- 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 +1089 -33
- package/dist/fhe-airdrop/index.d.cts +46 -8
- package/dist/fhe-airdrop/index.d.ts +46 -8
- package/dist/fhe-airdrop/index.js +929 -7
- 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 +364 -413
- package/dist/fhe-airdrop/react/index.d.cts +53 -72
- package/dist/fhe-airdrop/react/index.d.ts +53 -72
- package/dist/fhe-airdrop/react/index.js +258 -369
- 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 +68 -55
- package/dist/fhe-disperse/errors.d.ts +55 -0
- package/dist/fhe-disperse/index.cjs +34 -25
- package/dist/fhe-disperse/index.d.cts +1 -1
- package/dist/fhe-disperse/index.d.ts +1 -1
- package/dist/fhe-disperse/index.js +6 -5
- package/dist/fhe-disperse/react/index.cjs +42 -23
- package/dist/fhe-disperse/react/index.d.cts +3 -1
- package/dist/fhe-disperse/react/index.d.ts +3 -1
- package/dist/fhe-disperse/react/index.js +9 -6
- package/dist/fhe-vesting/advanced/index.cjs +8 -7
- package/dist/fhe-vesting/advanced/index.js +6 -5
- package/dist/fhe-vesting/advanced/react/index.cjs +12 -11
- package/dist/fhe-vesting/advanced/react/index.js +9 -8
- package/dist/fhe-vesting/index.cjs +35 -34
- package/dist/fhe-vesting/index.js +7 -6
- package/dist/fhe-vesting/manager.d.ts +19 -0
- package/dist/fhe-vesting/react/index.cjs +160 -140
- package/dist/fhe-vesting/react/index.d.cts +6 -4
- package/dist/fhe-vesting/react/index.d.ts +6 -4
- package/dist/fhe-vesting/react/index.js +24 -16
- package/dist/fhe-vesting/react/useAccessClaimableAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessSettledAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessTotalAllocation.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessVestedAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAdminGetClaimableAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetSettledAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetTotalAllocation.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetVestedAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +8 -0
- package/dist/fhe-vesting/react/useClaim.d.ts +1 -1
- package/dist/fhe-vesting/react/useDiscloseHandleToParty.d.ts +1 -1
- package/dist/fhe-vesting/react/useManagerDiscloseHandleToParty.d.ts +1 -1
- package/dist/fhe-vesting/react/usePartialClaim.d.ts +1 -1
- package/dist/fhe-vesting/react/useVestingInfo.d.ts +1 -1
- package/dist/fhe-vesting/types.d.ts +12 -1
- package/dist/index.cjs +27 -15
- package/dist/index.js +1 -1
- package/dist/testnet-faucet/index.cjs +17 -16
- package/dist/testnet-faucet/index.js +5 -4
- package/dist/testnet-faucet/react/index.cjs +11 -10
- package/dist/testnet-faucet/react/index.js +6 -5
- package/package.json +18 -9
- package/dist/chunk-4WPGQSNT.cjs +0 -44
- package/dist/chunk-6R4KNAPK.js +0 -1630
- package/dist/chunk-DUZIIRPF.js +0 -1655
- package/dist/chunk-MCRBVJGZ.cjs +0 -1637
- package/dist/chunk-ODLTEGHB.js +0 -41
- package/dist/chunk-ORFTDNFZ.js +0 -105
- package/dist/chunk-T46YXSBP.cjs +0 -109
- package/dist/chunk-TIUKIY5V.cjs +0 -1663
- 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 -310
- package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +0 -31
- package/dist/fhe-airdrop/react/useAirdropCanExtendClaimWindow.d.ts +0 -7
- package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +0 -27
- 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 -31
- 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/useGetClaimAmount.d.ts +0 -30
- 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
- package/dist/fhe-vesting/react/useGetClaimableAmount.d.ts +0 -13
- package/dist/fhe-vesting/react/useGetSettledAmount.d.ts +0 -14
- package/dist/fhe-vesting/react/useGetTotalAllocation.d.ts +0 -13
- package/dist/fhe-vesting/react/useGetVestedAmount.d.ts +0 -25
|
@@ -0,0 +1,600 @@
|
|
|
1
|
+
import type { Abi, Account, Address, Hex, PublicClient, WalletClient } from "viem";
|
|
2
|
+
import { type TokenOpsSdkError } from "../core/errors.js";
|
|
3
|
+
import { type SdkTelemetry } from "../core/telemetry.js";
|
|
4
|
+
import type { EncryptedViewResult } from "../fhe/types.js";
|
|
5
|
+
import type { DeploymentMode } from "./constants.js";
|
|
6
|
+
/**
|
|
7
|
+
* The minimum of a receipt log this module reads.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately narrower than viem's `Log`: `receipt.logs` satisfies it, and so
|
|
10
|
+
* does a hand-built fixture, which keeps the ACL-extraction contract testable
|
|
11
|
+
* without inventing block numbers and log indices that play no part in it.
|
|
12
|
+
*/
|
|
13
|
+
export interface AclCandidateLog {
|
|
14
|
+
address: Address;
|
|
15
|
+
topics: readonly Hex[];
|
|
16
|
+
data: Hex;
|
|
17
|
+
}
|
|
18
|
+
/** Inputs for {@link extractGrantedHandle}. */
|
|
19
|
+
export interface ExtractGrantedHandleArgs {
|
|
20
|
+
/** Receipt logs, unfiltered. */
|
|
21
|
+
logs: readonly AclCandidateLog[];
|
|
22
|
+
/** FHEVM ACL contract for the chain — the only address whose `Allowed` events count. */
|
|
23
|
+
aclAddress: Address;
|
|
24
|
+
/** The address the grant must name, i.e. the `FHE.allow(handle, <account>)` target. */
|
|
25
|
+
account: Address;
|
|
26
|
+
/** Optional: the contract that issued the grant, to exclude allows made by other contracts in the same tx. */
|
|
27
|
+
caller?: Address | undefined;
|
|
28
|
+
/** Method label for the thrown error. */
|
|
29
|
+
method?: string | undefined;
|
|
30
|
+
/** Transaction hash for the thrown error. */
|
|
31
|
+
txHash?: Hex | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Pull the encrypted handle a transaction granted to `account` out of its
|
|
35
|
+
* receipt logs.
|
|
36
|
+
*
|
|
37
|
+
* This is the module's implementation of CLAUDE.md pitfall 1, and the reason
|
|
38
|
+
* every encrypted view here is a transaction rather than a `readContract`.
|
|
39
|
+
* The tempting alternative — `simulateContract(...).result` — returns a
|
|
40
|
+
* handle that is **wrong but plausible**: an FHE op's output handle is derived
|
|
41
|
+
* from counters that advance inside the executed transaction, so the simulated
|
|
42
|
+
* value diverges from the one the executed transaction actually granted ACL
|
|
43
|
+
* on. Nothing fails at that point. The damage surfaces much later, as a
|
|
44
|
+
* `userDecrypt` rejected with "User X is not authorized to decrypt handle Y".
|
|
45
|
+
* The receipt's ACL `Allowed` event is the only source that cannot drift.
|
|
46
|
+
*
|
|
47
|
+
* **Last match wins — a defensive default, not a live requirement.** Across
|
|
48
|
+
* every entrypoint currently routed through `encryptedView`, exactly one
|
|
49
|
+
* `Allowed` event survives the `account` filter, so the choice between first
|
|
50
|
+
* and last is moot today:
|
|
51
|
+
*
|
|
52
|
+
* - `adminGetCurrentBalance` — a single `FHE.allow(balance, msg.sender)`
|
|
53
|
+
* (`ConfidentialAirdropBase.sol:358`).
|
|
54
|
+
* - `adminDiscloseBalanceToParty` — a single `FHE.allow(balance, party)` (`:367`).
|
|
55
|
+
* - `adminBatchDiscloseBalanceToParties` — N grants, but the balance is read
|
|
56
|
+
* once (`:377`) and the *same* handle is fanned out (`:379`), so every
|
|
57
|
+
* candidate carries an identical value and ordering cannot matter.
|
|
58
|
+
* - `getClaimAmount` on both variants — the sibling grants target other
|
|
59
|
+
* addresses: `FHE.allowThis` grants `address(this)` and `_grantCompliance`
|
|
60
|
+
* grants the manager clone (`ConfidentialAirdropBase.sol:431`), leaving one
|
|
61
|
+
* grant to the caller (`ECDSAConfidentialAirdrop.sol:166-167`,
|
|
62
|
+
* `MerkleConfidentialAirdrop.sol:264-266`).
|
|
63
|
+
*
|
|
64
|
+
* Last-wins is therefore chosen for entrypoints that do not exist yet, over
|
|
65
|
+
* `fhe-vesting`'s throw-on-ambiguous: a future compound view that grants twice
|
|
66
|
+
* should return its final handle rather than fail, and the batch-disclosure
|
|
67
|
+
* path already shows the shape where N events legitimately carry one answer.
|
|
68
|
+
*
|
|
69
|
+
* Note what is NOT a motivating case: the Merkle `claim` path does grant an
|
|
70
|
+
* intermediate handle before the outstanding one, but `claim` /
|
|
71
|
+
* `claimAndUnwrap` return void (`IMerkleConfidentialAirdrop.sol:51-70`), so
|
|
72
|
+
* they run as plain writes and their receipts never reach this function.
|
|
73
|
+
*
|
|
74
|
+
* @throws {@link ReceiptEventNotFoundError} when no `Allowed` event names `account`.
|
|
75
|
+
*/
|
|
76
|
+
export declare function extractGrantedHandle(args: ExtractGrantedHandleArgs): Hex;
|
|
77
|
+
/** @alpha */
|
|
78
|
+
export interface AirdropBaseClientConfig {
|
|
79
|
+
publicClient: PublicClient;
|
|
80
|
+
walletClient?: WalletClient | undefined;
|
|
81
|
+
/** The airdrop instance — a factory-deployed clone or UUPS proxy, never the implementation. */
|
|
82
|
+
address: Address;
|
|
83
|
+
/**
|
|
84
|
+
* Chain id used for the support check and the ACL lookup. Defaults to
|
|
85
|
+
* `publicClient.chain?.id`; one of the two must resolve, because the client
|
|
86
|
+
* refuses to talk to a chain it cannot name.
|
|
87
|
+
*/
|
|
88
|
+
chainId?: number | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* FHEVM ACL contract address override. Resolved from the chain id via the
|
|
91
|
+
* SDK's registry when omitted. Required because every encrypted view reads
|
|
92
|
+
* the granted handle out of this contract's `Allowed` events — pointing it
|
|
93
|
+
* at the wrong address does not fail loudly, it returns nothing to parse.
|
|
94
|
+
*/
|
|
95
|
+
aclAddress?: Address | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Optional telemetry sink. When provided, the SDK emits a
|
|
98
|
+
* `fhe-airdrop.client.init` event on construction and brackets public write
|
|
99
|
+
* methods with named spans (`fhe-airdrop.airdrop.pause`, …). Defaults to a
|
|
100
|
+
* no-op — zero overhead, zero leakage of consumer-side identifiers.
|
|
101
|
+
*
|
|
102
|
+
* Spans carry the method name and the instance address only. Encrypted
|
|
103
|
+
* handles may appear; decrypted amounts never do.
|
|
104
|
+
*/
|
|
105
|
+
telemetry?: SdkTelemetry | undefined;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Wiring a subclass supplies to the base constructor. Not part of the
|
|
109
|
+
* consumer-facing config: an application never chooses these, a variant client
|
|
110
|
+
* always does.
|
|
111
|
+
*/
|
|
112
|
+
export interface AirdropClientInternals {
|
|
113
|
+
/**
|
|
114
|
+
* The variant's full ABI — a superset of `confidentialAirdropBaseAbi`. Used for every
|
|
115
|
+
* read, write, preflight and revert decode, so passing the variant ABI is
|
|
116
|
+
* what lets an inherited helper carry a variant-only revert (e.g.
|
|
117
|
+
* `InvalidMerkleProof`) through to its typed error.
|
|
118
|
+
*/
|
|
119
|
+
abi?: Abi | undefined;
|
|
120
|
+
/** Telemetry span namespace segment, e.g. `"ecdsa"` for `fhe-airdrop.ecdsa.pause`. */
|
|
121
|
+
surface?: string | undefined;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Who sends the transaction, when it should not be the wallet client's own account.
|
|
125
|
+
*
|
|
126
|
+
* @alpha
|
|
127
|
+
*/
|
|
128
|
+
export interface WriteAccountOverride {
|
|
129
|
+
account?: Account | Address | undefined;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The surface every airdrop v2 instance shares, regardless of how it
|
|
133
|
+
* authorises a claim.
|
|
134
|
+
*
|
|
135
|
+
* `ConfidentialAirdropBase` is the abstract half of both deployed variants, so
|
|
136
|
+
* this class is usable directly against any instance address whose variant you
|
|
137
|
+
* do not care about (an admin panel listing campaigns, say). The ECDSA and
|
|
138
|
+
* Merkle clients extend it and add their own claim path.
|
|
139
|
+
*
|
|
140
|
+
* What it encapsulates beyond the raw ABI is the encrypted-view protocol: five
|
|
141
|
+
* of the contract's disclosure entrypoints look like getters and are not —
|
|
142
|
+
* they mutate ACL state, so they are transactions, and their result must be
|
|
143
|
+
* recovered from the receipt. See {@link extractGrantedHandle}.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* const airdrop = new AirdropBaseClient({ publicClient, walletClient, address });
|
|
147
|
+
* const { handle } = await airdrop.adminGetCurrentBalance();
|
|
148
|
+
* // `handle` is now decryptable by the caller via the Zama relayer.
|
|
149
|
+
*
|
|
150
|
+
* @alpha
|
|
151
|
+
*/
|
|
152
|
+
export declare class AirdropBaseClient {
|
|
153
|
+
readonly publicClient: PublicClient;
|
|
154
|
+
readonly walletClient?: WalletClient | undefined;
|
|
155
|
+
readonly address: Address;
|
|
156
|
+
readonly chainId: number;
|
|
157
|
+
readonly aclAddress: Address;
|
|
158
|
+
/** The ABI every inherited helper uses. Subclasses pass their variant's. */
|
|
159
|
+
protected readonly abi: Abi;
|
|
160
|
+
/** Telemetry span namespace, e.g. `fhe-airdrop.airdrop`. */
|
|
161
|
+
protected readonly spanPrefix: string;
|
|
162
|
+
protected readonly telemetry?: SdkTelemetry | undefined;
|
|
163
|
+
constructor(config: AirdropBaseClientConfig, internals?: AirdropClientInternals);
|
|
164
|
+
/**
|
|
165
|
+
* Halt claiming. Requires `PAUSER_ROLE`.
|
|
166
|
+
*
|
|
167
|
+
* Pausing does not stop the clock: `endTime` still passes while paused, so a
|
|
168
|
+
* long pause can consume the window outright. Pair it with
|
|
169
|
+
* {@link extendClaimWindow} when the campaign is meant to survive.
|
|
170
|
+
*
|
|
171
|
+
* @returns The transaction hash.
|
|
172
|
+
*/
|
|
173
|
+
pause(args?: WriteAccountOverride): Promise<Hex>;
|
|
174
|
+
/**
|
|
175
|
+
* Resume claiming. Requires `PAUSER_ROLE`.
|
|
176
|
+
*
|
|
177
|
+
* @returns The transaction hash.
|
|
178
|
+
*/
|
|
179
|
+
unpause(args?: WriteAccountOverride): Promise<Hex>;
|
|
180
|
+
/**
|
|
181
|
+
* Move the campaign's end time forward. Requires `WINDOW_ADMIN_ROLE`.
|
|
182
|
+
*
|
|
183
|
+
* Forward-only, and only on an instance created with
|
|
184
|
+
* `canExtendClaimWindow: true` — otherwise the contract reverts
|
|
185
|
+
* `ExtensionNotAllowed`, which the SDK surfaces as `FeatureDisabledError`.
|
|
186
|
+
*
|
|
187
|
+
* @param args.newEndTime Unix seconds, `uint32` on-chain; must exceed the current `endTime`.
|
|
188
|
+
* @returns The transaction hash.
|
|
189
|
+
*/
|
|
190
|
+
extendClaimWindow(args: {
|
|
191
|
+
newEndTime: number;
|
|
192
|
+
} & WriteAccountOverride): Promise<Hex>;
|
|
193
|
+
/**
|
|
194
|
+
* Sweep the instance's entire remaining confidential balance to `recipient`.
|
|
195
|
+
* Requires `TREASURY_ROLE`.
|
|
196
|
+
*
|
|
197
|
+
* The amount is not a parameter and never appears in plaintext anywhere:
|
|
198
|
+
* the contract reads its own encrypted balance and moves all of it.
|
|
199
|
+
*
|
|
200
|
+
* @returns The transaction hash.
|
|
201
|
+
*/
|
|
202
|
+
withdrawConfidential(args: {
|
|
203
|
+
recipient: Address;
|
|
204
|
+
} & WriteAccountOverride): Promise<Hex>;
|
|
205
|
+
/**
|
|
206
|
+
* Withdraw accrued claim-fee ETH. Requires `FEE_COLLECTOR_ROLE`.
|
|
207
|
+
*
|
|
208
|
+
* @param args.amount Wei. Exceeding the accrued balance reverts `InsufficientFeeBalance`
|
|
209
|
+
* (surfaced as `InsufficientBalanceError`) — this is public ETH, not a confidential quantity.
|
|
210
|
+
* @returns The transaction hash.
|
|
211
|
+
*/
|
|
212
|
+
withdrawGasFee(args: {
|
|
213
|
+
recipient: Address;
|
|
214
|
+
amount: bigint;
|
|
215
|
+
} & WriteAccountOverride): Promise<Hex>;
|
|
216
|
+
/**
|
|
217
|
+
* Sweep a plain ERC-20 that was sent to the instance by mistake. Requires
|
|
218
|
+
* `RESCUER_ROLE`.
|
|
219
|
+
*
|
|
220
|
+
* The campaign's own token is ERC-7984, not ERC-20, so it cannot be reached
|
|
221
|
+
* through this path — use {@link withdrawConfidential} for the pool.
|
|
222
|
+
*
|
|
223
|
+
* @returns The transaction hash.
|
|
224
|
+
*/
|
|
225
|
+
rescueERC20(args: {
|
|
226
|
+
token: Address;
|
|
227
|
+
recipient: Address;
|
|
228
|
+
} & WriteAccountOverride): Promise<Hex>;
|
|
229
|
+
/**
|
|
230
|
+
* Sweep a *different* ERC-7984 token that was sent to the instance by
|
|
231
|
+
* mistake. Requires `RESCUER_ROLE`.
|
|
232
|
+
*
|
|
233
|
+
* Passing the campaign's own token reverts `CannotRescueAirdropToken` — the
|
|
234
|
+
* guard that stops a rescuer draining the pool without `TREASURY_ROLE`.
|
|
235
|
+
*
|
|
236
|
+
* @returns The transaction hash.
|
|
237
|
+
*/
|
|
238
|
+
rescueOtherConfidentialToken(args: {
|
|
239
|
+
token: Address;
|
|
240
|
+
recipient: Address;
|
|
241
|
+
} & WriteAccountOverride): Promise<Hex>;
|
|
242
|
+
/** The ERC-7984 token this campaign distributes. */
|
|
243
|
+
token(): Promise<Address>;
|
|
244
|
+
/**
|
|
245
|
+
* The variant ordinal: `0` = ECDSA, `1` = Merkle (contract enum
|
|
246
|
+
* `AirdropType`). Read it to pick which variant client to construct against
|
|
247
|
+
* an address you were handed rather than created.
|
|
248
|
+
*/
|
|
249
|
+
airdropType(): Promise<number>;
|
|
250
|
+
/** Claim-window open, Unix seconds. */
|
|
251
|
+
startTime(): Promise<number>;
|
|
252
|
+
/** Claim-window close, Unix seconds. Movable forward via {@link extendClaimWindow}. */
|
|
253
|
+
endTime(): Promise<number>;
|
|
254
|
+
/** Whether claimants may unwrap to the underlying ERC-20 as part of a claim. */
|
|
255
|
+
unwrappable(): Promise<boolean>;
|
|
256
|
+
/** The instance's own compliance-manager clone — the only contract granted ACL on campaign handles. */
|
|
257
|
+
complianceManager(): Promise<Address>;
|
|
258
|
+
/** Per-claim ETH fee in wei; `0` on a fee-free campaign. */
|
|
259
|
+
gasFee(): Promise<bigint>;
|
|
260
|
+
/**
|
|
261
|
+
* Whether a claim would be accepted right now — in window **and** not
|
|
262
|
+
* paused. Distinct from `hasClaimStarted() && !hasClaimEnded()`, which
|
|
263
|
+
* ignores the pause flag.
|
|
264
|
+
*/
|
|
265
|
+
isClaimWindowActive(): Promise<boolean>;
|
|
266
|
+
/** Whether `startTime` has passed. Says nothing about the pause flag. */
|
|
267
|
+
hasClaimStarted(): Promise<boolean>;
|
|
268
|
+
/** Whether `endTime` has passed. Says nothing about the pause flag. */
|
|
269
|
+
hasClaimEnded(): Promise<boolean>;
|
|
270
|
+
/**
|
|
271
|
+
* Whether claiming is currently halted (`PausableUpgradeable.paused()`).
|
|
272
|
+
* Independent of the claim window — see {@link isClaimWindowActive}, which
|
|
273
|
+
* ANDs this together with the window check.
|
|
274
|
+
*/
|
|
275
|
+
paused(): Promise<boolean>;
|
|
276
|
+
/** Gates {@link pause} / {@link unpause}. */
|
|
277
|
+
PAUSER_ROLE(): Promise<Hex>;
|
|
278
|
+
/** Gates {@link extendClaimWindow}. */
|
|
279
|
+
WINDOW_ADMIN_ROLE(): Promise<Hex>;
|
|
280
|
+
/** Gates {@link withdrawConfidential}. */
|
|
281
|
+
TREASURY_ROLE(): Promise<Hex>;
|
|
282
|
+
/** Gates {@link rescueERC20} / {@link rescueOtherConfidentialToken}. */
|
|
283
|
+
RESCUER_ROLE(): Promise<Hex>;
|
|
284
|
+
/** Gates {@link withdrawGasFee}. The contract refuses to leave it empty on a fee-charging campaign. */
|
|
285
|
+
FEE_COLLECTOR_ROLE(): Promise<Hex>;
|
|
286
|
+
/** Gates `upgradeToAndCall` on UUPS instances; inert on clones. */
|
|
287
|
+
UPGRADER_ROLE(): Promise<Hex>;
|
|
288
|
+
/** Gates the admin disclosure surface, and bypasses gate #1 of the raw-handle disclosure path. */
|
|
289
|
+
DISCLOSURE_ADMIN_ROLE(): Promise<Hex>;
|
|
290
|
+
/**
|
|
291
|
+
* OpenZeppelin's root role (`bytes32(0)`), read from the instance rather
|
|
292
|
+
* than hard-coded so a re-parented hierarchy shows up here instead of
|
|
293
|
+
* silently diverging.
|
|
294
|
+
*
|
|
295
|
+
* It administers every role on this instance except `FEE_COLLECTOR_ROLE`,
|
|
296
|
+
* which administers itself - see {@link getRoleAdmin}.
|
|
297
|
+
*/
|
|
298
|
+
DEFAULT_ADMIN_ROLE(): Promise<Hex>;
|
|
299
|
+
/**
|
|
300
|
+
* The role whose holders may {@link grantRole} and {@link revokeRole} `role`.
|
|
301
|
+
*
|
|
302
|
+
* `DEFAULT_ADMIN_ROLE` for everything the instance sets up at `initialize`,
|
|
303
|
+
* except `FEE_COLLECTOR_ROLE`, which the contract re-parents to itself: only
|
|
304
|
+
* a current fee collector can add or remove another. That is why
|
|
305
|
+
* `planInstanceRoleSplit` (`./roles.js`) refuses to plan a fee-collector
|
|
306
|
+
* grant from an admin key - this read is how a caller confirms it.
|
|
307
|
+
*/
|
|
308
|
+
getRoleAdmin(role: Hex): Promise<Hex>;
|
|
309
|
+
/**
|
|
310
|
+
* Whether `holder` holds `role`.
|
|
311
|
+
*
|
|
312
|
+
* The role subject is called `holder`, not `account`, across all three role
|
|
313
|
+
* methods: on the two writes `account` already means "who sends this
|
|
314
|
+
* transaction" ({@link WriteAccountOverride}), and one key cannot be both —
|
|
315
|
+
* a grant made by an admin to somebody else is the normal case, not the
|
|
316
|
+
* exception.
|
|
317
|
+
*
|
|
318
|
+
* @param args.role A `bytes32` from one of the role getters above — not a hand-hashed string.
|
|
319
|
+
*/
|
|
320
|
+
hasRole(args: {
|
|
321
|
+
role: Hex;
|
|
322
|
+
holder: Address;
|
|
323
|
+
}): Promise<boolean>;
|
|
324
|
+
/**
|
|
325
|
+
* Grant `role` to `holder`. Requires the role's admin role
|
|
326
|
+
* (`DEFAULT_ADMIN_ROLE` unless the instance re-parented it).
|
|
327
|
+
*
|
|
328
|
+
* @returns The transaction hash.
|
|
329
|
+
*/
|
|
330
|
+
grantRole(args: {
|
|
331
|
+
role: Hex;
|
|
332
|
+
holder: Address;
|
|
333
|
+
} & WriteAccountOverride): Promise<Hex>;
|
|
334
|
+
/**
|
|
335
|
+
* Revoke `role` from `holder`. Requires the role's admin role.
|
|
336
|
+
*
|
|
337
|
+
* Two revocations are blocked on-chain rather than silently allowed:
|
|
338
|
+
* removing the last `DEFAULT_ADMIN_ROLE` member (`LastAdmin`) or the last
|
|
339
|
+
* `FEE_COLLECTOR_ROLE` member of a fee-charging campaign
|
|
340
|
+
* (`LastFeeCollector`). Both would strand the instance.
|
|
341
|
+
*
|
|
342
|
+
* @returns The transaction hash.
|
|
343
|
+
*/
|
|
344
|
+
revokeRole(args: {
|
|
345
|
+
role: Hex;
|
|
346
|
+
holder: Address;
|
|
347
|
+
} & WriteAccountOverride): Promise<Hex>;
|
|
348
|
+
/**
|
|
349
|
+
* Give up `role` yourself.
|
|
350
|
+
*
|
|
351
|
+
* The contract's signature is `renounceRole(role, callerConfirmation)` and
|
|
352
|
+
* it reverts `AccessControlBadConfirmation` unless `callerConfirmation` is
|
|
353
|
+
* the sender. This method therefore takes no holder at all and fills the
|
|
354
|
+
* confirmation from the resolved sending account: renouncing on somebody
|
|
355
|
+
* else's behalf is not a call that can succeed, so the SDK does not offer a
|
|
356
|
+
* shape that lets a caller try. To remove a role from another account, use
|
|
357
|
+
* {@link revokeRole}.
|
|
358
|
+
*
|
|
359
|
+
* Renouncing runs through the same `_revokeRole` floors as
|
|
360
|
+
* {@link revokeRole}, so it is **not** an escape hatch from them. In
|
|
361
|
+
* particular `DEFAULT_ADMIN_ROLE`'s floor is unconditional: the sole
|
|
362
|
+
* remaining admin cannot renounce (`LastAdmin`), because an instance with no
|
|
363
|
+
* admin has no role administrator left to re-grant one. The
|
|
364
|
+
* renounce-admin-to-freeze-the-instance pattern is deliberately unavailable
|
|
365
|
+
* here - grant a successor first, then have the predecessor renounce or be
|
|
366
|
+
* revoked.
|
|
367
|
+
*
|
|
368
|
+
* @param args.role A `bytes32` from one of the role getters above.
|
|
369
|
+
* @returns The transaction hash.
|
|
370
|
+
*/
|
|
371
|
+
renounceRole(args: {
|
|
372
|
+
role: Hex;
|
|
373
|
+
} & WriteAccountOverride): Promise<Hex>;
|
|
374
|
+
/**
|
|
375
|
+
* How many accounts hold `role`.
|
|
376
|
+
*
|
|
377
|
+
* Cheap enough to poll, and the value the contract's own floors are written
|
|
378
|
+
* against: a revoke of `DEFAULT_ADMIN_ROLE` at count 1 reverts `LastAdmin`,
|
|
379
|
+
* and of `FEE_COLLECTOR_ROLE` at count 1 on a fee-charging campaign reverts
|
|
380
|
+
* `LastFeeCollector`.
|
|
381
|
+
*/
|
|
382
|
+
getRoleMemberCount(role: Hex): Promise<bigint>;
|
|
383
|
+
/**
|
|
384
|
+
* The `index`-th holder of `role`, in the contract's own enumeration order.
|
|
385
|
+
*
|
|
386
|
+
* Ordering is `EnumerableSet`'s and is not stable across grants and
|
|
387
|
+
* revokes - index into it only alongside a
|
|
388
|
+
* {@link getRoleMemberCount} read taken at the same block, or prefer
|
|
389
|
+
* {@link getRoleMembers}, which returns the whole set in one call.
|
|
390
|
+
*/
|
|
391
|
+
getRoleMember(args: {
|
|
392
|
+
role: Hex;
|
|
393
|
+
index: bigint;
|
|
394
|
+
}): Promise<Address>;
|
|
395
|
+
/**
|
|
396
|
+
* Every account currently holding `role`.
|
|
397
|
+
*
|
|
398
|
+
* This is how the campaign's fee collectors are meant to be discovered: the
|
|
399
|
+
* contract deliberately ships no `feeCollectors()` view and points callers
|
|
400
|
+
* at `getRoleMembers(FEE_COLLECTOR_ROLE)` instead, so this read is the
|
|
401
|
+
* supported answer to "who can withdraw this campaign's accrued claim ETH?"
|
|
402
|
+
* - the membership the `LastFeeCollector` floor exists to keep non-empty.
|
|
403
|
+
*
|
|
404
|
+
* One `eth_call` and unpaginated: role sets on an airdrop instance are
|
|
405
|
+
* operator-sized, not user-sized.
|
|
406
|
+
*/
|
|
407
|
+
getRoleMembers(role: Hex): Promise<readonly Address[]>;
|
|
408
|
+
/**
|
|
409
|
+
* Point this instance's proxy at `newImplementation`, optionally calling
|
|
410
|
+
* into it in the same transaction. Requires `UPGRADER_ROLE`
|
|
411
|
+
* (`_authorizeUpgrade` is `onlyRole(UPGRADER_ROLE)`).
|
|
412
|
+
*
|
|
413
|
+
* **Inert on clone-mode instances.** A clone has no ERC-1967 implementation
|
|
414
|
+
* slot to rewrite; the call reverts at the proxy layer rather than doing
|
|
415
|
+
* anything partial. Call {@link deploymentMode}, or remember the create-time
|
|
416
|
+
* `mode`, before offering this in a UI. Do NOT reach for
|
|
417
|
+
* {@link proxiableUUID} - it reverts on clone and UUPS instances alike and
|
|
418
|
+
* cannot tell them apart.
|
|
419
|
+
*
|
|
420
|
+
* **Merkle campaigns cannot reach this at all through the SDK**, because the
|
|
421
|
+
* SDK refuses to create one in `uups` mode in the first place - see
|
|
422
|
+
* {@link MerkleUupsUnsupportedError} for the storage-retype reason.
|
|
423
|
+
*
|
|
424
|
+
* @param args.data Initializer calldata to run against the new
|
|
425
|
+
* implementation, or `"0x"` (the default) for a plain implementation
|
|
426
|
+
* swap. A non-empty payload runs with `delegatecall` semantics - it is the
|
|
427
|
+
* new implementation's code executing against this instance's storage.
|
|
428
|
+
* @param args.value Wei to attach. The function is `payable`, but the
|
|
429
|
+
* ERC-1967 upgrade path reverts `ERC1967NonPayable` when value is sent
|
|
430
|
+
* with empty `data`, so leave it unset for a plain swap.
|
|
431
|
+
* @returns The transaction hash.
|
|
432
|
+
*/
|
|
433
|
+
upgradeToAndCall(args: {
|
|
434
|
+
newImplementation: Address;
|
|
435
|
+
data?: Hex;
|
|
436
|
+
value?: bigint;
|
|
437
|
+
} & WriteAccountOverride): Promise<Hex>;
|
|
438
|
+
/**
|
|
439
|
+
* The ERC-1822 storage slot this implementation expects a proxy to keep its
|
|
440
|
+
* implementation address in.
|
|
441
|
+
*
|
|
442
|
+
* Succeeds **only when called on the implementation contract directly**,
|
|
443
|
+
* answering `0x360894...bbc`, and **reverts** `UUPSUnauthorizedCallContext`
|
|
444
|
+
* through any proxy: OpenZeppelin guards it with `notDelegated`, which
|
|
445
|
+
* rejects every delegatecall context. That is what makes it a target
|
|
446
|
+
* implementation's proof of UUPS compliance, not a probe of a live instance.
|
|
447
|
+
*
|
|
448
|
+
* **Not a mode discriminator.** This client is always pointed at an
|
|
449
|
+
* instance, so this call reverts here for `clone` and `uups` alike. Use
|
|
450
|
+
* {@link deploymentMode} to tell them apart.
|
|
451
|
+
*/
|
|
452
|
+
proxiableUUID(): Promise<Hex>;
|
|
453
|
+
/** OpenZeppelin's upgrade-interface version string, e.g. `"5.0.0"`. */
|
|
454
|
+
upgradeInterfaceVersion(): Promise<string>;
|
|
455
|
+
/**
|
|
456
|
+
* Which deployment shell this instance is: a minimal-proxy `clone`, or a
|
|
457
|
+
* `uups` ERC-1967 proxy that {@link upgradeToAndCall} can actually move.
|
|
458
|
+
*
|
|
459
|
+
* Read from the ERC-1967 implementation slot, which a UUPS proxy populates
|
|
460
|
+
* and a clone never has - a clone's implementation is baked into its runtime
|
|
461
|
+
* code. One `eth_getStorageAt`, no ABI involved.
|
|
462
|
+
*
|
|
463
|
+
* Neither obvious probe works in its place, which is why this exists:
|
|
464
|
+
* {@link proxiableUUID} carries OpenZeppelin's `notDelegated` guard and so
|
|
465
|
+
* reverts on both shells when called at an instance address, and
|
|
466
|
+
* {@link upgradeInterfaceVersion} reads `UPGRADE_INTERFACE_VERSION`, an
|
|
467
|
+
* implementation constant that answers `"5.0.0"` for both.
|
|
468
|
+
*
|
|
469
|
+
* @alpha
|
|
470
|
+
*/
|
|
471
|
+
deploymentMode(): Promise<DeploymentMode>;
|
|
472
|
+
/**
|
|
473
|
+
* Read the instance's own remaining pool balance as a handle the **caller**
|
|
474
|
+
* can decrypt. Requires `DISCLOSURE_ADMIN_ROLE`.
|
|
475
|
+
*
|
|
476
|
+
* @returns `{ handle, hash }` — pass `handle` to the Zama relayer's `userDecrypt`.
|
|
477
|
+
* @throws {@link ReceiptEventNotFoundError} when the transaction granted no ACL to the caller.
|
|
478
|
+
*/
|
|
479
|
+
adminGetCurrentBalance(args?: WriteAccountOverride): Promise<EncryptedViewResult>;
|
|
480
|
+
/**
|
|
481
|
+
* Disclose the instance's pool balance to `party`. Requires
|
|
482
|
+
* `DISCLOSURE_ADMIN_ROLE`.
|
|
483
|
+
*
|
|
484
|
+
* The ACL grant goes to `party`, **not** to the caller, so the returned
|
|
485
|
+
* handle is extracted from the grant naming `party` — and unless the caller
|
|
486
|
+
* is also `party`, the caller cannot decrypt what it just disclosed.
|
|
487
|
+
*
|
|
488
|
+
* @returns `{ handle, hash }` — the handle `party` may now decrypt.
|
|
489
|
+
*/
|
|
490
|
+
adminDiscloseBalanceToParty(args: {
|
|
491
|
+
party: Address;
|
|
492
|
+
} & WriteAccountOverride): Promise<EncryptedViewResult>;
|
|
493
|
+
/**
|
|
494
|
+
* Disclose the instance's pool balance to several parties in one
|
|
495
|
+
* transaction. Requires `DISCLOSURE_ADMIN_ROLE`.
|
|
496
|
+
*
|
|
497
|
+
* The contract reads the balance once and fans the *same* handle out to
|
|
498
|
+
* every party, which is why one handle is returned for the whole batch. It
|
|
499
|
+
* is recovered from the grant naming the first party.
|
|
500
|
+
*
|
|
501
|
+
* The contract's own two argument checks, `EmptyBatch` and `InvalidParty`
|
|
502
|
+
* (a zero address anywhere in the list), are mirrored client-side and
|
|
503
|
+
* thrown before the transaction is sent. Both are decidable off-chain from
|
|
504
|
+
* the argument alone, and both are easy to hit from a UI that maps a form
|
|
505
|
+
* over rows; paying gas to be told so adds nothing. Nothing beyond those two
|
|
506
|
+
* is checked here: duplicates, for instance, are wasteful but legal
|
|
507
|
+
* on-chain, and the SDK does not invent rules the contract does not have.
|
|
508
|
+
*
|
|
509
|
+
* @returns `{ handle, hash }` — the single handle every party may now decrypt.
|
|
510
|
+
* @throws {@link InvalidArgumentError} on an empty list or a zero-address party.
|
|
511
|
+
*/
|
|
512
|
+
adminBatchDiscloseBalanceToParties(args: {
|
|
513
|
+
parties: readonly Address[];
|
|
514
|
+
} & WriteAccountOverride): Promise<EncryptedViewResult>;
|
|
515
|
+
/**
|
|
516
|
+
* Grant `party` decrypt access to a handle you already hold.
|
|
517
|
+
*
|
|
518
|
+
* Two gates apply on-chain: the caller must itself be allowed on the handle
|
|
519
|
+
* (bypassed by `DISCLOSURE_ADMIN_ROLE`), and the *instance* must be allowed
|
|
520
|
+
* on it — so an arbitrary handle from another contract cannot be laundered
|
|
521
|
+
* through this campaign. A failure of the first surfaces as
|
|
522
|
+
* `FheHandleNotAllowedError`.
|
|
523
|
+
*
|
|
524
|
+
* @param args.handle An existing `euint64` handle — a public pointer, not a value.
|
|
525
|
+
* @returns The transaction hash. No new handle is produced.
|
|
526
|
+
*/
|
|
527
|
+
discloseHandleToParty(args: {
|
|
528
|
+
handle: Hex;
|
|
529
|
+
party: Address;
|
|
530
|
+
} & WriteAccountOverride): Promise<Hex>;
|
|
531
|
+
/**
|
|
532
|
+
* Grant `party` decrypt access to several handles at once. Same two gates as
|
|
533
|
+
* {@link discloseHandleToParty}, applied per handle; the first failure
|
|
534
|
+
* reverts the batch and names the offending handle.
|
|
535
|
+
*
|
|
536
|
+
* @returns The transaction hash. No new handles are produced.
|
|
537
|
+
*/
|
|
538
|
+
batchDiscloseHandlesToParty(args: {
|
|
539
|
+
handles: readonly Hex[];
|
|
540
|
+
party: Address;
|
|
541
|
+
} & WriteAccountOverride): Promise<Hex>;
|
|
542
|
+
/**
|
|
543
|
+
* Submit a transaction for a function that returns an encrypted handle via
|
|
544
|
+
* `FHE.allow`, and recover that handle from the receipt.
|
|
545
|
+
*
|
|
546
|
+
* Subclasses call this for their claim-preview entrypoints (`getClaimAmount`
|
|
547
|
+
* on both variants). Simulating instead would return a handle with no ACL
|
|
548
|
+
* behind it — see {@link extractGrantedHandle} for why.
|
|
549
|
+
*
|
|
550
|
+
* @param input.grantee The address the contract grants ACL to. Defaults to
|
|
551
|
+
* the sender, which is right for every `msg.sender` grant; disclosure
|
|
552
|
+
* entrypoints that grant a third party must pass it explicitly.
|
|
553
|
+
* @param input.method Label for telemetry and errors. Defaults to `functionName`.
|
|
554
|
+
* @returns `{ handle, hash }`.
|
|
555
|
+
*/
|
|
556
|
+
protected encryptedView(input: {
|
|
557
|
+
functionName: string;
|
|
558
|
+
args?: readonly unknown[] | undefined;
|
|
559
|
+
grantee?: Address | undefined;
|
|
560
|
+
account?: Account | Address | undefined;
|
|
561
|
+
method?: string | undefined;
|
|
562
|
+
/** Wei to attach — for fee-charging entrypoints that also return a handle. */
|
|
563
|
+
value?: bigint | undefined;
|
|
564
|
+
}): Promise<EncryptedViewResult>;
|
|
565
|
+
/**
|
|
566
|
+
* Send a transaction against the instance, mapping any revert to a typed
|
|
567
|
+
* error. Preflighted first so the revert is decoded before the user pays.
|
|
568
|
+
*/
|
|
569
|
+
protected write(functionName: string, args?: readonly unknown[], account?: Account | Address, method?: string, value?: bigint): Promise<Hex>;
|
|
570
|
+
protected read<T = unknown>(functionName: string, args?: readonly unknown[]): Promise<T>;
|
|
571
|
+
/**
|
|
572
|
+
* Simulate a write purely to surface typed reverts.
|
|
573
|
+
*
|
|
574
|
+
* The simulate's return value is discarded on principle: FHE handles
|
|
575
|
+
* produced during simulation diverge from the executed transaction's, so the
|
|
576
|
+
* only trustworthy source for a result is the receipt. What simulation is
|
|
577
|
+
* good for is letting viem decode a revert against the ABI first.
|
|
578
|
+
*/
|
|
579
|
+
protected preflightWrite(method: string, functionName: string, args: readonly unknown[], account: Account | Address, value?: bigint): Promise<void>;
|
|
580
|
+
/**
|
|
581
|
+
* Map a viem error to the SDK's typed palette.
|
|
582
|
+
*
|
|
583
|
+
* `productContext` deliberately carries only public identifiers — the
|
|
584
|
+
* caller, the chain. Never an amount: the whole point of this module is that
|
|
585
|
+
* amounts are ciphertext, and an error object is one of the easiest places
|
|
586
|
+
* for a plaintext to escape into a log.
|
|
587
|
+
*/
|
|
588
|
+
protected mapRevert(method: string, err: unknown, account: Account | Address): TokenOpsSdkError;
|
|
589
|
+
protected requireWallet(method: string): WalletClient;
|
|
590
|
+
protected resolveAccount(wallet: WalletClient, override: Account | Address | undefined, method: string): Account | Address;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Create an {@link AirdropBaseClient}. Mirrors viem's `create*` convention.
|
|
594
|
+
*
|
|
595
|
+
* @example
|
|
596
|
+
* const airdrop = createAirdropBaseClient({ publicClient, walletClient, address });
|
|
597
|
+
*
|
|
598
|
+
* @alpha
|
|
599
|
+
*/
|
|
600
|
+
export declare function createAirdropBaseClient(config: AirdropBaseClientConfig): AirdropBaseClient;
|