@tokenops/sdk 1.5.1 → 2.0.0-alpha.1
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 +198 -2
- package/CONTRIBUTING.md +4 -2
- package/README.md +146 -90
- package/SECURITY.md +7 -1
- package/SUPPORT.md +47 -0
- package/dist/{chunk-YQIBBEFJ.js → chunk-335Z2W67.js} +1 -1
- package/dist/{chunk-2NCLOQ56.cjs → chunk-3QHNYEQD.cjs} +77 -0
- package/dist/chunk-456VDDA3.js +370 -0
- package/dist/{chunk-SG65XWH7.js → chunk-4RAAATVY.js} +1 -3
- package/dist/{chunk-6BMP4ICG.js → chunk-4TSDNZQ3.js} +60 -2
- package/dist/{chunk-PUPKNW3R.cjs → chunk-5576FRT3.cjs} +30 -6
- package/dist/{chunk-AOP6HMPW.js → chunk-6GNR22OV.js} +75 -1
- package/dist/{chunk-NTZY6IB7.js → chunk-6NAVMWZQ.js} +4 -3
- package/dist/{chunk-C7BRZXJA.cjs → chunk-6PXXGACR.cjs} +8 -7
- package/dist/{chunk-IJFQ5L4I.js → chunk-74QFZ5MK.js} +4 -3
- package/dist/chunk-7AFPOE7N.cjs +59 -0
- package/dist/chunk-AXIPOR3C.js +56 -0
- package/dist/chunk-CTED3MTR.cjs +380 -0
- package/dist/{chunk-XGGTQQFH.js → chunk-DZHYSUGY.js} +28 -7
- package/dist/{chunk-OXTLPTO3.js → chunk-EAJ7SYHE.js} +4 -3
- package/dist/{chunk-V2PXZVBF.cjs → chunk-FGEB7RMY.cjs} +4 -4
- package/dist/chunk-GKKDAW44.js +8823 -0
- package/dist/{chunk-2PWNH3UE.js → chunk-H5POPGOZ.js} +63 -5
- package/dist/{chunk-W7IGCOVL.cjs → chunk-JQYC66TO.cjs} +9 -8
- package/dist/{chunk-PFXURMBZ.cjs → chunk-JZLGCTGK.cjs} +68 -8
- package/dist/{chunk-JYOTGRSO.cjs → chunk-KFRDLKMA.cjs} +61 -1
- package/dist/chunk-M4IT6DNJ.cjs +608 -0
- package/dist/{chunk-KLKI352M.cjs → chunk-MVDQMV25.cjs} +0 -3
- package/dist/chunk-NCVX3K2N.cjs +161 -0
- package/dist/chunk-NWFMBLSQ.js +4 -0
- package/dist/chunk-O5676ZWY.js +585 -0
- package/dist/chunk-PUX5VXDB.cjs +8845 -0
- package/dist/{chunk-IXLO7GO5.js → chunk-TWT3STIX.js} +46 -80
- package/dist/chunk-UG5RKLU2.cjs +6 -0
- package/dist/chunk-VP2B4WM2.js +154 -0
- package/dist/{chunk-5X5WL5CU.cjs → chunk-WJLECC22.cjs} +51 -88
- package/dist/{chunk-WENHUPZC.cjs → chunk-XAYGD4E4.cjs} +9 -8
- package/dist/core/addresses.d.ts +15 -3
- 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 +34 -13
- package/dist/fhe/index.d.cts +1 -0
- package/dist/fhe/index.d.ts +1 -0
- package/dist/fhe/index.js +19 -6
- package/dist/fhe/mock-erc7984.d.ts +4 -4
- package/dist/fhe/operators.d.ts +160 -3
- package/dist/fhe/react/index.cjs +14 -0
- package/dist/fhe/react/index.d.cts +2 -0
- package/dist/fhe/react/index.d.ts +2 -0
- package/dist/fhe/react/index.js +6 -0
- package/dist/fhe/react/useEnsureOperator.d.ts +56 -0
- package/dist/fhe/react/useIsOperator.d.ts +54 -0
- package/dist/fhe/sepolia-encryptor-web.d.ts +18 -3
- package/dist/fhe/types.d.ts +6 -0
- 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 +1238 -0
- package/dist/fhe-airdrop/advanced/index.cjs +10 -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 +2 -8
- package/dist/fhe-airdrop/advanced/react/index.cjs +34 -48
- package/dist/fhe-airdrop/advanced/react/index.d.cts +9 -3
- package/dist/fhe-airdrop/advanced/react/index.d.ts +9 -3
- package/dist/fhe-airdrop/advanced/react/index.js +33 -48
- 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/airdrop-base.d.ts +600 -0
- package/dist/fhe-airdrop/campaign.d.ts +297 -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 +245 -15
- package/dist/fhe-airdrop/factory.d.ts +533 -274
- package/dist/fhe-airdrop/guards.d.ts +273 -0
- package/dist/fhe-airdrop/index.cjs +1089 -33
- package/dist/fhe-airdrop/index.d.cts +46 -8
- package/dist/fhe-airdrop/index.d.ts +46 -8
- package/dist/fhe-airdrop/index.js +929 -7
- package/dist/fhe-airdrop/merkle-tree.d.ts +103 -0
- package/dist/fhe-airdrop/merkle.d.ts +180 -0
- package/dist/fhe-airdrop/react/_shared.d.ts +144 -71
- package/dist/fhe-airdrop/react/index.cjs +364 -413
- package/dist/fhe-airdrop/react/index.d.cts +53 -72
- package/dist/fhe-airdrop/react/index.d.ts +53 -72
- package/dist/fhe-airdrop/react/index.js +258 -369
- package/dist/fhe-airdrop/react/useAirdropGasFee.d.ts +10 -5
- 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/useAirdropToken.d.ts +11 -4
- package/dist/fhe-airdrop/react/useAirdropWindow.d.ts +37 -0
- package/dist/fhe-airdrop/react/useClaimedAmount.d.ts +29 -0
- package/dist/fhe-airdrop/react/useComplianceManager.d.ts +16 -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/useEcdsaClaim.d.ts +23 -0
- package/dist/fhe-airdrop/react/useEffectiveUpgradeable.d.ts +20 -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/useMerkleClaim.d.ts +34 -0
- package/dist/fhe-airdrop/react/useMerkleRoot.d.ts +15 -0
- package/dist/fhe-airdrop/react/useSetMerkleRoot.d.ts +22 -0
- package/dist/fhe-airdrop/react/useWithdrawConfidential.d.ts +23 -0
- package/dist/fhe-airdrop/roles.d.ts +147 -0
- package/dist/fhe-airdrop/types.d.ts +68 -55
- package/dist/fhe-disperse/errors.d.ts +55 -0
- package/dist/fhe-disperse/index.cjs +34 -25
- package/dist/fhe-disperse/index.d.cts +1 -1
- package/dist/fhe-disperse/index.d.ts +1 -1
- package/dist/fhe-disperse/index.js +6 -5
- package/dist/fhe-disperse/react/index.cjs +42 -23
- package/dist/fhe-disperse/react/index.d.cts +3 -1
- package/dist/fhe-disperse/react/index.d.ts +3 -1
- package/dist/fhe-disperse/react/index.js +9 -6
- package/dist/fhe-vesting/advanced/index.cjs +8 -7
- package/dist/fhe-vesting/advanced/index.js +6 -5
- package/dist/fhe-vesting/advanced/react/index.cjs +12 -11
- package/dist/fhe-vesting/advanced/react/index.js +9 -8
- package/dist/fhe-vesting/index.cjs +35 -34
- package/dist/fhe-vesting/index.js +7 -6
- package/dist/fhe-vesting/manager.d.ts +19 -0
- package/dist/fhe-vesting/react/index.cjs +160 -140
- package/dist/fhe-vesting/react/index.d.cts +6 -4
- package/dist/fhe-vesting/react/index.d.ts +6 -4
- package/dist/fhe-vesting/react/index.js +24 -16
- package/dist/fhe-vesting/react/useAccessClaimableAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessSettledAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessTotalAllocation.d.ts +11 -3
- package/dist/fhe-vesting/react/useAccessVestedAmount.d.ts +11 -3
- package/dist/fhe-vesting/react/useAdminGetClaimableAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetSettledAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetTotalAllocation.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminGetVestedAmount.d.ts +1 -1
- package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +8 -0
- package/dist/fhe-vesting/react/useClaim.d.ts +1 -1
- package/dist/fhe-vesting/react/useDiscloseHandleToParty.d.ts +1 -1
- package/dist/fhe-vesting/react/useManagerDiscloseHandleToParty.d.ts +1 -1
- package/dist/fhe-vesting/react/usePartialClaim.d.ts +1 -1
- package/dist/fhe-vesting/react/useVestingInfo.d.ts +1 -1
- package/dist/fhe-vesting/types.d.ts +12 -1
- package/dist/index.cjs +27 -15
- package/dist/index.js +1 -1
- package/dist/testnet-faucet/index.cjs +17 -16
- package/dist/testnet-faucet/index.js +5 -4
- package/dist/testnet-faucet/react/index.cjs +11 -10
- package/dist/testnet-faucet/react/index.js +6 -5
- package/package.json +18 -9
- package/dist/chunk-4WPGQSNT.cjs +0 -44
- package/dist/chunk-6R4KNAPK.js +0 -1630
- package/dist/chunk-DUZIIRPF.js +0 -1655
- package/dist/chunk-MCRBVJGZ.cjs +0 -1637
- package/dist/chunk-ODLTEGHB.js +0 -41
- package/dist/chunk-ORFTDNFZ.js +0 -105
- package/dist/chunk-T46YXSBP.cjs +0 -109
- package/dist/chunk-TIUKIY5V.cjs +0 -1663
- 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 -310
- package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +0 -31
- package/dist/fhe-airdrop/react/useAirdropCanExtendClaimWindow.d.ts +0 -7
- package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +0 -27
- 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/useAirdropGrantRole.d.ts +0 -16
- 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/useAirdropRevokeRole.d.ts +0 -15
- 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 -31
- 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/useGetClaimAmount.d.ts +0 -30
- package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +0 -51
- 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/useSignClaimAuthorization.d.ts +0 -31
- 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
- package/dist/fhe-vesting/react/useGetClaimableAmount.d.ts +0 -13
- package/dist/fhe-vesting/react/useGetSettledAmount.d.ts +0 -14
- package/dist/fhe-vesting/react/useGetTotalAllocation.d.ts +0 -13
- package/dist/fhe-vesting/react/useGetVestedAmount.d.ts +0 -25
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { mapZamaError } from './chunk-WMACINXO.js';
|
|
2
|
-
import { scaleRatio } from './chunk-
|
|
2
|
+
import { resolveEncryptor, encryptUint64Batch, scaleRatio, encryptUint64 } from './chunk-6GNR22OV.js';
|
|
3
3
|
import { getFhevmAclAddress, requireFhevmAclAddress, ACL_ALLOWED_EVENT } from './chunk-ZWXJTBZO.js';
|
|
4
4
|
import { erc7984OperatorAbi } from './chunk-7VELUOMI.js';
|
|
5
|
-
import { SDK_VERSION
|
|
5
|
+
import { SDK_VERSION } from './chunk-NWFMBLSQ.js';
|
|
6
|
+
import { mapContractRevert, isContractRevert } from './chunk-4RAAATVY.js';
|
|
6
7
|
import { normaliseAddress } from './chunk-ZA673I3O.js';
|
|
8
|
+
import { asEncryptedHandle, asTxHash } from './chunk-KWFFIJYX.js';
|
|
9
|
+
import { TokenOpsSdkError, PausedError, InsufficientFeeError, AccessDeniedError, InvalidArgumentError, OperatorNotApprovedError, MissingEncryptorError, ReceiptEventNotFoundError, ReceiptEventAmbiguousError, MissingWalletClientError, MissingAccountError } from './chunk-QBJ7O2B4.js';
|
|
7
10
|
import { withTelemetry } from './chunk-Q2GP5UDC.js';
|
|
8
|
-
import {
|
|
9
|
-
import { InvalidArgumentError, TokenOpsSdkError, PausedError, InsufficientFeeError, AccessDeniedError, OperatorNotApprovedError, MissingEncryptorError, ReceiptEventNotFoundError, ReceiptEventAmbiguousError, MissingWalletClientError, MissingAccountError } from './chunk-QBJ7O2B4.js';
|
|
10
|
-
import { bytesToHex, parseEventLogs, isAddress } from 'viem';
|
|
11
|
+
import { parseEventLogs, isAddress, BaseError, ContractFunctionZeroDataError } from 'viem';
|
|
11
12
|
|
|
12
13
|
// src/fhe-vesting/abis/manager.ts
|
|
13
14
|
var confidentialVestingManagerAbi = [
|
|
@@ -987,78 +988,6 @@ var confidentialVestingManagerAbi = [
|
|
|
987
988
|
type: "function"
|
|
988
989
|
}
|
|
989
990
|
];
|
|
990
|
-
function resolveEncryptor(source) {
|
|
991
|
-
if (source === void 0) return void 0;
|
|
992
|
-
return typeof source === "function" ? source() : source;
|
|
993
|
-
}
|
|
994
|
-
var MAX_UINT64 = (1n << 64n) - 1n;
|
|
995
|
-
function assertUint64(value, label) {
|
|
996
|
-
if (value < 0n || value > MAX_UINT64) {
|
|
997
|
-
throw new InvalidArgumentError({
|
|
998
|
-
method: "encryptUint64",
|
|
999
|
-
argument: label,
|
|
1000
|
-
reason: `does not fit in uint64 (0..2^64-1)`,
|
|
1001
|
-
value
|
|
1002
|
-
});
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
async function encryptUint64({
|
|
1006
|
-
encryptor,
|
|
1007
|
-
contractAddress,
|
|
1008
|
-
userAddress,
|
|
1009
|
-
value
|
|
1010
|
-
}) {
|
|
1011
|
-
assertUint64(value, "value");
|
|
1012
|
-
const { handles, inputProof } = await encryptor.encrypt({
|
|
1013
|
-
values: [{ value, type: "euint64" }],
|
|
1014
|
-
contractAddress,
|
|
1015
|
-
userAddress
|
|
1016
|
-
});
|
|
1017
|
-
if (handles.length !== 1) {
|
|
1018
|
-
throw new InvalidArgumentError({
|
|
1019
|
-
method: "encryptUint64",
|
|
1020
|
-
argument: "handles",
|
|
1021
|
-
reason: `expected 1 handle, got ${handles.length}`,
|
|
1022
|
-
value: handles.length
|
|
1023
|
-
});
|
|
1024
|
-
}
|
|
1025
|
-
return {
|
|
1026
|
-
handle: asEncryptedHandle(bytesToHex(handles[0])),
|
|
1027
|
-
inputProof: asExternalInputProof(bytesToHex(inputProof))
|
|
1028
|
-
};
|
|
1029
|
-
}
|
|
1030
|
-
async function encryptUint64Batch({
|
|
1031
|
-
encryptor,
|
|
1032
|
-
contractAddress,
|
|
1033
|
-
userAddress,
|
|
1034
|
-
values
|
|
1035
|
-
}) {
|
|
1036
|
-
if (values.length === 0) {
|
|
1037
|
-
throw new InvalidArgumentError({
|
|
1038
|
-
method: "encryptUint64Batch",
|
|
1039
|
-
argument: "values",
|
|
1040
|
-
reason: "must be non-empty"
|
|
1041
|
-
});
|
|
1042
|
-
}
|
|
1043
|
-
values.forEach((v, i) => assertUint64(v, `values[${i}]`));
|
|
1044
|
-
const { handles, inputProof } = await encryptor.encrypt({
|
|
1045
|
-
values: values.map((value) => ({ value, type: "euint64" })),
|
|
1046
|
-
contractAddress,
|
|
1047
|
-
userAddress
|
|
1048
|
-
});
|
|
1049
|
-
if (handles.length !== values.length) {
|
|
1050
|
-
throw new InvalidArgumentError({
|
|
1051
|
-
method: "encryptUint64Batch",
|
|
1052
|
-
argument: "handles",
|
|
1053
|
-
reason: `expected ${values.length} handles, got ${handles.length}`,
|
|
1054
|
-
value: handles.length
|
|
1055
|
-
});
|
|
1056
|
-
}
|
|
1057
|
-
return {
|
|
1058
|
-
handles: handles.map((h) => asEncryptedHandle(bytesToHex(h))),
|
|
1059
|
-
inputProof: asExternalInputProof(bytesToHex(inputProof))
|
|
1060
|
-
};
|
|
1061
|
-
}
|
|
1062
991
|
|
|
1063
992
|
// src/fhe-vesting/errors.ts
|
|
1064
993
|
var VestingNotFoundError = class extends TokenOpsSdkError {
|
|
@@ -1554,6 +1483,11 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1554
1483
|
* - Operator: creator has approved this manager as an ERC-7984 operator on
|
|
1555
1484
|
* the distribution token, required for the manager's
|
|
1556
1485
|
* `confidentialTransferFrom` pull ({@link OperatorNotApprovedError} blocker).
|
|
1486
|
+
* If the bound `token` does not implement the ERC-7984 `isOperator`
|
|
1487
|
+
* view — a revert, or a zero-data response for an EOA / undeployed
|
|
1488
|
+
* address — operator status is undetermined rather than the call
|
|
1489
|
+
* throwing: `isOperatorSet` reports `false` and the read failure becomes
|
|
1490
|
+
* an {@link InvalidArgumentError} blocker on `token` instead (TOK-436).
|
|
1557
1491
|
*
|
|
1558
1492
|
* **Not preflight-detectable — read before trusting `ready: true`:**
|
|
1559
1493
|
* - The creator's confidential token balance is an encrypted `euint64` the
|
|
@@ -1585,15 +1519,19 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1585
1519
|
this.token(),
|
|
1586
1520
|
this.#read("VESTING_CREATOR_ROLE")
|
|
1587
1521
|
]);
|
|
1588
|
-
const [hasCreatorRole,
|
|
1522
|
+
const [hasCreatorRole, operatorRead] = await Promise.all([
|
|
1589
1523
|
this.hasRole(creatorRole, args.creator),
|
|
1590
1524
|
this.publicClient.readContract({
|
|
1591
1525
|
address: token,
|
|
1592
1526
|
abi: erc7984OperatorAbi,
|
|
1593
1527
|
functionName: "isOperator",
|
|
1594
1528
|
args: [args.creator, this.address]
|
|
1529
|
+
}).then((v) => ({ ok: true, value: v })).catch((err) => {
|
|
1530
|
+
if (isNotErc7984Failure(err)) return { ok: false, err };
|
|
1531
|
+
throw err;
|
|
1595
1532
|
})
|
|
1596
1533
|
]);
|
|
1534
|
+
const isOperatorSet = operatorRead.ok ? operatorRead.value : false;
|
|
1597
1535
|
if (!hasCreatorRole) {
|
|
1598
1536
|
pushBlocker(
|
|
1599
1537
|
new AccessDeniedError({
|
|
@@ -1604,7 +1542,16 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1604
1542
|
})
|
|
1605
1543
|
);
|
|
1606
1544
|
}
|
|
1607
|
-
if (!
|
|
1545
|
+
if (!operatorRead.ok) {
|
|
1546
|
+
pushBlocker(
|
|
1547
|
+
new InvalidArgumentError({
|
|
1548
|
+
method: "createVesting",
|
|
1549
|
+
argument: "token",
|
|
1550
|
+
reason: "does not implement the ERC-7984 `isOperator(address,address)` view \u2014 it is not a confidential token (or the address holds no contract on this chain)",
|
|
1551
|
+
value: token
|
|
1552
|
+
})
|
|
1553
|
+
);
|
|
1554
|
+
} else if (!isOperatorSet) {
|
|
1608
1555
|
pushBlocker(
|
|
1609
1556
|
new OperatorNotApprovedError({
|
|
1610
1557
|
method: "createVesting",
|
|
@@ -1697,6 +1644,13 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1697
1644
|
* for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
|
|
1698
1645
|
* transparent TTT test token uses 18 decimals.
|
|
1699
1646
|
*
|
|
1647
|
+
* Prerequisites: caller must have set this manager as an operator on the
|
|
1648
|
+
* token: `token.setOperator(managerAddress, deadline)` — or use
|
|
1649
|
+
* `ensureOperator()` from `@tokenops/sdk/fhe`. Skipping it fails with
|
|
1650
|
+
* {@link OperatorNotApprovedError} (the SDK's mapping of the on-chain
|
|
1651
|
+
* `ERC7984UnauthorizedSpender` revert, whose message is the canonical
|
|
1652
|
+
* `OPERATOR_NOT_APPROVED_REMEDIATION` copy).
|
|
1653
|
+
*
|
|
1700
1654
|
* @returns Transaction hash. Parse the `VestingCreated` event to extract the `vestingId`.
|
|
1701
1655
|
* @example
|
|
1702
1656
|
* const hash = await manager.createVesting({
|
|
@@ -1746,6 +1700,13 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1746
1700
|
* for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
|
|
1747
1701
|
* transparent TTT test token uses 18 decimals.
|
|
1748
1702
|
*
|
|
1703
|
+
* Prerequisites: caller must have set this manager as an operator on the
|
|
1704
|
+
* token: `token.setOperator(managerAddress, deadline)` — or use
|
|
1705
|
+
* `ensureOperator()` from `@tokenops/sdk/fhe`. Skipping it fails with
|
|
1706
|
+
* {@link OperatorNotApprovedError} (the SDK's mapping of the on-chain
|
|
1707
|
+
* `ERC7984UnauthorizedSpender` revert, whose message is the canonical
|
|
1708
|
+
* `OPERATOR_NOT_APPROVED_REMEDIATION` copy).
|
|
1709
|
+
*
|
|
1749
1710
|
* @returns Transaction hash.
|
|
1750
1711
|
*/
|
|
1751
1712
|
async batchCreateVesting(args) {
|
|
@@ -2858,6 +2819,11 @@ var ConfidentialVestingManagerClient = class {
|
|
|
2858
2819
|
function createConfidentialVestingManagerClient(config) {
|
|
2859
2820
|
return new ConfidentialVestingManagerClient(config);
|
|
2860
2821
|
}
|
|
2822
|
+
function isNotErc7984Failure(err) {
|
|
2823
|
+
if (isContractRevert(err)) return true;
|
|
2824
|
+
if (!(err instanceof BaseError)) return false;
|
|
2825
|
+
return err.walk((e) => e instanceof ContractFunctionZeroDataError) instanceof ContractFunctionZeroDataError;
|
|
2826
|
+
}
|
|
2861
2827
|
function accountAddress(account) {
|
|
2862
2828
|
return typeof account === "string" ? account : account.address;
|
|
2863
2829
|
}
|
|
@@ -2915,4 +2881,4 @@ function collectVestingParamsErrors(params, where) {
|
|
|
2915
2881
|
return errors;
|
|
2916
2882
|
}
|
|
2917
2883
|
|
|
2918
|
-
export { ClaimLockedError, ConfidentialVestingManagerClient, NoPendingTransferError, NotPendingRecipientError, NotVestingRecipientError, TransferAlreadyPendingError, TransferExpiredError, VestingExpiredError, VestingNotFoundError, VestingNotRevocableError, VestingRevokedError, confidentialVestingManagerAbi, createConfidentialVestingManagerClient
|
|
2884
|
+
export { ClaimLockedError, ConfidentialVestingManagerClient, NoPendingTransferError, NotPendingRecipientError, NotVestingRecipientError, TransferAlreadyPendingError, TransferExpiredError, VestingExpiredError, VestingNotFoundError, VestingNotRevocableError, VestingRevokedError, confidentialVestingManagerAbi, createConfidentialVestingManagerClient };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { createConfidentialAirdropFactoryClient, resolveEncryptor, createAirdropBaseClient, createMerkleAirdropClient, createEcdsaAirdropClient } from './chunk-GKKDAW44.js';
|
|
2
|
+
import { getFheAirdropFactoryAddress } from './chunk-DZHYSUGY.js';
|
|
3
|
+
import { DeploymentAddressUnavailableError } from './chunk-QBJ7O2B4.js';
|
|
4
|
+
import { useRef, useMemo } from 'react';
|
|
5
|
+
import { usePublicClient, useWalletClient } from 'wagmi';
|
|
6
|
+
|
|
7
|
+
var FHE_AIRDROP_KEY = "tokenops-sdk";
|
|
8
|
+
var FHE_AIRDROP_NAMESPACE = "fhe-airdrop";
|
|
9
|
+
function airdropQueryKey(params) {
|
|
10
|
+
return [
|
|
11
|
+
FHE_AIRDROP_KEY,
|
|
12
|
+
FHE_AIRDROP_NAMESPACE,
|
|
13
|
+
params.chainId ?? null,
|
|
14
|
+
params.address ? normalizeKeyArg(params.address) : null,
|
|
15
|
+
params.fn,
|
|
16
|
+
params.args.map(normalizeKeyArg)
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
function airdropQueryKeyPrefix(params) {
|
|
20
|
+
const prefix = [
|
|
21
|
+
FHE_AIRDROP_KEY,
|
|
22
|
+
FHE_AIRDROP_NAMESPACE,
|
|
23
|
+
params.chainId ?? null,
|
|
24
|
+
params.address ? normalizeKeyArg(params.address) : null
|
|
25
|
+
];
|
|
26
|
+
if (params.fn !== void 0) prefix.push(params.fn);
|
|
27
|
+
return prefix;
|
|
28
|
+
}
|
|
29
|
+
function normalizeKeyArg(value) {
|
|
30
|
+
if (typeof value === "bigint") return value.toString();
|
|
31
|
+
if (Array.isArray(value)) return value.map(normalizeKeyArg);
|
|
32
|
+
if (value && typeof value === "object") {
|
|
33
|
+
return Object.fromEntries(
|
|
34
|
+
Object.entries(value).map(([k, v]) => [k, normalizeKeyArg(v)])
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (typeof value === "string" && value.startsWith("0x")) return value.toLowerCase();
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
function tryResolveAirdropFactoryAddress(override, chainId) {
|
|
41
|
+
if (override) return override;
|
|
42
|
+
if (chainId === void 0) return void 0;
|
|
43
|
+
return getFheAirdropFactoryAddress(chainId);
|
|
44
|
+
}
|
|
45
|
+
function computeAirdropFactoryResolutionError(override, chainId) {
|
|
46
|
+
if (override) return void 0;
|
|
47
|
+
if (chainId === void 0) {
|
|
48
|
+
return new DeploymentAddressUnavailableError({
|
|
49
|
+
reason: "chain-id-missing",
|
|
50
|
+
product: "fheAirdrop",
|
|
51
|
+
contract: "airdropFactory",
|
|
52
|
+
clientLabel: "ConfidentialAirdropFactoryClient"
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const resolved = getFheAirdropFactoryAddress(chainId);
|
|
56
|
+
if (!resolved) {
|
|
57
|
+
return new DeploymentAddressUnavailableError({
|
|
58
|
+
reason: "registry-not-deployed",
|
|
59
|
+
product: "fheAirdrop",
|
|
60
|
+
contract: "airdropFactory",
|
|
61
|
+
chainId,
|
|
62
|
+
clientLabel: "ConfidentialAirdropFactoryClient"
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return void 0;
|
|
66
|
+
}
|
|
67
|
+
function useMemoAirdropFactoryClient(opts = {}) {
|
|
68
|
+
const publicClient = usePublicClient({ chainId: opts.chainId });
|
|
69
|
+
const { data: walletClient } = useWalletClient({ chainId: opts.chainId });
|
|
70
|
+
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
71
|
+
const resolvedAddress = tryResolveAirdropFactoryAddress(opts.address, chainId);
|
|
72
|
+
const resolutionError = computeAirdropFactoryResolutionError(opts.address, chainId);
|
|
73
|
+
const encryptorSourceRef = useRef(opts.encryptor);
|
|
74
|
+
encryptorSourceRef.current = opts.encryptor;
|
|
75
|
+
const telemetry = opts.telemetry;
|
|
76
|
+
const client = useMemo(() => {
|
|
77
|
+
if (!publicClient) return void 0;
|
|
78
|
+
if (!resolvedAddress) return void 0;
|
|
79
|
+
return createConfidentialAirdropFactoryClient({
|
|
80
|
+
publicClient,
|
|
81
|
+
...walletClient ? { walletClient } : {},
|
|
82
|
+
address: resolvedAddress,
|
|
83
|
+
...chainId !== void 0 ? { chainId } : {},
|
|
84
|
+
// Lazy — invoked per-encryption inside the headless client.
|
|
85
|
+
encryptor: () => resolveEncryptor(encryptorSourceRef.current),
|
|
86
|
+
...telemetry ? { telemetry } : {}
|
|
87
|
+
});
|
|
88
|
+
}, [publicClient, walletClient, resolvedAddress, chainId, telemetry]);
|
|
89
|
+
return {
|
|
90
|
+
client,
|
|
91
|
+
resolutionError,
|
|
92
|
+
publicClient,
|
|
93
|
+
walletClient: walletClient ?? void 0,
|
|
94
|
+
chainId,
|
|
95
|
+
resolvedAddress
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function useMemoAirdropBaseClient(opts) {
|
|
99
|
+
const publicClient = usePublicClient({ chainId: opts.chainId });
|
|
100
|
+
const { data: walletClient } = useWalletClient({ chainId: opts.chainId });
|
|
101
|
+
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
102
|
+
const telemetry = opts.telemetry;
|
|
103
|
+
const client = useMemo(() => {
|
|
104
|
+
if (!publicClient) return void 0;
|
|
105
|
+
if (!opts.address) return void 0;
|
|
106
|
+
return createAirdropBaseClient({
|
|
107
|
+
publicClient,
|
|
108
|
+
...walletClient ? { walletClient } : {},
|
|
109
|
+
address: opts.address,
|
|
110
|
+
...chainId !== void 0 ? { chainId } : {},
|
|
111
|
+
...telemetry ? { telemetry } : {}
|
|
112
|
+
});
|
|
113
|
+
}, [publicClient, walletClient, opts.address, chainId, telemetry]);
|
|
114
|
+
return { client, publicClient, walletClient: walletClient ?? void 0, chainId };
|
|
115
|
+
}
|
|
116
|
+
function useMemoMerkleAirdropClient(opts) {
|
|
117
|
+
const publicClient = usePublicClient({ chainId: opts.chainId });
|
|
118
|
+
const { data: walletClient } = useWalletClient({ chainId: opts.chainId });
|
|
119
|
+
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
120
|
+
const telemetry = opts.telemetry;
|
|
121
|
+
const client = useMemo(() => {
|
|
122
|
+
if (!publicClient) return void 0;
|
|
123
|
+
if (!opts.address) return void 0;
|
|
124
|
+
return createMerkleAirdropClient({
|
|
125
|
+
publicClient,
|
|
126
|
+
...walletClient ? { walletClient } : {},
|
|
127
|
+
address: opts.address,
|
|
128
|
+
...chainId !== void 0 ? { chainId } : {},
|
|
129
|
+
...telemetry ? { telemetry } : {}
|
|
130
|
+
});
|
|
131
|
+
}, [publicClient, walletClient, opts.address, chainId, telemetry]);
|
|
132
|
+
return { client, publicClient, walletClient: walletClient ?? void 0, chainId };
|
|
133
|
+
}
|
|
134
|
+
function useMemoEcdsaAirdropClient(opts) {
|
|
135
|
+
const publicClient = usePublicClient({ chainId: opts.chainId });
|
|
136
|
+
const { data: walletClient } = useWalletClient({ chainId: opts.chainId });
|
|
137
|
+
const chainId = opts.chainId ?? publicClient?.chain?.id;
|
|
138
|
+
const telemetry = opts.telemetry;
|
|
139
|
+
const client = useMemo(() => {
|
|
140
|
+
if (!publicClient) return void 0;
|
|
141
|
+
if (!opts.address) return void 0;
|
|
142
|
+
return createEcdsaAirdropClient({
|
|
143
|
+
publicClient,
|
|
144
|
+
...walletClient ? { walletClient } : {},
|
|
145
|
+
address: opts.address,
|
|
146
|
+
dedupMode: opts.dedupMode,
|
|
147
|
+
...chainId !== void 0 ? { chainId } : {},
|
|
148
|
+
...telemetry ? { telemetry } : {}
|
|
149
|
+
});
|
|
150
|
+
}, [publicClient, walletClient, opts.address, opts.dedupMode, chainId, telemetry]);
|
|
151
|
+
return { client, publicClient, walletClient: walletClient ?? void 0, chainId };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export { airdropQueryKey, airdropQueryKeyPrefix, useMemoAirdropBaseClient, useMemoAirdropFactoryClient, useMemoEcdsaAirdropClient, useMemoMerkleAirdropClient };
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkTEBM66WA_cjs = require('./chunk-TEBM66WA.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunk3QHNYEQD_cjs = require('./chunk-3QHNYEQD.cjs');
|
|
5
5
|
var chunkFAXIIH5R_cjs = require('./chunk-FAXIIH5R.cjs');
|
|
6
6
|
var chunkFWHYQZ5E_cjs = require('./chunk-FWHYQZ5E.cjs');
|
|
7
|
-
var
|
|
7
|
+
var chunkUG5RKLU2_cjs = require('./chunk-UG5RKLU2.cjs');
|
|
8
|
+
var chunkMVDQMV25_cjs = require('./chunk-MVDQMV25.cjs');
|
|
8
9
|
var chunkJK4XMMKM_cjs = require('./chunk-JK4XMMKM.cjs');
|
|
9
|
-
var chunkVJKZWYYJ_cjs = require('./chunk-VJKZWYYJ.cjs');
|
|
10
10
|
var chunk66IHPTOK_cjs = require('./chunk-66IHPTOK.cjs');
|
|
11
11
|
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
12
|
+
var chunkVJKZWYYJ_cjs = require('./chunk-VJKZWYYJ.cjs');
|
|
12
13
|
var viem = require('viem');
|
|
13
14
|
|
|
14
15
|
// src/fhe-vesting/abis/manager.ts
|
|
@@ -989,78 +990,6 @@ var confidentialVestingManagerAbi = [
|
|
|
989
990
|
type: "function"
|
|
990
991
|
}
|
|
991
992
|
];
|
|
992
|
-
function resolveEncryptor(source) {
|
|
993
|
-
if (source === void 0) return void 0;
|
|
994
|
-
return typeof source === "function" ? source() : source;
|
|
995
|
-
}
|
|
996
|
-
var MAX_UINT64 = (1n << 64n) - 1n;
|
|
997
|
-
function assertUint64(value, label) {
|
|
998
|
-
if (value < 0n || value > MAX_UINT64) {
|
|
999
|
-
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
1000
|
-
method: "encryptUint64",
|
|
1001
|
-
argument: label,
|
|
1002
|
-
reason: `does not fit in uint64 (0..2^64-1)`,
|
|
1003
|
-
value
|
|
1004
|
-
});
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
async function encryptUint64({
|
|
1008
|
-
encryptor,
|
|
1009
|
-
contractAddress,
|
|
1010
|
-
userAddress,
|
|
1011
|
-
value
|
|
1012
|
-
}) {
|
|
1013
|
-
assertUint64(value, "value");
|
|
1014
|
-
const { handles, inputProof } = await encryptor.encrypt({
|
|
1015
|
-
values: [{ value, type: "euint64" }],
|
|
1016
|
-
contractAddress,
|
|
1017
|
-
userAddress
|
|
1018
|
-
});
|
|
1019
|
-
if (handles.length !== 1) {
|
|
1020
|
-
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
1021
|
-
method: "encryptUint64",
|
|
1022
|
-
argument: "handles",
|
|
1023
|
-
reason: `expected 1 handle, got ${handles.length}`,
|
|
1024
|
-
value: handles.length
|
|
1025
|
-
});
|
|
1026
|
-
}
|
|
1027
|
-
return {
|
|
1028
|
-
handle: chunk66IHPTOK_cjs.asEncryptedHandle(viem.bytesToHex(handles[0])),
|
|
1029
|
-
inputProof: chunk66IHPTOK_cjs.asExternalInputProof(viem.bytesToHex(inputProof))
|
|
1030
|
-
};
|
|
1031
|
-
}
|
|
1032
|
-
async function encryptUint64Batch({
|
|
1033
|
-
encryptor,
|
|
1034
|
-
contractAddress,
|
|
1035
|
-
userAddress,
|
|
1036
|
-
values
|
|
1037
|
-
}) {
|
|
1038
|
-
if (values.length === 0) {
|
|
1039
|
-
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
1040
|
-
method: "encryptUint64Batch",
|
|
1041
|
-
argument: "values",
|
|
1042
|
-
reason: "must be non-empty"
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
values.forEach((v, i) => assertUint64(v, `values[${i}]`));
|
|
1046
|
-
const { handles, inputProof } = await encryptor.encrypt({
|
|
1047
|
-
values: values.map((value) => ({ value, type: "euint64" })),
|
|
1048
|
-
contractAddress,
|
|
1049
|
-
userAddress
|
|
1050
|
-
});
|
|
1051
|
-
if (handles.length !== values.length) {
|
|
1052
|
-
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
1053
|
-
method: "encryptUint64Batch",
|
|
1054
|
-
argument: "handles",
|
|
1055
|
-
reason: `expected ${values.length} handles, got ${handles.length}`,
|
|
1056
|
-
value: handles.length
|
|
1057
|
-
});
|
|
1058
|
-
}
|
|
1059
|
-
return {
|
|
1060
|
-
handles: handles.map((h) => chunk66IHPTOK_cjs.asEncryptedHandle(viem.bytesToHex(h))),
|
|
1061
|
-
inputProof: chunk66IHPTOK_cjs.asExternalInputProof(viem.bytesToHex(inputProof))
|
|
1062
|
-
};
|
|
1063
|
-
}
|
|
1064
993
|
|
|
1065
994
|
// src/fhe-vesting/errors.ts
|
|
1066
995
|
var VestingNotFoundError = class extends chunk67OV5CX2_cjs.TokenOpsSdkError {
|
|
@@ -1263,7 +1192,7 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1263
1192
|
chainId: chainIdForInit ?? null,
|
|
1264
1193
|
hasWallet: !!this.walletClient,
|
|
1265
1194
|
aclResolved: !!config.aclAddress || chainIdForInit !== void 0 && !!chunkFAXIIH5R_cjs.getFhevmAclAddress(chainIdForInit),
|
|
1266
|
-
sdkVersion:
|
|
1195
|
+
sdkVersion: chunkUG5RKLU2_cjs.SDK_VERSION
|
|
1267
1196
|
});
|
|
1268
1197
|
}
|
|
1269
1198
|
/**
|
|
@@ -1556,6 +1485,11 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1556
1485
|
* - Operator: creator has approved this manager as an ERC-7984 operator on
|
|
1557
1486
|
* the distribution token, required for the manager's
|
|
1558
1487
|
* `confidentialTransferFrom` pull ({@link OperatorNotApprovedError} blocker).
|
|
1488
|
+
* If the bound `token` does not implement the ERC-7984 `isOperator`
|
|
1489
|
+
* view — a revert, or a zero-data response for an EOA / undeployed
|
|
1490
|
+
* address — operator status is undetermined rather than the call
|
|
1491
|
+
* throwing: `isOperatorSet` reports `false` and the read failure becomes
|
|
1492
|
+
* an {@link InvalidArgumentError} blocker on `token` instead (TOK-436).
|
|
1559
1493
|
*
|
|
1560
1494
|
* **Not preflight-detectable — read before trusting `ready: true`:**
|
|
1561
1495
|
* - The creator's confidential token balance is an encrypted `euint64` the
|
|
@@ -1587,15 +1521,19 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1587
1521
|
this.token(),
|
|
1588
1522
|
this.#read("VESTING_CREATOR_ROLE")
|
|
1589
1523
|
]);
|
|
1590
|
-
const [hasCreatorRole,
|
|
1524
|
+
const [hasCreatorRole, operatorRead] = await Promise.all([
|
|
1591
1525
|
this.hasRole(creatorRole, args.creator),
|
|
1592
1526
|
this.publicClient.readContract({
|
|
1593
1527
|
address: token,
|
|
1594
1528
|
abi: chunkFWHYQZ5E_cjs.erc7984OperatorAbi,
|
|
1595
1529
|
functionName: "isOperator",
|
|
1596
1530
|
args: [args.creator, this.address]
|
|
1531
|
+
}).then((v) => ({ ok: true, value: v })).catch((err) => {
|
|
1532
|
+
if (isNotErc7984Failure(err)) return { ok: false, err };
|
|
1533
|
+
throw err;
|
|
1597
1534
|
})
|
|
1598
1535
|
]);
|
|
1536
|
+
const isOperatorSet = operatorRead.ok ? operatorRead.value : false;
|
|
1599
1537
|
if (!hasCreatorRole) {
|
|
1600
1538
|
pushBlocker(
|
|
1601
1539
|
new chunk67OV5CX2_cjs.AccessDeniedError({
|
|
@@ -1606,7 +1544,16 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1606
1544
|
})
|
|
1607
1545
|
);
|
|
1608
1546
|
}
|
|
1609
|
-
if (!
|
|
1547
|
+
if (!operatorRead.ok) {
|
|
1548
|
+
pushBlocker(
|
|
1549
|
+
new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
1550
|
+
method: "createVesting",
|
|
1551
|
+
argument: "token",
|
|
1552
|
+
reason: "does not implement the ERC-7984 `isOperator(address,address)` view \u2014 it is not a confidential token (or the address holds no contract on this chain)",
|
|
1553
|
+
value: token
|
|
1554
|
+
})
|
|
1555
|
+
);
|
|
1556
|
+
} else if (!isOperatorSet) {
|
|
1610
1557
|
pushBlocker(
|
|
1611
1558
|
new chunk67OV5CX2_cjs.OperatorNotApprovedError({
|
|
1612
1559
|
method: "createVesting",
|
|
@@ -1699,6 +1646,13 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1699
1646
|
* for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
|
|
1700
1647
|
* transparent TTT test token uses 18 decimals.
|
|
1701
1648
|
*
|
|
1649
|
+
* Prerequisites: caller must have set this manager as an operator on the
|
|
1650
|
+
* token: `token.setOperator(managerAddress, deadline)` — or use
|
|
1651
|
+
* `ensureOperator()` from `@tokenops/sdk/fhe`. Skipping it fails with
|
|
1652
|
+
* {@link OperatorNotApprovedError} (the SDK's mapping of the on-chain
|
|
1653
|
+
* `ERC7984UnauthorizedSpender` revert, whose message is the canonical
|
|
1654
|
+
* `OPERATOR_NOT_APPROVED_REMEDIATION` copy).
|
|
1655
|
+
*
|
|
1702
1656
|
* @returns Transaction hash. Parse the `VestingCreated` event to extract the `vestingId`.
|
|
1703
1657
|
* @example
|
|
1704
1658
|
* const hash = await manager.createVesting({
|
|
@@ -1748,6 +1702,13 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1748
1702
|
* for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
|
|
1749
1703
|
* transparent TTT test token uses 18 decimals.
|
|
1750
1704
|
*
|
|
1705
|
+
* Prerequisites: caller must have set this manager as an operator on the
|
|
1706
|
+
* token: `token.setOperator(managerAddress, deadline)` — or use
|
|
1707
|
+
* `ensureOperator()` from `@tokenops/sdk/fhe`. Skipping it fails with
|
|
1708
|
+
* {@link OperatorNotApprovedError} (the SDK's mapping of the on-chain
|
|
1709
|
+
* `ERC7984UnauthorizedSpender` revert, whose message is the canonical
|
|
1710
|
+
* `OPERATOR_NOT_APPROVED_REMEDIATION` copy).
|
|
1711
|
+
*
|
|
1751
1712
|
* @returns Transaction hash.
|
|
1752
1713
|
*/
|
|
1753
1714
|
async batchCreateVesting(args) {
|
|
@@ -1764,14 +1725,14 @@ var ConfidentialVestingManagerClient = class {
|
|
|
1764
1725
|
);
|
|
1765
1726
|
const wallet = this.#requireWallet("batchCreateVesting");
|
|
1766
1727
|
const account = this.#resolveAccount(wallet, args.account, "batchCreateVesting");
|
|
1767
|
-
const encryptor = args.encryptor ?? resolveEncryptor(this.encryptor);
|
|
1728
|
+
const encryptor = args.encryptor ?? chunk3QHNYEQD_cjs.resolveEncryptor(this.encryptor);
|
|
1768
1729
|
if (!encryptor) {
|
|
1769
1730
|
throw new chunk67OV5CX2_cjs.MissingEncryptorError("batchCreateVesting");
|
|
1770
1731
|
}
|
|
1771
1732
|
const userAddress = accountAddress(account);
|
|
1772
1733
|
let batch;
|
|
1773
1734
|
try {
|
|
1774
|
-
batch = await encryptUint64Batch({
|
|
1735
|
+
batch = await chunk3QHNYEQD_cjs.encryptUint64Batch({
|
|
1775
1736
|
encryptor,
|
|
1776
1737
|
contractAddress: this.address,
|
|
1777
1738
|
userAddress,
|
|
@@ -2018,7 +1979,7 @@ var ConfidentialVestingManagerClient = class {
|
|
|
2018
1979
|
async splitVesting(args) {
|
|
2019
1980
|
const wallet = this.#requireWallet("splitVesting");
|
|
2020
1981
|
const account = this.#resolveAccount(wallet, args.account, "splitVesting");
|
|
2021
|
-
const { numerator, denominator } = args.preScaled ? { numerator: args.numerator, denominator: args.denominator } :
|
|
1982
|
+
const { numerator, denominator } = args.preScaled ? { numerator: args.numerator, denominator: args.denominator } : chunk3QHNYEQD_cjs.scaleRatio({
|
|
2022
1983
|
numerator: args.numerator,
|
|
2023
1984
|
denominator: args.denominator,
|
|
2024
1985
|
// The encrypted numerator is submitted via `encryptUint64`, so
|
|
@@ -2553,14 +2514,14 @@ var ConfidentialVestingManagerClient = class {
|
|
|
2553
2514
|
return acct;
|
|
2554
2515
|
}
|
|
2555
2516
|
async #encryptUint64(value, encryptor, account) {
|
|
2556
|
-
const enc = encryptor ?? resolveEncryptor(this.encryptor);
|
|
2517
|
+
const enc = encryptor ?? chunk3QHNYEQD_cjs.resolveEncryptor(this.encryptor);
|
|
2557
2518
|
if (!enc) {
|
|
2558
2519
|
throw new chunk67OV5CX2_cjs.MissingEncryptorError("encryptUint64", {
|
|
2559
2520
|
hint: "Pass `encryptor` to the call or the client config (eager or lazy factory)."
|
|
2560
2521
|
});
|
|
2561
2522
|
}
|
|
2562
2523
|
try {
|
|
2563
|
-
return await encryptUint64({
|
|
2524
|
+
return await chunk3QHNYEQD_cjs.encryptUint64({
|
|
2564
2525
|
encryptor: enc,
|
|
2565
2526
|
contractAddress: this.address,
|
|
2566
2527
|
userAddress: accountAddress(account),
|
|
@@ -2604,7 +2565,7 @@ var ConfidentialVestingManagerClient = class {
|
|
|
2604
2565
|
* the offending schedule id in its context.
|
|
2605
2566
|
*/
|
|
2606
2567
|
#mapRevert(method, err, productContext, account) {
|
|
2607
|
-
return
|
|
2568
|
+
return chunkMVDQMV25_cjs.mapContractRevert(err, {
|
|
2608
2569
|
method,
|
|
2609
2570
|
contractAddress: this.address,
|
|
2610
2571
|
abi: confidentialVestingManagerAbi,
|
|
@@ -2650,7 +2611,7 @@ var ConfidentialVestingManagerClient = class {
|
|
|
2650
2611
|
...value !== void 0 ? { value } : {}
|
|
2651
2612
|
});
|
|
2652
2613
|
} catch (err) {
|
|
2653
|
-
if (
|
|
2614
|
+
if (chunkMVDQMV25_cjs.isContractRevert(err)) {
|
|
2654
2615
|
throw this.#mapRevert(method, err, productContext, accountAddress(account));
|
|
2655
2616
|
}
|
|
2656
2617
|
}
|
|
@@ -2860,6 +2821,11 @@ var ConfidentialVestingManagerClient = class {
|
|
|
2860
2821
|
function createConfidentialVestingManagerClient(config) {
|
|
2861
2822
|
return new ConfidentialVestingManagerClient(config);
|
|
2862
2823
|
}
|
|
2824
|
+
function isNotErc7984Failure(err) {
|
|
2825
|
+
if (chunkMVDQMV25_cjs.isContractRevert(err)) return true;
|
|
2826
|
+
if (!(err instanceof viem.BaseError)) return false;
|
|
2827
|
+
return err.walk((e) => e instanceof viem.ContractFunctionZeroDataError) instanceof viem.ContractFunctionZeroDataError;
|
|
2828
|
+
}
|
|
2863
2829
|
function accountAddress(account) {
|
|
2864
2830
|
return typeof account === "string" ? account : account.address;
|
|
2865
2831
|
}
|
|
@@ -2930,6 +2896,3 @@ exports.VestingNotRevocableError = VestingNotRevocableError;
|
|
|
2930
2896
|
exports.VestingRevokedError = VestingRevokedError;
|
|
2931
2897
|
exports.confidentialVestingManagerAbi = confidentialVestingManagerAbi;
|
|
2932
2898
|
exports.createConfidentialVestingManagerClient = createConfidentialVestingManagerClient;
|
|
2933
|
-
exports.encryptUint64 = encryptUint64;
|
|
2934
|
-
exports.encryptUint64Batch = encryptUint64Batch;
|
|
2935
|
-
exports.resolveEncryptor = resolveEncryptor;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkUG5RKLU2_cjs = require('./chunk-UG5RKLU2.cjs');
|
|
4
|
+
var chunkMVDQMV25_cjs = require('./chunk-MVDQMV25.cjs');
|
|
5
|
+
var chunk5576FRT3_cjs = require('./chunk-5576FRT3.cjs');
|
|
5
6
|
var chunkJK4XMMKM_cjs = require('./chunk-JK4XMMKM.cjs');
|
|
6
|
-
var chunkVJKZWYYJ_cjs = require('./chunk-VJKZWYYJ.cjs');
|
|
7
7
|
var chunk66IHPTOK_cjs = require('./chunk-66IHPTOK.cjs');
|
|
8
8
|
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
9
|
+
var chunkVJKZWYYJ_cjs = require('./chunk-VJKZWYYJ.cjs');
|
|
9
10
|
var chains = require('viem/chains');
|
|
10
11
|
var viem = require('viem');
|
|
11
12
|
|
|
@@ -1825,7 +1826,7 @@ var TestnetFaucetClient = class {
|
|
|
1825
1826
|
this.#chainId = chainId;
|
|
1826
1827
|
assertTestnetFaucetChain(chainId);
|
|
1827
1828
|
const addressOverride = config.address ? chunkJK4XMMKM_cjs.normaliseAddress(config.address) : void 0;
|
|
1828
|
-
const resolved = addressOverride ?? (chainId === void 0 ? void 0 :
|
|
1829
|
+
const resolved = addressOverride ?? (chainId === void 0 ? void 0 : chunk5576FRT3_cjs.getConfidentialTestTokenAddress(chainId));
|
|
1829
1830
|
if (!resolved) {
|
|
1830
1831
|
throw new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
|
|
1831
1832
|
reason: chainId === void 0 ? "chain-id-missing" : "registry-not-deployed",
|
|
@@ -1840,7 +1841,7 @@ var TestnetFaucetClient = class {
|
|
|
1840
1841
|
this.#telemetry?.event("testnet-faucet.client.init", {
|
|
1841
1842
|
chainId: chainId ?? null,
|
|
1842
1843
|
hasWallet: !!this.walletClient,
|
|
1843
|
-
sdkVersion:
|
|
1844
|
+
sdkVersion: chunkUG5RKLU2_cjs.SDK_VERSION
|
|
1844
1845
|
});
|
|
1845
1846
|
}
|
|
1846
1847
|
// ============================================================
|
|
@@ -1863,7 +1864,7 @@ var TestnetFaucetClient = class {
|
|
|
1863
1864
|
*/
|
|
1864
1865
|
async underlyingToken() {
|
|
1865
1866
|
if (this.#cachedUnderlying) return this.#cachedUnderlying;
|
|
1866
|
-
const fromRegistry = this.#cttAddressIsOverride || this.#chainId === void 0 ? void 0 :
|
|
1867
|
+
const fromRegistry = this.#cttAddressIsOverride || this.#chainId === void 0 ? void 0 : chunk5576FRT3_cjs.getTestTokenAddress(this.#chainId);
|
|
1867
1868
|
const resolved = fromRegistry ?? await this.#readCtt("underlying");
|
|
1868
1869
|
this.#cachedUnderlying = chunkJK4XMMKM_cjs.normaliseAddress(resolved);
|
|
1869
1870
|
return this.#cachedUnderlying;
|
|
@@ -2147,13 +2148,13 @@ var TestnetFaucetClient = class {
|
|
|
2147
2148
|
account
|
|
2148
2149
|
});
|
|
2149
2150
|
} catch (err) {
|
|
2150
|
-
if (
|
|
2151
|
+
if (chunkMVDQMV25_cjs.isContractRevert(err)) {
|
|
2151
2152
|
throw this.#mapRevert(target, method, err, void 0, accountAddress(account));
|
|
2152
2153
|
}
|
|
2153
2154
|
}
|
|
2154
2155
|
}
|
|
2155
2156
|
#mapRevert(target, method, err, productContext, account) {
|
|
2156
|
-
return
|
|
2157
|
+
return chunkMVDQMV25_cjs.mapContractRevert(err, {
|
|
2157
2158
|
method,
|
|
2158
2159
|
contractAddress: target.address,
|
|
2159
2160
|
abi: target.abi,
|