@tokenops/sdk 2.0.0-alpha.1 → 2.0.0-alpha.2
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 +29 -0
- package/README.md +5 -5
- package/dist/{chunk-JZLGCTGK.cjs → chunk-3YHBO2DL.cjs} +2 -2
- package/dist/{chunk-H5POPGOZ.js → chunk-44YJPMQC.js} +1 -1
- package/dist/{chunk-DZHYSUGY.js → chunk-A4DCEE33.js} +11 -5
- package/dist/{chunk-M4IT6DNJ.cjs → chunk-AREQJHKA.cjs} +108 -3
- package/dist/chunk-EBLBPUPI.cjs +255 -0
- package/dist/chunk-EYDA6Q6C.js +245 -0
- package/dist/{chunk-XAYGD4E4.cjs → chunk-FEDX7B6T.cjs} +3 -3
- package/dist/{chunk-JQYC66TO.cjs → chunk-FHWSBGWE.cjs} +5 -5
- package/dist/{chunk-5576FRT3.cjs → chunk-FT5H2Q7Y.cjs} +11 -5
- package/dist/{chunk-456VDDA3.js → chunk-GADGBQJO.js} +78 -25
- package/dist/{chunk-6NAVMWZQ.js → chunk-IGO5XSPS.js} +2 -2
- package/dist/{chunk-CTED3MTR.cjs → chunk-IUKKNJ2R.cjs} +82 -29
- package/dist/{chunk-FGEB7RMY.cjs → chunk-MM5BV5CS.cjs} +4 -4
- package/dist/{chunk-335Z2W67.js → chunk-PYYSB5ZN.js} +1 -1
- package/dist/{chunk-PUX5VXDB.cjs → chunk-PZZK3O3S.cjs} +1040 -42
- package/dist/{chunk-74QFZ5MK.js → chunk-SPLNGUFF.js} +1 -1
- package/dist/{chunk-6PXXGACR.cjs → chunk-UHHMVBLU.cjs} +2 -2
- package/dist/{chunk-O5676ZWY.js → chunk-VW356KR3.js} +108 -5
- package/dist/{chunk-EAJ7SYHE.js → chunk-WJMEBBU7.js} +1 -1
- package/dist/{chunk-GKKDAW44.js → chunk-X7WBPCEU.js} +1026 -32
- package/dist/core/addresses.d.ts +4 -4
- package/dist/core/errors.d.ts +1 -1
- package/dist/fhe/types.d.ts +2 -2
- package/dist/fhe-airdrop/abis/merkle.d.ts +24 -12
- package/dist/fhe-airdrop/advanced/index.cjs +4 -4
- package/dist/fhe-airdrop/advanced/index.js +1 -1
- package/dist/fhe-airdrop/advanced/react/index.cjs +590 -9
- package/dist/fhe-airdrop/advanced/react/index.d.cts +34 -0
- package/dist/fhe-airdrop/advanced/react/index.d.ts +34 -0
- package/dist/fhe-airdrop/advanced/react/index.js +561 -7
- package/dist/fhe-airdrop/advanced/react/useClearCompliancePolicy.d.ts +28 -0
- package/dist/fhe-airdrop/advanced/react/useClearUpgradeabilityPolicy.d.ts +26 -0
- package/dist/fhe-airdrop/advanced/react/useDisableCustomFee.d.ts +25 -0
- package/dist/fhe-airdrop/advanced/react/useEcdsaInitCodeHash.d.ts +30 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryComplianceDelegate.d.ts +25 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryCompliancePolicy.d.ts +38 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryCustomFee.d.ts +24 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryGrantRole.d.ts +32 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryHasRole.d.ts +27 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryImplementations.d.ts +33 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryRenounceRole.d.ts +36 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryRevokeRole.d.ts +35 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryRoleConstants.d.ts +46 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryRoleMembers.d.ts +47 -0
- package/dist/fhe-airdrop/advanced/react/useFactoryUpgradeabilityPolicy.d.ts +39 -0
- package/dist/fhe-airdrop/advanced/react/useMerkleInitCodeHash.d.ts +24 -0
- package/dist/fhe-airdrop/advanced/react/useSetComplianceDelegate.d.ts +33 -0
- package/dist/fhe-airdrop/advanced/react/useSetComplianceManagerImpl.d.ts +27 -0
- package/dist/fhe-airdrop/advanced/react/useSetCompliancePolicy.d.ts +28 -0
- package/dist/fhe-airdrop/advanced/react/useSetCustomFee.d.ts +28 -0
- package/dist/fhe-airdrop/advanced/react/useSetDefaultDelegateToCompliance.d.ts +31 -0
- package/dist/fhe-airdrop/advanced/react/useSetDefaultGasFee.d.ts +28 -0
- package/dist/fhe-airdrop/advanced/react/useSetDefaultUpgradeable.d.ts +27 -0
- package/dist/fhe-airdrop/advanced/react/useSetEcdsaImplementation.d.ts +34 -0
- package/dist/fhe-airdrop/advanced/react/useSetFeeCollector.d.ts +27 -0
- package/dist/fhe-airdrop/advanced/react/useSetMerkleImplementation.d.ts +30 -0
- package/dist/fhe-airdrop/advanced/react/useSetUpgradeabilityPolicy.d.ts +31 -0
- package/dist/fhe-airdrop/airdrop-base.d.ts +8 -0
- package/dist/fhe-airdrop/campaign.d.ts +61 -20
- package/dist/fhe-airdrop/constants.d.ts +1 -1
- package/dist/fhe-airdrop/errors.d.ts +28 -0
- package/dist/fhe-airdrop/guards.d.ts +46 -2
- package/dist/fhe-airdrop/index.cjs +74 -971
- package/dist/fhe-airdrop/index.d.cts +2 -2
- package/dist/fhe-airdrop/index.d.ts +2 -2
- package/dist/fhe-airdrop/index.js +8 -927
- package/dist/fhe-airdrop/merkle-tree.d.ts +32 -38
- package/dist/fhe-airdrop/merkle.d.ts +52 -31
- package/dist/fhe-airdrop/react/_shared.d.ts +13 -0
- package/dist/fhe-airdrop/react/index.cjs +934 -84
- package/dist/fhe-airdrop/react/index.d.cts +49 -3
- package/dist/fhe-airdrop/react/index.d.ts +49 -3
- package/dist/fhe-airdrop/react/index.js +825 -22
- package/dist/fhe-airdrop/react/keys.d.ts +90 -0
- package/dist/fhe-airdrop/react/useAccessEcdsaClaimAmount.d.ts +26 -0
- package/dist/fhe-airdrop/react/useAccessMerkleClaimAmount.d.ts +27 -0
- package/dist/fhe-airdrop/react/useAddComplianceDelegate.d.ts +37 -0
- package/dist/fhe-airdrop/react/useAdminBatchDiscloseBalanceToParties.d.ts +36 -0
- package/dist/fhe-airdrop/react/useAdminDiscloseBalanceToParty.d.ts +31 -0
- package/dist/fhe-airdrop/react/useAdminGetCurrentBalance.d.ts +27 -0
- package/dist/fhe-airdrop/react/useAirdropConfig.d.ts +49 -0
- package/dist/fhe-airdrop/react/useAirdropDeploymentMode.d.ts +28 -0
- package/dist/fhe-airdrop/react/useAirdropGrantRole.d.ts +35 -0
- package/dist/fhe-airdrop/react/useAirdropRenounceRole.d.ts +36 -0
- package/dist/fhe-airdrop/react/useAirdropRevokeRole.d.ts +33 -0
- package/dist/fhe-airdrop/react/useAirdropRoleAdmin.d.ts +28 -0
- package/dist/fhe-airdrop/react/useAirdropRoleConstants.d.ts +67 -0
- package/dist/fhe-airdrop/react/useAirdropRoleMembers.d.ts +49 -0
- package/dist/fhe-airdrop/react/useAirdropUpgradeToAndCall.d.ts +45 -0
- package/dist/fhe-airdrop/react/useBatchDiscloseHandlesToParty.d.ts +32 -0
- package/dist/fhe-airdrop/react/useBuildMerkleCampaign.d.ts +68 -0
- package/dist/fhe-airdrop/react/useComplianceGrantRole.d.ts +32 -0
- package/dist/fhe-airdrop/react/useComplianceHasRole.d.ts +37 -0
- package/dist/fhe-airdrop/react/useComplianceInfo.d.ts +50 -0
- package/dist/fhe-airdrop/react/useComplianceManagerOf.d.ts +32 -0
- package/dist/fhe-airdrop/react/useComplianceRenounceRole.d.ts +38 -0
- package/dist/fhe-airdrop/react/useComplianceRevokeRole.d.ts +36 -0
- package/dist/fhe-airdrop/react/useComplianceRoleConstants.d.ts +41 -0
- package/dist/fhe-airdrop/react/useComplianceRoleMembers.d.ts +45 -0
- package/dist/fhe-airdrop/react/useCreateAndFundEcdsaAirdrop.d.ts +55 -0
- package/dist/fhe-airdrop/react/useCreateAndFundMerkleAirdrop.d.ts +52 -0
- package/dist/fhe-airdrop/react/useDiscloseHandleToParty.d.ts +35 -0
- package/dist/fhe-airdrop/react/useEcdsaClaim.d.ts +4 -3
- package/dist/fhe-airdrop/react/useEcdsaClaimAndUnwrap.d.ts +27 -0
- package/dist/fhe-airdrop/react/useEcdsaDomain.d.ts +41 -0
- package/dist/fhe-airdrop/react/useEffectiveDelegateToCompliance.d.ts +26 -0
- package/dist/fhe-airdrop/react/useEncryptCampaignAmounts.d.ts +59 -0
- package/dist/fhe-airdrop/react/useIsActiveDelegate.d.ts +29 -0
- package/dist/fhe-airdrop/react/useIsMerkleRootMutable.d.ts +21 -0
- package/dist/fhe-airdrop/react/useIsSignatureValid.d.ts +46 -0
- package/dist/fhe-airdrop/react/useMerkleClaim.d.ts +7 -19
- package/dist/fhe-airdrop/react/useMerkleClaimAndUnwrap.d.ts +29 -0
- package/dist/fhe-airdrop/react/usePlanMerkleCampaign.d.ts +53 -0
- package/dist/fhe-airdrop/react/usePreflightClaim.d.ts +46 -0
- package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +67 -0
- package/dist/fhe-airdrop/react/useRescueERC20.d.ts +30 -0
- package/dist/fhe-airdrop/react/useRescueOtherConfidentialToken.d.ts +34 -0
- package/dist/fhe-airdrop/react/useRevokeComplianceDelegate.d.ts +37 -0
- package/dist/fhe-airdrop/react/useRotateMerkleRoot.d.ts +52 -0
- package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +42 -0
- package/dist/fhe-airdrop/react/useWithdrawGasFee.d.ts +37 -0
- package/dist/fhe-airdrop/types.d.ts +14 -1
- package/dist/fhe-disperse/index.cjs +21 -21
- package/dist/fhe-disperse/index.js +2 -2
- package/dist/fhe-disperse/react/index.cjs +22 -22
- package/dist/fhe-disperse/react/index.js +3 -3
- package/dist/fhe-vesting/advanced/index.cjs +5 -5
- package/dist/fhe-vesting/advanced/index.js +3 -3
- package/dist/fhe-vesting/advanced/react/index.cjs +7 -7
- package/dist/fhe-vesting/advanced/react/index.js +4 -4
- package/dist/fhe-vesting/index.cjs +8 -8
- package/dist/fhe-vesting/index.js +2 -2
- package/dist/fhe-vesting/react/index.cjs +114 -114
- package/dist/fhe-vesting/react/index.js +3 -3
- package/dist/index.cjs +18 -18
- package/dist/index.js +1 -1
- package/dist/testnet-faucet/index.cjs +14 -14
- package/dist/testnet-faucet/index.js +2 -2
- package/dist/testnet-faucet/react/index.cjs +8 -8
- package/dist/testnet-faucet/react/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-NCVX3K2N.cjs +0 -161
- package/dist/chunk-VP2B4WM2.js +0 -154
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query-key factories shared by the reads and the writes that invalidate them.
|
|
3
|
+
*
|
|
4
|
+
* Internal: neither barrel re-exports this. Consumers who want to invalidate by hand
|
|
5
|
+
* use the exported {@link airdropQueryKey} / {@link airdropQueryKeyPrefix} builders.
|
|
6
|
+
*
|
|
7
|
+
* It exists because a write hook has to rebuild its read's key exactly — same `fn`
|
|
8
|
+
* label, same `args` order — and a read and a write living in different files with
|
|
9
|
+
* hand-copied literals is the one drift hazard that no test catches: the write
|
|
10
|
+
* succeeds, the invalidation silently misses, and the UI shows a stale value. Every
|
|
11
|
+
* key referenced from more than one file is defined here once.
|
|
12
|
+
*
|
|
13
|
+
* A `fn` label used by exactly one hook stays inline in that hook.
|
|
14
|
+
*/
|
|
15
|
+
import type { Address, Hex } from "viem";
|
|
16
|
+
/** Chain + contract scope every key below is built against. */
|
|
17
|
+
interface Scope {
|
|
18
|
+
chainId: number | undefined;
|
|
19
|
+
address: Address | undefined;
|
|
20
|
+
}
|
|
21
|
+
/** `fn` labels. Shared so a read and its invalidating write cannot spell one differently. */
|
|
22
|
+
export declare const AIRDROP_FN: {
|
|
23
|
+
readonly claimedAmount: "getClaimedAmount";
|
|
24
|
+
readonly paused: "paused";
|
|
25
|
+
readonly window: "window";
|
|
26
|
+
readonly config: "config";
|
|
27
|
+
readonly merkleRoot: "merkleRoot";
|
|
28
|
+
readonly merkleRootMutable: "isMerkleRootMutable";
|
|
29
|
+
readonly hasRole: "hasRole";
|
|
30
|
+
readonly roleMembers: "roleMembers";
|
|
31
|
+
readonly gasFee: "gasFee";
|
|
32
|
+
readonly preflightCreate: "preflightCreate";
|
|
33
|
+
readonly isSignatureValid: "isSignatureValid";
|
|
34
|
+
readonly fees: "fees";
|
|
35
|
+
readonly registry: "registry";
|
|
36
|
+
readonly customFee: "customFee";
|
|
37
|
+
readonly implementations: "implementations";
|
|
38
|
+
readonly compliancePolicy: "compliancePolicy";
|
|
39
|
+
readonly upgradeabilityPolicy: "upgradeabilityPolicy";
|
|
40
|
+
readonly factoryHasRole: "factoryHasRole";
|
|
41
|
+
readonly factoryRoleMembers: "factoryRoleMembers";
|
|
42
|
+
readonly complianceInfo: "complianceInfo";
|
|
43
|
+
readonly activeDelegate: "isActiveDelegate";
|
|
44
|
+
readonly clientDelegates: "clientDelegates";
|
|
45
|
+
readonly complianceHasRole: "complianceHasRole";
|
|
46
|
+
readonly complianceRoleMembers: "complianceRoleMembers";
|
|
47
|
+
};
|
|
48
|
+
export declare const airdropKeys: {
|
|
49
|
+
/** One account's cumulative delivered total. Keyed on the CLAIM IDENTITY, never the sender. */
|
|
50
|
+
readonly claimedAmount: (s: Scope, account: Address | undefined) => unknown[];
|
|
51
|
+
readonly paused: (s: Scope) => unknown[];
|
|
52
|
+
readonly window: (s: Scope) => unknown[];
|
|
53
|
+
readonly config: (s: Scope) => unknown[];
|
|
54
|
+
readonly gasFee: (s: Scope) => unknown[];
|
|
55
|
+
readonly merkleRoot: (s: Scope) => unknown[];
|
|
56
|
+
readonly merkleRootMutable: (s: Scope) => unknown[];
|
|
57
|
+
readonly hasRole: (s: Scope, role: Hex | undefined, holder: Address | undefined) => unknown[];
|
|
58
|
+
/** Every cached `hasRole` for this instance, whatever role/holder pair was queried. */
|
|
59
|
+
readonly hasRoleAll: (s: Scope) => unknown[];
|
|
60
|
+
readonly roleMembers: (s: Scope, role: Hex | undefined) => unknown[];
|
|
61
|
+
readonly roleMembersAll: (s: Scope) => unknown[];
|
|
62
|
+
/** Every cached create-preflight, whatever params/mode/salt combination was queried. */
|
|
63
|
+
readonly preflightCreateAll: (s: Scope) => unknown[];
|
|
64
|
+
/** Every cached signature check on this instance; a claim consumes a digest and flips it. */
|
|
65
|
+
readonly isSignatureValidAll: (s: Scope) => unknown[];
|
|
66
|
+
readonly fees: (s: Scope) => unknown[];
|
|
67
|
+
readonly customFee: (s: Scope, creator: Address | undefined) => unknown[];
|
|
68
|
+
readonly customFeeAll: (s: Scope) => unknown[];
|
|
69
|
+
/** Every registry page, whatever offset/limit was queried. */
|
|
70
|
+
readonly registryAll: (s: Scope) => unknown[];
|
|
71
|
+
readonly implementations: (s: Scope) => unknown[];
|
|
72
|
+
readonly compliancePolicy: (s: Scope, creator: Address | undefined) => unknown[];
|
|
73
|
+
readonly compliancePolicyAll: (s: Scope) => unknown[];
|
|
74
|
+
readonly upgradeabilityPolicy: (s: Scope, creator: Address | undefined) => unknown[];
|
|
75
|
+
readonly upgradeabilityPolicyAll: (s: Scope) => unknown[];
|
|
76
|
+
readonly factoryHasRole: (s: Scope, role: Hex | undefined, holder: Address | undefined) => unknown[];
|
|
77
|
+
readonly factoryHasRoleAll: (s: Scope) => unknown[];
|
|
78
|
+
readonly factoryRoleMembers: (s: Scope, role: Hex | undefined) => unknown[];
|
|
79
|
+
readonly factoryRoleMembersAll: (s: Scope) => unknown[];
|
|
80
|
+
readonly complianceInfo: (s: Scope) => unknown[];
|
|
81
|
+
readonly activeDelegate: (s: Scope, delegate: Address | undefined) => unknown[];
|
|
82
|
+
readonly activeDelegateAll: (s: Scope) => unknown[];
|
|
83
|
+
readonly clientDelegates: (s: Scope, index: bigint | undefined) => unknown[];
|
|
84
|
+
readonly clientDelegatesAll: (s: Scope) => unknown[];
|
|
85
|
+
readonly complianceHasRole: (s: Scope, role: Hex | undefined, holder: Address | undefined) => unknown[];
|
|
86
|
+
readonly complianceHasRoleAll: (s: Scope) => unknown[];
|
|
87
|
+
readonly complianceRoleMembers: (s: Scope, role: Hex | undefined) => unknown[];
|
|
88
|
+
readonly complianceRoleMembersAll: (s: Scope) => unknown[];
|
|
89
|
+
};
|
|
90
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
import type { EncryptedViewResult } from "../../fhe/types.js";
|
|
3
|
+
import type { GetClaimAmountArgs as EcdsaGetClaimAmountArgs } from "../ecdsa.js";
|
|
4
|
+
import { type EcdsaAirdropInstanceClientOptions } from "./_shared.js";
|
|
5
|
+
/**
|
|
6
|
+
* **Submits a transaction.** Previews a signed encrypted allocation as an encrypted
|
|
7
|
+
* handle. Pass `data.handle` to the Zama relayer's `userDecrypt`.
|
|
8
|
+
*
|
|
9
|
+
* **The submitter can decrypt what it previews here.** The contract grants the amount
|
|
10
|
+
* with `FHE.allow(amount, msg.sender)`, unlike {@link useAccessMerkleClaimAmount}, whose
|
|
11
|
+
* grantee is the entry's claim identity rather than the caller.
|
|
12
|
+
*
|
|
13
|
+
* `dedupMode` must be supplied - the contract has no on-chain getter for it; pass the
|
|
14
|
+
* same value used at `createEcdsaAirdrop` time.
|
|
15
|
+
*
|
|
16
|
+
* **Invalidates:** nothing. The preview consumes neither replay guard nor the EIP-712
|
|
17
|
+
* digest, so the same input is still claimable for real afterwards and no cached read
|
|
18
|
+
* changes value.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const preview = useAccessEcdsaClaimAmount({ address: airdropAddress, dedupMode: "perAddress" });
|
|
22
|
+
* const { handle } = await preview.mutateAsync({ encryptedInput, dedupId, deadline, signer, signature });
|
|
23
|
+
*
|
|
24
|
+
* @alpha
|
|
25
|
+
*/
|
|
26
|
+
export declare function useAccessEcdsaClaimAmount(options: EcdsaAirdropInstanceClientOptions): UseMutationResult<EncryptedViewResult, Error, EcdsaGetClaimAmountArgs>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
import type { EncryptedViewResult } from "../../fhe/types.js";
|
|
3
|
+
import type { GetClaimAmountArgs } from "../merkle.js";
|
|
4
|
+
import { type AirdropInstanceClientOptions } from "./_shared.js";
|
|
5
|
+
/**
|
|
6
|
+
* **Submits a transaction.** Previews the outstanding amount for a proof-bearing Merkle
|
|
7
|
+
* entry as an encrypted handle. Pass `data.handle` to the Zama relayer's `userDecrypt`.
|
|
8
|
+
*
|
|
9
|
+
* `entry.boundTo` must be the sending account (the coprocessor verifies the input proof
|
|
10
|
+
* against the literal caller); `entry.account` selects the leaf.
|
|
11
|
+
*
|
|
12
|
+
* **`entry.account` is the only party that can decrypt the result, not the submitter.**
|
|
13
|
+
* The contract grants the outstanding handle with `_outstandingOf(account, account, …)`,
|
|
14
|
+
* so a third-party submitter gets back a valid handle it learns nothing from - never
|
|
15
|
+
* offer it a `userDecrypt` action. This is the opposite of
|
|
16
|
+
* {@link useAccessEcdsaClaimAmount}, whose preview is ACL'd to `msg.sender`.
|
|
17
|
+
*
|
|
18
|
+
* **Invalidates:** nothing. The preview consumes no accounting and no per-leaf state, so
|
|
19
|
+
* no cached read changes value - the same entry still pays the same amount afterwards.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const preview = useAccessMerkleClaimAmount({ address: airdropAddress });
|
|
23
|
+
* const { handle } = await preview.mutateAsync({ entry });
|
|
24
|
+
*
|
|
25
|
+
* @alpha
|
|
26
|
+
*/
|
|
27
|
+
export declare function useAccessMerkleClaimAmount(options: AirdropInstanceClientOptions): UseMutationResult<EncryptedViewResult, Error, GetClaimAmountArgs>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Address, Hex } from "viem";
|
|
3
|
+
import type { WriteAccountOverride } from "../airdrop-base.js";
|
|
4
|
+
import { type AirdropInstanceClientOptions } from "./_shared.js";
|
|
5
|
+
/** @alpha */
|
|
6
|
+
export interface AddComplianceDelegateArgs extends WriteAccountOverride {
|
|
7
|
+
/** The account to grant never-expiring user-decryption delegation to. */
|
|
8
|
+
delegate: Address;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Grant `delegate` permanent user-decryption delegation over this compliance
|
|
12
|
+
* clone's airdrop. `options.address` is the CLONE. Requires
|
|
13
|
+
* `DELEGATION_ADMIN_ROLE` on it (check with {@link useComplianceHasRole}).
|
|
14
|
+
*
|
|
15
|
+
* **The gateway lag is this hook's headline.** The delegation is live in the
|
|
16
|
+
* ACL the instant the transaction lands, but the Zama gateway learns about it
|
|
17
|
+
* out of band - the SDK's own guidance is 1-2 minutes. Do not tell the user
|
|
18
|
+
* delegated decryption is ready on success; classify the first delegated
|
|
19
|
+
* reads' failures with `isAclPropagationError` and retry with backoff.
|
|
20
|
+
*
|
|
21
|
+
* **Invalidates:** this clone's {@link useComplianceInfo} entry (the
|
|
22
|
+
* client-delegate set grew) and its {@link useIsActiveDelegate} entry for
|
|
23
|
+
* exactly `delegate`. Both keyed on the clone address - the airdrop instance
|
|
24
|
+
* is a different contract with its own cache namespace and is untouched.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* Do not send this and {@link useRevokeComplianceDelegate} for the same
|
|
28
|
+
* delegate in one block: the FHEVM ACL rejects the pair with an opaque revert
|
|
29
|
+
* that names neither the delegate nor the cause.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const add = useAddComplianceDelegate({ address: managerAddress });
|
|
33
|
+
* await add.mutateAsync({ delegate: complianceOfficer });
|
|
34
|
+
*
|
|
35
|
+
* @alpha
|
|
36
|
+
*/
|
|
37
|
+
export declare function useAddComplianceDelegate(options: AirdropInstanceClientOptions): UseMutationResult<Hex, Error, AddComplianceDelegateArgs>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
import type { EncryptedViewResult } from "../../fhe/types.js";
|
|
4
|
+
import type { WriteAccountOverride } from "../airdrop-base.js";
|
|
5
|
+
import { type AirdropInstanceClientOptions } from "./_shared.js";
|
|
6
|
+
/** @alpha */
|
|
7
|
+
export interface UseAdminBatchDiscloseBalanceToPartiesArgs extends WriteAccountOverride {
|
|
8
|
+
/**
|
|
9
|
+
* Every address to grant. Must be non-empty and contain no zero address;
|
|
10
|
+
* duplicates are wasteful but legal on-chain and are not rejected.
|
|
11
|
+
*/
|
|
12
|
+
parties: readonly Address[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* **Submits a transaction.** Discloses the instance's confidential pool
|
|
16
|
+
* balance to several parties at once. Requires `DISCLOSURE_ADMIN_ROLE`.
|
|
17
|
+
*
|
|
18
|
+
* One handle covers the whole batch: the contract reads the balance once and
|
|
19
|
+
* fans the same handle out, so `data.handle` (recovered from the grant naming
|
|
20
|
+
* `parties[0]`) is what *every* listed party decrypts. The caller is not a
|
|
21
|
+
* grantee unless it is in the list.
|
|
22
|
+
*
|
|
23
|
+
* An empty list and a zero-address party are rejected client-side as
|
|
24
|
+
* `InvalidArgumentError` before any gas is spent. Both are decidable from a
|
|
25
|
+
* form's own state, so validate the rows and show field errors rather than
|
|
26
|
+
* routing these through `onError`.
|
|
27
|
+
*
|
|
28
|
+
* **Invalidates:** nothing. ACL is append-only and no read hook caches grants.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* const disclose = useAdminBatchDiscloseBalanceToParties({ address: airdropAddress });
|
|
32
|
+
* const { handle } = await disclose.mutateAsync({ parties: [auditor, regulator] });
|
|
33
|
+
*
|
|
34
|
+
* @alpha
|
|
35
|
+
*/
|
|
36
|
+
export declare function useAdminBatchDiscloseBalanceToParties(options: AirdropInstanceClientOptions): UseMutationResult<EncryptedViewResult, Error, UseAdminBatchDiscloseBalanceToPartiesArgs>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
import type { EncryptedViewResult } from "../../fhe/types.js";
|
|
4
|
+
import type { WriteAccountOverride } from "../airdrop-base.js";
|
|
5
|
+
import { type AirdropInstanceClientOptions } from "./_shared.js";
|
|
6
|
+
/** @alpha */
|
|
7
|
+
export interface UseAdminDiscloseBalanceToPartyArgs extends WriteAccountOverride {
|
|
8
|
+
/** The address granted decrypt access - and the only address that can use the returned handle. */
|
|
9
|
+
party: Address;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* **Submits a transaction.** Discloses the instance's confidential pool
|
|
13
|
+
* balance to `party`. Requires `DISCLOSURE_ADMIN_ROLE`.
|
|
14
|
+
*
|
|
15
|
+
* **The grantee is `party`, not the caller.** The handle is recovered from the
|
|
16
|
+
* ACL `Allowed` event naming `party`, so unless the caller is also `party` the
|
|
17
|
+
* returned `data.handle` is one it cannot decrypt - hand it to `party` rather
|
|
18
|
+
* than to your own `userDecrypt`, or the relayer rejects it with "not
|
|
19
|
+
* authorized to decrypt". As with every encrypted view here, the handle comes
|
|
20
|
+
* from the receipt and never from a simulation (CLAUDE.md Pitfall #1).
|
|
21
|
+
*
|
|
22
|
+
* **Invalidates:** nothing. ACL is append-only and no read hook in this
|
|
23
|
+
* subpath caches who is allowed on a handle.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const disclose = useAdminDiscloseBalanceToParty({ address: airdropAddress });
|
|
27
|
+
* const { handle } = await disclose.mutateAsync({ party: auditorAddress });
|
|
28
|
+
*
|
|
29
|
+
* @alpha
|
|
30
|
+
*/
|
|
31
|
+
export declare function useAdminDiscloseBalanceToParty(options: AirdropInstanceClientOptions): UseMutationResult<EncryptedViewResult, Error, UseAdminDiscloseBalanceToPartyArgs>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
import type { EncryptedViewResult } from "../../fhe/types.js";
|
|
3
|
+
import type { WriteAccountOverride } from "../airdrop-base.js";
|
|
4
|
+
import { type AirdropInstanceClientOptions } from "./_shared.js";
|
|
5
|
+
/**
|
|
6
|
+
* **Submits a transaction.** Reads the instance's remaining confidential pool
|
|
7
|
+
* balance as an `euint64` handle the caller may decrypt - pass `data.handle`
|
|
8
|
+
* to the Zama relayer's `userDecrypt`. Requires `DISCLOSURE_ADMIN_ROLE`.
|
|
9
|
+
*
|
|
10
|
+
* The name reads like a getter but the entrypoint calls `FHE.allow`, so it is
|
|
11
|
+
* `nonpayable` and its handle comes from the receipt's ACL `Allowed` event -
|
|
12
|
+
* never from a simulation, whose handle would carry no grant (CLAUDE.md
|
|
13
|
+
* Pitfall #1). That is why this is a mutation and not a query.
|
|
14
|
+
*
|
|
15
|
+
* **Invalidates:** nothing. It grants ACL and reads no cached state. Note the
|
|
16
|
+
* converse too: funding and withdrawing move the balance this returns, but a
|
|
17
|
+
* mutation result is not a cache entry, so no write can refresh it - re-run
|
|
18
|
+
* this hook after `useFundAirdrop` or `useWithdrawConfidential` to see the
|
|
19
|
+
* new value.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const balance = useAdminGetCurrentBalance({ address: airdropAddress });
|
|
23
|
+
* const { handle } = await balance.mutateAsync();
|
|
24
|
+
*
|
|
25
|
+
* @alpha
|
|
26
|
+
*/
|
|
27
|
+
export declare function useAdminGetCurrentBalance(options: AirdropInstanceClientOptions): UseMutationResult<EncryptedViewResult, Error, WriteAccountOverride | void>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
import type { AirdropVariant } from "../errors.js";
|
|
4
|
+
import { type AirdropInstanceHookOptions } from "./_shared.js";
|
|
5
|
+
/**
|
|
6
|
+
* Create-time-immutable instance configuration - combines five `AirdropBaseClient`
|
|
7
|
+
* reads into one.
|
|
8
|
+
*
|
|
9
|
+
* @alpha
|
|
10
|
+
*/
|
|
11
|
+
export interface AirdropConfig {
|
|
12
|
+
/** The ERC-7984 token this campaign distributes. */
|
|
13
|
+
token: Address;
|
|
14
|
+
/** The raw variant ordinal from the contract enum: `0` = ECDSA, `1` = Merkle. */
|
|
15
|
+
airdropType: number;
|
|
16
|
+
/** {@link airdropType} as a name, so a consumer can pick which variant hook set to mount. */
|
|
17
|
+
variant: AirdropVariant;
|
|
18
|
+
/** Whether claimants may unwrap to the underlying ERC-20 as part of a claim. */
|
|
19
|
+
unwrappable: boolean;
|
|
20
|
+
/** The instance's own compliance-manager clone. */
|
|
21
|
+
complianceManager: Address;
|
|
22
|
+
/** Per-claim ETH fee in wei; `0` on a fee-free campaign. */
|
|
23
|
+
gasFee: bigint;
|
|
24
|
+
}
|
|
25
|
+
/** @alpha */
|
|
26
|
+
export type UseAirdropConfigArgs = AirdropInstanceHookOptions<AirdropConfig>;
|
|
27
|
+
/**
|
|
28
|
+
* Read an airdrop instance's immutable configuration in one round trip.
|
|
29
|
+
*
|
|
30
|
+
* Bundles `token` / `airdropType` / `unwrappable` / `complianceManager` / `gasFee` -
|
|
31
|
+
* what a UI needs before it can render anything else about a campaign, and how
|
|
32
|
+
* `airdropType` and `unwrappable` get covered without shipping two more one-line hooks
|
|
33
|
+
* nobody would call separately. `variant` is derived from the ordinal so a consumer can
|
|
34
|
+
* branch to the ECDSA or Merkle hook set without decoding the enum itself.
|
|
35
|
+
*
|
|
36
|
+
* Defaults to `staleTime: Infinity` - none of these values is mutable after create. Pass
|
|
37
|
+
* `query: { staleTime: 0 }` to override.
|
|
38
|
+
*
|
|
39
|
+
* The existing {@link useAirdropToken}, {@link useAirdropGasFee} and
|
|
40
|
+
* {@link useComplianceManager} overlap this bundle and stay: they are one `eth_call`
|
|
41
|
+
* rather than five, which is cheaper for a UI that needs exactly one value.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* const { data: config } = useAirdropConfig({ address: airdropAddress });
|
|
45
|
+
* if (config?.variant === "merkle") { ... }
|
|
46
|
+
*
|
|
47
|
+
* @alpha
|
|
48
|
+
*/
|
|
49
|
+
export declare function useAirdropConfig(args: UseAirdropConfigArgs): UseQueryResult<AirdropConfig, Error>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import type { DeploymentMode } from "../constants.js";
|
|
3
|
+
import { type AirdropInstanceHookOptions } from "./_shared.js";
|
|
4
|
+
/** @alpha */
|
|
5
|
+
export type UseAirdropDeploymentModeArgs = AirdropInstanceHookOptions<DeploymentMode>;
|
|
6
|
+
/**
|
|
7
|
+
* Read which deployment shell an airdrop instance is: a minimal-proxy
|
|
8
|
+
* `"clone"`, or a `"uups"` ERC-1967 proxy that
|
|
9
|
+
* {@link useAirdropUpgradeToAndCall} can actually move. Gate any upgrade UI
|
|
10
|
+
* on this.
|
|
11
|
+
*
|
|
12
|
+
* One `eth_getStorageAt` against the ERC-1967 implementation slot, no ABI
|
|
13
|
+
* involved. It is the only reliable discriminator: `proxiableUUID` reverts on
|
|
14
|
+
* both shells when called at an instance address, and
|
|
15
|
+
* `UPGRADE_INTERFACE_VERSION` answers `"5.0.0"` for both.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* Defaults to `staleTime: Infinity` — a clone never becomes a proxy, and an
|
|
19
|
+
* upgrade swaps the implementation without changing the shell. Override via
|
|
20
|
+
* `query.staleTime` if you need a refetch anyway.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* const { data: mode } = useAirdropDeploymentMode({ address: airdropAddress });
|
|
24
|
+
* const canUpgrade = mode === "uups";
|
|
25
|
+
*
|
|
26
|
+
* @alpha
|
|
27
|
+
*/
|
|
28
|
+
export declare function useAirdropDeploymentMode(args: UseAirdropDeploymentModeArgs): UseQueryResult<DeploymentMode, Error>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Address, Hex } from "viem";
|
|
3
|
+
import type { WriteAccountOverride } from "../airdrop-base.js";
|
|
4
|
+
import { type AirdropInstanceClientOptions } from "./_shared.js";
|
|
5
|
+
/** @alpha */
|
|
6
|
+
export interface AirdropGrantRoleArgs extends WriteAccountOverride {
|
|
7
|
+
/** A `bytes32` role identifier - read it from {@link useAirdropRoleConstants}, never hand-hashed. */
|
|
8
|
+
role: Hex;
|
|
9
|
+
/** The account receiving the role. Distinct from `account`, which is who sends the transaction. */
|
|
10
|
+
holder: Address;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Grant one role on one airdrop instance.
|
|
14
|
+
*
|
|
15
|
+
* Requires the role's admin role, which is `DEFAULT_ADMIN_ROLE` for every role
|
|
16
|
+
* the instance sets up at `initialize` except `FEE_COLLECTOR_ROLE` - that one
|
|
17
|
+
* administers itself, so only a current fee collector can add another. Confirm
|
|
18
|
+
* with {@link useAirdropRoleAdmin} before offering the grant in a UI.
|
|
19
|
+
*
|
|
20
|
+
* **Invalidates:** this instance's `useAirdropHasRole` entry for exactly
|
|
21
|
+
* `(role, holder)`, and its `useAirdropRoleMembers` entry for `role` (the
|
|
22
|
+
* member list and the count both move). Scoped to this instance - other
|
|
23
|
+
* campaigns' role caches and other role/holder pairs are untouched.
|
|
24
|
+
*
|
|
25
|
+
* For a multi-role split right after create, prefer {@link useGrantInstanceRoles}:
|
|
26
|
+
* it orders the creator's admin revoke last so the key issuing the grants never
|
|
27
|
+
* locks itself out mid-sequence.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const grant = useAirdropGrantRole({ address: airdropAddress });
|
|
31
|
+
* await grant.mutateAsync({ role: roles.PAUSER_ROLE, holder: opsAddress });
|
|
32
|
+
*
|
|
33
|
+
* @alpha
|
|
34
|
+
*/
|
|
35
|
+
export declare function useAirdropGrantRole(options: AirdropInstanceClientOptions): UseMutationResult<Hex, Error, AirdropGrantRoleArgs>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Hex } from "viem";
|
|
3
|
+
import type { WriteAccountOverride } from "../airdrop-base.js";
|
|
4
|
+
import { type AirdropInstanceClientOptions } from "./_shared.js";
|
|
5
|
+
/** @alpha */
|
|
6
|
+
export interface AirdropRenounceRoleArgs extends WriteAccountOverride {
|
|
7
|
+
/** A `bytes32` role identifier - read it from {@link useAirdropRoleConstants}, never hand-hashed. */
|
|
8
|
+
role: Hex;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Give up a role on an airdrop instance yourself.
|
|
12
|
+
*
|
|
13
|
+
* Self-only by construction: the contract's `renounceRole(role, callerConfirmation)`
|
|
14
|
+
* reverts `AccessControlBadConfirmation` unless the confirmation is the sender,
|
|
15
|
+
* so there is no holder to pass - the headless client fills it from the
|
|
16
|
+
* resolved sending account. To remove a role from somebody else use
|
|
17
|
+
* {@link useAirdropRevokeRole}.
|
|
18
|
+
*
|
|
19
|
+
* Renouncing runs the same on-chain floors as a revoke, so it is not an escape
|
|
20
|
+
* hatch from them: the sole remaining `DEFAULT_ADMIN_ROLE` holder cannot
|
|
21
|
+
* renounce (`LastAdmin`). Grant a successor first.
|
|
22
|
+
*
|
|
23
|
+
* **Invalidates:** every `useAirdropHasRole` entry for this instance (prefix,
|
|
24
|
+
* all role/holder pairs), plus its `useAirdropRoleMembers` entry for `role`.
|
|
25
|
+
* The prefix is deliberate - the holder here is whichever account the wallet
|
|
26
|
+
* client resolves at submit time, which need not match any `(role, holder)`
|
|
27
|
+
* pair a component happens to have cached, and a narrower key would invalidate
|
|
28
|
+
* nothing while throwing nothing. Still scoped to this instance.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* const renounce = useAirdropRenounceRole({ address: airdropAddress });
|
|
32
|
+
* await renounce.mutateAsync({ role: roles.DEFAULT_ADMIN_ROLE });
|
|
33
|
+
*
|
|
34
|
+
* @alpha
|
|
35
|
+
*/
|
|
36
|
+
export declare function useAirdropRenounceRole(options: AirdropInstanceClientOptions): UseMutationResult<Hex, Error, AirdropRenounceRoleArgs>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Address, Hex } from "viem";
|
|
3
|
+
import type { WriteAccountOverride } from "../airdrop-base.js";
|
|
4
|
+
import { type AirdropInstanceClientOptions } from "./_shared.js";
|
|
5
|
+
/** @alpha */
|
|
6
|
+
export interface AirdropRevokeRoleArgs extends WriteAccountOverride {
|
|
7
|
+
/** A `bytes32` role identifier - read it from {@link useAirdropRoleConstants}, never hand-hashed. */
|
|
8
|
+
role: Hex;
|
|
9
|
+
/** The account losing the role. Distinct from `account`, which is who sends the transaction. */
|
|
10
|
+
holder: Address;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Revoke one role from one holder on one airdrop instance.
|
|
14
|
+
*
|
|
15
|
+
* Requires the role's admin role (see {@link useAirdropRoleAdmin};
|
|
16
|
+
* `FEE_COLLECTOR_ROLE` administers itself).
|
|
17
|
+
*
|
|
18
|
+
* Two revocations the contract refuses outright, both pre-checkable with
|
|
19
|
+
* {@link useAirdropRoleMembers}'s `count`: the last `DEFAULT_ADMIN_ROLE` member
|
|
20
|
+
* (`LastAdmin`), and the last `FEE_COLLECTOR_ROLE` member of a fee-charging
|
|
21
|
+
* campaign (`LastFeeCollector`). Grant the successor first, then revoke.
|
|
22
|
+
*
|
|
23
|
+
* **Invalidates:** this instance's `useAirdropHasRole` entry for exactly
|
|
24
|
+
* `(role, holder)`, and its `useAirdropRoleMembers` entry for `role`. Scoped to
|
|
25
|
+
* this instance only.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* const revoke = useAirdropRevokeRole({ address: airdropAddress });
|
|
29
|
+
* await revoke.mutateAsync({ role: roles.PAUSER_ROLE, holder: formerOpsAddress });
|
|
30
|
+
*
|
|
31
|
+
* @alpha
|
|
32
|
+
*/
|
|
33
|
+
export declare function useAirdropRevokeRole(options: AirdropInstanceClientOptions): UseMutationResult<Hex, Error, AirdropRevokeRoleArgs>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Hex } from "viem";
|
|
3
|
+
import { type AirdropInstanceHookOptions } from "./_shared.js";
|
|
4
|
+
/** @alpha */
|
|
5
|
+
export interface UseAirdropRoleAdminArgs extends AirdropInstanceHookOptions<Hex> {
|
|
6
|
+
/** The role whose administrator to read - from {@link useAirdropRoleConstants}, not hand-hashed. */
|
|
7
|
+
role?: Hex;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Which role's holders may grant and revoke `role` on an airdrop instance.
|
|
11
|
+
*
|
|
12
|
+
* `DEFAULT_ADMIN_ROLE` for everything the instance wires up at `initialize`,
|
|
13
|
+
* with one exception the instance is alone in this module in having:
|
|
14
|
+
* `FEE_COLLECTOR_ROLE` is re-parented to itself, so only a current fee
|
|
15
|
+
* collector can add or remove another. This read is how a UI confirms that
|
|
16
|
+
* before it lets an admin key attempt a fee-collector grant that
|
|
17
|
+
* `planInstanceRoleSplit` already refuses to plan.
|
|
18
|
+
*
|
|
19
|
+
* Stays idle until `role` is defined, so a component can call it while a form
|
|
20
|
+
* is still filling in. Set once at initialize, hence `staleTime: Infinity` by
|
|
21
|
+
* default (overridable through `query`).
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const { data: admin } = useAirdropRoleAdmin({ address, role: roles?.FEE_COLLECTOR_ROLE });
|
|
25
|
+
*
|
|
26
|
+
* @alpha
|
|
27
|
+
*/
|
|
28
|
+
export declare function useAirdropRoleAdmin(args: UseAirdropRoleAdminArgs): UseQueryResult<Hex, Error>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Hex } from "viem";
|
|
3
|
+
import type { DedupMode } from "../constants.js";
|
|
4
|
+
import { type AirdropInstanceHookOptions } from "./_shared.js";
|
|
5
|
+
/**
|
|
6
|
+
* The `bytes32` role identifiers an airdrop instance exposes - the eight every
|
|
7
|
+
* variant shares, plus whichever ninth belongs to the variant asked for.
|
|
8
|
+
*
|
|
9
|
+
* @alpha
|
|
10
|
+
*/
|
|
11
|
+
export interface AirdropRoleConstants {
|
|
12
|
+
/** Gates `pause` / `unpause`. */
|
|
13
|
+
PAUSER_ROLE: Hex;
|
|
14
|
+
/** Gates `extendClaimWindow`. */
|
|
15
|
+
WINDOW_ADMIN_ROLE: Hex;
|
|
16
|
+
/** Gates `withdrawConfidential`. */
|
|
17
|
+
TREASURY_ROLE: Hex;
|
|
18
|
+
/** Gates the ERC-20 / foreign-token rescue surface. */
|
|
19
|
+
RESCUER_ROLE: Hex;
|
|
20
|
+
/** Gates `withdrawGasFee`, and administers itself rather than being administered by `DEFAULT_ADMIN_ROLE`. */
|
|
21
|
+
FEE_COLLECTOR_ROLE: Hex;
|
|
22
|
+
/** Gates `upgradeToAndCall` on UUPS instances; inert on clones. */
|
|
23
|
+
UPGRADER_ROLE: Hex;
|
|
24
|
+
/** Gates the admin disclosure surface. */
|
|
25
|
+
DISCLOSURE_ADMIN_ROLE: Hex;
|
|
26
|
+
/** OpenZeppelin's root role, read off the instance rather than assumed to be `bytes32(0)`. */
|
|
27
|
+
DEFAULT_ADMIN_ROLE: Hex;
|
|
28
|
+
/** Gates `setMerkleRoot`. Present only when `variant: "merkle"` was requested. */
|
|
29
|
+
MERKLE_ADMIN_ROLE?: Hex;
|
|
30
|
+
/** The role whose holders may authorize an ECDSA claim. Present only when `variant: "ecdsa"` was requested. */
|
|
31
|
+
SIGNER_ROLE?: Hex;
|
|
32
|
+
}
|
|
33
|
+
/** @alpha */
|
|
34
|
+
export interface UseAirdropRoleConstantsArgs extends AirdropInstanceHookOptions<AirdropRoleConstants> {
|
|
35
|
+
/**
|
|
36
|
+
* Also read the variant-only role: `MERKLE_ADMIN_ROLE` or `SIGNER_ROLE`.
|
|
37
|
+
* Omit it for the eight shared constants and neither extra read fires.
|
|
38
|
+
*/
|
|
39
|
+
variant?: "ecdsa" | "merkle";
|
|
40
|
+
/**
|
|
41
|
+
* Only relevant with `variant: "ecdsa"`, and only to keep the client
|
|
42
|
+
* construction honest - no read here consumes it. Pass the campaign's real
|
|
43
|
+
* policy if you have it to hand.
|
|
44
|
+
*/
|
|
45
|
+
dedupMode?: DedupMode;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Read an airdrop instance's role identifiers in one fan-out.
|
|
49
|
+
*
|
|
50
|
+
* Every value is a bytecode constant, so this is cacheable indefinitely
|
|
51
|
+
* (`staleTime: Infinity` by default, overridable through `query`). Feed the
|
|
52
|
+
* results into {@link useAirdropHasRole}, {@link useAirdropRoleMembers},
|
|
53
|
+
* {@link useAirdropRoleAdmin} and the role mutations - hand-hashing
|
|
54
|
+
* `keccak256("PAUSER_ROLE")` client-side would turn a constant renamed in a
|
|
55
|
+
* future contract version into a `grantRole` that silently grants a role
|
|
56
|
+
* nothing checks.
|
|
57
|
+
*
|
|
58
|
+
* One bundled hook rather than ten one-liners nobody would call separately: a
|
|
59
|
+
* UI needs the whole palette to render a role panel at all.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const { data: roles } = useAirdropRoleConstants({ address, variant: "merkle" });
|
|
63
|
+
* const { data: isPauser } = useAirdropHasRole({ address, role: roles?.PAUSER_ROLE, holder });
|
|
64
|
+
*
|
|
65
|
+
* @alpha
|
|
66
|
+
*/
|
|
67
|
+
export declare function useAirdropRoleConstants(args: UseAirdropRoleConstantsArgs): UseQueryResult<AirdropRoleConstants, Error>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Address, Hex } from "viem";
|
|
3
|
+
import { type AirdropInstanceHookOptions } from "./_shared.js";
|
|
4
|
+
/**
|
|
5
|
+
* One role's membership on an airdrop instance - the set and its size, read
|
|
6
|
+
* together.
|
|
7
|
+
*
|
|
8
|
+
* @alpha
|
|
9
|
+
*/
|
|
10
|
+
export interface AirdropRoleMembership {
|
|
11
|
+
/** Every account currently holding the role, in the contract's `EnumerableSet` order. */
|
|
12
|
+
members: readonly Address[];
|
|
13
|
+
/** How many accounts hold it. The variable the contract's own revoke floors are written against. */
|
|
14
|
+
count: bigint;
|
|
15
|
+
}
|
|
16
|
+
/** @alpha */
|
|
17
|
+
export interface UseAirdropRoleMembersArgs extends AirdropInstanceHookOptions<AirdropRoleMembership> {
|
|
18
|
+
/** The role whose members to list - from {@link useAirdropRoleConstants}, not hand-hashed. */
|
|
19
|
+
role?: Hex;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* List who holds `role` on an airdrop instance, with the member count.
|
|
23
|
+
*
|
|
24
|
+
* This is the supported way to discover a campaign's fee collectors: the
|
|
25
|
+
* contract deliberately ships no `feeCollectors()` view and points callers at
|
|
26
|
+
* `getRoleMembers(FEE_COLLECTOR_ROLE)` instead.
|
|
27
|
+
*
|
|
28
|
+
* `count` is bundled rather than split into its own hook because it is the
|
|
29
|
+
* variable the contract's revoke floors are written against - a revoke of
|
|
30
|
+
* `DEFAULT_ADMIN_ROLE` at count 1 reverts `LastAdmin`, and of
|
|
31
|
+
* `FEE_COLLECTOR_ROLE` at count 1 on a fee-charging campaign reverts
|
|
32
|
+
* `LastFeeCollector` - so a UI showing the list wants to know in the same
|
|
33
|
+
* render whether a revoke is possible at all.
|
|
34
|
+
*
|
|
35
|
+
* Unpaginated: role sets here are operator-sized, not user-sized.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* Invalidated by {@link useAirdropGrantRole}, {@link useAirdropRevokeRole},
|
|
39
|
+
* {@link useAirdropRenounceRole} and {@link useGrantInstanceRoles}. Member
|
|
40
|
+
* order is `EnumerableSet`'s and is not stable across grants and revokes -
|
|
41
|
+
* treat it as a set, not a list.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* const { data } = useAirdropRoleMembers({ address, role: roles?.FEE_COLLECTOR_ROLE });
|
|
45
|
+
* const canRevoke = (data?.count ?? 0n) > 1n;
|
|
46
|
+
*
|
|
47
|
+
* @alpha
|
|
48
|
+
*/
|
|
49
|
+
export declare function useAirdropRoleMembers(args: UseAirdropRoleMembersArgs): UseQueryResult<AirdropRoleMembership, Error>;
|