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