@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,423 @@
|
|
|
1
|
+
import { resolveEncryptor, encryptUint64Batch, encryptUint64 } from './chunk-X7WBPCEU.js';
|
|
2
|
+
import { assertPredictionFresh, FeeCollectorSelfAdministeredError } from './chunk-VW356KR3.js';
|
|
3
|
+
import { normaliseAddress } from './chunk-ZA673I3O.js';
|
|
4
|
+
import { InvalidArgumentError, MissingWalletClientError, MissingAccountError, ContractRevertError, MissingEncryptorError, isTokenOpsSdkError, UnknownWriteFailureError } from './chunk-QBJ7O2B4.js';
|
|
5
|
+
import { StandardMerkleTree } from '@openzeppelin/merkle-tree';
|
|
6
|
+
import { keccak256, encodeAbiParameters, isAddress, isAddressEqual, zeroAddress } from 'viem';
|
|
7
|
+
|
|
8
|
+
function leafOf(args) {
|
|
9
|
+
const inner = keccak256(
|
|
10
|
+
encodeAbiParameters(
|
|
11
|
+
[{ type: "address" }, { type: "address" }, { type: "bytes32" }],
|
|
12
|
+
[args.instance, args.account, args.handle]
|
|
13
|
+
)
|
|
14
|
+
);
|
|
15
|
+
return keccak256(inner);
|
|
16
|
+
}
|
|
17
|
+
var HANDLE_PATTERN = /^0x[0-9a-fA-F]{64}$/;
|
|
18
|
+
function assertLeaves(instance, leaves, method) {
|
|
19
|
+
if (!isAddress(instance, { strict: false })) {
|
|
20
|
+
throw new InvalidArgumentError({
|
|
21
|
+
method,
|
|
22
|
+
argument: "instance",
|
|
23
|
+
reason: "is not a 20-byte hex address",
|
|
24
|
+
value: instance
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (isAddressEqual(instance, zeroAddress)) {
|
|
28
|
+
throw new InvalidArgumentError({
|
|
29
|
+
method,
|
|
30
|
+
argument: "instance",
|
|
31
|
+
reason: "is the zero address; leaves must be scoped to the airdrop instance"
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (leaves.length === 0) {
|
|
35
|
+
throw new InvalidArgumentError({
|
|
36
|
+
method,
|
|
37
|
+
argument: "leaves",
|
|
38
|
+
reason: "a tree needs at least one leaf"
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const seen = /* @__PURE__ */ new Map();
|
|
42
|
+
leaves.forEach((leaf, index) => {
|
|
43
|
+
if (!isAddress(leaf.account, { strict: false })) {
|
|
44
|
+
throw new InvalidArgumentError({
|
|
45
|
+
method,
|
|
46
|
+
argument: `leaves[${index}].account`,
|
|
47
|
+
reason: "is not a 20-byte hex address",
|
|
48
|
+
value: leaf.account
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (isAddressEqual(leaf.account, zeroAddress)) {
|
|
52
|
+
throw new InvalidArgumentError({
|
|
53
|
+
method,
|
|
54
|
+
argument: `leaves[${index}].account`,
|
|
55
|
+
reason: "is the zero address; the contract rejects it with ZeroAccount"
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (!HANDLE_PATTERN.test(leaf.handle)) {
|
|
59
|
+
throw new InvalidArgumentError({
|
|
60
|
+
method,
|
|
61
|
+
argument: `leaves[${index}].handle`,
|
|
62
|
+
reason: "is not a 32-byte hex handle; the tree would commit to a value no claim can reproduce",
|
|
63
|
+
value: leaf.handle
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const key = leaf.account.toLowerCase();
|
|
67
|
+
const first = seen.get(key);
|
|
68
|
+
if (first !== void 0) {
|
|
69
|
+
throw new InvalidArgumentError({
|
|
70
|
+
method,
|
|
71
|
+
argument: `leaves[${index}].account`,
|
|
72
|
+
reason: `appears twice (also at index ${first}); one root pays max, not sum, of an account's leaves \u2014 merge them into a single cumulative total`
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
seen.set(key, index);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
function buildMerkleTree(args) {
|
|
79
|
+
return buildMerkleTreeInternal(args, "buildMerkleTree");
|
|
80
|
+
}
|
|
81
|
+
function buildMerkleTreeInternal({ instance, leaves }, method) {
|
|
82
|
+
assertLeaves(instance, leaves, method);
|
|
83
|
+
const airdrop = normaliseAddress(instance);
|
|
84
|
+
const accounts = leaves.map((leaf) => normaliseAddress(leaf.account));
|
|
85
|
+
const rows = accounts.map((account, i) => [airdrop, account, leaves[i].handle]);
|
|
86
|
+
const tree = StandardMerkleTree.of(rows, ["address", "address", "bytes32"]);
|
|
87
|
+
return {
|
|
88
|
+
root: tree.root,
|
|
89
|
+
// `getProof(i)` indexes the INPUT array, not the tree: `StandardMerkleTree` sorts
|
|
90
|
+
// leaves internally but keeps `values` in insertion order, so entry `i` always belongs
|
|
91
|
+
// to `leaves[i]`.
|
|
92
|
+
entries: leaves.map((leaf, i) => ({
|
|
93
|
+
...leaf,
|
|
94
|
+
account: accounts[i],
|
|
95
|
+
merkleProof: tree.getProof(i)
|
|
96
|
+
}))
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
var MAX_UINT64 = (1n << 64n) - 1n;
|
|
100
|
+
var MERKLE_BATCH_LIMIT = 2048 / 64;
|
|
101
|
+
function validateCampaignRecipients(recipients) {
|
|
102
|
+
validateCampaignRecipientsInternal(recipients, "validateCampaignRecipients");
|
|
103
|
+
}
|
|
104
|
+
function validateCampaignRecipientsInternal(recipients, method) {
|
|
105
|
+
if (recipients.length === 0) {
|
|
106
|
+
throw new InvalidArgumentError({
|
|
107
|
+
method,
|
|
108
|
+
argument: "recipients",
|
|
109
|
+
reason: "a campaign needs at least one recipient"
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const seen = /* @__PURE__ */ new Map();
|
|
113
|
+
recipients.forEach((entry, index) => {
|
|
114
|
+
if (!isAddress(entry.recipient, { strict: false })) {
|
|
115
|
+
throw new InvalidArgumentError({
|
|
116
|
+
method,
|
|
117
|
+
argument: `recipients[${index}].recipient`,
|
|
118
|
+
reason: "is not a 20-byte hex address",
|
|
119
|
+
value: entry.recipient
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
if (isAddressEqual(entry.recipient, zeroAddress)) {
|
|
123
|
+
throw new InvalidArgumentError({
|
|
124
|
+
method,
|
|
125
|
+
argument: `recipients[${index}].recipient`,
|
|
126
|
+
reason: "is the zero address, whose leaf can never be claimed"
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
if (entry.cumulativeTotal < 0n || entry.cumulativeTotal > MAX_UINT64) {
|
|
130
|
+
throw new InvalidArgumentError({
|
|
131
|
+
method,
|
|
132
|
+
argument: `recipients[${index}].cumulativeTotal`,
|
|
133
|
+
// Deliberately no `value`: the total is confidential.
|
|
134
|
+
reason: "is outside uint64 range (0..2^64-1)"
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
const key = entry.recipient.toLowerCase();
|
|
138
|
+
const first = seen.get(key);
|
|
139
|
+
if (first !== void 0) {
|
|
140
|
+
throw new InvalidArgumentError({
|
|
141
|
+
method,
|
|
142
|
+
argument: `recipients[${index}].recipient`,
|
|
143
|
+
reason: `appears twice (also at index ${first}); one root pays max, not sum, of a recipient's leaves \u2014 merge them into a single cumulative total`
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
seen.set(key, index);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
async function encryptRoster({ instance, recipients, encryptor, submitter }, method) {
|
|
150
|
+
validateCampaignRecipientsInternal(recipients, method);
|
|
151
|
+
if (!isAddress(instance, { strict: false })) {
|
|
152
|
+
throw new InvalidArgumentError({
|
|
153
|
+
method,
|
|
154
|
+
argument: "instance",
|
|
155
|
+
reason: "is not a 20-byte hex address",
|
|
156
|
+
value: instance
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
if (isAddressEqual(instance, zeroAddress)) {
|
|
160
|
+
throw new InvalidArgumentError({
|
|
161
|
+
method,
|
|
162
|
+
argument: "instance",
|
|
163
|
+
reason: "is the zero address; inputs must be bound to the airdrop instance"
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
const enc = resolveEncryptor(encryptor);
|
|
167
|
+
if (!enc) {
|
|
168
|
+
throw new MissingEncryptorError(method, {
|
|
169
|
+
hint: "Pass an encryptor instance, or a lazy factory that returns one."
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
if (submitter !== void 0) {
|
|
173
|
+
if (!isAddress(submitter, { strict: false })) {
|
|
174
|
+
throw new InvalidArgumentError({
|
|
175
|
+
method,
|
|
176
|
+
argument: "submitter",
|
|
177
|
+
reason: "is not a 20-byte hex address",
|
|
178
|
+
value: submitter
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
if (isAddressEqual(submitter, zeroAddress)) {
|
|
182
|
+
throw new InvalidArgumentError({
|
|
183
|
+
method,
|
|
184
|
+
argument: "submitter",
|
|
185
|
+
reason: "is the zero address; no proof can be bound to it, so no leaf would be claimable"
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
const airdrop = normaliseAddress(instance);
|
|
190
|
+
const accounts = recipients.map((r) => normaliseAddress(r.recipient));
|
|
191
|
+
if (submitter !== void 0) {
|
|
192
|
+
const boundTo = normaliseAddress(submitter);
|
|
193
|
+
const chunks = [];
|
|
194
|
+
for (let i = 0; i < recipients.length; i += MERKLE_BATCH_LIMIT) {
|
|
195
|
+
chunks.push(recipients.slice(i, i + MERKLE_BATCH_LIMIT));
|
|
196
|
+
}
|
|
197
|
+
const encryptedChunks = await Promise.all(
|
|
198
|
+
chunks.map(
|
|
199
|
+
(chunk) => encryptUint64Batch({
|
|
200
|
+
encryptor: enc,
|
|
201
|
+
contractAddress: airdrop,
|
|
202
|
+
userAddress: boundTo,
|
|
203
|
+
values: chunk.map((r) => r.cumulativeTotal)
|
|
204
|
+
})
|
|
205
|
+
)
|
|
206
|
+
);
|
|
207
|
+
return accounts.map((account, i) => {
|
|
208
|
+
const chunk = encryptedChunks[Math.floor(i / MERKLE_BATCH_LIMIT)];
|
|
209
|
+
return {
|
|
210
|
+
account,
|
|
211
|
+
boundTo,
|
|
212
|
+
handle: chunk.handles[i % MERKLE_BATCH_LIMIT],
|
|
213
|
+
inputProof: chunk.inputProof
|
|
214
|
+
};
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
const encrypted = await Promise.all(
|
|
218
|
+
recipients.map(
|
|
219
|
+
(r, i) => encryptUint64({
|
|
220
|
+
encryptor: enc,
|
|
221
|
+
contractAddress: airdrop,
|
|
222
|
+
userAddress: accounts[i],
|
|
223
|
+
value: r.cumulativeTotal
|
|
224
|
+
})
|
|
225
|
+
)
|
|
226
|
+
);
|
|
227
|
+
return accounts.map((account, i) => ({
|
|
228
|
+
account,
|
|
229
|
+
boundTo: account,
|
|
230
|
+
handle: encrypted[i].handle,
|
|
231
|
+
inputProof: encrypted[i].inputProof
|
|
232
|
+
}));
|
|
233
|
+
}
|
|
234
|
+
async function encryptCampaignAmounts(args) {
|
|
235
|
+
return encryptRoster(args, "encryptCampaignAmounts");
|
|
236
|
+
}
|
|
237
|
+
async function buildMerkleCampaign({
|
|
238
|
+
instance,
|
|
239
|
+
recipients,
|
|
240
|
+
encryptor,
|
|
241
|
+
submitter
|
|
242
|
+
}) {
|
|
243
|
+
const leaves = await encryptRoster(
|
|
244
|
+
{ instance, recipients, encryptor, submitter },
|
|
245
|
+
"buildMerkleCampaign"
|
|
246
|
+
);
|
|
247
|
+
return buildMerkleTreeInternal({ instance, leaves }, "buildMerkleCampaign");
|
|
248
|
+
}
|
|
249
|
+
async function planMerkleCampaign({
|
|
250
|
+
factory,
|
|
251
|
+
params,
|
|
252
|
+
mode,
|
|
253
|
+
creator,
|
|
254
|
+
userSalt,
|
|
255
|
+
recipients,
|
|
256
|
+
encryptor,
|
|
257
|
+
submitter
|
|
258
|
+
}) {
|
|
259
|
+
validateCampaignRecipientsInternal(recipients, "planMerkleCampaign");
|
|
260
|
+
const initCodeHashBefore = await factory.getMerkleInitCodeHash({ params, mode });
|
|
261
|
+
const predictedAddress = await factory.predictMerkleAirdropAddress({
|
|
262
|
+
params,
|
|
263
|
+
mode,
|
|
264
|
+
deployer: creator,
|
|
265
|
+
userSalt
|
|
266
|
+
});
|
|
267
|
+
const campaign = await buildMerkleCampaign({
|
|
268
|
+
instance: predictedAddress,
|
|
269
|
+
recipients,
|
|
270
|
+
encryptor,
|
|
271
|
+
submitter
|
|
272
|
+
});
|
|
273
|
+
const initCodeHashAfter = await factory.getMerkleInitCodeHash({ params, mode });
|
|
274
|
+
assertPredictionFresh({
|
|
275
|
+
variant: "merkle",
|
|
276
|
+
initCodeHashBefore,
|
|
277
|
+
initCodeHashAfter,
|
|
278
|
+
predictedAddress,
|
|
279
|
+
method: "planMerkleCampaign"
|
|
280
|
+
});
|
|
281
|
+
return { ...campaign, predictedAddress, initCodeHashBefore, initCodeHashAfter };
|
|
282
|
+
}
|
|
283
|
+
async function rotateMerkleRoot({
|
|
284
|
+
airdrop,
|
|
285
|
+
recipients,
|
|
286
|
+
encryptor,
|
|
287
|
+
submitter,
|
|
288
|
+
account
|
|
289
|
+
}) {
|
|
290
|
+
const campaign = await buildMerkleCampaign({
|
|
291
|
+
instance: airdrop.address,
|
|
292
|
+
recipients,
|
|
293
|
+
encryptor,
|
|
294
|
+
submitter
|
|
295
|
+
});
|
|
296
|
+
const hash = await airdrop.setMerkleRoot({ newRoot: campaign.root, account });
|
|
297
|
+
return { ...campaign, hash };
|
|
298
|
+
}
|
|
299
|
+
var ASSIGNABLE_ROLES = [
|
|
300
|
+
{ key: "pauser", role: "PAUSER_ROLE" },
|
|
301
|
+
{ key: "windowAdmin", role: "WINDOW_ADMIN_ROLE" },
|
|
302
|
+
{ key: "treasury", role: "TREASURY_ROLE" },
|
|
303
|
+
{ key: "rescuer", role: "RESCUER_ROLE" },
|
|
304
|
+
{ key: "disclosureAdmin", role: "DISCLOSURE_ADMIN_ROLE" },
|
|
305
|
+
{ key: "upgrader", role: "UPGRADER_ROLE" },
|
|
306
|
+
{ key: "merkleAdmin", role: "MERKLE_ADMIN_ROLE", variant: "merkle" },
|
|
307
|
+
{ key: "signer", role: "SIGNER_ROLE", variant: "ecdsa" }
|
|
308
|
+
];
|
|
309
|
+
function planInstanceRoleSplit(args) {
|
|
310
|
+
const { assignment, caller, airdropType } = args;
|
|
311
|
+
if (assignment.feeCollector !== void 0) {
|
|
312
|
+
throw new FeeCollectorSelfAdministeredError({ requestedGrantee: assignment.feeCollector });
|
|
313
|
+
}
|
|
314
|
+
const steps = [];
|
|
315
|
+
for (const { key, role, variant } of ASSIGNABLE_ROLES) {
|
|
316
|
+
const account = assignment[key];
|
|
317
|
+
if (account === void 0) continue;
|
|
318
|
+
if (variant !== void 0 && variant !== airdropType) {
|
|
319
|
+
throw new InvalidArgumentError({
|
|
320
|
+
method: "planInstanceRoleSplit",
|
|
321
|
+
argument: `assignment.${key}`,
|
|
322
|
+
reason: `${role} only exists on ${variant} campaigns; this is a(n) ${airdropType} campaign`
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
steps.push({ kind: "grant", role, account });
|
|
326
|
+
}
|
|
327
|
+
if (assignment.admin !== void 0) {
|
|
328
|
+
if (isAddressEqual(assignment.admin, zeroAddress)) {
|
|
329
|
+
throw new InvalidArgumentError({
|
|
330
|
+
method: "planInstanceRoleSplit",
|
|
331
|
+
argument: "assignment.admin",
|
|
332
|
+
reason: "granting DEFAULT_ADMIN_ROLE to the zero address is never valid"
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
steps.push({ kind: "grant", role: "DEFAULT_ADMIN_ROLE", account: assignment.admin });
|
|
336
|
+
steps.push({ kind: "revoke", role: "DEFAULT_ADMIN_ROLE", account: caller });
|
|
337
|
+
}
|
|
338
|
+
return steps;
|
|
339
|
+
}
|
|
340
|
+
function roleGetterAbiEntry(name) {
|
|
341
|
+
return {
|
|
342
|
+
inputs: [],
|
|
343
|
+
name,
|
|
344
|
+
outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }],
|
|
345
|
+
stateMutability: "view",
|
|
346
|
+
type: "function"
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
var ROLE_GETTER_ABI = [
|
|
350
|
+
roleGetterAbiEntry("PAUSER_ROLE"),
|
|
351
|
+
roleGetterAbiEntry("WINDOW_ADMIN_ROLE"),
|
|
352
|
+
roleGetterAbiEntry("TREASURY_ROLE"),
|
|
353
|
+
roleGetterAbiEntry("RESCUER_ROLE"),
|
|
354
|
+
roleGetterAbiEntry("DISCLOSURE_ADMIN_ROLE"),
|
|
355
|
+
roleGetterAbiEntry("UPGRADER_ROLE"),
|
|
356
|
+
roleGetterAbiEntry("MERKLE_ADMIN_ROLE"),
|
|
357
|
+
roleGetterAbiEntry("SIGNER_ROLE")
|
|
358
|
+
];
|
|
359
|
+
var DEFAULT_ADMIN_ROLE_CONSTANT = `0x${"0".repeat(64)}`;
|
|
360
|
+
async function resolveRoleConstant(airdrop, role) {
|
|
361
|
+
if (role === "DEFAULT_ADMIN_ROLE") return DEFAULT_ADMIN_ROLE_CONSTANT;
|
|
362
|
+
const result = await airdrop.publicClient.readContract({
|
|
363
|
+
address: airdrop.address,
|
|
364
|
+
abi: ROLE_GETTER_ABI,
|
|
365
|
+
functionName: role
|
|
366
|
+
});
|
|
367
|
+
return result;
|
|
368
|
+
}
|
|
369
|
+
function toOutcomeError(step, airdrop, error) {
|
|
370
|
+
if (isTokenOpsSdkError(error)) return error;
|
|
371
|
+
return new UnknownWriteFailureError({
|
|
372
|
+
method: `grantInstanceRoles.${step.kind}.${step.role}`,
|
|
373
|
+
contractAddress: airdrop.address,
|
|
374
|
+
cause: error
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
async function grantInstanceRoles(args) {
|
|
378
|
+
const { airdrop, assignment, revokeFromCreator = true } = args;
|
|
379
|
+
const wallet = airdrop.walletClient;
|
|
380
|
+
if (!wallet) {
|
|
381
|
+
throw new MissingWalletClientError("grantInstanceRoles");
|
|
382
|
+
}
|
|
383
|
+
const callerAccount = wallet.account;
|
|
384
|
+
if (!callerAccount) {
|
|
385
|
+
throw new MissingAccountError("grantInstanceRoles");
|
|
386
|
+
}
|
|
387
|
+
const caller = typeof callerAccount === "string" ? callerAccount : callerAccount.address;
|
|
388
|
+
const airdropType = await airdrop.airdropType() === 1 ? "merkle" : "ecdsa";
|
|
389
|
+
let steps = planInstanceRoleSplit({ assignment, caller, airdropType });
|
|
390
|
+
if (!revokeFromCreator) {
|
|
391
|
+
steps = steps.filter((step) => !(step.kind === "revoke" && step.role === "DEFAULT_ADMIN_ROLE"));
|
|
392
|
+
}
|
|
393
|
+
const outcomes = [];
|
|
394
|
+
for (const step of steps) {
|
|
395
|
+
try {
|
|
396
|
+
const role = await resolveRoleConstant(airdrop, step.role);
|
|
397
|
+
const hash = step.kind === "grant" ? await airdrop.grantRole({ role, holder: step.account, account: caller }) : await airdrop.revokeRole({ role, holder: step.account, account: caller });
|
|
398
|
+
const receipt = await airdrop.publicClient.waitForTransactionReceipt({ hash });
|
|
399
|
+
if (receipt.status !== "success") {
|
|
400
|
+
outcomes.push({
|
|
401
|
+
role: step.role,
|
|
402
|
+
account: step.account,
|
|
403
|
+
error: new ContractRevertError({
|
|
404
|
+
method: `grantInstanceRoles.${step.kind}.${step.role}`,
|
|
405
|
+
contractAddress: airdrop.address,
|
|
406
|
+
message: `grantInstanceRoles.${step.kind}.${step.role}: transaction ${hash} was mined with a reverted status; the role change did not apply.`
|
|
407
|
+
})
|
|
408
|
+
});
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
outcomes.push({ role: step.role, account: step.account, hash });
|
|
412
|
+
} catch (error) {
|
|
413
|
+
outcomes.push({
|
|
414
|
+
role: step.role,
|
|
415
|
+
account: step.account,
|
|
416
|
+
error: toOutcomeError(step, airdrop, error)
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return outcomes;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export { buildMerkleCampaign, buildMerkleTree, encryptCampaignAmounts, grantInstanceRoles, leafOf, planInstanceRoleSplit, planMerkleCampaign, rotateMerkleRoot, validateCampaignRecipients };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createConfidentialVestingManagerClient } from './chunk-
|
|
2
|
-
import { resolveEncryptor } from './chunk-
|
|
3
|
-
import { createConfidentialVestingFactoryClient } from './chunk-
|
|
4
|
-
import { getFheVestingFactoryAddress } from './chunk-
|
|
5
|
-
import { DeploymentAddressUnavailableError } from './chunk-
|
|
1
|
+
import { createConfidentialVestingManagerClient } from './chunk-TWT3STIX.js';
|
|
2
|
+
import { resolveEncryptor } from './chunk-6GNR22OV.js';
|
|
3
|
+
import { createConfidentialVestingFactoryClient } from './chunk-WJMEBBU7.js';
|
|
4
|
+
import { getFheVestingFactoryAddress } from './chunk-A4DCEE33.js';
|
|
5
|
+
import { DeploymentAddressUnavailableError } from './chunk-QBJ7O2B4.js';
|
|
6
6
|
import { useMemo, useRef, useEffect } from 'react';
|
|
7
7
|
import { usePublicClient, useWalletClient } from 'wagmi';
|
|
8
8
|
|