@tokenops/sdk 1.0.0
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 +207 -0
- package/CONTRIBUTING.md +113 -0
- package/LICENSE +32 -0
- package/README.md +677 -0
- package/SECURITY.md +59 -0
- package/dist/chunk-52TC6BF7.js +2755 -0
- package/dist/chunk-56UI7LUR.cjs +516 -0
- package/dist/chunk-5SA2HF2W.cjs +1635 -0
- package/dist/chunk-5SGMJADP.cjs +139 -0
- package/dist/chunk-62DF53UQ.cjs +749 -0
- package/dist/chunk-66IHPTOK.cjs +20 -0
- package/dist/chunk-6ECAHP5O.cjs +1496 -0
- package/dist/chunk-72YGZEQE.js +742 -0
- package/dist/chunk-7VELUOMI.js +35 -0
- package/dist/chunk-BE2AIZ3K.js +23 -0
- package/dist/chunk-CMRETRZO.js +46 -0
- package/dist/chunk-COPFW5Z4.js +82 -0
- package/dist/chunk-CQIPRNS7.cjs +25 -0
- package/dist/chunk-ECT3NL2L.js +124 -0
- package/dist/chunk-FWHYQZ5E.cjs +37 -0
- package/dist/chunk-FYQ2UW4T.js +37 -0
- package/dist/chunk-HGXNRR25.js +105 -0
- package/dist/chunk-HTOMTEA3.cjs +3406 -0
- package/dist/chunk-ITQ7WKVC.cjs +101 -0
- package/dist/chunk-IVE3QEGD.js +478 -0
- package/dist/chunk-JFLEEXKP.js +325 -0
- package/dist/chunk-JFR5J4FL.cjs +128 -0
- package/dist/chunk-K6MFFDBJ.cjs +109 -0
- package/dist/chunk-KWFFIJYX.js +11 -0
- package/dist/chunk-NS44KBV5.cjs +89 -0
- package/dist/chunk-OLDGMKW2.cjs +93 -0
- package/dist/chunk-Q2GP5UDC.js +29 -0
- package/dist/chunk-Q7ARQSUH.cjs +42 -0
- package/dist/chunk-QCA7O2Q5.cjs +49 -0
- package/dist/chunk-QIHZVLIK.js +3388 -0
- package/dist/chunk-SUOG3BQS.cjs +2772 -0
- package/dist/chunk-T5LVV3KY.cjs +44 -0
- package/dist/chunk-UOG4PJL5.js +1488 -0
- package/dist/chunk-VDXVNZCO.cjs +329 -0
- package/dist/chunk-VJKZWYYJ.cjs +32 -0
- package/dist/chunk-WRCUDSUJ.js +96 -0
- package/dist/chunk-XSNLAS5M.js +135 -0
- package/dist/chunk-XXXDQSHE.js +1628 -0
- package/dist/chunk-ZHFLRKFY.js +41 -0
- package/dist/chunk-ZXCOJY2Z.js +87 -0
- package/dist/core/addresses.d.ts +59 -0
- package/dist/core/brands.d.ts +87 -0
- package/dist/core/chains.d.ts +102 -0
- package/dist/core/errors.d.ts +687 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/normalise.d.ts +27 -0
- package/dist/core/preflight.d.ts +25 -0
- package/dist/core/revert-mapper.d.ts +74 -0
- package/dist/core/telemetry.d.ts +50 -0
- package/dist/core/types.d.ts +10 -0
- package/dist/core/version.d.ts +15 -0
- package/dist/core/zama-error-mapper.d.ts +27 -0
- package/dist/fhe/acl.d.ts +73 -0
- package/dist/fhe/erc7984-abi.d.ts +53 -0
- package/dist/fhe/index.cjs +599 -0
- package/dist/fhe/index.d.cts +11 -0
- package/dist/fhe/index.d.ts +11 -0
- package/dist/fhe/index.js +394 -0
- package/dist/fhe/mock-encryptor.d.ts +90 -0
- package/dist/fhe/mock-erc7984.d.ts +134 -0
- package/dist/fhe/operators.d.ts +190 -0
- package/dist/fhe/react/index.cjs +102 -0
- package/dist/fhe/react/index.d.cts +10 -0
- package/dist/fhe/react/index.d.ts +10 -0
- package/dist/fhe/react/index.js +85 -0
- package/dist/fhe/react/use-decrypted-handle.d.ts +102 -0
- package/dist/fhe/scale-ratio.d.ts +168 -0
- package/dist/fhe/sepolia-encryptor-web.d.ts +101 -0
- package/dist/fhe/sepolia-encryptor.d.ts +132 -0
- package/dist/fhe/types.d.ts +62 -0
- package/dist/fhe-airdrop/abis/cloneable.d.ts +781 -0
- package/dist/fhe-airdrop/abis/factory.d.ts +714 -0
- package/dist/fhe-airdrop/abis/index.d.ts +2 -0
- package/dist/fhe-airdrop/advanced/factory-advanced.d.ts +53 -0
- package/dist/fhe-airdrop/advanced/index.cjs +21 -0
- package/dist/fhe-airdrop/advanced/index.d.cts +13 -0
- package/dist/fhe-airdrop/advanced/index.d.ts +13 -0
- package/dist/fhe-airdrop/advanced/index.js +8 -0
- package/dist/fhe-airdrop/advanced/react/index.cjs +61 -0
- package/dist/fhe-airdrop/advanced/react/index.d.cts +5 -0
- package/dist/fhe-airdrop/advanced/react/index.d.ts +5 -0
- package/dist/fhe-airdrop/advanced/react/index.js +59 -0
- package/dist/fhe-airdrop/advanced/react/usePredictAirdropAddress.d.ts +49 -0
- package/dist/fhe-airdrop/airdrop.d.ts +308 -0
- package/dist/fhe-airdrop/encryption.d.ts +109 -0
- package/dist/fhe-airdrop/errors.d.ts +60 -0
- package/dist/fhe-airdrop/factory.d.ts +281 -0
- package/dist/fhe-airdrop/index.cjs +227 -0
- package/dist/fhe-airdrop/index.d.cts +10 -0
- package/dist/fhe-airdrop/index.d.ts +10 -0
- package/dist/fhe-airdrop/index.js +10 -0
- package/dist/fhe-airdrop/react/_shared.d.ts +107 -0
- package/dist/fhe-airdrop/react/index.cjs +638 -0
- package/dist/fhe-airdrop/react/index.d.cts +90 -0
- package/dist/fhe-airdrop/react/index.d.ts +90 -0
- package/dist/fhe-airdrop/react/index.js +430 -0
- package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +31 -0
- package/dist/fhe-airdrop/react/useAirdropCanExtendClaimWindow.d.ts +7 -0
- package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +25 -0
- package/dist/fhe-airdrop/react/useAirdropClaimTypehash.d.ts +10 -0
- package/dist/fhe-airdrop/react/useAirdropClaimedSignatures.d.ts +16 -0
- package/dist/fhe-airdrop/react/useAirdropDeploymentBlockNumber.d.ts +6 -0
- package/dist/fhe-airdrop/react/useAirdropDomainSeparator.d.ts +8 -0
- package/dist/fhe-airdrop/react/useAirdropEndTime.d.ts +10 -0
- package/dist/fhe-airdrop/react/useAirdropFactoryCustomFee.d.ts +17 -0
- package/dist/fhe-airdrop/react/useAirdropFactoryDefaultGasFee.d.ts +10 -0
- package/dist/fhe-airdrop/react/useAirdropFactoryDisableCustomFee.d.ts +15 -0
- package/dist/fhe-airdrop/react/useAirdropFactoryFeeCollector.d.ts +11 -0
- package/dist/fhe-airdrop/react/useAirdropFactoryInitCodeHash.d.ts +17 -0
- package/dist/fhe-airdrop/react/useAirdropFactorySetCustomFee.d.ts +17 -0
- package/dist/fhe-airdrop/react/useAirdropFactorySetDefaultGasFee.d.ts +16 -0
- package/dist/fhe-airdrop/react/useAirdropFactorySetFeeCollector.d.ts +15 -0
- package/dist/fhe-airdrop/react/useAirdropGasFee.d.ts +11 -0
- package/dist/fhe-airdrop/react/useAirdropGrantRole.d.ts +16 -0
- package/dist/fhe-airdrop/react/useAirdropHasClaimEnded.d.ts +7 -0
- package/dist/fhe-airdrop/react/useAirdropHasClaimStarted.d.ts +7 -0
- package/dist/fhe-airdrop/react/useAirdropHasRole.d.ts +14 -0
- package/dist/fhe-airdrop/react/useAirdropIsClaimWindowActive.d.ts +9 -0
- package/dist/fhe-airdrop/react/useAirdropIsPaused.d.ts +8 -0
- package/dist/fhe-airdrop/react/useAirdropIsSignatureClaimed.d.ts +22 -0
- package/dist/fhe-airdrop/react/useAirdropIsSignatureValid.d.ts +50 -0
- package/dist/fhe-airdrop/react/useAirdropRevokeRole.d.ts +15 -0
- package/dist/fhe-airdrop/react/useAirdropStartTime.d.ts +10 -0
- package/dist/fhe-airdrop/react/useAirdropToken.d.ts +11 -0
- package/dist/fhe-airdrop/react/useAirdropWithdrawGasFee.d.ts +15 -0
- package/dist/fhe-airdrop/react/useAirdropWithdrawOtherConfidentialToken.d.ts +14 -0
- package/dist/fhe-airdrop/react/useAirdropWithdrawOtherToken.d.ts +14 -0
- package/dist/fhe-airdrop/react/useClaim.d.ts +29 -0
- package/dist/fhe-airdrop/react/useConfidentialAirdropFactoryImplementation.d.ts +11 -0
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +33 -0
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +40 -0
- package/dist/fhe-airdrop/react/useCreateConfidentialAirdrop.d.ts +29 -0
- package/dist/fhe-airdrop/react/useCreateConfidentialAirdropAndGetAddress.d.ts +31 -0
- package/dist/fhe-airdrop/react/useDisableCustomFee.d.ts +14 -0
- package/dist/fhe-airdrop/react/useExtendClaimWindow.d.ts +16 -0
- package/dist/fhe-airdrop/react/useFactoryCustomFee.d.ts +17 -0
- package/dist/fhe-airdrop/react/useFactoryDefaultGasFee.d.ts +10 -0
- package/dist/fhe-airdrop/react/useFactoryFeeCollector.d.ts +11 -0
- package/dist/fhe-airdrop/react/useFactoryInitCodeHash.d.ts +17 -0
- package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +25 -0
- package/dist/fhe-airdrop/react/useGetClaimAmount.d.ts +30 -0
- package/dist/fhe-airdrop/react/useSetCustomFee.d.ts +16 -0
- package/dist/fhe-airdrop/react/useSetDefaultGasFee.d.ts +15 -0
- package/dist/fhe-airdrop/react/useSetFeeCollector.d.ts +14 -0
- package/dist/fhe-airdrop/react/useSetPaused.d.ts +14 -0
- package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +31 -0
- package/dist/fhe-airdrop/react/useWithdraw.d.ts +12 -0
- package/dist/fhe-airdrop/react/useWithdrawOtherConfidentialToken.d.ts +13 -0
- package/dist/fhe-airdrop/react/useWithdrawOtherToken.d.ts +13 -0
- package/dist/fhe-airdrop/types.d.ts +21 -0
- package/dist/fhe-disperse/abis/index.d.ts +2 -0
- package/dist/fhe-disperse/abis/singleton.d.ts +1297 -0
- package/dist/fhe-disperse/abis/wallet.d.ts +111 -0
- package/dist/fhe-disperse/encryption.d.ts +77 -0
- package/dist/fhe-disperse/errors.d.ts +39 -0
- package/dist/fhe-disperse/index.cjs +248 -0
- package/dist/fhe-disperse/index.d.cts +14 -0
- package/dist/fhe-disperse/index.d.ts +14 -0
- package/dist/fhe-disperse/index.js +11 -0
- package/dist/fhe-disperse/react/_shared.d.ts +104 -0
- package/dist/fhe-disperse/react/index.cjs +752 -0
- package/dist/fhe-disperse/react/index.d.cts +82 -0
- package/dist/fhe-disperse/react/index.d.ts +82 -0
- package/dist/fhe-disperse/react/index.js +522 -0
- package/dist/fhe-disperse/react/useAccessEncryptedFeeReserve.d.ts +35 -0
- package/dist/fhe-disperse/react/useApproveTokenOnWallets.d.ts +25 -0
- package/dist/fhe-disperse/react/useBatchDiscloseHandlesToParty.d.ts +16 -0
- package/dist/fhe-disperse/react/useCalculateFee.d.ts +26 -0
- package/dist/fhe-disperse/react/useDeploymentBlockNumber.d.ts +11 -0
- package/dist/fhe-disperse/react/useDisableCustomFee.d.ts +20 -0
- package/dist/fhe-disperse/react/useDiscloseHandleToParty.d.ts +20 -0
- package/dist/fhe-disperse/react/useDisperse.d.ts +28 -0
- package/dist/fhe-disperse/react/useGetBatchLimits.d.ts +12 -0
- package/dist/fhe-disperse/react/useGetFeeConfig.d.ts +15 -0
- package/dist/fhe-disperse/react/useGetFees.d.ts +19 -0
- package/dist/fhe-disperse/react/useGetWallets.d.ts +19 -0
- package/dist/fhe-disperse/react/useGrantRole.d.ts +24 -0
- package/dist/fhe-disperse/react/useHasApprovedSubwallets.d.ts +25 -0
- package/dist/fhe-disperse/react/useHasRole.d.ts +22 -0
- package/dist/fhe-disperse/react/useIsPaused.d.ts +11 -0
- package/dist/fhe-disperse/react/useIsRegistered.d.ts +15 -0
- package/dist/fhe-disperse/react/usePause.d.ts +18 -0
- package/dist/fhe-disperse/react/usePredictWallets.d.ts +19 -0
- package/dist/fhe-disperse/react/usePreflightDisperse.d.ts +37 -0
- package/dist/fhe-disperse/react/useRecoverERC20FromWallets.d.ts +21 -0
- package/dist/fhe-disperse/react/useRecoverFromWallets.d.ts +21 -0
- package/dist/fhe-disperse/react/useRegister.d.ts +40 -0
- package/dist/fhe-disperse/react/useRescueConfidentialTokens.d.ts +21 -0
- package/dist/fhe-disperse/react/useRescueERC20.d.ts +21 -0
- package/dist/fhe-disperse/react/useRevokeRole.d.ts +24 -0
- package/dist/fhe-disperse/react/useRevokeTokenOnWallets.d.ts +24 -0
- package/dist/fhe-disperse/react/useSetCustomFee.d.ts +24 -0
- package/dist/fhe-disperse/react/useSetFeeConfig.d.ts +23 -0
- package/dist/fhe-disperse/react/useSetMaxBatchSizeDirect.d.ts +20 -0
- package/dist/fhe-disperse/react/useSetMaxBatchSizeHolding.d.ts +20 -0
- package/dist/fhe-disperse/react/useSetMaxBatchSizeTokenFee.d.ts +20 -0
- package/dist/fhe-disperse/react/useSingletonBatchDiscloseHandlesToParty.d.ts +13 -0
- package/dist/fhe-disperse/react/useSingletonBatchLimits.d.ts +12 -0
- package/dist/fhe-disperse/react/useSingletonCalculateFee.d.ts +26 -0
- package/dist/fhe-disperse/react/useSingletonDeploymentBlockNumber.d.ts +11 -0
- package/dist/fhe-disperse/react/useSingletonDisableCustomFee.d.ts +21 -0
- package/dist/fhe-disperse/react/useSingletonDiscloseHandleToParty.d.ts +17 -0
- package/dist/fhe-disperse/react/useSingletonFees.d.ts +19 -0
- package/dist/fhe-disperse/react/useSingletonGrantRole.d.ts +26 -0
- package/dist/fhe-disperse/react/useSingletonHasApprovedSubwallets.d.ts +25 -0
- package/dist/fhe-disperse/react/useSingletonHasRole.d.ts +23 -0
- package/dist/fhe-disperse/react/useSingletonIsPaused.d.ts +11 -0
- package/dist/fhe-disperse/react/useSingletonIsRegistered.d.ts +15 -0
- package/dist/fhe-disperse/react/useSingletonPause.d.ts +19 -0
- package/dist/fhe-disperse/react/useSingletonPredictWallets.d.ts +19 -0
- package/dist/fhe-disperse/react/useSingletonRevokeRole.d.ts +26 -0
- package/dist/fhe-disperse/react/useSingletonSetCustomFee.d.ts +25 -0
- package/dist/fhe-disperse/react/useSingletonUnpause.d.ts +18 -0
- package/dist/fhe-disperse/react/useSingletonWalletImplementation.d.ts +12 -0
- package/dist/fhe-disperse/react/useSingletonWallets.d.ts +19 -0
- package/dist/fhe-disperse/react/useSingletonWithdrawGasFee.d.ts +21 -0
- package/dist/fhe-disperse/react/useSingletonWithdrawTokenFee.d.ts +50 -0
- package/dist/fhe-disperse/react/useUnpause.d.ts +17 -0
- package/dist/fhe-disperse/react/useWalletImplementation.d.ts +12 -0
- package/dist/fhe-disperse/react/useWithdrawGasFee.d.ts +26 -0
- package/dist/fhe-disperse/react/useWithdrawTokenFee.d.ts +70 -0
- package/dist/fhe-disperse/singleton.d.ts +442 -0
- package/dist/fhe-disperse/subtotals.d.ts +14 -0
- package/dist/fhe-disperse/types.d.ts +332 -0
- package/dist/fhe-disperse/validate.d.ts +78 -0
- package/dist/fhe-vesting/abis/factory.d.ts +676 -0
- package/dist/fhe-vesting/abis/index.d.ts +3 -0
- package/dist/fhe-vesting/abis/manager.d.ts +1797 -0
- package/dist/fhe-vesting/advanced/factory-advanced.d.ts +52 -0
- package/dist/fhe-vesting/advanced/index.cjs +21 -0
- package/dist/fhe-vesting/advanced/index.d.cts +12 -0
- package/dist/fhe-vesting/advanced/index.d.ts +12 -0
- package/dist/fhe-vesting/advanced/index.js +8 -0
- package/dist/fhe-vesting/advanced/react/index.cjs +75 -0
- package/dist/fhe-vesting/advanced/react/index.d.cts +5 -0
- package/dist/fhe-vesting/advanced/react/index.d.ts +5 -0
- package/dist/fhe-vesting/advanced/react/index.js +73 -0
- package/dist/fhe-vesting/advanced/react/usePredictManagerAddress.d.ts +41 -0
- package/dist/fhe-vesting/encryption.d.ts +104 -0
- package/dist/fhe-vesting/errors.d.ts +183 -0
- package/dist/fhe-vesting/factory.d.ts +207 -0
- package/dist/fhe-vesting/index.cjs +269 -0
- package/dist/fhe-vesting/index.d.cts +9 -0
- package/dist/fhe-vesting/index.d.ts +9 -0
- package/dist/fhe-vesting/index.js +12 -0
- package/dist/fhe-vesting/manager.d.ts +808 -0
- package/dist/fhe-vesting/react/_shared.d.ts +122 -0
- package/dist/fhe-vesting/react/index.cjs +1054 -0
- package/dist/fhe-vesting/react/index.d.cts +123 -0
- package/dist/fhe-vesting/react/index.d.ts +123 -0
- package/dist/fhe-vesting/react/index.js +771 -0
- package/dist/fhe-vesting/react/useAcceptVestingTransfer.d.ts +12 -0
- package/dist/fhe-vesting/react/useAccessClaimableAmount.d.ts +14 -0
- package/dist/fhe-vesting/react/useAccessSettledAmount.d.ts +15 -0
- package/dist/fhe-vesting/react/useAccessTotalAllocation.d.ts +14 -0
- package/dist/fhe-vesting/react/useAccessVestedAmount.d.ts +26 -0
- package/dist/fhe-vesting/react/useAdminBatchDiscloseToParty.d.ts +16 -0
- package/dist/fhe-vesting/react/useAdminClaim.d.ts +9 -0
- package/dist/fhe-vesting/react/useAdminDiscloseToParty.d.ts +8 -0
- package/dist/fhe-vesting/react/useAdminGetClaimableAmount.d.ts +13 -0
- package/dist/fhe-vesting/react/useAdminGetSettledAmount.d.ts +13 -0
- package/dist/fhe-vesting/react/useAdminGetTokenBalance.d.ts +13 -0
- package/dist/fhe-vesting/react/useAdminGetTotalAllocation.d.ts +13 -0
- package/dist/fhe-vesting/react/useAdminGetVestedAmount.d.ts +15 -0
- package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +8 -0
- package/dist/fhe-vesting/react/useAllRecipients.d.ts +8 -0
- package/dist/fhe-vesting/react/useAllRecipientsLength.d.ts +6 -0
- package/dist/fhe-vesting/react/useAllRecipientsSliced.d.ts +13 -0
- package/dist/fhe-vesting/react/useBatchCreateVesting.d.ts +24 -0
- package/dist/fhe-vesting/react/useBatchDiscloseHandlesToParty.d.ts +13 -0
- package/dist/fhe-vesting/react/useBatchDiscloseToParty.d.ts +18 -0
- package/dist/fhe-vesting/react/useBatchRevokeVesting.d.ts +12 -0
- package/dist/fhe-vesting/react/useCancelVestingTransfer.d.ts +12 -0
- package/dist/fhe-vesting/react/useClaim.d.ts +19 -0
- package/dist/fhe-vesting/react/useConfidentialVestingFactoryImplementation.d.ts +11 -0
- package/dist/fhe-vesting/react/useCreateManager.d.ts +32 -0
- package/dist/fhe-vesting/react/useCreateManagerAndGetAddress.d.ts +31 -0
- package/dist/fhe-vesting/react/useCreateVesting.d.ts +38 -0
- package/dist/fhe-vesting/react/useDirectVestingTransfer.d.ts +13 -0
- package/dist/fhe-vesting/react/useDisableCustomFee.d.ts +14 -0
- package/dist/fhe-vesting/react/useDiscloseHandleToParty.d.ts +14 -0
- package/dist/fhe-vesting/react/useDiscloseToParty.d.ts +14 -0
- package/dist/fhe-vesting/react/useFactoryCustomFee.d.ts +17 -0
- package/dist/fhe-vesting/react/useFactoryDefaultFeeType.d.ts +11 -0
- package/dist/fhe-vesting/react/useFactoryDefaultGasFee.d.ts +10 -0
- package/dist/fhe-vesting/react/useFactoryDefaultTokenFee.d.ts +10 -0
- package/dist/fhe-vesting/react/useFactoryFeeCollector.d.ts +10 -0
- package/dist/fhe-vesting/react/useFactoryInitCodeHash.d.ts +18 -0
- package/dist/fhe-vesting/react/useGetClaimableAmount.d.ts +13 -0
- package/dist/fhe-vesting/react/useGetSettledAmount.d.ts +14 -0
- package/dist/fhe-vesting/react/useGetTotalAllocation.d.ts +13 -0
- package/dist/fhe-vesting/react/useGetVestedAmount.d.ts +25 -0
- package/dist/fhe-vesting/react/useGrantRole.d.ts +15 -0
- package/dist/fhe-vesting/react/useHasRole.d.ts +14 -0
- package/dist/fhe-vesting/react/useInitiateVestingTransfer.d.ts +12 -0
- package/dist/fhe-vesting/react/useIsRecipient.d.ts +10 -0
- package/dist/fhe-vesting/react/useManagerBatchDiscloseHandlesToParty.d.ts +15 -0
- package/dist/fhe-vesting/react/useManagerDeploymentBlockNumber.d.ts +7 -0
- package/dist/fhe-vesting/react/useManagerDiscloseHandleToParty.d.ts +16 -0
- package/dist/fhe-vesting/react/useManagerFactoryCustomFee.d.ts +17 -0
- package/dist/fhe-vesting/react/useManagerFactoryDefaultGasFee.d.ts +10 -0
- package/dist/fhe-vesting/react/useManagerFactoryDisableCustomFee.d.ts +15 -0
- package/dist/fhe-vesting/react/useManagerFactoryFeeCollector.d.ts +10 -0
- package/dist/fhe-vesting/react/useManagerFactoryInitCodeHash.d.ts +18 -0
- package/dist/fhe-vesting/react/useManagerFactorySetCustomFee.d.ts +19 -0
- package/dist/fhe-vesting/react/useManagerFactorySetDefaultGasFee.d.ts +13 -0
- package/dist/fhe-vesting/react/useManagerFactorySetFeeCollector.d.ts +14 -0
- package/dist/fhe-vesting/react/useManagerFee.d.ts +7 -0
- package/dist/fhe-vesting/react/useManagerFeeInfo.d.ts +18 -0
- package/dist/fhe-vesting/react/useManagerFeeType.d.ts +7 -0
- package/dist/fhe-vesting/react/useManagerGrantRole.d.ts +17 -0
- package/dist/fhe-vesting/react/useManagerHasRole.d.ts +15 -0
- package/dist/fhe-vesting/react/useManagerIsPausable.d.ts +6 -0
- package/dist/fhe-vesting/react/useManagerIsSplitEnabled.d.ts +6 -0
- package/dist/fhe-vesting/react/useManagerMaxBatchSize.d.ts +6 -0
- package/dist/fhe-vesting/react/useManagerMaxRevokeBatchSize.d.ts +6 -0
- package/dist/fhe-vesting/react/useManagerPause.d.ts +13 -0
- package/dist/fhe-vesting/react/useManagerPaused.d.ts +6 -0
- package/dist/fhe-vesting/react/useManagerRevokeRole.d.ts +17 -0
- package/dist/fhe-vesting/react/useManagerToken.d.ts +11 -0
- package/dist/fhe-vesting/react/useManagerUnpause.d.ts +12 -0
- package/dist/fhe-vesting/react/useManagerWithdrawGasFee.d.ts +14 -0
- package/dist/fhe-vesting/react/useManagerWithdrawOtherConfidentialToken.d.ts +14 -0
- package/dist/fhe-vesting/react/useManagerWithdrawOtherToken.d.ts +14 -0
- package/dist/fhe-vesting/react/useManagerWithdrawTokenFee.d.ts +11 -0
- package/dist/fhe-vesting/react/usePartialClaim.d.ts +15 -0
- package/dist/fhe-vesting/react/usePause.d.ts +12 -0
- package/dist/fhe-vesting/react/usePendingVestingTransfer.d.ts +20 -0
- package/dist/fhe-vesting/react/useRecipientVestings.d.ts +11 -0
- package/dist/fhe-vesting/react/useRecipientVestingsLength.d.ts +10 -0
- package/dist/fhe-vesting/react/useRecipientVestingsSliced.d.ts +12 -0
- package/dist/fhe-vesting/react/useRenounceRole.d.ts +16 -0
- package/dist/fhe-vesting/react/useResetGasFee.d.ts +10 -0
- package/dist/fhe-vesting/react/useResetTokenFee.d.ts +10 -0
- package/dist/fhe-vesting/react/useRevokeRole.d.ts +15 -0
- package/dist/fhe-vesting/react/useRevokeVesting.d.ts +15 -0
- package/dist/fhe-vesting/react/useRoleConstants.d.ts +19 -0
- package/dist/fhe-vesting/react/useSetCustomFee.d.ts +18 -0
- package/dist/fhe-vesting/react/useSetDefaultFeeType.d.ts +14 -0
- package/dist/fhe-vesting/react/useSetDefaultGasFee.d.ts +12 -0
- package/dist/fhe-vesting/react/useSetDefaultTokenFee.d.ts +13 -0
- package/dist/fhe-vesting/react/useSetFeeCollector.d.ts +13 -0
- package/dist/fhe-vesting/react/useSetMaxBatchSize.d.ts +12 -0
- package/dist/fhe-vesting/react/useSetMaxRevokeBatchSize.d.ts +12 -0
- package/dist/fhe-vesting/react/useSplitVesting.d.ts +28 -0
- package/dist/fhe-vesting/react/useTransferFeeCollectorRole.d.ts +12 -0
- package/dist/fhe-vesting/react/useUnpause.d.ts +11 -0
- package/dist/fhe-vesting/react/useVestingClaim.d.ts +19 -0
- package/dist/fhe-vesting/react/useVestingInfo.d.ts +25 -0
- package/dist/fhe-vesting/react/useWithdrawAdmin.d.ts +17 -0
- package/dist/fhe-vesting/react/useWithdrawGasFee.d.ts +13 -0
- package/dist/fhe-vesting/react/useWithdrawOtherConfidentialToken.d.ts +13 -0
- package/dist/fhe-vesting/react/useWithdrawOtherToken.d.ts +13 -0
- package/dist/fhe-vesting/react/useWithdrawTokenFee.d.ts +18 -0
- package/dist/fhe-vesting/types.d.ts +72 -0
- package/dist/index.cjs +237 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +14 -0
- package/dist/telemetry/console.d.ts +29 -0
- package/dist/telemetry/index.cjs +113 -0
- package/dist/telemetry/index.d.cts +3 -0
- package/dist/telemetry/index.d.ts +3 -0
- package/dist/telemetry/index.js +102 -0
- package/dist/telemetry/tokenops.d.ts +15 -0
- package/package.json +316 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
export { ERC7984_OPERATOR_MAX_DEADLINE, ERC7984_SET_OPERATOR_ABI, revokeOperator, setOperator } from '../chunk-WRCUDSUJ.js';
|
|
2
|
+
export { erc7984OperatorAbi } from '../chunk-7VELUOMI.js';
|
|
3
|
+
export { FHE_SPLIT_DENOMINATOR, scaleRatio, share } from '../chunk-XSNLAS5M.js';
|
|
4
|
+
export { ACL_ALLOWED_EVENT, FHEVM_ACL_ADDRESS_BY_CHAIN, getFhevmAclAddress, requireFhevmAclAddress } from '../chunk-FYQ2UW4T.js';
|
|
5
|
+
import { normaliseAddress } from '../chunk-BE2AIZ3K.js';
|
|
6
|
+
import { withTelemetry } from '../chunk-Q2GP5UDC.js';
|
|
7
|
+
import { TokenOpsContractError } from '../chunk-IVE3QEGD.js';
|
|
8
|
+
export { AccessDeniedError, AlreadyInitializedError, BatchTooLargeError, ContractRevertError, DecryptionFailedError, DeploymentAddressUnavailableError, EncryptionFailedError, FeatureDisabledError, FheHandleNotAllowedError, InsufficientBalanceError, InsufficientFeeError, InsufficientGasFundsError, InvalidArgumentError, InvalidSignatureError, MissingAccountError, MissingClientError, MissingEncryptorError, MissingPublicClientError, MissingWalletClientError, NetworkError, PausedError, ReceiptEventAmbiguousError, ReceiptEventNotFoundError, ReentrancyError, RelayerUnreachableError, SigningFailedError, TokenOpsContractError, TokenOpsSdkError, TokenOpsValidationError, TransferFailedError, UnknownWriteFailureError, UnsupportedChainError, UserDecryptNotAllowedError, UserRejectedSignatureError, WalletChainMismatchError, WalletRejectedError, isTokenOpsSdkError } from '../chunk-IVE3QEGD.js';
|
|
9
|
+
import { RelayerWeb, MainnetConfig, SepoliaConfig } from '@zama-fhe/sdk';
|
|
10
|
+
|
|
11
|
+
// src/fhe/mock-encryptor.ts
|
|
12
|
+
var FHEVM_HANDLE_VERSION = 0;
|
|
13
|
+
var FHEVM_EXECUTOR_ADDRESS_LOCAL = "0xe3a9105a3a932253A70F126eb1E3b589C643dD24";
|
|
14
|
+
var COPROCESSOR_SIGNER_PRIVATE_KEY_LOCAL = "0x7ec8ada6642fc4ccfb7729bc29c17cf8d21b61abd5642d1db992c0b8672ab901";
|
|
15
|
+
async function requirePeerDep(spec, hint) {
|
|
16
|
+
try {
|
|
17
|
+
return await import(
|
|
18
|
+
/* webpackIgnore: true */
|
|
19
|
+
spec
|
|
20
|
+
);
|
|
21
|
+
} catch (err) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`@tokenops/sdk: peer dependency "${spec}" is required for createMockEncryptor.
|
|
24
|
+
install it with: ${hint}
|
|
25
|
+
underlying error: ${String(err)}`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async function createMockRelayerProvider(mockUtils, ethers, opts) {
|
|
30
|
+
const provider = new ethers.JsonRpcProvider(opts.rpcUrl);
|
|
31
|
+
const signer = new ethers.Wallet(opts.coprocessorSignerPrivateKey, provider);
|
|
32
|
+
const db = new mockUtils.FhevmDBMap();
|
|
33
|
+
const head = await provider.getBlockNumber();
|
|
34
|
+
await db.init(head);
|
|
35
|
+
const coprocessor = await mockUtils.MockCoprocessor.create(provider, {
|
|
36
|
+
coprocessorContractAddress: opts.fhevmExecutorContractAddress,
|
|
37
|
+
coprocessorSigners: [signer],
|
|
38
|
+
inputVerifierContractAddress: opts.inputVerifierContractAddress,
|
|
39
|
+
db
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
provider,
|
|
43
|
+
async send(method, params) {
|
|
44
|
+
switch (method) {
|
|
45
|
+
case mockUtils.relayer.RELAYER_V1_INPUT_PROOF: {
|
|
46
|
+
const payload = params[0];
|
|
47
|
+
mockUtils.relayer.assertIsMockRelayerV1InputProofPayload(payload);
|
|
48
|
+
const contractChainId = Number(payload.contractChainId);
|
|
49
|
+
if (opts.aclContractAddress.toLowerCase() !== payload.mockData.aclContractAddress.toLowerCase()) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`createMockEncryptor: ACL mismatch: expected ${opts.aclContractAddress}, got ${payload.mockData.aclContractAddress}`
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
const handlesBytes32List = mockUtils.FhevmHandle.computeHandles(
|
|
55
|
+
ethers.getBytes(payload.ciphertextWithInputVerification),
|
|
56
|
+
payload.mockData.fhevmTypes,
|
|
57
|
+
payload.mockData.aclContractAddress,
|
|
58
|
+
contractChainId,
|
|
59
|
+
FHEVM_HANDLE_VERSION
|
|
60
|
+
);
|
|
61
|
+
const response = await coprocessor.computeCoprocessorSignatures(
|
|
62
|
+
handlesBytes32List,
|
|
63
|
+
contractChainId,
|
|
64
|
+
payload.contractAddress,
|
|
65
|
+
payload.userAddress,
|
|
66
|
+
payload.extraData
|
|
67
|
+
);
|
|
68
|
+
for (let i = 0; i < response.handles.length; i++) {
|
|
69
|
+
const raw = response.handles[i] ?? "";
|
|
70
|
+
const handleHex = raw.startsWith("0x") ? raw : `0x${raw}`;
|
|
71
|
+
const cleartext = payload.mockData.clearTextValuesBigIntHex[i] ?? "0x0";
|
|
72
|
+
const meta = payload.mockData.metadatas[i];
|
|
73
|
+
await coprocessor.insertHandleBytes32(handleHex, cleartext, meta);
|
|
74
|
+
}
|
|
75
|
+
return response;
|
|
76
|
+
}
|
|
77
|
+
case mockUtils.relayer.RELAYER_V1_USER_DECRYPT: {
|
|
78
|
+
const payload = params[0];
|
|
79
|
+
mockUtils.relayer.assertIsRelayerV1UserDecryptPayload(payload);
|
|
80
|
+
await coprocessor.awaitCoprocessor();
|
|
81
|
+
await mockUtils.MockFhevmInstance.verifyUserACLPermissions(
|
|
82
|
+
provider,
|
|
83
|
+
opts.aclContractAddress,
|
|
84
|
+
payload.handleContractPairs,
|
|
85
|
+
payload.userAddress
|
|
86
|
+
);
|
|
87
|
+
await mockUtils.MockFhevmInstance.verifyUserDecryptSignature(
|
|
88
|
+
payload.publicKey,
|
|
89
|
+
payload.signature,
|
|
90
|
+
payload.contractAddresses,
|
|
91
|
+
payload.userAddress,
|
|
92
|
+
Number(payload.requestValidity.startTimestamp),
|
|
93
|
+
Number(payload.requestValidity.durationDays),
|
|
94
|
+
opts.verifyingContractAddressDecryption,
|
|
95
|
+
Number(payload.contractsChainId)
|
|
96
|
+
);
|
|
97
|
+
const handleBytes32HexList = payload.handleContractPairs.map(
|
|
98
|
+
(h) => ethers.toBeHex(ethers.toBigInt(h.handle), 32)
|
|
99
|
+
);
|
|
100
|
+
const clearTextHexList = await coprocessor.queryHandlesBytes32AsHex(handleBytes32HexList);
|
|
101
|
+
return {
|
|
102
|
+
payload: { decrypted_values: clearTextHexList },
|
|
103
|
+
signature: ethers.ZeroHash
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
default:
|
|
107
|
+
return provider.send(method, params);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
async function createMockEncryptor(options = {}) {
|
|
113
|
+
const rpcUrl = options.rpcUrl ?? "http://127.0.0.1:8545";
|
|
114
|
+
const chainId = options.chainId ?? 31337;
|
|
115
|
+
const mockUtils = await requirePeerDep(
|
|
116
|
+
"@fhevm/mock-utils",
|
|
117
|
+
"pnpm add -D @fhevm/mock-utils"
|
|
118
|
+
);
|
|
119
|
+
const zamaSdk = await requirePeerDep(
|
|
120
|
+
"@zama-fhe/sdk",
|
|
121
|
+
"pnpm add @zama-fhe/sdk@^3"
|
|
122
|
+
);
|
|
123
|
+
const ethers = await requirePeerDep(
|
|
124
|
+
"ethers",
|
|
125
|
+
"pnpm add ethers@^6 (peer dep of @fhevm/mock-utils)"
|
|
126
|
+
);
|
|
127
|
+
const HardhatConfig = zamaSdk.HardhatConfig;
|
|
128
|
+
const hostAddresses = {
|
|
129
|
+
aclContractAddress: options.hostAddresses?.aclContractAddress ?? HardhatConfig.aclContractAddress,
|
|
130
|
+
inputVerifierContractAddress: options.hostAddresses?.inputVerifierContractAddress ?? HardhatConfig.inputVerifierContractAddress,
|
|
131
|
+
kmsContractAddress: options.hostAddresses?.kmsContractAddress ?? HardhatConfig.kmsContractAddress,
|
|
132
|
+
verifyingContractAddressDecryption: options.hostAddresses?.verifyingContractAddressDecryption ?? HardhatConfig.verifyingContractAddressDecryption,
|
|
133
|
+
verifyingContractAddressInputVerification: options.hostAddresses?.verifyingContractAddressInputVerification ?? HardhatConfig.verifyingContractAddressInputVerification,
|
|
134
|
+
fhevmExecutorContractAddress: options.hostAddresses?.fhevmExecutorContractAddress ?? FHEVM_EXECUTOR_ADDRESS_LOCAL,
|
|
135
|
+
gatewayChainId: options.hostAddresses?.gatewayChainId ?? HardhatConfig.gatewayChainId
|
|
136
|
+
};
|
|
137
|
+
const relayer = await createMockRelayerProvider(mockUtils, ethers, {
|
|
138
|
+
rpcUrl,
|
|
139
|
+
aclContractAddress: hostAddresses.aclContractAddress,
|
|
140
|
+
inputVerifierContractAddress: hostAddresses.inputVerifierContractAddress,
|
|
141
|
+
verifyingContractAddressDecryption: hostAddresses.verifyingContractAddressDecryption,
|
|
142
|
+
fhevmExecutorContractAddress: hostAddresses.fhevmExecutorContractAddress,
|
|
143
|
+
coprocessorSignerPrivateKey: options.coprocessorSignerPrivateKey ?? COPROCESSOR_SIGNER_PRIVATE_KEY_LOCAL
|
|
144
|
+
});
|
|
145
|
+
const instance = await mockUtils.MockFhevmInstance.create(
|
|
146
|
+
relayer,
|
|
147
|
+
relayer.provider,
|
|
148
|
+
{
|
|
149
|
+
aclContractAddress: hostAddresses.aclContractAddress,
|
|
150
|
+
inputVerifierContractAddress: hostAddresses.inputVerifierContractAddress,
|
|
151
|
+
kmsContractAddress: hostAddresses.kmsContractAddress,
|
|
152
|
+
verifyingContractAddressDecryption: hostAddresses.verifyingContractAddressDecryption,
|
|
153
|
+
verifyingContractAddressInputVerification: hostAddresses.verifyingContractAddressInputVerification,
|
|
154
|
+
chainId,
|
|
155
|
+
gatewayChainId: hostAddresses.gatewayChainId
|
|
156
|
+
},
|
|
157
|
+
{ inputVerifierProperties: {}, kmsVerifierProperties: {} }
|
|
158
|
+
);
|
|
159
|
+
return {
|
|
160
|
+
instance,
|
|
161
|
+
chainId,
|
|
162
|
+
async encrypt({ values, contractAddress, userAddress }) {
|
|
163
|
+
const input = instance.createEncryptedInput(contractAddress, userAddress);
|
|
164
|
+
for (const v of values) {
|
|
165
|
+
addValue(input, v);
|
|
166
|
+
}
|
|
167
|
+
return input.encrypt();
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function addValue(input, v) {
|
|
172
|
+
switch (v.type) {
|
|
173
|
+
case "euint8":
|
|
174
|
+
input.add8(v.value);
|
|
175
|
+
return;
|
|
176
|
+
case "euint16":
|
|
177
|
+
input.add16(v.value);
|
|
178
|
+
return;
|
|
179
|
+
case "euint32":
|
|
180
|
+
input.add32(v.value);
|
|
181
|
+
return;
|
|
182
|
+
case "euint64":
|
|
183
|
+
input.add64(v.value);
|
|
184
|
+
return;
|
|
185
|
+
case "euint128":
|
|
186
|
+
input.add128(v.value);
|
|
187
|
+
return;
|
|
188
|
+
case "ebool":
|
|
189
|
+
input.addBool(v.value);
|
|
190
|
+
return;
|
|
191
|
+
case "eaddress":
|
|
192
|
+
input.addAddress(v.value);
|
|
193
|
+
return;
|
|
194
|
+
default:
|
|
195
|
+
throw new Error(
|
|
196
|
+
`createMockEncryptor: unsupported FHE type "${v.type}"`
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
var createLocalFhevmEncryptor = createMockEncryptor;
|
|
201
|
+
|
|
202
|
+
// src/fhe/mock-erc7984.ts
|
|
203
|
+
var MOCK_ERC7984_MINT_ABI = [
|
|
204
|
+
{
|
|
205
|
+
type: "function",
|
|
206
|
+
name: "mint",
|
|
207
|
+
stateMutability: "nonpayable",
|
|
208
|
+
inputs: [
|
|
209
|
+
{ name: "to", type: "address" },
|
|
210
|
+
{ name: "amount", type: "uint64" }
|
|
211
|
+
],
|
|
212
|
+
outputs: []
|
|
213
|
+
}
|
|
214
|
+
];
|
|
215
|
+
var UINT64_MAX = (1n << 64n) - 1n;
|
|
216
|
+
async function mintMockERC7984(args) {
|
|
217
|
+
const { publicClient, walletClient, account, waitForReceipt = true, telemetry } = args;
|
|
218
|
+
const token = normaliseAddress(args.token);
|
|
219
|
+
const to = normaliseAddress(args.to);
|
|
220
|
+
return withTelemetry(telemetry, "fhe.mintMockERC7984", async () => {
|
|
221
|
+
const fromAccount = account ?? walletClient.account;
|
|
222
|
+
if (!fromAccount) {
|
|
223
|
+
throw new TokenOpsContractError(
|
|
224
|
+
"mintMockERC7984: no account available \u2014 pass `account` explicitly or attach an account to the walletClient",
|
|
225
|
+
{ contract: "ERC7984", call: "mint" }
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
if (args.amount < 0n || args.amount > UINT64_MAX) {
|
|
229
|
+
throw new TokenOpsContractError(
|
|
230
|
+
`mintMockERC7984: amount ${args.amount} out of uint64 range [0, ${UINT64_MAX}]`,
|
|
231
|
+
{ contract: "ERC7984", call: "mint", amount: args.amount.toString() }
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
let hash;
|
|
235
|
+
try {
|
|
236
|
+
hash = await walletClient.writeContract({
|
|
237
|
+
address: token,
|
|
238
|
+
abi: MOCK_ERC7984_MINT_ABI,
|
|
239
|
+
functionName: "mint",
|
|
240
|
+
args: [to, args.amount],
|
|
241
|
+
account: fromAccount,
|
|
242
|
+
// viem requires `chain` to be passed explicitly when the wallet has
|
|
243
|
+
// no default chain. Forward whatever the wallet is bound to.
|
|
244
|
+
chain: walletClient.chain
|
|
245
|
+
});
|
|
246
|
+
} catch (err) {
|
|
247
|
+
throw new TokenOpsContractError(
|
|
248
|
+
`mintMockERC7984: writeContract failed (token=${token}, to=${to})`,
|
|
249
|
+
{
|
|
250
|
+
contract: "ERC7984",
|
|
251
|
+
call: "mint",
|
|
252
|
+
token,
|
|
253
|
+
to,
|
|
254
|
+
cause: err
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
let blockNumber = 0n;
|
|
259
|
+
if (waitForReceipt) {
|
|
260
|
+
try {
|
|
261
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash });
|
|
262
|
+
blockNumber = receipt.blockNumber;
|
|
263
|
+
} catch (err) {
|
|
264
|
+
throw new TokenOpsContractError(`mintMockERC7984: receipt wait failed (tx=${hash})`, {
|
|
265
|
+
contract: "ERC7984",
|
|
266
|
+
call: "mint",
|
|
267
|
+
tx: hash,
|
|
268
|
+
cause: err
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return { hash, blockNumber };
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
function createMockErc7984Client(args) {
|
|
276
|
+
const address = normaliseAddress(args.address);
|
|
277
|
+
const { publicClient, walletClient, telemetry } = args;
|
|
278
|
+
return {
|
|
279
|
+
address,
|
|
280
|
+
mint(callArgs) {
|
|
281
|
+
return mintMockERC7984({
|
|
282
|
+
publicClient,
|
|
283
|
+
walletClient,
|
|
284
|
+
token: address,
|
|
285
|
+
...telemetry !== void 0 ? { telemetry } : {},
|
|
286
|
+
...callArgs
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// src/fhe/sepolia-encryptor.ts
|
|
293
|
+
var SEPOLIA_CHAIN_ID = 11155111;
|
|
294
|
+
var MAINNET_CHAIN_ID = 1;
|
|
295
|
+
async function requirePeerDep2(spec, hint) {
|
|
296
|
+
try {
|
|
297
|
+
return await import(
|
|
298
|
+
/* webpackIgnore: true */
|
|
299
|
+
spec
|
|
300
|
+
);
|
|
301
|
+
} catch (err) {
|
|
302
|
+
throw new Error(
|
|
303
|
+
`@tokenops/sdk: peer dependency "${spec}" is required for createSepoliaEncryptor.
|
|
304
|
+
install it with: ${hint}
|
|
305
|
+
underlying error: ${String(err)}`
|
|
306
|
+
);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
async function createSepoliaEncryptor(options = {}) {
|
|
310
|
+
const chainId = options.chainId ?? SEPOLIA_CHAIN_ID;
|
|
311
|
+
const zamaSdkNode = await requirePeerDep2(
|
|
312
|
+
"@zama-fhe/sdk/node",
|
|
313
|
+
"pnpm add @zama-fhe/sdk@^3"
|
|
314
|
+
);
|
|
315
|
+
const baseConfig = chainId === MAINNET_CHAIN_ID ? zamaSdkNode.MainnetConfig : zamaSdkNode.SepoliaConfig;
|
|
316
|
+
const transportConfig = { ...baseConfig };
|
|
317
|
+
if (options.relayerUrl !== void 0) {
|
|
318
|
+
transportConfig.relayerUrl = options.relayerUrl;
|
|
319
|
+
}
|
|
320
|
+
const safeLogger = options.logger ? {
|
|
321
|
+
debug: () => {
|
|
322
|
+
},
|
|
323
|
+
info: () => {
|
|
324
|
+
},
|
|
325
|
+
warn: () => {
|
|
326
|
+
},
|
|
327
|
+
error: () => {
|
|
328
|
+
},
|
|
329
|
+
...options.logger
|
|
330
|
+
} : void 0;
|
|
331
|
+
const instance = new zamaSdkNode.RelayerNode({
|
|
332
|
+
transports: { [chainId]: transportConfig },
|
|
333
|
+
getChainId: () => Promise.resolve(chainId),
|
|
334
|
+
poolSize: options.poolSize,
|
|
335
|
+
logger: safeLogger,
|
|
336
|
+
fheArtifactStorage: options.fheArtifactStorage,
|
|
337
|
+
fheArtifactCacheTTL: options.fheArtifactCacheTTL
|
|
338
|
+
});
|
|
339
|
+
return {
|
|
340
|
+
instance,
|
|
341
|
+
chainId,
|
|
342
|
+
async encrypt({ values, contractAddress, userAddress }) {
|
|
343
|
+
return instance.encrypt({ values, contractAddress, userAddress });
|
|
344
|
+
},
|
|
345
|
+
terminate() {
|
|
346
|
+
instance.terminate();
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function createSepoliaEncryptorWeb(opts) {
|
|
351
|
+
const chainId = opts.chainId ?? SEPOLIA_CHAIN_ID;
|
|
352
|
+
if (typeof RelayerWeb !== "function") {
|
|
353
|
+
throw new Error(
|
|
354
|
+
`@tokenops/sdk: @zama-fhe/sdk is required for createSepoliaEncryptorWeb.
|
|
355
|
+
install it with: pnpm add @zama-fhe/sdk@^3
|
|
356
|
+
(RelayerWeb was not a constructor \u2014 the module resolved to ${typeof RelayerWeb})`
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
const baseConfig = chainId === MAINNET_CHAIN_ID ? MainnetConfig : SepoliaConfig;
|
|
360
|
+
const transportConfig = { ...baseConfig };
|
|
361
|
+
if (opts.relayerUrl !== void 0) {
|
|
362
|
+
transportConfig.relayerUrl = opts.relayerUrl;
|
|
363
|
+
}
|
|
364
|
+
void opts.publicClient;
|
|
365
|
+
void opts.walletClient;
|
|
366
|
+
const safeLogger = opts.logger ? {
|
|
367
|
+
debug: () => {
|
|
368
|
+
},
|
|
369
|
+
info: () => {
|
|
370
|
+
},
|
|
371
|
+
warn: () => {
|
|
372
|
+
},
|
|
373
|
+
error: () => {
|
|
374
|
+
},
|
|
375
|
+
...opts.logger
|
|
376
|
+
} : void 0;
|
|
377
|
+
const instance = new RelayerWeb({
|
|
378
|
+
transports: { [chainId]: transportConfig },
|
|
379
|
+
getChainId: () => Promise.resolve(chainId),
|
|
380
|
+
logger: safeLogger
|
|
381
|
+
});
|
|
382
|
+
return Promise.resolve({
|
|
383
|
+
instance,
|
|
384
|
+
chainId,
|
|
385
|
+
encrypt({ values, contractAddress, userAddress }) {
|
|
386
|
+
return instance.encrypt({ values, contractAddress, userAddress });
|
|
387
|
+
},
|
|
388
|
+
terminate() {
|
|
389
|
+
instance.terminate();
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export { MAINNET_CHAIN_ID, MOCK_ERC7984_MINT_ABI, SEPOLIA_CHAIN_ID, createLocalFhevmEncryptor, createMockEncryptor, createMockErc7984Client, createSepoliaEncryptor, createSepoliaEncryptorWeb, mintMockERC7984 };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Address } from "viem";
|
|
2
|
+
import type { Encryptor } from "../fhe-vesting/encryption.js";
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for {@link createMockEncryptor}. Most consumers only need
|
|
5
|
+
* `rpcUrl`; everything else has deterministic defaults that match what
|
|
6
|
+
* `pnpm fhevm:up` deploys.
|
|
7
|
+
*/
|
|
8
|
+
export interface CreateMockEncryptorOptions {
|
|
9
|
+
/**
|
|
10
|
+
* JSON-RPC endpoint of a local Anvil node with FHEVM host contracts already
|
|
11
|
+
* deployed (i.e. `pnpm fhevm:up` succeeded). Defaults to
|
|
12
|
+
* `http://127.0.0.1:8545`.
|
|
13
|
+
*/
|
|
14
|
+
rpcUrl?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Chain id of the local node. Defaults to `31337` (forge-fhevm default).
|
|
17
|
+
* Override only if you ran `pnpm fhevm:up` with a non-default `--chain-id`.
|
|
18
|
+
*/
|
|
19
|
+
chainId?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Mock-utils host-contract addresses. Defaults to the Zama `HardhatConfig`
|
|
22
|
+
* deterministic deployment forge-fhevm produces. Override if you brought
|
|
23
|
+
* the FHEVM host contracts up some other way and they landed at different
|
|
24
|
+
* addresses.
|
|
25
|
+
*/
|
|
26
|
+
hostAddresses?: {
|
|
27
|
+
aclContractAddress: Address;
|
|
28
|
+
inputVerifierContractAddress: Address;
|
|
29
|
+
kmsContractAddress: Address;
|
|
30
|
+
verifyingContractAddressDecryption: Address;
|
|
31
|
+
verifyingContractAddressInputVerification: Address;
|
|
32
|
+
fhevmExecutorContractAddress?: Address;
|
|
33
|
+
gatewayChainId?: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Override the coprocessor signer private key. Defaults to the deterministic
|
|
37
|
+
* forge-fhevm signer; you only need this if you deployed the host contracts
|
|
38
|
+
* with a custom KMS / coprocessor signer set.
|
|
39
|
+
*/
|
|
40
|
+
coprocessorSignerPrivateKey?: `0x${string}`;
|
|
41
|
+
}
|
|
42
|
+
/** Returned by {@link createMockEncryptor}. Carries the underlying
|
|
43
|
+
* `MockFhevmInstance` so consumers who need user-decrypt can reach it. */
|
|
44
|
+
export interface MockEncryptor extends Encryptor {
|
|
45
|
+
/**
|
|
46
|
+
* The underlying `MockFhevmInstance`. Use this for `userDecrypt` flows that
|
|
47
|
+
* the SDK's structural {@link Encryptor} interface doesn't expose.
|
|
48
|
+
* **Process-scoped:** handles produced by one instance can only be decrypted
|
|
49
|
+
* by that same instance (the cleartext db lives in memory).
|
|
50
|
+
*/
|
|
51
|
+
readonly instance: unknown;
|
|
52
|
+
/** Local chain id this encryptor is bound to. */
|
|
53
|
+
readonly chainId: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Construct an SDK-shaped {@link Encryptor} backed by `MockFhevmInstance`
|
|
57
|
+
* against a local FHEVM-ready Anvil node (`pnpm fhevm:up`). One call replaces
|
|
58
|
+
* the 7-address `MockFhevmInstance.create` boilerplate every local-chain
|
|
59
|
+
* consumer used to copy from `node_modules/@fhevm/mock-utils`.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* import { createMockEncryptor } from "@tokenops/sdk/fhe";
|
|
64
|
+
*
|
|
65
|
+
* const encryptor = await createMockEncryptor({ rpcUrl: "http://127.0.0.1:8545" });
|
|
66
|
+
* const mgr = createConfidentialVestingManagerClient({ publicClient, walletClient, address, encryptor });
|
|
67
|
+
* await mgr.createVesting({ params, amount: 1_000_000n });
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @remarks
|
|
71
|
+
* `MockFhevmInstance` is **process-scoped**: handles produced by one instance
|
|
72
|
+
* are only decryptable by that same instance. For end-to-end encrypt →
|
|
73
|
+
* submit → decrypt loops, keep one encryptor alive for the whole run and
|
|
74
|
+
* serialize state (`vestingId`, `manager`, etc.) to disk between steps. See
|
|
75
|
+
* `/concepts/encryption` for the recommended pattern.
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* For Sepolia / mainnet, use {@link createSepoliaEncryptor} (the SDK's
|
|
79
|
+
* one-call wrapper over `RelayerNode` from `@zama-fhe/sdk/node`) in Node, and
|
|
80
|
+
* `RelayerWeb` from `@zama-fhe/sdk` (root) in the browser. The legacy
|
|
81
|
+
* `RelayerNode.create({ chainId })` / `RelayerWeb.create({ chainId })`
|
|
82
|
+
* docs snippets refer to a static factory that does NOT exist on either
|
|
83
|
+
* class — both are constructed with `new ...({ transports, getChainId })`.
|
|
84
|
+
*/
|
|
85
|
+
export declare function createMockEncryptor(options?: CreateMockEncryptorOptions): Promise<MockEncryptor>;
|
|
86
|
+
/**
|
|
87
|
+
* Alias for {@link createMockEncryptor}. Some docs and consumer agents reach
|
|
88
|
+
* for the more-descriptive name; both resolve to the same implementation.
|
|
89
|
+
*/
|
|
90
|
+
export declare const createLocalFhevmEncryptor: typeof createMockEncryptor;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { Account, Address, Hex, PublicClient, WalletClient } from "viem";
|
|
2
|
+
import { type SdkTelemetry } from "../core/telemetry.js";
|
|
3
|
+
/**
|
|
4
|
+
* Minimal `mint(address,uint64)` ABI fragment. Embedded inline (rather than
|
|
5
|
+
* imported from a shared mock-token JSON artifact) because the selector is
|
|
6
|
+
* stable across every ERC-7984-conformant mock — production ERC-7984s with
|
|
7
|
+
* a `mint(address,uint64)` shape are accepted by the same fragment. No
|
|
8
|
+
* artifact dependency.
|
|
9
|
+
*
|
|
10
|
+
* The contract signature is:
|
|
11
|
+
*
|
|
12
|
+
* ```solidity
|
|
13
|
+
* function mint(address to, uint64 amount) external;
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const MOCK_ERC7984_MINT_ABI: readonly [{
|
|
17
|
+
readonly type: "function";
|
|
18
|
+
readonly name: "mint";
|
|
19
|
+
readonly stateMutability: "nonpayable";
|
|
20
|
+
readonly inputs: readonly [{
|
|
21
|
+
readonly name: "to";
|
|
22
|
+
readonly type: "address";
|
|
23
|
+
}, {
|
|
24
|
+
readonly name: "amount";
|
|
25
|
+
readonly type: "uint64";
|
|
26
|
+
}];
|
|
27
|
+
readonly outputs: readonly [];
|
|
28
|
+
}];
|
|
29
|
+
/** Arguments for {@link mintMockERC7984}. Mirrors the shape of
|
|
30
|
+
* {@link import("./operators.js").SetOperatorArgs} so consumers wiring both
|
|
31
|
+
* helpers in sequence reuse the same client / account references. */
|
|
32
|
+
export interface MintMockERC7984Args {
|
|
33
|
+
/** Read-only viem client for receipt waiting. */
|
|
34
|
+
publicClient: PublicClient;
|
|
35
|
+
/** Wallet client used to send the `mint` call. */
|
|
36
|
+
walletClient: WalletClient;
|
|
37
|
+
/** MockERC7984Token contract address. */
|
|
38
|
+
token: Address;
|
|
39
|
+
/** Recipient of the freshly-minted ciphertext balance. */
|
|
40
|
+
to: Address;
|
|
41
|
+
/**
|
|
42
|
+
* Amount to mint, base units. `uint64` upper bound (`2**64 - 1 ≈ 1.8e+19`)
|
|
43
|
+
* is the on-chain ceiling; the helper rejects bigints above that BEFORE
|
|
44
|
+
* viem encodes them so the revert message is the SDK's, not viem's.
|
|
45
|
+
*/
|
|
46
|
+
amount: bigint;
|
|
47
|
+
/**
|
|
48
|
+
* Account paying the mint. Same `Account | Address` shape as
|
|
49
|
+
* {@link import("./operators.js").SetOperatorArgs.account} — passing the
|
|
50
|
+
* full `Account` object preserves the local-signing path
|
|
51
|
+
* (`eth_sendRawTransaction`); passing only an `Address` falls back to
|
|
52
|
+
* `eth_sendTransaction` which most public RPCs reject.
|
|
53
|
+
*/
|
|
54
|
+
account?: Account | Address;
|
|
55
|
+
/**
|
|
56
|
+
* If `true` (default), waits for the transaction to be mined before
|
|
57
|
+
* returning. Set to `false` for fire-and-forget flows where the caller
|
|
58
|
+
* waits separately.
|
|
59
|
+
*/
|
|
60
|
+
waitForReceipt?: boolean;
|
|
61
|
+
/** Optional telemetry sink — span emits as `fhe.mintMockERC7984`. */
|
|
62
|
+
telemetry?: SdkTelemetry;
|
|
63
|
+
}
|
|
64
|
+
/** Result of {@link mintMockERC7984}: the tx hash plus the mined block
|
|
65
|
+
* number (or `0n` when `waitForReceipt: false`). Shape mirrors the docs-site
|
|
66
|
+
* stopgap's return so the migration is a drop-in. */
|
|
67
|
+
export interface MintMockERC7984Result {
|
|
68
|
+
hash: Hex;
|
|
69
|
+
blockNumber: bigint;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Mint `amount` MockERC7984 ciphertext units to `to`. Required pre-step for
|
|
73
|
+
* any outside-in `/fhe-vesting` / `/fhe-airdrop` / `/fhe-disperse` walkthrough
|
|
74
|
+
* where the operator's wallet needs a starting balance before the next
|
|
75
|
+
* `setOperator` + `createX` call.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* import { mintMockERC7984, DEPLOYED_ADDRESSES } from "@tokenops/sdk";
|
|
80
|
+
*
|
|
81
|
+
* const { hash, blockNumber } = await mintMockERC7984({
|
|
82
|
+
* publicClient,
|
|
83
|
+
* walletClient,
|
|
84
|
+
* token: DEPLOYED_ADDRESSES.tokens.testConfidential[11155111]!,
|
|
85
|
+
* to: walletClient.account!.address,
|
|
86
|
+
* amount: 1_000_000n,
|
|
87
|
+
* });
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @throws {@link TokenOpsContractError} if the writeContract or receipt-wait
|
|
91
|
+
* step throws. The original viem error is attached as the cause.
|
|
92
|
+
*/
|
|
93
|
+
export declare function mintMockERC7984(args: MintMockERC7984Args): Promise<MintMockERC7984Result>;
|
|
94
|
+
/** Args for {@link createMockErc7984Client}. */
|
|
95
|
+
export interface CreateMockErc7984ClientArgs {
|
|
96
|
+
publicClient: PublicClient;
|
|
97
|
+
walletClient: WalletClient;
|
|
98
|
+
address: Address;
|
|
99
|
+
/** Optional telemetry forwarded to every method call. */
|
|
100
|
+
telemetry?: SdkTelemetry;
|
|
101
|
+
}
|
|
102
|
+
/** Small client returned by {@link createMockErc7984Client}. Mirrors the
|
|
103
|
+
* broader SDK client shape (`{ address, mint }`) so consumers wiring multiple
|
|
104
|
+
* helpers can stash the client once and reuse the bound address. */
|
|
105
|
+
export interface MockErc7984Client {
|
|
106
|
+
readonly address: Address;
|
|
107
|
+
/**
|
|
108
|
+
* Mint to `to`. The bound `address` is forwarded as the `token` — pass
|
|
109
|
+
* everything else inline. Same {@link MintMockERC7984Args} shape minus the
|
|
110
|
+
* `token`, `publicClient`, `walletClient`, `telemetry` fields the client
|
|
111
|
+
* already owns.
|
|
112
|
+
*/
|
|
113
|
+
mint(args: Omit<MintMockERC7984Args, "token" | "publicClient" | "walletClient" | "telemetry">): Promise<MintMockERC7984Result>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Construct a bound `MockERC7984Token` client. Lighter than
|
|
117
|
+
* {@link mintMockERC7984} when a consumer makes multiple mints against the
|
|
118
|
+
* same token — the bound `address` + clients are stashed once.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts
|
|
122
|
+
* import { createMockErc7984Client, DEPLOYED_ADDRESSES } from "@tokenops/sdk/fhe";
|
|
123
|
+
*
|
|
124
|
+
* const token = createMockErc7984Client({
|
|
125
|
+
* publicClient,
|
|
126
|
+
* walletClient,
|
|
127
|
+
* address: DEPLOYED_ADDRESSES.tokens.testConfidential[11155111]!,
|
|
128
|
+
* });
|
|
129
|
+
*
|
|
130
|
+
* await token.mint({ to: alice, amount: 1_000_000n });
|
|
131
|
+
* await token.mint({ to: bob, amount: 2_000_000n });
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function createMockErc7984Client(args: CreateMockErc7984ClientArgs): MockErc7984Client;
|