@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,97 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
/**
|
|
3
|
+
* Inputs for {@link leafOf}.
|
|
4
|
+
*
|
|
5
|
+
* @alpha
|
|
6
|
+
*/
|
|
7
|
+
export interface LeafOfArgs {
|
|
8
|
+
/** The `MerkleConfidentialAirdrop` instance the leaf is scoped to — `address(this)` on-chain. */
|
|
9
|
+
instance: Address;
|
|
10
|
+
/** The claim identity, independent of both the transaction submitter and the payout destination. */
|
|
11
|
+
account: Address;
|
|
12
|
+
/** The encrypted handle committing the account's cumulative total allocation. */
|
|
13
|
+
handle: Hex;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Compute a Merkle leaf byte-for-byte identical to the contract's `_leafOf` — see the
|
|
17
|
+
* module comment for the verified derivation.
|
|
18
|
+
*
|
|
19
|
+
* @alpha
|
|
20
|
+
*/
|
|
21
|
+
export declare function leafOf(args: LeafOfArgs): Hex;
|
|
22
|
+
/**
|
|
23
|
+
* The minimum a leaf must carry. `buildMerkleTree` is generic over anything wider, so a
|
|
24
|
+
* caller's own fields ride along onto the entry.
|
|
25
|
+
*
|
|
26
|
+
* Deliberately does NOT include `boundTo`: the tree does not commit the submitter, so it
|
|
27
|
+
* is not needed to build one. Pass it anyway (alongside `inputProof`) and it rides through
|
|
28
|
+
* to the entry, which is what makes the result assignable to {@link CampaignEntry}.
|
|
29
|
+
*
|
|
30
|
+
* @alpha
|
|
31
|
+
*/
|
|
32
|
+
export interface MerkleLeafInput {
|
|
33
|
+
/** The claim identity this leaf commits — whose payout and cumulative accounting it keys. */
|
|
34
|
+
account: Address;
|
|
35
|
+
/** The encrypted handle committing this account's cumulative total. */
|
|
36
|
+
handle: Hex;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Inputs for {@link buildMerkleTree}.
|
|
40
|
+
*
|
|
41
|
+
* @alpha
|
|
42
|
+
*/
|
|
43
|
+
export interface BuildMerkleTreeArgs<L extends MerkleLeafInput> {
|
|
44
|
+
/** The `MerkleConfidentialAirdrop` instance the leaves are scoped to. Not the factory, not the implementation. */
|
|
45
|
+
instance: Address;
|
|
46
|
+
leaves: readonly L[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* A built tree: the root to publish, and every input leaf with its proof attached.
|
|
50
|
+
*
|
|
51
|
+
* @alpha
|
|
52
|
+
*/
|
|
53
|
+
export interface BuiltMerkleTree<L extends MerkleLeafInput> {
|
|
54
|
+
root: Hex;
|
|
55
|
+
entries: readonly (L & {
|
|
56
|
+
merkleProof: readonly Hex[];
|
|
57
|
+
})[];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Build the Merkle tree a `MerkleConfidentialAirdrop` verifies against, from handles
|
|
61
|
+
* produced anywhere.
|
|
62
|
+
*
|
|
63
|
+
* **Pure.** No relayer, no chain access, no encryptor — same leaves in, same root out.
|
|
64
|
+
*
|
|
65
|
+
* **The tree commits to the handle, not the amount, and not the submitter.** `_leafOf`
|
|
66
|
+
* hashes `(instance, account, handle)`, so whoever encrypted must have bound each input
|
|
67
|
+
* to `(instance, the intended submitter)`. This function cannot check that: it will
|
|
68
|
+
* happily build a tree over wrongly-bound handles, and the failure surfaces at claim time
|
|
69
|
+
* inside the coprocessor.
|
|
70
|
+
*
|
|
71
|
+
* **Extra fields ride along.** Whatever a leaf carries beyond `account` and `handle` —
|
|
72
|
+
* `boundTo`, an `inputProof`, your own row id — comes back on the entry, still aligned
|
|
73
|
+
* with its proof. Passing `{ account, boundTo, handle, inputProof }` therefore yields a
|
|
74
|
+
* value structurally assignable to {@link CampaignEntry}.
|
|
75
|
+
*
|
|
76
|
+
* @param args The instance the leaves are scoped to, and the leaves.
|
|
77
|
+
* @returns The root to publish, and one proof-bearing entry per input leaf, in input order.
|
|
78
|
+
* @throws {@link InvalidArgumentError} on a zero or malformed instance, an empty leaf set, a malformed or zero account, a duplicate account, or a handle that is not 32 bytes.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* const { root, entries } = buildMerkleTree({
|
|
82
|
+
* instance: airdrop,
|
|
83
|
+
* leaves: [{ account: alice, boundTo: alice, handle, inputProof }],
|
|
84
|
+
* });
|
|
85
|
+
* await merkle.setMerkleRoot({ newRoot: root });
|
|
86
|
+
*
|
|
87
|
+
* @alpha
|
|
88
|
+
*/
|
|
89
|
+
export declare function buildMerkleTree<L extends MerkleLeafInput>(args: BuildMerkleTreeArgs<L>): BuiltMerkleTree<L>;
|
|
90
|
+
/**
|
|
91
|
+
* Real implementation behind {@link buildMerkleTree}, parameterised on the function name
|
|
92
|
+
* a thrown {@link InvalidArgumentError} blames.
|
|
93
|
+
*
|
|
94
|
+
* Not part of the public surface — exported only so `buildMerkleCampaign` can call it
|
|
95
|
+
* with its own name. Neither barrel re-exports it.
|
|
96
|
+
*/
|
|
97
|
+
export declare function buildMerkleTreeInternal<L extends MerkleLeafInput>({ instance, leaves }: BuildMerkleTreeArgs<L>, method: string): BuiltMerkleTree<L>;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import type { Address, Hex } from "viem";
|
|
2
|
+
import { type EncryptedHandle } from "../core/brands.js";
|
|
3
|
+
import type { EncryptedViewResult } from "../fhe/types.js";
|
|
4
|
+
import { AirdropBaseClient, type AirdropBaseClientConfig, type WriteAccountOverride } from "./airdrop-base.js";
|
|
5
|
+
import type { CampaignEntry } from "./types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Inputs shared by {@link MerkleAirdropClient.claim} and {@link MerkleAirdropClient.claimAndUnwrap}.
|
|
8
|
+
*
|
|
9
|
+
* @alpha
|
|
10
|
+
*/
|
|
11
|
+
export interface MerkleClaimArgs extends WriteAccountOverride {
|
|
12
|
+
/**
|
|
13
|
+
* Payout destination. Omit (or pass the zero address) to default to
|
|
14
|
+
* `entry.account` — note that is the CLAIM IDENTITY, not the sender, so on a
|
|
15
|
+
* relayed claim omitting `to` still pays the recipient.
|
|
16
|
+
*
|
|
17
|
+
* Only the account itself may redirect elsewhere; a third-party submitter passing
|
|
18
|
+
* a different `to` is refused before the write with
|
|
19
|
+
* {@link UnauthorizedRedirectError}.
|
|
20
|
+
*/
|
|
21
|
+
to?: Address;
|
|
22
|
+
/**
|
|
23
|
+
* The proof-bearing claim entry, built by a campaign builder (`campaign.ts`).
|
|
24
|
+
*
|
|
25
|
+
* `entry.account` is submitted as the claim identity and selects the leaf.
|
|
26
|
+
* `entry.boundTo` must be the sending account, because the coprocessor verifies
|
|
27
|
+
* the input proof against the literal caller — the SDK checks this before the
|
|
28
|
+
* write rather than letting the transaction revert.
|
|
29
|
+
*/
|
|
30
|
+
entry: CampaignEntry;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Inputs for {@link MerkleAirdropClient.getClaimAmount}.
|
|
34
|
+
*
|
|
35
|
+
* @alpha
|
|
36
|
+
*/
|
|
37
|
+
export interface GetClaimAmountArgs extends WriteAccountOverride {
|
|
38
|
+
/**
|
|
39
|
+
* Same binding rule as {@link MerkleClaimArgs.entry}: `entry.boundTo` must be the
|
|
40
|
+
* calling account. The preview's result is ACL'd to `entry.account`, so a relayer
|
|
41
|
+
* can confirm a leaf verifies without being able to read the amount.
|
|
42
|
+
*/
|
|
43
|
+
entry: CampaignEntry;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Client for one `MerkleConfidentialAirdrop` instance — the variant whose
|
|
47
|
+
* claims are authorised by inclusion in a published Merkle tree rather than
|
|
48
|
+
* an off-chain signature. Each leaf commits `(instance, account, handle)`, where
|
|
49
|
+
* `handle` is that account's CUMULATIVE total allocation, not a per-drop tranche —
|
|
50
|
+
* see the `@remarks` on {@link getClaimedAmount}.
|
|
51
|
+
*
|
|
52
|
+
* `claim` names its claim identity explicitly, so a relayer can settle a leaf on a
|
|
53
|
+
* recipient's behalf. `claimAndUnwrap` deliberately cannot: it is always submitted
|
|
54
|
+
* for the caller.
|
|
55
|
+
*
|
|
56
|
+
* Adds the claim surface on top of {@link AirdropBaseClient}'s shared
|
|
57
|
+
* lifecycle/treasury/rescue/role/disclosure methods: `claim` /
|
|
58
|
+
* `claimAndUnwrap` submit a proof-bearing allocation, `getClaimAmount`
|
|
59
|
+
* previews the outstanding amount as a decryptable handle, and
|
|
60
|
+
* `getClaimedAmount` reads an account's running delivered total.
|
|
61
|
+
*
|
|
62
|
+
* Every claim entrypoint here takes the exact-equality gas fee
|
|
63
|
+
* ({@link AirdropBaseClient.gasFee}) automatically — read fresh on every
|
|
64
|
+
* `claim`/`claimAndUnwrap` call and attached as the transaction's `value`, so
|
|
65
|
+
* a caller never has to source it themselves or risk sending the wrong
|
|
66
|
+
* amount against the contract's `msg.value != gasFee()` revert.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* const airdrop = new MerkleAirdropClient({ publicClient, walletClient, address });
|
|
70
|
+
* const hash = await airdrop.claim({ entry });
|
|
71
|
+
*
|
|
72
|
+
* @alpha
|
|
73
|
+
*/
|
|
74
|
+
export declare class MerkleAirdropClient extends AirdropBaseClient {
|
|
75
|
+
constructor(config: AirdropBaseClientConfig);
|
|
76
|
+
/**
|
|
77
|
+
* Claim the outstanding amount for a proof-bearing entry, delivering the tokens to
|
|
78
|
+
* `to` — which defaults to `entry.account`, the CLAIM IDENTITY, not the sender.
|
|
79
|
+
*
|
|
80
|
+
* Requires `msg.value == gasFee()` exactly — handled for you; see the
|
|
81
|
+
* class TSDoc.
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* There is no per-leaf consumption on this variant — replay safety is the
|
|
85
|
+
* accounting itself, not a spent-flag. Re-presenting an already-settled
|
|
86
|
+
* entry computes an encrypted-zero outstanding amount and pays nothing,
|
|
87
|
+
* but the gas fee is still charged (the amounts are encrypted, so a
|
|
88
|
+
* zero-outstanding claim cannot be detected or rejected on-chain).
|
|
89
|
+
* Presenting two different entries for the SAME recipient under one root
|
|
90
|
+
* pays whichever entry's cumulative total is higher net of what the other
|
|
91
|
+
* already delivered — effectively `max`, not `sum`, of the two totals.
|
|
92
|
+
*
|
|
93
|
+
* @throws {@link ClaimNotStartedError} before `startTime`.
|
|
94
|
+
* @throws {@link ClaimWindowClosedError} after `endTime`.
|
|
95
|
+
* @throws {@link InvalidArgumentError} (`argument: "entry.boundTo"`) when the entry's proof is bound to
|
|
96
|
+
* another address, or (`argument: "merkleProof"`) when the proof does not verify against the current root.
|
|
97
|
+
* @throws {@link UnauthorizedRedirectError} when a third-party submitter passes a `to` other than `entry.account`.
|
|
98
|
+
* @returns The transaction hash.
|
|
99
|
+
*/
|
|
100
|
+
claim(args: MerkleClaimArgs): Promise<Hex>;
|
|
101
|
+
/**
|
|
102
|
+
* Claim then route the allocation straight into the wrapper's unwrap
|
|
103
|
+
* (`to` becomes the underlying ERC-20 beneficiary). Reverts
|
|
104
|
+
* `TokenNotUnwrappable` (surfaced as `FeatureDisabledError`) on a
|
|
105
|
+
* non-unwrappable campaign.
|
|
106
|
+
*
|
|
107
|
+
* Same replay/accounting semantics and `msg.value == gasFee()` requirement
|
|
108
|
+
* as {@link claim} — see its `@remarks`.
|
|
109
|
+
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* **Self-only by design.** This entrypoint takes no claim identity: releasing an
|
|
112
|
+
* allocation as a public ERC-20 transfer publishes the amount irreversibly, which is
|
|
113
|
+
* the recipient's own choice to make. A relayed unwrap is therefore unrepresentable
|
|
114
|
+
* rather than merely rejected, and an entry whose `account` is not the sender is
|
|
115
|
+
* refused before the write. A third party can still submit a confidential
|
|
116
|
+
* {@link claim}.
|
|
117
|
+
*
|
|
118
|
+
* @returns The transaction hash. The underlying ERC-20 is released later by
|
|
119
|
+
* a separate, permissionless `finalizeUnwrap` — this hash is only the
|
|
120
|
+
* unwrap request.
|
|
121
|
+
*/
|
|
122
|
+
claimAndUnwrap(args: MerkleClaimArgs): Promise<Hex>;
|
|
123
|
+
/**
|
|
124
|
+
* Preview the outstanding amount for a proof-bearing entry as a handle the
|
|
125
|
+
* caller can decrypt. Consumes no accounting and no per-leaf state — the
|
|
126
|
+
* same entry still pays the same amount after a preview. No fee.
|
|
127
|
+
*
|
|
128
|
+
* **Submits a transaction.** The contract calls `FHE.allow(outstanding, account)`, so
|
|
129
|
+
* the result is recovered from the receipt's ACL `Allowed` event, never from a
|
|
130
|
+
* simulation. See {@link AirdropBaseClient}'s class TSDoc.
|
|
131
|
+
*
|
|
132
|
+
* **`entry.account` is the decryptable party, not the caller.** A relayer previewing on
|
|
133
|
+
* someone's behalf gets a valid handle it cannot read — that is the contract's intent,
|
|
134
|
+
* and it is what makes a blind relayed submission possible.
|
|
135
|
+
*
|
|
136
|
+
* @returns `{ handle, hash }` — pass `handle` to the Zama relayer's `userDecrypt`, as `entry.account`.
|
|
137
|
+
*/
|
|
138
|
+
getClaimAmount(args: GetClaimAmountArgs): Promise<EncryptedViewResult>;
|
|
139
|
+
/**
|
|
140
|
+
* Read `account`'s running delivered total as an encrypted handle.
|
|
141
|
+
*
|
|
142
|
+
* @remarks
|
|
143
|
+
* Since round 8 a Merkle leaf commits the recipient's CUMULATIVE total
|
|
144
|
+
* allocation, not a per-drop tranche, and this getter mirrors that: it
|
|
145
|
+
* returns the cumulative amount actually DELIVERED so far, not a per-claim
|
|
146
|
+
* amount. A claim pays `total - min(total, alreadyDelivered)`, where
|
|
147
|
+
* `alreadyDelivered` is exactly this value.
|
|
148
|
+
*
|
|
149
|
+
* Two consequences worth calling out explicitly:
|
|
150
|
+
* - **A root rotation is a top-up, not a second payout.** Rotating the
|
|
151
|
+
* root republishes updated cumulative totals; this value is keyed by
|
|
152
|
+
* `account` alone (not by root), so a claim against the new root pays
|
|
153
|
+
* only the increase over what this getter already reports.
|
|
154
|
+
* - **One leaf per recipient per root.** If a tree mistakenly commits two
|
|
155
|
+
* leaves for the same recipient, claiming both pays the higher of the
|
|
156
|
+
* two totals net of this running value — `max`, not `sum`.
|
|
157
|
+
*
|
|
158
|
+
* **An account that has never claimed returns the ZERO handle, which cannot be
|
|
159
|
+
* decrypted.** It is an uninitialized ciphertext, so nobody holds an ACL on it and
|
|
160
|
+
* the relayer rejects it with "not authorized to user decrypt handle 0x0…0" rather
|
|
161
|
+
* than answering zero. Treat `handle === zeroHash` as "nothing delivered yet" and
|
|
162
|
+
* skip the decrypt; only call `userDecrypt` on a non-zero handle. (A mock FHEVM
|
|
163
|
+
* instance does answer zero here, so this only bites against a live relayer.)
|
|
164
|
+
*
|
|
165
|
+
* @returns The account's cumulative delivered total as an encrypted handle, or the
|
|
166
|
+
* zero handle if it has never claimed.
|
|
167
|
+
*/
|
|
168
|
+
getClaimedAmount(account: Address): Promise<EncryptedHandle>;
|
|
169
|
+
/** The currently published root. Proofs must verify against this exact value. */
|
|
170
|
+
merkleRoot(): Promise<Hex>;
|
|
171
|
+
/** Whether {@link setMerkleRoot} can succeed at all — fixed at create time, never toggled after. */
|
|
172
|
+
isMerkleRootMutable(): Promise<boolean>;
|
|
173
|
+
/**
|
|
174
|
+
* Rotate the published root. Requires `MERKLE_ADMIN_ROLE`.
|
|
175
|
+
*
|
|
176
|
+
* A rotation republishes UPDATED cumulative totals — it tops accounts up,
|
|
177
|
+
* it never claws back: {@link getClaimedAmount}'s running total survives
|
|
178
|
+
* the rotation and every future claim still nets it out. See that
|
|
179
|
+
* getter's `@remarks`.
|
|
180
|
+
*
|
|
181
|
+
* @throws {@link FeatureDisabledError} (`feature: "merkleRootRotation"`) when the campaign was created
|
|
182
|
+
* with `isMerkleRootMutable: false`.
|
|
183
|
+
* @throws {@link InvalidArgumentError} (`argument: "merkleRoot"`) when `newRoot` is zero — a zero root
|
|
184
|
+
* would silently brick every claim with no way to fix it; pause instead.
|
|
185
|
+
* @returns The transaction hash.
|
|
186
|
+
*/
|
|
187
|
+
setMerkleRoot(args: {
|
|
188
|
+
newRoot: Hex;
|
|
189
|
+
} & WriteAccountOverride): Promise<Hex>;
|
|
190
|
+
/** Gates {@link setMerkleRoot}. */
|
|
191
|
+
MERKLE_ADMIN_ROLE(): Promise<Hex>;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Create a {@link MerkleAirdropClient}. Mirrors viem's `create*` convention.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* const airdrop = createMerkleAirdropClient({ publicClient, walletClient, address });
|
|
198
|
+
*
|
|
199
|
+
* @alpha
|
|
200
|
+
*/
|
|
201
|
+
export declare function createMerkleAirdropClient(config: AirdropBaseClientConfig): MerkleAirdropClient;
|
|
@@ -1,64 +1,135 @@
|
|
|
1
|
+
import type { UseQueryOptions } from "@tanstack/react-query";
|
|
1
2
|
import type { Address, PublicClient, WalletClient } from "viem";
|
|
2
3
|
import { DeploymentAddressUnavailableError } from "../../core/errors.js";
|
|
3
|
-
import
|
|
4
|
+
import type { SdkTelemetry } from "../../core/telemetry.js";
|
|
5
|
+
import { type AirdropBaseClient } from "../airdrop-base.js";
|
|
6
|
+
import type { DedupMode } from "../constants.js";
|
|
7
|
+
import { type EcdsaAirdropClient } from "../ecdsa.js";
|
|
8
|
+
import { type EncryptorSource } from "../encryption.js";
|
|
4
9
|
import { type ConfidentialAirdropFactoryClient } from "../factory.js";
|
|
5
|
-
import { type
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
import { type MerkleAirdropClient } from "../merkle.js";
|
|
11
|
+
import { type ComplianceManagerClient } from "../compliance.js";
|
|
12
|
+
/**
|
|
13
|
+
* Stable query-key prefix for every hook in this subpath — matches the
|
|
14
|
+
* sibling subpaths' convention (`FHE_VESTING_KEY`/`FHE_DISPERSE_KEY`/
|
|
15
|
+
* `TESTNET_FAUCET_KEY` all use `"tokenops-sdk"`; see `src/fhe-vesting/react/_shared.ts`,
|
|
16
|
+
* `src/fhe-disperse/react/_shared.ts`, `src/testnet-faucet/react/_shared.ts`).
|
|
17
|
+
*
|
|
18
|
+
* Not `"tokenops"` — an earlier draft of this file used that value; fixed so
|
|
19
|
+
* a consumer calling `queryClient.invalidateQueries({ queryKey: ["tokenops-sdk"] })`
|
|
20
|
+
* to clear every `@tokenops/sdk` cache entry doesn't silently miss this
|
|
21
|
+
* subpath's queries.
|
|
22
|
+
*/
|
|
23
|
+
export declare const FHE_AIRDROP_KEY: "tokenops-sdk";
|
|
24
|
+
export declare const FHE_AIRDROP_NAMESPACE: "fhe-airdrop";
|
|
25
|
+
/**
|
|
26
|
+
* Build the TanStack Query key for an `/fhe-airdrop` read.
|
|
27
|
+
*
|
|
28
|
+
* Namespaced by chain id AND instance/factory address so cache entries never
|
|
29
|
+
* bleed across chains or campaigns — two different campaign instances (or
|
|
30
|
+
* the same instance on two chains) never share a cache slot. Caller-specific
|
|
31
|
+
* reads (e.g. `getClaimedAmount(account)`) pass `account` as part of `args`,
|
|
32
|
+
* so switching the connected account changes the key and never serves a
|
|
33
|
+
* stale value cached under the previous account.
|
|
34
|
+
*
|
|
35
|
+
* @returns `["tokenops-sdk", "fhe-airdrop", chainId, address, fn, args]`.
|
|
36
|
+
*
|
|
37
|
+
* @alpha
|
|
38
|
+
*/
|
|
39
|
+
export declare function airdropQueryKey(params: {
|
|
40
|
+
chainId: number | undefined;
|
|
41
|
+
address: Address | undefined;
|
|
42
|
+
fn: string;
|
|
43
|
+
args: ReadonlyArray<unknown>;
|
|
44
|
+
}): unknown[];
|
|
45
|
+
/**
|
|
46
|
+
* Build the *prefix* of {@link airdropQueryKey} up to (and including) `fn` —
|
|
47
|
+
* useful for `invalidateQueries({ queryKey: airdropQueryKeyPrefix(...), exact: false })`
|
|
48
|
+
* when a write affects every cached read for one function regardless of args
|
|
49
|
+
* (e.g. every `hasRole` entry for one instance, regardless of which
|
|
50
|
+
* role/holder pair was queried).
|
|
51
|
+
*
|
|
52
|
+
* @alpha
|
|
53
|
+
*/
|
|
54
|
+
export declare function airdropQueryKeyPrefix(params: {
|
|
55
|
+
chainId: number | undefined;
|
|
56
|
+
address: Address | undefined;
|
|
57
|
+
fn?: string;
|
|
58
|
+
}): unknown[];
|
|
59
|
+
/**
|
|
60
|
+
* The client-construction subset of every hook's options — deliberately NOT
|
|
61
|
+
* generic over `TData`. Client-memo helpers (`useMemoAirdropBaseClient`,
|
|
62
|
+
* etc.) accept this narrower shape rather than {@link AirdropHookOptions},
|
|
63
|
+
* because a `useQuery<TData, ...>` per-hook `query` option makes the wider
|
|
64
|
+
* type invariant in `TData` (the `enabled` callback's parameter type), which
|
|
65
|
+
* would otherwise force every memo helper to be generic too.
|
|
66
|
+
*
|
|
67
|
+
* @alpha
|
|
68
|
+
*/
|
|
69
|
+
export interface AirdropClientOptions {
|
|
70
|
+
/** Instance or factory address override. Factory hooks default this by chain id; instance hooks require it. */
|
|
9
71
|
address?: Address;
|
|
10
72
|
/** Override the chain id used for default address resolution. Defaults to `usePublicClient().chain?.id`. */
|
|
11
73
|
chainId?: number;
|
|
12
|
-
}
|
|
13
|
-
/** Per-hook overrides for factory hooks that submit encrypted inputs. */
|
|
14
|
-
export interface FactoryHookOptions extends BaseHookOptions {
|
|
15
74
|
/**
|
|
16
|
-
* Lazy or eager encryptor source.
|
|
17
|
-
*
|
|
18
|
-
* (`
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* component and wire `encryptor: () => sdk.relayer` — the SDK
|
|
22
|
-
* calls this per-encryption so it picks up the live `ZamaSDK` instance
|
|
23
|
-
* rather than a stale capture (CLAUDE.md Pitfall #3).
|
|
75
|
+
* Lazy or eager encryptor source. Only consumed by hooks that submit
|
|
76
|
+
* encrypted inputs (`useFundAirdrop`). Recommended in React: capture
|
|
77
|
+
* `useZamaSDK()` once and wire `encryptor: () => sdk.relayer` so the SDK
|
|
78
|
+
* picks up the live context at submit time (CLAUDE.md Pitfall #3) rather
|
|
79
|
+
* than a stale capture. An eager `Encryptor` instance also type-checks.
|
|
24
80
|
*/
|
|
25
81
|
encryptor?: EncryptorSource;
|
|
82
|
+
/**
|
|
83
|
+
* Optional telemetry adapter. Forwarded into the headless client so spans
|
|
84
|
+
* and `*.client.init` events flow through whichever sink the consumer
|
|
85
|
+
* wires up (PostHog, OTel, Sentry, custom).
|
|
86
|
+
*/
|
|
87
|
+
telemetry?: SdkTelemetry;
|
|
26
88
|
}
|
|
27
|
-
/** Per-hook overrides for FHE-airdrop *clone* hooks — `address` is required (per-airdrop). */
|
|
28
|
-
export interface AirdropHookOptions {
|
|
29
|
-
/** Deployed airdrop clone address. Required — there is no chain-level default. */
|
|
30
|
-
address: Address;
|
|
31
|
-
/** Override the FHEVM ACL address (defaults to chain-id lookup). */
|
|
32
|
-
aclAddress?: Address;
|
|
33
|
-
/** Override the chain id used for ACL/public-client lookup. Defaults to `usePublicClient().chain?.id`. */
|
|
34
|
-
chainId?: number;
|
|
35
|
-
}
|
|
36
|
-
/** Stable query-key prefix for every hook in this subpath. */
|
|
37
|
-
export declare const FHE_AIRDROP_KEY: "tokenops-sdk";
|
|
38
|
-
export declare const FHE_AIRDROP_NAMESPACE: "fhe-airdrop";
|
|
39
89
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
90
|
+
* Common per-hook overrides — every public read hook accepts these alongside its own args.
|
|
91
|
+
*
|
|
92
|
+
* @alpha
|
|
43
93
|
*/
|
|
44
|
-
export
|
|
94
|
+
export interface AirdropHookOptions<TData = unknown> extends AirdropClientOptions {
|
|
95
|
+
/**
|
|
96
|
+
* Escape hatch for TanStack Query's own cache-behavior options
|
|
97
|
+
* (`staleTime`, `gcTime`, `select`, `refetchInterval`, …). Cannot override
|
|
98
|
+
* `queryKey` / `queryFn` — those stay owned by the hook so cache identity
|
|
99
|
+
* is never at risk of drifting from what was actually fetched.
|
|
100
|
+
*/
|
|
101
|
+
query?: Omit<UseQueryOptions<TData, Error>, "queryKey" | "queryFn">;
|
|
102
|
+
}
|
|
45
103
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
104
|
+
* Instance-scoped hook options — `address` is required (a campaign instance, not a chain-wide default).
|
|
105
|
+
*
|
|
106
|
+
* @alpha
|
|
48
107
|
*/
|
|
49
|
-
export
|
|
108
|
+
export type AirdropInstanceHookOptions<TData = unknown> = AirdropHookOptions<TData> & {
|
|
109
|
+
address: Address;
|
|
110
|
+
};
|
|
50
111
|
/**
|
|
51
|
-
*
|
|
52
|
-
* `(publicClient, walletClient, address)`. The encryptor source is passed
|
|
53
|
-
* through as a **lazy** function (mirroring Pitfall #3 from CLAUDE.md): the
|
|
54
|
-
* SDK calls it per-encryption, picking up the live React context at submit
|
|
55
|
-
* time rather than baking in a stale capture.
|
|
112
|
+
* Non-generic instance-scoped client options, for memo helpers.
|
|
56
113
|
*
|
|
57
|
-
* @
|
|
58
|
-
|
|
59
|
-
|
|
114
|
+
* @alpha
|
|
115
|
+
*/
|
|
116
|
+
export type AirdropInstanceClientOptions = AirdropClientOptions & {
|
|
117
|
+
address: Address;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Resolve the airdrop factory address for `chainId`, mirroring the headless
|
|
121
|
+
* client's resolution. Returns `undefined` instead of throwing — used by
|
|
122
|
+
* query-key builders and `enabled` gates.
|
|
123
|
+
*/
|
|
124
|
+
export declare function tryResolveAirdropFactoryAddress(override: Address | undefined, chainId: number | undefined): Address | undefined;
|
|
125
|
+
/**
|
|
126
|
+
* Memoize a {@link ConfidentialAirdropFactoryClient} keyed on
|
|
127
|
+
* `(publicClient, walletClient, address, chainId)`. The encryptor source is
|
|
128
|
+
* threaded through as a lazy ref (CLAUDE.md Pitfall #3): the client calls it
|
|
129
|
+
* per-encryption, so it always sees the live React value rather than one
|
|
130
|
+
* baked in at memo time.
|
|
60
131
|
*/
|
|
61
|
-
export declare function
|
|
132
|
+
export declare function useMemoAirdropFactoryClient(opts?: AirdropClientOptions): {
|
|
62
133
|
client: ConfidentialAirdropFactoryClient | undefined;
|
|
63
134
|
resolutionError: DeploymentAddressUnavailableError | undefined;
|
|
64
135
|
publicClient: PublicClient | undefined;
|
|
@@ -67,41 +138,56 @@ export declare function useMemoFactoryClient(opts?: FactoryHookOptions): {
|
|
|
67
138
|
resolvedAddress: Address | undefined;
|
|
68
139
|
};
|
|
69
140
|
/**
|
|
70
|
-
* Memoize
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* `{ encryptedInput, signature }` pair as-is — so no encryptor is wired here.
|
|
141
|
+
* Memoize an {@link AirdropBaseClient} for `opts.address` — the surface
|
|
142
|
+
* shared by both variants (lifecycle, treasury, rescue, roles, disclosure).
|
|
143
|
+
* Use this for hooks that don't need a variant-specific method.
|
|
74
144
|
*/
|
|
75
|
-
export declare function
|
|
76
|
-
client:
|
|
145
|
+
export declare function useMemoAirdropBaseClient(opts: AirdropInstanceClientOptions): {
|
|
146
|
+
client: AirdropBaseClient | undefined;
|
|
147
|
+
publicClient: PublicClient | undefined;
|
|
148
|
+
walletClient: WalletClient | undefined;
|
|
149
|
+
chainId: number | undefined;
|
|
150
|
+
};
|
|
151
|
+
/** Memoize a {@link MerkleAirdropClient} for `opts.address`. */
|
|
152
|
+
export declare function useMemoMerkleAirdropClient(opts: AirdropInstanceClientOptions): {
|
|
153
|
+
client: MerkleAirdropClient | undefined;
|
|
77
154
|
publicClient: PublicClient | undefined;
|
|
78
155
|
walletClient: WalletClient | undefined;
|
|
79
156
|
chainId: number | undefined;
|
|
80
157
|
};
|
|
81
158
|
/**
|
|
82
|
-
*
|
|
83
|
-
* 1. Explicit `override` (eager `Encryptor` or lazy `() => Encryptor | undefined`).
|
|
84
|
-
* 2. The hook-level `encryptor` source from the hook options.
|
|
159
|
+
* Memoize a {@link ComplianceManagerClient} for `opts.address`.
|
|
85
160
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
|
|
161
|
+
* `address` is the manager CLONE, not the airdrop instance and not the factory — read it
|
|
162
|
+
* from `factory.complianceManagerOf(airdrop)` or off `CreateAirdropResult.complianceManager`.
|
|
163
|
+
*/
|
|
164
|
+
export declare function useMemoComplianceManagerClient(opts: AirdropInstanceClientOptions): {
|
|
165
|
+
client: ComplianceManagerClient | undefined;
|
|
166
|
+
publicClient: PublicClient | undefined;
|
|
167
|
+
walletClient: WalletClient | undefined;
|
|
168
|
+
chainId: number | undefined;
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Per-hook overrides for {@link useMemoEcdsaAirdropClient} — `dedupMode` has no on-chain getter, so it must be supplied.
|
|
89
172
|
*
|
|
90
|
-
*
|
|
91
|
-
* dynamically import `@zama-fhe/react-sdk` — calling `useZamaSDK()` from
|
|
92
|
-
* inside `mutationFn` would violate the rules of hooks. Consumers wire the
|
|
93
|
-
* encryptor at hook construction. The safe pattern is two lines:
|
|
94
|
-
* `const sdk = useZamaSDK();` then `encryptor: () => sdk.relayer` — never
|
|
95
|
-
* `() => useZamaSDK().relayer` inline (that calls a React hook inside a
|
|
96
|
-
* mutation body, violating the rules of hooks).
|
|
173
|
+
* @alpha
|
|
97
174
|
*/
|
|
98
|
-
export
|
|
175
|
+
export type EcdsaAirdropInstanceHookOptions<TData = unknown> = AirdropInstanceHookOptions<TData> & {
|
|
176
|
+
/** @see EcdsaAirdropClientConfig.dedupMode */
|
|
177
|
+
dedupMode: DedupMode;
|
|
178
|
+
};
|
|
99
179
|
/**
|
|
100
|
-
*
|
|
180
|
+
* Non-generic version of {@link EcdsaAirdropInstanceHookOptions}, for the memo helper.
|
|
101
181
|
*
|
|
102
|
-
*
|
|
103
|
-
* - Lowercase the contract address (TanStack uses structural equality; viem
|
|
104
|
-
* sometimes returns checksummed addresses).
|
|
105
|
-
* - Convert bigints to base-10 strings (TanStack's serializer doesn't handle bigints).
|
|
182
|
+
* @alpha
|
|
106
183
|
*/
|
|
107
|
-
export
|
|
184
|
+
export type EcdsaAirdropInstanceClientOptions = AirdropInstanceClientOptions & {
|
|
185
|
+
dedupMode: DedupMode;
|
|
186
|
+
};
|
|
187
|
+
/** Memoize an {@link EcdsaAirdropClient} for `opts.address`. */
|
|
188
|
+
export declare function useMemoEcdsaAirdropClient(opts: EcdsaAirdropInstanceClientOptions): {
|
|
189
|
+
client: EcdsaAirdropClient | undefined;
|
|
190
|
+
publicClient: PublicClient | undefined;
|
|
191
|
+
walletClient: WalletClient | undefined;
|
|
192
|
+
chainId: number | undefined;
|
|
193
|
+
};
|