@tokenops/sdk 1.6.0 → 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 +77 -8
- package/CONTRIBUTING.md +4 -2
- package/README.md +146 -90
- package/SUPPORT.md +47 -0
- package/dist/{chunk-BD4LZBVF.cjs → chunk-3QHNYEQD.cjs} +18 -17
- package/dist/{chunk-YFIWCYHC.cjs → chunk-3YHBO2DL.cjs} +56 -54
- package/dist/{chunk-QET3Q4JP.js → chunk-44YJPMQC.js} +8 -6
- package/dist/{chunk-6WSNS3UV.js → chunk-4RAAATVY.js} +2 -4
- package/dist/{chunk-4KJ66YRH.js → chunk-4TSDNZQ3.js} +2 -2
- package/dist/chunk-66IHPTOK.cjs +20 -0
- package/dist/{chunk-2RNW4MIJ.cjs → chunk-67OV5CX2.cjs} +0 -18
- package/dist/{chunk-PD7ME2BT.js → chunk-6GNR22OV.js} +2 -1
- package/dist/{chunk-WOEETTH7.cjs → chunk-7AFPOE7N.cjs} +6 -6
- package/dist/{chunk-QKKBBH7I.js → chunk-A4DCEE33.js} +34 -7
- package/dist/chunk-AREQJHKA.cjs +713 -0
- package/dist/{chunk-U57COLUE.js → chunk-AXIPOR3C.js} +2 -2
- package/dist/chunk-EBLBPUPI.cjs +255 -0
- package/dist/chunk-EYDA6Q6C.js +245 -0
- package/dist/{chunk-SYHNZSZZ.cjs → chunk-FAXIIH5R.cjs} +3 -3
- package/dist/{chunk-AYGRYDBX.cjs → chunk-FEDX7B6T.cjs} +37 -35
- package/dist/{chunk-CBRL2PJA.cjs → chunk-FHWSBGWE.cjs} +12 -12
- package/dist/{chunk-WUXUWTFW.cjs → chunk-FT5H2Q7Y.cjs} +37 -7
- package/dist/chunk-GADGBQJO.js +423 -0
- package/dist/{chunk-VHSNYUYV.js → chunk-IGO5XSPS.js} +5 -5
- package/dist/chunk-IUKKNJ2R.cjs +433 -0
- package/dist/{chunk-VR3FREBX.cjs → chunk-JK4XMMKM.cjs} +3 -3
- package/dist/{chunk-4ZCXK4VI.cjs → chunk-KFRDLKMA.cjs} +14 -14
- package/dist/chunk-KWFFIJYX.js +11 -0
- package/dist/{chunk-7G7UOQV4.cjs → chunk-MM5BV5CS.cjs} +4 -4
- package/dist/{chunk-43RFBQ73.cjs → chunk-MVDQMV25.cjs} +29 -32
- package/dist/chunk-NWFMBLSQ.js +4 -0
- package/dist/{chunk-HETNKZEE.js → chunk-PYYSB5ZN.js} +1 -1
- package/dist/chunk-PZZK3O3S.cjs +9843 -0
- package/dist/{chunk-DRSPMIZ7.js → chunk-QBJ7O2B4.js} +1 -11
- package/dist/{chunk-WTK6JDSI.js → chunk-SPLNGUFF.js} +6 -4
- package/dist/{chunk-UJS4N2XM.cjs → chunk-TEBM66WA.cjs} +12 -12
- package/dist/{chunk-TN65XNTI.js → chunk-TWT3STIX.js} +8 -6
- package/dist/chunk-UG5RKLU2.cjs +6 -0
- package/dist/{chunk-EUKPOXWR.cjs → chunk-UHHMVBLU.cjs} +17 -15
- package/dist/chunk-VW356KR3.js +688 -0
- package/dist/{chunk-BK7YIVLK.cjs → chunk-WJLECC22.cjs} +75 -73
- package/dist/{chunk-V5D7BHW3.js → chunk-WJMEBBU7.js} +6 -4
- package/dist/{chunk-NFW7AUEX.js → chunk-WMACINXO.js} +1 -1
- package/dist/chunk-X7WBPCEU.js +9817 -0
- package/dist/{chunk-46T67CE2.js → chunk-ZA673I3O.js} +1 -1
- package/dist/{chunk-YPYCWLYP.js → chunk-ZWXJTBZO.js} +1 -1
- package/dist/core/addresses.d.ts +14 -2
- package/dist/core/brands.d.ts +8 -2
- package/dist/core/errors.d.ts +71 -10
- package/dist/core/preflight.d.ts +1 -0
- package/dist/fhe/erc7984-abi.d.ts +1 -0
- package/dist/fhe/index.cjs +64 -63
- package/dist/fhe/index.js +7 -6
- package/dist/fhe/operators.d.ts +22 -5
- package/dist/fhe/react/index.cjs +13 -12
- package/dist/fhe/react/index.js +6 -5
- package/dist/fhe/types.d.ts +8 -2
- 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 +1250 -0
- package/dist/fhe-airdrop/advanced/index.cjs +11 -12
- package/dist/fhe-airdrop/advanced/index.d.cts +34 -11
- package/dist/fhe-airdrop/advanced/index.d.ts +34 -11
- package/dist/fhe-airdrop/advanced/index.js +3 -8
- package/dist/fhe-airdrop/advanced/react/index.cjs +619 -51
- package/dist/fhe-airdrop/advanced/react/index.d.cts +43 -3
- package/dist/fhe-airdrop/advanced/react/index.d.ts +43 -3
- package/dist/fhe-airdrop/advanced/react/index.js +592 -52
- 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/usePredictEcdsaAirdropAddress.d.ts +33 -0
- package/dist/fhe-airdrop/advanced/react/usePredictMerkleAirdropAddress.d.ts +27 -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 +608 -0
- package/dist/fhe-airdrop/campaign.d.ts +338 -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 +273 -15
- package/dist/fhe-airdrop/factory.d.ts +533 -274
- package/dist/fhe-airdrop/guards.d.ts +317 -0
- package/dist/fhe-airdrop/index.cjs +233 -73
- package/dist/fhe-airdrop/index.d.cts +46 -8
- package/dist/fhe-airdrop/index.d.ts +46 -8
- package/dist/fhe-airdrop/index.js +11 -7
- package/dist/fhe-airdrop/merkle-tree.d.ts +97 -0
- package/dist/fhe-airdrop/merkle.d.ts +201 -0
- package/dist/fhe-airdrop/react/_shared.d.ts +156 -70
- package/dist/fhe-airdrop/react/index.cjs +1174 -384
- package/dist/fhe-airdrop/react/index.d.cts +99 -74
- package/dist/fhe-airdrop/react/index.d.ts +99 -74
- package/dist/fhe-airdrop/react/index.js +993 -303
- 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/useAirdropGasFee.d.ts +10 -5
- package/dist/fhe-airdrop/react/useAirdropGrantRole.d.ts +29 -10
- 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/useAirdropRenounceRole.d.ts +36 -0
- package/dist/fhe-airdrop/react/useAirdropRevokeRole.d.ts +27 -9
- 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/useAirdropToken.d.ts +11 -4
- package/dist/fhe-airdrop/react/useAirdropUpgradeToAndCall.d.ts +45 -0
- package/dist/fhe-airdrop/react/useAirdropWindow.d.ts +37 -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/useClaimedAmount.d.ts +29 -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/useComplianceManager.d.ts +16 -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/useCreateEcdsaAirdrop.d.ts +28 -0
- package/dist/fhe-airdrop/react/useCreateMerkleAirdrop.d.ts +25 -0
- package/dist/fhe-airdrop/react/useDiscloseHandleToParty.d.ts +35 -0
- package/dist/fhe-airdrop/react/useEcdsaClaim.d.ts +24 -0
- 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/useEffectiveUpgradeable.d.ts +20 -0
- package/dist/fhe-airdrop/react/useEncryptCampaignAmounts.d.ts +59 -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/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 +22 -0
- package/dist/fhe-airdrop/react/useMerkleClaimAndUnwrap.d.ts +29 -0
- package/dist/fhe-airdrop/react/useMerkleRoot.d.ts +15 -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 +51 -35
- 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/useSetMerkleRoot.d.ts +22 -0
- package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +32 -21
- package/dist/fhe-airdrop/react/useWithdrawConfidential.d.ts +23 -0
- package/dist/fhe-airdrop/react/useWithdrawGasFee.d.ts +37 -0
- package/dist/fhe-airdrop/roles.d.ts +147 -0
- package/dist/fhe-airdrop/types.d.ts +78 -63
- package/dist/fhe-disperse/index.cjs +70 -68
- package/dist/fhe-disperse/index.js +10 -8
- package/dist/fhe-disperse/react/index.cjs +94 -92
- package/dist/fhe-disperse/react/index.js +13 -11
- package/dist/fhe-vesting/advanced/index.cjs +10 -8
- package/dist/fhe-vesting/advanced/index.js +8 -6
- package/dist/fhe-vesting/advanced/react/index.cjs +16 -14
- package/dist/fhe-vesting/advanced/react/index.js +13 -11
- package/dist/fhe-vesting/index.cjs +74 -72
- package/dist/fhe-vesting/index.js +11 -9
- package/dist/fhe-vesting/react/index.cjs +228 -226
- package/dist/fhe-vesting/react/index.js +15 -13
- package/dist/index.cjs +100 -87
- package/dist/index.js +3 -2
- package/dist/testnet-faucet/index.cjs +57 -55
- package/dist/testnet-faucet/index.js +7 -5
- package/dist/testnet-faucet/react/index.cjs +55 -53
- package/dist/testnet-faucet/react/index.js +9 -7
- package/package.json +6 -2
- package/dist/chunk-CNP4L3GF.js +0 -105
- package/dist/chunk-KSDSXJ34.js +0 -41
- package/dist/chunk-LBWRFZR3.cjs +0 -1681
- package/dist/chunk-OL6SHN3D.cjs +0 -44
- package/dist/chunk-S2XD75JM.js +0 -1637
- package/dist/chunk-SPGSO5SO.cjs +0 -1644
- package/dist/chunk-UE5XK2SY.js +0 -1673
- package/dist/chunk-WO72UBQD.cjs +0 -109
- package/dist/fhe-airdrop/advanced/factory-advanced.d.ts +0 -53
- package/dist/fhe-airdrop/advanced/react/usePredictAirdropAddress.d.ts +0 -49
- package/dist/fhe-airdrop/airdrop.d.ts +0 -317
- package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +0 -37
- package/dist/fhe-airdrop/react/useAirdropCanExtendClaimWindow.d.ts +0 -7
- package/dist/fhe-airdrop/react/useAirdropClaimTypehash.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropClaimedSignatures.d.ts +0 -16
- package/dist/fhe-airdrop/react/useAirdropDeploymentBlockNumber.d.ts +0 -6
- package/dist/fhe-airdrop/react/useAirdropDomainSeparator.d.ts +0 -8
- package/dist/fhe-airdrop/react/useAirdropEndTime.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropFactoryCustomFee.d.ts +0 -17
- package/dist/fhe-airdrop/react/useAirdropFactoryDefaultGasFee.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropFactoryDisableCustomFee.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropFactoryFeeCollector.d.ts +0 -11
- package/dist/fhe-airdrop/react/useAirdropFactoryInitCodeHash.d.ts +0 -17
- package/dist/fhe-airdrop/react/useAirdropFactorySetCustomFee.d.ts +0 -17
- package/dist/fhe-airdrop/react/useAirdropFactorySetDefaultGasFee.d.ts +0 -16
- package/dist/fhe-airdrop/react/useAirdropFactorySetFeeCollector.d.ts +0 -15
- package/dist/fhe-airdrop/react/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/useAirdropStartTime.d.ts +0 -10
- package/dist/fhe-airdrop/react/useAirdropWithdrawGasFee.d.ts +0 -15
- package/dist/fhe-airdrop/react/useAirdropWithdrawOtherConfidentialToken.d.ts +0 -14
- package/dist/fhe-airdrop/react/useAirdropWithdrawOtherToken.d.ts +0 -14
- package/dist/fhe-airdrop/react/useClaim.d.ts +0 -39
- package/dist/fhe-airdrop/react/useConfidentialAirdropFactoryImplementation.d.ts +0 -11
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +0 -41
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +0 -48
- package/dist/fhe-airdrop/react/useCreateConfidentialAirdrop.d.ts +0 -29
- package/dist/fhe-airdrop/react/useCreateConfidentialAirdropAndGetAddress.d.ts +0 -31
- package/dist/fhe-airdrop/react/useDisableCustomFee.d.ts +0 -14
- package/dist/fhe-airdrop/react/useFactoryCustomFee.d.ts +0 -17
- package/dist/fhe-airdrop/react/useFactoryDefaultGasFee.d.ts +0 -10
- package/dist/fhe-airdrop/react/useFactoryFeeCollector.d.ts +0 -11
- package/dist/fhe-airdrop/react/useFactoryInitCodeHash.d.ts +0 -17
- package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +0 -33
- package/dist/fhe-airdrop/react/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/useWithdraw.d.ts +0 -12
- package/dist/fhe-airdrop/react/useWithdrawOtherConfidentialToken.d.ts +0 -13
- package/dist/fhe-airdrop/react/useWithdrawOtherToken.d.ts +0 -13
|
@@ -0,0 +1,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>;
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
2
|
import type { Address } from "viem";
|
|
3
|
-
import { type
|
|
3
|
+
import { type AirdropInstanceHookOptions } from "./_shared.js";
|
|
4
|
+
/** @alpha */
|
|
5
|
+
export type UseAirdropTokenArgs = AirdropInstanceHookOptions<Address>;
|
|
4
6
|
/**
|
|
5
|
-
* Read the
|
|
6
|
-
*
|
|
7
|
+
* Read the ERC-7984 token an airdrop instance distributes.
|
|
8
|
+
*
|
|
9
|
+
* Works against either variant — `token` is declared on the shared
|
|
10
|
+
* `ConfidentialAirdropBase` surface, so this hook needs no ECDSA/Merkle
|
|
11
|
+
* distinction.
|
|
7
12
|
*
|
|
8
13
|
* @example
|
|
9
14
|
* const { data: token } = useAirdropToken({ address: airdropAddress });
|
|
15
|
+
*
|
|
16
|
+
* @alpha
|
|
10
17
|
*/
|
|
11
|
-
export declare function useAirdropToken(
|
|
18
|
+
export declare function useAirdropToken(args: UseAirdropTokenArgs): UseQueryResult<Address, Error>;
|
|
@@ -0,0 +1,45 @@
|
|
|
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 AirdropUpgradeToAndCallArgs extends WriteAccountOverride {
|
|
7
|
+
/** The new implementation the proxy should point at. */
|
|
8
|
+
newImplementation: Address;
|
|
9
|
+
/**
|
|
10
|
+
* Initializer calldata to run against the new implementation, or `"0x"`
|
|
11
|
+
* (the default) for a plain swap. A non-empty payload is a `delegatecall`:
|
|
12
|
+
* the new implementation's code executes against THIS instance's storage.
|
|
13
|
+
*/
|
|
14
|
+
data?: Hex;
|
|
15
|
+
/**
|
|
16
|
+
* Wei to attach. Leave unset for a plain swap — ERC-1967 reverts
|
|
17
|
+
* `ERC1967NonPayable` when value is sent with empty `data`.
|
|
18
|
+
*/
|
|
19
|
+
value?: bigint;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Point an airdrop instance's ERC-1967 proxy at a new implementation,
|
|
23
|
+
* optionally calling into it in the same transaction. Requires
|
|
24
|
+
* `UPGRADER_ROLE`.
|
|
25
|
+
*
|
|
26
|
+
* **Inert on clone-mode instances** — a clone has no implementation slot to
|
|
27
|
+
* rewrite. Gate the UI on `useAirdropDeploymentMode().data === "uups"`;
|
|
28
|
+
* `proxiableUUID` cannot tell the two shells apart. Merkle campaigns never
|
|
29
|
+
* reach this at all, because the SDK refuses to create one in `uups` mode
|
|
30
|
+
* (`MerkleUupsUnsupportedError`).
|
|
31
|
+
*
|
|
32
|
+
* **Non-empty `data` runs as a delegatecall against this instance's own
|
|
33
|
+
* storage** — a wrong payload can brick the campaign irrecoverably.
|
|
34
|
+
*
|
|
35
|
+
* **Invalidates:** nothing. No hook in this subpath reads the instance's
|
|
36
|
+
* implementation pointer, and `deploymentMode` does not change across an
|
|
37
|
+
* upgrade.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* const upgrade = useAirdropUpgradeToAndCall({ address: airdropAddress });
|
|
41
|
+
* await upgrade.mutateAsync({ newImplementation: nextImpl });
|
|
42
|
+
*
|
|
43
|
+
* @alpha
|
|
44
|
+
*/
|
|
45
|
+
export declare function useAirdropUpgradeToAndCall(options: AirdropInstanceClientOptions): UseMutationResult<Hex, Error, AirdropUpgradeToAndCallArgs>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import { type AirdropInstanceHookOptions } from "./_shared.js";
|
|
3
|
+
/**
|
|
4
|
+
* Plaintext claim-window snapshot — combines five `AirdropBaseClient` reads into one.
|
|
5
|
+
*
|
|
6
|
+
* @alpha
|
|
7
|
+
*/
|
|
8
|
+
export interface AirdropWindow {
|
|
9
|
+
/** Claim-window open, Unix seconds. */
|
|
10
|
+
startTime: number;
|
|
11
|
+
/** Claim-window close, Unix seconds. Movable forward via `useExtendClaimWindow`. */
|
|
12
|
+
endTime: number;
|
|
13
|
+
/** Whether `startTime` has passed. Says nothing about the pause flag. */
|
|
14
|
+
hasStarted: boolean;
|
|
15
|
+
/** Whether `endTime` has passed. Says nothing about the pause flag. */
|
|
16
|
+
hasEnded: boolean;
|
|
17
|
+
/** In window AND not paused — the actual "would a claim be accepted right now" answer. */
|
|
18
|
+
isActive: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** @alpha */
|
|
21
|
+
export type UseAirdropWindowArgs = AirdropInstanceHookOptions<AirdropWindow>;
|
|
22
|
+
/**
|
|
23
|
+
* Read an airdrop instance's claim-window snapshot in one round trip.
|
|
24
|
+
*
|
|
25
|
+
* Bundles `startTime` / `endTime` / `hasClaimStarted` / `hasClaimEnded` /
|
|
26
|
+
* `isClaimWindowActive` — five independent contract reads a UI almost always
|
|
27
|
+
* wants together (e.g. "claim opens at X, closes at Y, currently active: Z")
|
|
28
|
+
* — rather than shipping five near-identical one-line hooks nobody would call
|
|
29
|
+
* separately (the v1 mistake this cutover is deliberately not repeating).
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const { data: window } = useAirdropWindow({ address: airdropAddress });
|
|
33
|
+
* if (window?.isActive) { ... }
|
|
34
|
+
*
|
|
35
|
+
* @alpha
|
|
36
|
+
*/
|
|
37
|
+
export declare function useAirdropWindow(args: UseAirdropWindowArgs): UseQueryResult<AirdropWindow, Error>;
|
|
@@ -0,0 +1,32 @@
|
|
|
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 UseBatchDiscloseHandlesToPartyArgs extends WriteAccountOverride {
|
|
7
|
+
/** Existing `euint64` handles - public pointers, not values. */
|
|
8
|
+
handles: readonly Hex[];
|
|
9
|
+
/** The single address granted decrypt access on every handle. */
|
|
10
|
+
party: Address;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Grants one `party` decrypt access to several handles you already hold, in a
|
|
14
|
+
* single transaction. Produces no new handles, so it returns the transaction
|
|
15
|
+
* hash.
|
|
16
|
+
*
|
|
17
|
+
* The same two gates as `useDiscloseHandleToParty` apply per handle - the
|
|
18
|
+
* caller allowed on it (unless it holds `DISCLOSURE_ADMIN_ROLE`) and the
|
|
19
|
+
* instance allowed on it - and the first failure reverts the whole batch,
|
|
20
|
+
* naming the offending handle. It is all-or-nothing: a partial grant is never
|
|
21
|
+
* left behind.
|
|
22
|
+
*
|
|
23
|
+
* **Invalidates:** nothing. ACL is append-only and no read hook in this
|
|
24
|
+
* subpath caches who is allowed on a handle.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const disclose = useBatchDiscloseHandlesToParty({ address: airdropAddress });
|
|
28
|
+
* await disclose.mutateAsync({ handles: [balanceHandle, claimHandle], party: auditor });
|
|
29
|
+
*
|
|
30
|
+
* @alpha
|
|
31
|
+
*/
|
|
32
|
+
export declare function useBatchDiscloseHandlesToParty(options: AirdropInstanceClientOptions): UseMutationResult<Hex, Error, UseBatchDiscloseHandlesToPartyArgs>;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type UseMutationResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
import { type CampaignSubmitterOption } from "../campaign.js";
|
|
4
|
+
import { type EncryptorSource } from "../encryption.js";
|
|
5
|
+
import type { BuiltCampaign, CampaignRecipient } from "../types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Hook-level config for {@link useBuildMerkleCampaign}. The instance already
|
|
8
|
+
* exists on the mutable-root path, so no chain client is needed — only the
|
|
9
|
+
* encryptor.
|
|
10
|
+
*
|
|
11
|
+
* @alpha
|
|
12
|
+
*/
|
|
13
|
+
export interface UseBuildMerkleCampaignOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Eager or lazy encryptor. Wire it lazily so the live React context is read
|
|
16
|
+
* at submit time rather than captured at mount (CLAUDE.md Pitfall #3):
|
|
17
|
+
* `const sdk = useZamaSDK()` once, then `encryptor: () => sdk.relayer`.
|
|
18
|
+
*/
|
|
19
|
+
encryptor?: EncryptorSource;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Variables for {@link useBuildMerkleCampaign}.
|
|
23
|
+
*
|
|
24
|
+
* @alpha
|
|
25
|
+
*/
|
|
26
|
+
export interface UseBuildMerkleCampaignArgs extends CampaignSubmitterOption {
|
|
27
|
+
/** The LIVE `MerkleConfidentialAirdrop` instance every input is bound to. Not the factory, not the implementation. */
|
|
28
|
+
instance: Address;
|
|
29
|
+
/** CUMULATIVE totals per account, never per-drop tranches. */
|
|
30
|
+
recipients: readonly CampaignRecipient[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Encrypt a roster and build the Merkle tree those ciphertexts belong to, for
|
|
34
|
+
* an instance that already exists — the **mutable-root** path. Publish the
|
|
35
|
+
* returned `root` with {@link useSetMerkleRoot}, or let
|
|
36
|
+
* {@link useRotateMerkleRoot} build and publish in one call. For an instance
|
|
37
|
+
* whose root is fixed at create time use {@link usePlanMerkleCampaign}: there
|
|
38
|
+
* is no address to encrypt against yet.
|
|
39
|
+
*
|
|
40
|
+
* **The returned `entries` ARE the campaign — persist them before the
|
|
41
|
+
* component unmounts.** The instance stores only the 32-byte root; there is no
|
|
42
|
+
* getter and no event that maps an account to its handle, input proof or
|
|
43
|
+
* Merkle branch. A recipient who does not hold their own
|
|
44
|
+
* `(handle, inputProof, merkleProof)` triple can never claim, and no on-chain
|
|
45
|
+
* data reconstructs it. Losing this result to a re-render is the likeliest way
|
|
46
|
+
* to brick a campaign.
|
|
47
|
+
*
|
|
48
|
+
* A mutation rather than a query: encryption is randomised, so the same roster
|
|
49
|
+
* builds a different root every call and there is no cache identity to key.
|
|
50
|
+
*
|
|
51
|
+
* Each entry is `{ account, boundTo, handle, inputProof, merkleProof }` —
|
|
52
|
+
* `account` selects the leaf and the cumulative accounting, `boundTo` is the
|
|
53
|
+
* only address the coprocessor accepts as sender. They are equal unless
|
|
54
|
+
* `submitter` was set.
|
|
55
|
+
*
|
|
56
|
+
* **Invalidates:** nothing. Off-chain work only; the root is not published here.
|
|
57
|
+
*
|
|
58
|
+
* @throws {@link InvalidArgumentError} on a duplicate, zero-address or out-of-`uint64`-range roster entry, or a zero `instance`.
|
|
59
|
+
* @throws {@link MissingEncryptorError} when `encryptor` resolves to `undefined`.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* const build = useBuildMerkleCampaign({ encryptor: () => sdk.relayer });
|
|
63
|
+
* const { root, entries } = await build.mutateAsync({ instance: airdrop, recipients });
|
|
64
|
+
* await persist(entries); // before anything else
|
|
65
|
+
*
|
|
66
|
+
* @alpha
|
|
67
|
+
*/
|
|
68
|
+
export declare function useBuildMerkleCampaign(options?: UseBuildMerkleCampaignOptions): UseMutationResult<BuiltCampaign, Error, UseBuildMerkleCampaignArgs>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
import type { EncryptedHandle } from "../../core/brands.js";
|
|
4
|
+
import { type AirdropInstanceHookOptions } from "./_shared.js";
|
|
5
|
+
/** @alpha */
|
|
6
|
+
export interface UseClaimedAmountArgs extends AirdropInstanceHookOptions<EncryptedHandle> {
|
|
7
|
+
/** The account whose cumulative delivered total to read. */
|
|
8
|
+
account?: Address;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Read `account`'s cumulative delivered total on a `MerkleConfidentialAirdrop`
|
|
12
|
+
* instance, as an encrypted handle — pass it to the Zama relayer's
|
|
13
|
+
* `userDecrypt` to see the plaintext.
|
|
14
|
+
*
|
|
15
|
+
* **Caller-specific — `account` is part of the cache key.** Switching the
|
|
16
|
+
* connected account (or checking a different address) never serves a value
|
|
17
|
+
* cached for the previous account; see {@link airdropQueryKey}.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* This is the recipient's CUMULATIVE total delivered so far, not a per-claim
|
|
21
|
+
* amount — see {@link MerkleAirdropClient.getClaimedAmount}'s TSDoc for the
|
|
22
|
+
* root-rotation and one-leaf-per-recipient consequences of that.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* const { data: claimedHandle } = useClaimedAmount({ address, account });
|
|
26
|
+
*
|
|
27
|
+
* @alpha
|
|
28
|
+
*/
|
|
29
|
+
export declare function useClaimedAmount(args: UseClaimedAmountArgs): UseQueryResult<EncryptedHandle, Error>;
|
|
@@ -0,0 +1,32 @@
|
|
|
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 ComplianceGrantRoleArgs extends WriteAccountOverride {
|
|
7
|
+
/** A `bytes32` role identifier - from {@link useComplianceRoleConstants}, 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 a compliance-manager clone. `options.address` is the
|
|
14
|
+
* CLONE. Requires the role's admin role, which is `DEFAULT_ADMIN_ROLE` for
|
|
15
|
+
* both roles this contract defines.
|
|
16
|
+
*
|
|
17
|
+
* This is how a campaign owner hands delegate administration to a compliance
|
|
18
|
+
* team without giving them anything on the airdrop instance itself - the two
|
|
19
|
+
* contracts keep separate role sets, and a grant here confers no pause,
|
|
20
|
+
* treasury or disclosure power over the campaign.
|
|
21
|
+
*
|
|
22
|
+
* **Invalidates:** this clone's {@link useComplianceHasRole} entry for exactly
|
|
23
|
+
* `(role, holder)` and its {@link useComplianceRoleMembers} entry for `role`
|
|
24
|
+
* (the list and the count both move). Scoped to this clone.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const grant = useComplianceGrantRole({ address: managerAddress });
|
|
28
|
+
* await grant.mutateAsync({ role: roles.DELEGATION_ADMIN_ROLE, holder: complianceTeam });
|
|
29
|
+
*
|
|
30
|
+
* @alpha
|
|
31
|
+
*/
|
|
32
|
+
export declare function useComplianceGrantRole(options: AirdropInstanceClientOptions): UseMutationResult<Hex, Error, ComplianceGrantRoleArgs>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Address, Hex } from "viem";
|
|
3
|
+
import { type AirdropInstanceHookOptions } from "./_shared.js";
|
|
4
|
+
/** @alpha */
|
|
5
|
+
export interface UseComplianceHasRoleArgs extends AirdropInstanceHookOptions<boolean> {
|
|
6
|
+
/** A `bytes32` role identifier - from {@link useComplianceRoleConstants}, not hand-hashed. */
|
|
7
|
+
role?: Hex;
|
|
8
|
+
/** The account to check. Distinct from a delegate: this is who may MANAGE delegates. */
|
|
9
|
+
holder?: Address;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Whether `holder` holds `role` on a compliance-manager clone. `address` is
|
|
13
|
+
* the CLONE.
|
|
14
|
+
*
|
|
15
|
+
* With `DELEGATION_ADMIN_ROLE` this is the gate on the delegate surface -
|
|
16
|
+
* mount {@link useAddComplianceDelegate}'s and
|
|
17
|
+
* {@link useRevokeComplianceDelegate}'s controls behind it. Holding a role
|
|
18
|
+
* here grants nothing on the airdrop instance itself; the two contracts have
|
|
19
|
+
* separate role sets.
|
|
20
|
+
*
|
|
21
|
+
* Stays disabled until both `role` and `holder` are defined, so a UI can call
|
|
22
|
+
* it unconditionally while the role constants are still loading.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* Invalidated by {@link useComplianceGrantRole},
|
|
26
|
+
* {@link useComplianceRevokeRole} and {@link useComplianceRenounceRole}.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* const { data: canDelegate } = useComplianceHasRole({
|
|
30
|
+
* address: managerAddress,
|
|
31
|
+
* role: roles?.DELEGATION_ADMIN_ROLE,
|
|
32
|
+
* holder: account,
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* @alpha
|
|
36
|
+
*/
|
|
37
|
+
export declare function useComplianceHasRole(args: UseComplianceHasRoleArgs): UseQueryResult<boolean, Error>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
import { type AirdropInstanceHookOptions } from "./_shared.js";
|
|
4
|
+
/**
|
|
5
|
+
* One compliance-manager clone's wiring - who it serves and who may decrypt
|
|
6
|
+
* through it, read together.
|
|
7
|
+
*
|
|
8
|
+
* @alpha
|
|
9
|
+
*/
|
|
10
|
+
export interface ComplianceInfo {
|
|
11
|
+
/** The one airdrop instance this clone serves. */
|
|
12
|
+
airdrop: Address;
|
|
13
|
+
/**
|
|
14
|
+
* The platform compliance delegate, or the zero address when this clone was
|
|
15
|
+
* created with the factory's compliance policy OFF. Never "not wired yet" -
|
|
16
|
+
* see the hook's TSDoc. Irrevocable when set.
|
|
17
|
+
*/
|
|
18
|
+
platformDelegate: Address;
|
|
19
|
+
/** The mutable client-delegate set. Excludes `platformDelegate`. */
|
|
20
|
+
clientDelegates: readonly Address[];
|
|
21
|
+
}
|
|
22
|
+
/** @alpha */
|
|
23
|
+
export type UseComplianceInfoArgs = AirdropInstanceHookOptions<ComplianceInfo>;
|
|
24
|
+
/**
|
|
25
|
+
* Read a compliance-manager clone's whole wiring in one round trip - the
|
|
26
|
+
* airdrop it serves, its platform delegate, and its client-delegate set.
|
|
27
|
+
*
|
|
28
|
+
* `address` is the CLONE, not the airdrop instance: resolve it with
|
|
29
|
+
* {@link useComplianceManagerOf} or take it off `CreateAirdropResult.complianceManager`.
|
|
30
|
+
*
|
|
31
|
+
* A zero `platformDelegate` is unambiguous. The factory runs the clone's
|
|
32
|
+
* `initialize` atomically inside `createX`, so there is no observable
|
|
33
|
+
* "deployed but not yet wired" state - zero always means "created with the
|
|
34
|
+
* platform compliance policy off", never "not set up yet".
|
|
35
|
+
*
|
|
36
|
+
* `clientDelegates` deliberately omits the platform delegate, so it is not the
|
|
37
|
+
* answer to "may this address decrypt?" - use {@link useIsActiveDelegate},
|
|
38
|
+
* which reads the ACL directly and covers both slots.
|
|
39
|
+
*
|
|
40
|
+
* @remarks
|
|
41
|
+
* Invalidated by {@link useAddComplianceDelegate} and
|
|
42
|
+
* {@link useRevokeComplianceDelegate}.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* const { data } = useComplianceInfo({ address: complianceManagerAddress });
|
|
46
|
+
* const hasPlatformDelegate = data?.platformDelegate !== "0x0000000000000000000000000000000000000000";
|
|
47
|
+
*
|
|
48
|
+
* @alpha
|
|
49
|
+
*/
|
|
50
|
+
export declare function useComplianceInfo(args: UseComplianceInfoArgs): UseQueryResult<ComplianceInfo, Error>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
import { type AirdropInstanceHookOptions } from "./_shared.js";
|
|
4
|
+
/** @alpha */
|
|
5
|
+
export type UseComplianceManagerArgs = AirdropInstanceHookOptions<Address>;
|
|
6
|
+
/**
|
|
7
|
+
* Read an airdrop instance's own compliance-manager clone — the only
|
|
8
|
+
* contract, besides the caller, ever granted ACL on that instance's
|
|
9
|
+
* confidential handles.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const { data: complianceManager } = useComplianceManager({ address: airdropAddress });
|
|
13
|
+
*
|
|
14
|
+
* @alpha
|
|
15
|
+
*/
|
|
16
|
+
export declare function useComplianceManager(args: UseComplianceManagerArgs): UseQueryResult<Address, Error>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Address } from "viem";
|
|
3
|
+
import { type AirdropHookOptions } from "./_shared.js";
|
|
4
|
+
/** @alpha */
|
|
5
|
+
export interface UseComplianceManagerOfArgs extends AirdropHookOptions<Address> {
|
|
6
|
+
/** The airdrop instance whose compliance-manager clone to resolve. */
|
|
7
|
+
airdrop?: Address;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Resolve the `ComplianceRoleManager` clone bound to an airdrop instance, by
|
|
11
|
+
* asking the factory. This is the entry point for every other compliance
|
|
12
|
+
* hook: they are all scoped to the CLONE address, not the instance address.
|
|
13
|
+
*
|
|
14
|
+
* **Also a provenance check.** The factory records this mapping only for
|
|
15
|
+
* instances it deployed, so a zero address means the instance did not come
|
|
16
|
+
* from this factory - do not mount the compliance hooks on it.
|
|
17
|
+
*
|
|
18
|
+
* Cached indefinitely (`staleTime: Infinity`, overridable through `query`):
|
|
19
|
+
* the mapping is written once, inside `createX`, and never changes.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* {@link useComplianceManager} answers the same question from the other side,
|
|
23
|
+
* by asking the instance for its own clone. Prefer this hook when you hold no
|
|
24
|
+
* instance client, or when you want the provenance answer as well.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const { data: manager } = useComplianceManagerOf({ airdrop: airdropAddress });
|
|
28
|
+
* const { data: info } = useComplianceInfo({ address: manager! });
|
|
29
|
+
*
|
|
30
|
+
* @alpha
|
|
31
|
+
*/
|
|
32
|
+
export declare function useComplianceManagerOf(args?: UseComplianceManagerOfArgs): UseQueryResult<Address, Error>;
|
|
@@ -0,0 +1,38 @@
|
|
|
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 ComplianceRenounceRoleArgs extends WriteAccountOverride {
|
|
7
|
+
/** A `bytes32` role identifier - from {@link useComplianceRoleConstants}, never hand-hashed. */
|
|
8
|
+
role: Hex;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Give up a role on a compliance-manager clone yourself. `options.address` is
|
|
12
|
+
* the CLONE.
|
|
13
|
+
*
|
|
14
|
+
* Self-only by construction: the contract's
|
|
15
|
+
* `renounceRole(role, callerConfirmation)` reverts
|
|
16
|
+
* `AccessControlBadConfirmation` unless the confirmation is the sender, so
|
|
17
|
+
* there is no holder to pass - the headless client fills it from the resolved
|
|
18
|
+
* sending account. To remove somebody else's role use
|
|
19
|
+
* {@link useComplianceRevokeRole}.
|
|
20
|
+
*
|
|
21
|
+
* No last-admin floor guards this: the sole `DEFAULT_ADMIN_ROLE` holder CAN
|
|
22
|
+
* renounce, and doing so freezes the clone's delegate set permanently.
|
|
23
|
+
*
|
|
24
|
+
* **Invalidates:** every {@link useComplianceHasRole} entry for this clone
|
|
25
|
+
* (prefix, all role/holder pairs), plus its
|
|
26
|
+
* {@link useComplianceRoleMembers} entry for `role`. The prefix is
|
|
27
|
+
* deliberate - the holder here is whichever account the wallet client resolves
|
|
28
|
+
* at submit time, which need not match any `(role, holder)` pair a component
|
|
29
|
+
* happens to have cached, and a narrower key would invalidate nothing while
|
|
30
|
+
* throwing nothing. Still scoped to this clone.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* const renounce = useComplianceRenounceRole({ address: managerAddress });
|
|
34
|
+
* await renounce.mutateAsync({ role: roles.DELEGATION_ADMIN_ROLE });
|
|
35
|
+
*
|
|
36
|
+
* @alpha
|
|
37
|
+
*/
|
|
38
|
+
export declare function useComplianceRenounceRole(options: AirdropInstanceClientOptions): UseMutationResult<Hex, Error, ComplianceRenounceRoleArgs>;
|
|
@@ -0,0 +1,36 @@
|
|
|
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 ComplianceRevokeRoleArgs extends WriteAccountOverride {
|
|
7
|
+
/** A `bytes32` role identifier - from {@link useComplianceRoleConstants}, 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 a compliance-manager clone.
|
|
14
|
+
* `options.address` is the CLONE. Requires the role's admin role.
|
|
15
|
+
*
|
|
16
|
+
* **Revoking a delegation admin revokes no delegation.** The FHEVM ACL is
|
|
17
|
+
* append-only, so every delegate that account already added keeps decrypting
|
|
18
|
+
* until {@link useRevokeComplianceDelegate} is called for it explicitly. This
|
|
19
|
+
* is the most likely wrong assumption about this button: it removes the power
|
|
20
|
+
* to add more delegates, nothing else.
|
|
21
|
+
*
|
|
22
|
+
* The contract enforces no last-admin floor either - revoking the sole
|
|
23
|
+
* `DEFAULT_ADMIN_ROLE` holder freezes the clone's delegate set permanently.
|
|
24
|
+
* Check {@link useComplianceRoleMembers}'s `count` first.
|
|
25
|
+
*
|
|
26
|
+
* **Invalidates:** this clone's {@link useComplianceHasRole} entry for exactly
|
|
27
|
+
* `(role, holder)` and its {@link useComplianceRoleMembers} entry for `role`.
|
|
28
|
+
* Scoped to this clone.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* const revoke = useComplianceRevokeRole({ address: managerAddress });
|
|
32
|
+
* await revoke.mutateAsync({ role: roles.DELEGATION_ADMIN_ROLE, holder: formerTeam });
|
|
33
|
+
*
|
|
34
|
+
* @alpha
|
|
35
|
+
*/
|
|
36
|
+
export declare function useComplianceRevokeRole(options: AirdropInstanceClientOptions): UseMutationResult<Hex, Error, ComplianceRevokeRoleArgs>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type UseQueryResult } from "@tanstack/react-query";
|
|
2
|
+
import type { Hex } from "viem";
|
|
3
|
+
import { type AirdropInstanceHookOptions } from "./_shared.js";
|
|
4
|
+
/**
|
|
5
|
+
* The `bytes32` role identifiers a compliance-manager clone exposes.
|
|
6
|
+
*
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
9
|
+
export interface ComplianceRoleConstants {
|
|
10
|
+
/** Gates `addDelegate` / `revokeDelegate`. */
|
|
11
|
+
DELEGATION_ADMIN_ROLE: Hex;
|
|
12
|
+
/** OpenZeppelin's root role, read off the clone rather than assumed to be `bytes32(0)`. It administers `DELEGATION_ADMIN_ROLE`. */
|
|
13
|
+
DEFAULT_ADMIN_ROLE: Hex;
|
|
14
|
+
}
|
|
15
|
+
/** @alpha */
|
|
16
|
+
export type UseComplianceRoleConstantsArgs = AirdropInstanceHookOptions<ComplianceRoleConstants>;
|
|
17
|
+
/**
|
|
18
|
+
* Read a compliance-manager clone's role identifiers. `address` is the CLONE.
|
|
19
|
+
*
|
|
20
|
+
* Both values are bytecode constants, so this is cacheable indefinitely
|
|
21
|
+
* (`staleTime: Infinity` by default, overridable through `query`). Feed them
|
|
22
|
+
* into {@link useComplianceHasRole}, {@link useComplianceRoleMembers} and the
|
|
23
|
+
* role mutations rather than hand-hashing `keccak256("DELEGATION_ADMIN_ROLE")`
|
|
24
|
+
* client-side, which would turn a constant renamed in a future contract
|
|
25
|
+
* version into a grant of a role nothing checks.
|
|
26
|
+
*
|
|
27
|
+
* Bundled despite being only two reads, so the shape matches
|
|
28
|
+
* {@link useAirdropRoleConstants} and the factory equivalent - and because two
|
|
29
|
+
* one-line hooks for two constants is the pattern this subpath avoids.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const { data: roles } = useComplianceRoleConstants({ address: managerAddress });
|
|
33
|
+
* const { data: canDelegate } = useComplianceHasRole({
|
|
34
|
+
* address: managerAddress,
|
|
35
|
+
* role: roles?.DELEGATION_ADMIN_ROLE,
|
|
36
|
+
* holder: account,
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* @alpha
|
|
40
|
+
*/
|
|
41
|
+
export declare function useComplianceRoleConstants(args: UseComplianceRoleConstantsArgs): UseQueryResult<ComplianceRoleConstants, Error>;
|