@tokenops/sdk 1.5.1 → 1.6.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 +158 -2
- package/SECURITY.md +7 -1
- package/dist/{chunk-67OV5CX2.cjs → chunk-2RNW4MIJ.cjs} +18 -0
- package/dist/{chunk-KLKI352M.cjs → chunk-43RFBQ73.cjs} +29 -29
- package/dist/{chunk-ZA673I3O.js → chunk-46T67CE2.js} +1 -1
- package/dist/{chunk-6BMP4ICG.js → chunk-4KJ66YRH.js} +61 -3
- package/dist/{chunk-JYOTGRSO.cjs → chunk-4ZCXK4VI.cjs} +68 -8
- package/dist/{chunk-SG65XWH7.js → chunk-6WSNS3UV.js} +1 -1
- package/dist/{chunk-V2PXZVBF.cjs → chunk-7G7UOQV4.cjs} +4 -4
- package/dist/{chunk-WENHUPZC.cjs → chunk-AYGRYDBX.cjs} +35 -36
- package/dist/{chunk-2NCLOQ56.cjs → chunk-BD4LZBVF.cjs} +85 -9
- package/dist/{chunk-5X5WL5CU.cjs → chunk-BK7YIVLK.cjs} +110 -149
- package/dist/{chunk-W7IGCOVL.cjs → chunk-CBRL2PJA.cjs} +12 -11
- package/dist/{chunk-ORFTDNFZ.js → chunk-CNP4L3GF.js} +4 -4
- package/dist/{chunk-QBJ7O2B4.js → chunk-DRSPMIZ7.js} +11 -1
- package/dist/{chunk-C7BRZXJA.cjs → chunk-EUKPOXWR.cjs} +15 -16
- package/dist/{chunk-YQIBBEFJ.js → chunk-HETNKZEE.js} +1 -1
- package/dist/{chunk-ODLTEGHB.js → chunk-KSDSXJ34.js} +1 -1
- package/dist/{chunk-TIUKIY5V.cjs → chunk-LBWRFZR3.cjs} +58 -40
- package/dist/{chunk-WMACINXO.js → chunk-NFW7AUEX.js} +1 -1
- package/dist/{chunk-4WPGQSNT.cjs → chunk-OL6SHN3D.cjs} +3 -3
- package/dist/{chunk-AOP6HMPW.js → chunk-PD7ME2BT.js} +75 -2
- package/dist/{chunk-2PWNH3UE.js → chunk-QET3Q4JP.js} +65 -9
- package/dist/{chunk-XGGTQQFH.js → chunk-QKKBBH7I.js} +2 -2
- package/dist/{chunk-6R4KNAPK.js → chunk-S2XD75JM.js} +10 -3
- package/dist/{chunk-MCRBVJGZ.cjs → chunk-SPGSO5SO.cjs} +29 -22
- package/dist/{chunk-FAXIIH5R.cjs → chunk-SYHNZSZZ.cjs} +3 -3
- package/dist/{chunk-IXLO7GO5.js → chunk-TN65XNTI.js} +47 -83
- package/dist/chunk-U57COLUE.js +56 -0
- package/dist/{chunk-DUZIIRPF.js → chunk-UE5XK2SY.js} +27 -9
- package/dist/{chunk-TEBM66WA.cjs → chunk-UJS4N2XM.cjs} +12 -12
- package/dist/{chunk-OXTLPTO3.js → chunk-V5D7BHW3.js} +4 -5
- package/dist/{chunk-NTZY6IB7.js → chunk-VHSNYUYV.js} +5 -4
- package/dist/{chunk-JK4XMMKM.cjs → chunk-VR3FREBX.cjs} +3 -3
- package/dist/{chunk-T46YXSBP.cjs → chunk-WO72UBQD.cjs} +11 -11
- package/dist/chunk-WOEETTH7.cjs +59 -0
- package/dist/{chunk-IJFQ5L4I.js → chunk-WTK6JDSI.js} +4 -5
- package/dist/{chunk-PUPKNW3R.cjs → chunk-WUXUWTFW.cjs} +3 -3
- package/dist/{chunk-PFXURMBZ.cjs → chunk-YFIWCYHC.cjs} +112 -54
- package/dist/{chunk-ZWXJTBZO.js → chunk-YPYCWLYP.js} +1 -1
- package/dist/core/addresses.d.ts +1 -1
- package/dist/core/errors.d.ts +1 -1
- package/dist/fhe/index.cjs +84 -64
- package/dist/fhe/index.d.cts +1 -0
- package/dist/fhe/index.d.ts +1 -0
- package/dist/fhe/index.js +21 -9
- package/dist/fhe/mock-erc7984.d.ts +4 -4
- package/dist/fhe/operators.d.ts +142 -2
- package/dist/fhe/react/index.cjs +21 -8
- package/dist/fhe/react/index.d.cts +2 -0
- package/dist/fhe/react/index.d.ts +2 -0
- package/dist/fhe/react/index.js +8 -3
- 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-airdrop/advanced/index.cjs +8 -9
- package/dist/fhe-airdrop/advanced/index.js +6 -7
- package/dist/fhe-airdrop/advanced/react/index.cjs +13 -14
- package/dist/fhe-airdrop/advanced/react/index.js +9 -10
- package/dist/fhe-airdrop/airdrop.d.ts +7 -0
- package/dist/fhe-airdrop/index.cjs +66 -67
- package/dist/fhe-airdrop/index.js +7 -8
- package/dist/fhe-airdrop/react/index.cjs +148 -137
- package/dist/fhe-airdrop/react/index.d.cts +3 -1
- package/dist/fhe-airdrop/react/index.d.ts +3 -1
- package/dist/fhe-airdrop/react/index.js +16 -14
- package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +17 -11
- package/dist/fhe-airdrop/react/useClaim.d.ts +8 -0
- package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +1 -1
- package/dist/fhe-airdrop/types.d.ts +14 -3
- package/dist/fhe-disperse/errors.d.ts +55 -0
- package/dist/fhe-disperse/index.cjs +74 -67
- package/dist/fhe-disperse/index.d.cts +1 -1
- package/dist/fhe-disperse/index.d.ts +1 -1
- package/dist/fhe-disperse/index.js +8 -9
- package/dist/fhe-disperse/react/index.cjs +105 -88
- 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 +12 -11
- package/dist/fhe-vesting/advanced/index.cjs +8 -9
- package/dist/fhe-vesting/advanced/index.js +6 -7
- package/dist/fhe-vesting/advanced/react/index.cjs +14 -15
- package/dist/fhe-vesting/advanced/react/index.js +11 -12
- package/dist/fhe-vesting/index.cjs +75 -76
- package/dist/fhe-vesting/index.js +9 -10
- package/dist/fhe-vesting/manager.d.ts +19 -0
- package/dist/fhe-vesting/react/index.cjs +245 -227
- 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 +27 -21
- 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 +87 -88
- package/dist/index.js +2 -3
- package/dist/testnet-faucet/index.cjs +55 -56
- package/dist/testnet-faucet/index.js +5 -6
- package/dist/testnet-faucet/react/index.cjs +53 -54
- package/dist/testnet-faucet/react/index.js +7 -8
- package/package.json +13 -8
- package/dist/chunk-66IHPTOK.cjs +0 -20
- package/dist/chunk-KWFFIJYX.js +0 -11
- package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +0 -27
- package/dist/fhe-airdrop/react/useGetClaimAmount.d.ts +0 -30
- 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,9 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunkBK7YIVLK_cjs = require('./chunk-BK7YIVLK.cjs');
|
|
4
|
+
var chunkBD4LZBVF_cjs = require('./chunk-BD4LZBVF.cjs');
|
|
5
|
+
var chunkEUKPOXWR_cjs = require('./chunk-EUKPOXWR.cjs');
|
|
6
|
+
var chunkWUXUWTFW_cjs = require('./chunk-WUXUWTFW.cjs');
|
|
7
|
+
var chunk2RNW4MIJ_cjs = require('./chunk-2RNW4MIJ.cjs');
|
|
7
8
|
var react = require('react');
|
|
8
9
|
var wagmi = require('wagmi');
|
|
9
10
|
|
|
@@ -25,7 +26,7 @@ function useHookFiredEvent(hookName, telemetry, hasWallet, chainId) {
|
|
|
25
26
|
function tryResolveFactoryAddress(override, chainId) {
|
|
26
27
|
if (override) return override;
|
|
27
28
|
if (chainId === void 0) return void 0;
|
|
28
|
-
return
|
|
29
|
+
return chunkWUXUWTFW_cjs.getFheVestingFactoryAddress(chainId);
|
|
29
30
|
}
|
|
30
31
|
function useMemoFactoryClient(opts = {}) {
|
|
31
32
|
const publicClient = wagmi.usePublicClient({ chainId: opts.chainId });
|
|
@@ -38,7 +39,7 @@ function useMemoFactoryClient(opts = {}) {
|
|
|
38
39
|
const client = react.useMemo(() => {
|
|
39
40
|
if (!publicClient) return void 0;
|
|
40
41
|
if (!resolvedAddress) return void 0;
|
|
41
|
-
return
|
|
42
|
+
return chunkEUKPOXWR_cjs.createConfidentialVestingFactoryClient({
|
|
42
43
|
publicClient,
|
|
43
44
|
...walletClient ? { walletClient } : {},
|
|
44
45
|
address: resolvedAddress,
|
|
@@ -58,16 +59,16 @@ function useMemoFactoryClient(opts = {}) {
|
|
|
58
59
|
function computeFactoryResolutionError(override, chainId) {
|
|
59
60
|
if (override) return void 0;
|
|
60
61
|
if (chainId === void 0) {
|
|
61
|
-
return new
|
|
62
|
+
return new chunk2RNW4MIJ_cjs.DeploymentAddressUnavailableError({
|
|
62
63
|
reason: "chain-id-missing",
|
|
63
64
|
product: "fheVesting",
|
|
64
65
|
contract: "confidentialVestingFactory",
|
|
65
66
|
clientLabel: "ConfidentialVestingFactoryClient"
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
|
-
const resolved =
|
|
69
|
+
const resolved = chunkWUXUWTFW_cjs.getFheVestingFactoryAddress(chainId);
|
|
69
70
|
if (!resolved) {
|
|
70
|
-
return new
|
|
71
|
+
return new chunk2RNW4MIJ_cjs.DeploymentAddressUnavailableError({
|
|
71
72
|
reason: "registry-not-deployed",
|
|
72
73
|
product: "fheVesting",
|
|
73
74
|
contract: "confidentialVestingFactory",
|
|
@@ -88,13 +89,13 @@ function useMemoManagerClient(opts) {
|
|
|
88
89
|
const client = react.useMemo(() => {
|
|
89
90
|
if (!publicClient) return void 0;
|
|
90
91
|
if (!opts.address) return void 0;
|
|
91
|
-
return
|
|
92
|
+
return chunkBK7YIVLK_cjs.createConfidentialVestingManagerClient({
|
|
92
93
|
publicClient,
|
|
93
94
|
...walletClient ? { walletClient } : {},
|
|
94
95
|
address: opts.address,
|
|
95
96
|
// Lazy — invoked per-encryption inside the headless client. Picks up
|
|
96
97
|
// whichever EncryptorSource the consumer last passed in.
|
|
97
|
-
encryptor: () =>
|
|
98
|
+
encryptor: () => chunkBD4LZBVF_cjs.resolveEncryptor(encryptorSourceRef.current),
|
|
98
99
|
...opts.aclAddress ? { aclAddress: opts.aclAddress } : {},
|
|
99
100
|
...telemetry ? { telemetry } : {}
|
|
100
101
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { createConfidentialAirdropClient } from './chunk-
|
|
2
|
-
import { createConfidentialAirdropFactoryClient, resolveEncryptor } from './chunk-
|
|
3
|
-
import { getFheAirdropFactoryAddress } from './chunk-
|
|
4
|
-
import { DeploymentAddressUnavailableError } from './chunk-
|
|
1
|
+
import { createConfidentialAirdropClient } from './chunk-S2XD75JM.js';
|
|
2
|
+
import { createConfidentialAirdropFactoryClient, resolveEncryptor } from './chunk-UE5XK2SY.js';
|
|
3
|
+
import { getFheAirdropFactoryAddress } from './chunk-QKKBBH7I.js';
|
|
4
|
+
import { DeploymentAddressUnavailableError } from './chunk-DRSPMIZ7.js';
|
|
5
5
|
import { useRef, useMemo } from 'react';
|
|
6
6
|
import { usePublicClient, useWalletClient } from 'wagmi';
|
|
7
7
|
|
|
@@ -492,4 +492,14 @@ var TokenOpsContractError = class extends TokenOpsSdkError {
|
|
|
492
492
|
}
|
|
493
493
|
};
|
|
494
494
|
|
|
495
|
-
|
|
495
|
+
// src/core/brands.ts
|
|
496
|
+
var asEncryptedHandle = (h) => h;
|
|
497
|
+
var asExternalInputProof = (h) => h;
|
|
498
|
+
var asTxHash = (h) => h;
|
|
499
|
+
var asVestingId = (h) => h;
|
|
500
|
+
var asAirdropId = (h) => h;
|
|
501
|
+
var asDisperseId = (h) => h;
|
|
502
|
+
var asRole = (h) => h;
|
|
503
|
+
var asSignature = (h) => h;
|
|
504
|
+
|
|
505
|
+
export { AccessDeniedError, AlreadyInitializedError, BatchTooLargeError, ContractRevertError, DecryptionFailedError, DeploymentAddressUnavailableError, EncryptionFailedError, FeatureDisabledError, FheHandleNotAllowedError, InsufficientBalanceError, InsufficientFeeError, InsufficientGasFundsError, InvalidArgumentError, InvalidSignatureError, MissingAccountError, MissingClientError, MissingEncryptorError, MissingPublicClientError, MissingWalletClientError, NetworkError, OPERATOR_NOT_APPROVED_REMEDIATION, OperatorNotApprovedError, PausedError, ReceiptEventAmbiguousError, ReceiptEventNotFoundError, ReentrancyError, RelayerUnreachableError, SigningFailedError, TokenOpsContractError, TokenOpsSdkError, TokenOpsValidationError, TransferFailedError, UnknownWriteFailureError, UnsupportedChainError, UserDecryptNotAllowedError, UserRejectedSignatureError, WalletChainMismatchError, WalletRejectedError, asAirdropId, asDisperseId, asEncryptedHandle, asExternalInputProof, asRole, asSignature, asTxHash, asVestingId, isTokenOpsSdkError };
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunk43RFBQ73_cjs = require('./chunk-43RFBQ73.cjs');
|
|
4
|
+
var chunkWUXUWTFW_cjs = require('./chunk-WUXUWTFW.cjs');
|
|
5
|
+
var chunkVR3FREBX_cjs = require('./chunk-VR3FREBX.cjs');
|
|
6
|
+
var chunk2RNW4MIJ_cjs = require('./chunk-2RNW4MIJ.cjs');
|
|
6
7
|
var chunkVJKZWYYJ_cjs = require('./chunk-VJKZWYYJ.cjs');
|
|
7
|
-
var chunk66IHPTOK_cjs = require('./chunk-66IHPTOK.cjs');
|
|
8
|
-
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
9
8
|
var viem = require('viem');
|
|
10
9
|
|
|
11
10
|
// src/fhe-vesting/abis/factory.ts
|
|
@@ -444,10 +443,10 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
444
443
|
this.publicClient = config.publicClient;
|
|
445
444
|
this.walletClient = config.walletClient;
|
|
446
445
|
const chainId = config.chainId ?? config.publicClient.chain?.id;
|
|
447
|
-
const addressOverride = config.address ?
|
|
448
|
-
const resolved = addressOverride ?? (chainId === void 0 ? void 0 :
|
|
446
|
+
const addressOverride = config.address ? chunkVR3FREBX_cjs.normaliseAddress(config.address) : void 0;
|
|
447
|
+
const resolved = addressOverride ?? (chainId === void 0 ? void 0 : chunkWUXUWTFW_cjs.getFheVestingFactoryAddress(chainId));
|
|
449
448
|
if (!resolved) {
|
|
450
|
-
throw new
|
|
449
|
+
throw new chunk2RNW4MIJ_cjs.DeploymentAddressUnavailableError({
|
|
451
450
|
reason: chainId === void 0 ? "chain-id-missing" : "registry-not-deployed",
|
|
452
451
|
product: "fheVesting",
|
|
453
452
|
contract: "confidentialVestingFactory",
|
|
@@ -463,7 +462,7 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
463
462
|
hasWallet: !!this.walletClient,
|
|
464
463
|
aclResolved: true,
|
|
465
464
|
// factory has no ACL dependency; constant for funnel-shape parity with manager.
|
|
466
|
-
sdkVersion:
|
|
465
|
+
sdkVersion: chunk43RFBQ73_cjs.SDK_VERSION
|
|
467
466
|
});
|
|
468
467
|
}
|
|
469
468
|
// ----------------------- writes -----------------------
|
|
@@ -653,20 +652,20 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
653
652
|
});
|
|
654
653
|
const ours = events.filter((ev) => ev.address.toLowerCase() === this.address.toLowerCase());
|
|
655
654
|
if (ours.length === 0) {
|
|
656
|
-
throw new
|
|
655
|
+
throw new chunk2RNW4MIJ_cjs.TokenOpsSdkError(
|
|
657
656
|
`${method}: no ManagerCreated event from factory ${this.address} in tx ${hash}`
|
|
658
657
|
);
|
|
659
658
|
}
|
|
660
659
|
if (ours.length > 1) {
|
|
661
|
-
throw new
|
|
660
|
+
throw new chunk2RNW4MIJ_cjs.TokenOpsSdkError(
|
|
662
661
|
`${method}: ${ours.length} ManagerCreated events from factory ${this.address} in tx ${hash}; ambiguous result`
|
|
663
662
|
);
|
|
664
663
|
}
|
|
665
|
-
return { hash:
|
|
664
|
+
return { hash: chunk2RNW4MIJ_cjs.asTxHash(hash), manager: ours[0].args.manager };
|
|
666
665
|
}
|
|
667
666
|
#requireWallet(method) {
|
|
668
667
|
if (!this.walletClient) {
|
|
669
|
-
throw new
|
|
668
|
+
throw new chunk2RNW4MIJ_cjs.MissingWalletClientError(method);
|
|
670
669
|
}
|
|
671
670
|
return this.walletClient;
|
|
672
671
|
}
|
|
@@ -674,7 +673,7 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
674
673
|
const wallet = this.#requireWallet(functionName);
|
|
675
674
|
const acct = account ?? wallet.account;
|
|
676
675
|
if (!acct) {
|
|
677
|
-
throw new
|
|
676
|
+
throw new chunk2RNW4MIJ_cjs.MissingAccountError(String(functionName));
|
|
678
677
|
}
|
|
679
678
|
await this.#preflightWrite(String(functionName), functionName, args, acct);
|
|
680
679
|
try {
|
|
@@ -691,7 +690,7 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
691
690
|
}
|
|
692
691
|
}
|
|
693
692
|
#mapRevert(method, err, account) {
|
|
694
|
-
return
|
|
693
|
+
return chunk43RFBQ73_cjs.mapContractRevert(err, {
|
|
695
694
|
method,
|
|
696
695
|
contractAddress: this.address,
|
|
697
696
|
abi: confidentialVestingFactoryAbi,
|
|
@@ -716,7 +715,7 @@ var ConfidentialVestingFactoryClient = class {
|
|
|
716
715
|
...value !== void 0 ? { value } : {}
|
|
717
716
|
});
|
|
718
717
|
} catch (err) {
|
|
719
|
-
if (
|
|
718
|
+
if (chunk43RFBQ73_cjs.isContractRevert(err)) {
|
|
720
719
|
throw this.#mapRevert(method, err, accountAddress(account));
|
|
721
720
|
}
|
|
722
721
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfidentialVestingFactoryClient, confidentialVestingFactoryAbi } from './chunk-
|
|
1
|
+
import { ConfidentialVestingFactoryClient, confidentialVestingFactoryAbi } from './chunk-V5D7BHW3.js';
|
|
2
2
|
|
|
3
3
|
// src/fhe-vesting/advanced/factory-advanced.ts
|
|
4
4
|
var ConfidentialVestingFactoryAdvancedClient = class extends ConfidentialVestingFactoryClient {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfidentialAirdropFactoryClient, confidentialAirdropFactoryAbi } from './chunk-
|
|
1
|
+
import { ConfidentialAirdropFactoryClient, confidentialAirdropFactoryAbi } from './chunk-UE5XK2SY.js';
|
|
2
2
|
|
|
3
3
|
// src/fhe-airdrop/advanced/factory-advanced.ts
|
|
4
4
|
var ConfidentialAirdropFactoryAdvancedClient = class extends ConfidentialAirdropFactoryClient {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkFWHYQZ5E_cjs = require('./chunk-FWHYQZ5E.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
4
|
+
var chunk43RFBQ73_cjs = require('./chunk-43RFBQ73.cjs');
|
|
5
|
+
var chunkWUXUWTFW_cjs = require('./chunk-WUXUWTFW.cjs');
|
|
6
|
+
var chunkVR3FREBX_cjs = require('./chunk-VR3FREBX.cjs');
|
|
7
|
+
var chunk2RNW4MIJ_cjs = require('./chunk-2RNW4MIJ.cjs');
|
|
7
8
|
var chunkVJKZWYYJ_cjs = require('./chunk-VJKZWYYJ.cjs');
|
|
8
|
-
var chunk66IHPTOK_cjs = require('./chunk-66IHPTOK.cjs');
|
|
9
|
-
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
10
9
|
var viem = require('viem');
|
|
11
10
|
|
|
12
11
|
// src/fhe-airdrop/abis/factory.ts
|
|
@@ -936,7 +935,7 @@ function resolveEncryptor(source) {
|
|
|
936
935
|
var MAX_UINT64 = (1n << 64n) - 1n;
|
|
937
936
|
function assertUint64(value, label) {
|
|
938
937
|
if (value < 0n || value > MAX_UINT64) {
|
|
939
|
-
throw new
|
|
938
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
940
939
|
method: "encryptUint64",
|
|
941
940
|
argument: label,
|
|
942
941
|
reason: "exceeds uint64 range (0..2^64-1)",
|
|
@@ -957,7 +956,7 @@ async function encryptUint64({
|
|
|
957
956
|
userAddress
|
|
958
957
|
});
|
|
959
958
|
if (handles.length !== 1) {
|
|
960
|
-
throw new
|
|
959
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
961
960
|
method: "encryptUint64",
|
|
962
961
|
argument: "handles",
|
|
963
962
|
reason: `expected 1 handle, got ${handles.length}`,
|
|
@@ -965,8 +964,8 @@ async function encryptUint64({
|
|
|
965
964
|
});
|
|
966
965
|
}
|
|
967
966
|
return {
|
|
968
|
-
handle:
|
|
969
|
-
inputProof:
|
|
967
|
+
handle: chunk2RNW4MIJ_cjs.asEncryptedHandle(viem.bytesToHex(handles[0])),
|
|
968
|
+
inputProof: chunk2RNW4MIJ_cjs.asExternalInputProof(viem.bytesToHex(inputProof))
|
|
970
969
|
};
|
|
971
970
|
}
|
|
972
971
|
async function encryptUint64Batch({
|
|
@@ -976,7 +975,7 @@ async function encryptUint64Batch({
|
|
|
976
975
|
values
|
|
977
976
|
}) {
|
|
978
977
|
if (values.length === 0) {
|
|
979
|
-
throw new
|
|
978
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
980
979
|
method: "encryptUint64Batch",
|
|
981
980
|
argument: "values",
|
|
982
981
|
reason: "must be non-empty"
|
|
@@ -989,7 +988,7 @@ async function encryptUint64Batch({
|
|
|
989
988
|
userAddress
|
|
990
989
|
});
|
|
991
990
|
if (handles.length !== values.length) {
|
|
992
|
-
throw new
|
|
991
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
993
992
|
method: "encryptUint64Batch",
|
|
994
993
|
argument: "handles",
|
|
995
994
|
reason: `expected ${values.length} handles, got ${handles.length}`,
|
|
@@ -997,23 +996,23 @@ async function encryptUint64Batch({
|
|
|
997
996
|
});
|
|
998
997
|
}
|
|
999
998
|
return {
|
|
1000
|
-
handles: handles.map((h) =>
|
|
1001
|
-
inputProof:
|
|
999
|
+
handles: handles.map((h) => chunk2RNW4MIJ_cjs.asEncryptedHandle(viem.bytesToHex(h))),
|
|
1000
|
+
inputProof: chunk2RNW4MIJ_cjs.asExternalInputProof(viem.bytesToHex(inputProof))
|
|
1002
1001
|
};
|
|
1003
1002
|
}
|
|
1004
1003
|
async function signClaimAuthorization(args) {
|
|
1005
1004
|
if (args.encryptedAmountHandle.length !== 66) {
|
|
1006
|
-
throw new
|
|
1005
|
+
throw new chunk2RNW4MIJ_cjs.TokenOpsSdkError(
|
|
1007
1006
|
`signClaimAuthorization: encryptedAmountHandle must be a 32-byte hex string (0x + 64 chars), got length ${args.encryptedAmountHandle.length}`
|
|
1008
1007
|
);
|
|
1009
1008
|
}
|
|
1010
1009
|
const account = args.walletClient.account;
|
|
1011
1010
|
if (!account) {
|
|
1012
|
-
throw new
|
|
1011
|
+
throw new chunk2RNW4MIJ_cjs.MissingAccountError("signClaimAuthorization");
|
|
1013
1012
|
}
|
|
1014
1013
|
const chainId = args.walletClient.chain?.id;
|
|
1015
1014
|
if (!chainId) {
|
|
1016
|
-
throw new
|
|
1015
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1017
1016
|
method: "signClaimAuthorization",
|
|
1018
1017
|
argument: "walletClient.chain.id",
|
|
1019
1018
|
reason: "required for EIP712 chainId binding; pass a walletClient constructed with a known chain (e.g. `createWalletClient({ chain: sepolia, ... })`)."
|
|
@@ -1039,7 +1038,7 @@ async function signClaimAuthorization(args) {
|
|
|
1039
1038
|
encryptedAmount: args.encryptedAmountHandle
|
|
1040
1039
|
}
|
|
1041
1040
|
});
|
|
1042
|
-
return
|
|
1041
|
+
return chunk2RNW4MIJ_cjs.asSignature(sig);
|
|
1043
1042
|
}
|
|
1044
1043
|
var airdropFactoryProductMapper = () => void 0;
|
|
1045
1044
|
var ConfidentialAirdropFactoryClient = class {
|
|
@@ -1053,10 +1052,10 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1053
1052
|
this.walletClient = config.walletClient;
|
|
1054
1053
|
this.encryptor = config.encryptor;
|
|
1055
1054
|
const chainId = config.chainId ?? config.publicClient.chain?.id;
|
|
1056
|
-
const addressOverride = config.address ?
|
|
1057
|
-
const resolved = addressOverride ?? (chainId === void 0 ? void 0 :
|
|
1055
|
+
const addressOverride = config.address ? chunkVR3FREBX_cjs.normaliseAddress(config.address) : void 0;
|
|
1056
|
+
const resolved = addressOverride ?? (chainId === void 0 ? void 0 : chunkWUXUWTFW_cjs.getFheAirdropFactoryAddress(chainId));
|
|
1058
1057
|
if (!resolved) {
|
|
1059
|
-
throw new
|
|
1058
|
+
throw new chunk2RNW4MIJ_cjs.DeploymentAddressUnavailableError({
|
|
1060
1059
|
reason: chainId === void 0 ? "chain-id-missing" : "registry-not-deployed",
|
|
1061
1060
|
product: "fheAirdrop",
|
|
1062
1061
|
contract: "confidentialAirdropFactory",
|
|
@@ -1072,7 +1071,7 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1072
1071
|
hasWallet: !!this.walletClient,
|
|
1073
1072
|
aclResolved: true,
|
|
1074
1073
|
// factory has no ACL dependency; constant for funnel-shape parity with client.
|
|
1075
|
-
sdkVersion:
|
|
1074
|
+
sdkVersion: chunk43RFBQ73_cjs.SDK_VERSION
|
|
1076
1075
|
});
|
|
1077
1076
|
}
|
|
1078
1077
|
// ----------------------- writes -----------------------
|
|
@@ -1407,7 +1406,7 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1407
1406
|
const tokenOk = viem.isAddress(params.token, { strict: true }) && params.token !== ZERO_ADDRESS;
|
|
1408
1407
|
if (!tokenOk) {
|
|
1409
1408
|
pushBlocker(
|
|
1410
|
-
new
|
|
1409
|
+
new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1411
1410
|
method: "createConfidentialAirdrop",
|
|
1412
1411
|
argument: "params.token",
|
|
1413
1412
|
reason: "must be a valid, non-zero EIP-55 checksummed address",
|
|
@@ -1418,7 +1417,7 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1418
1417
|
const adminOk = viem.isAddress(params.admin, { strict: true }) && params.admin !== ZERO_ADDRESS;
|
|
1419
1418
|
if (!adminOk) {
|
|
1420
1419
|
pushBlocker(
|
|
1421
|
-
new
|
|
1420
|
+
new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1422
1421
|
method: "createConfidentialAirdrop",
|
|
1423
1422
|
argument: "params.admin",
|
|
1424
1423
|
reason: "must be a valid, non-zero EIP-55 checksummed address",
|
|
@@ -1428,7 +1427,7 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1428
1427
|
}
|
|
1429
1428
|
if (params.startTimestamp >= params.endTimestamp) {
|
|
1430
1429
|
pushBlocker(
|
|
1431
|
-
new
|
|
1430
|
+
new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1432
1431
|
method: "createConfidentialAirdrop",
|
|
1433
1432
|
argument: "params.startTimestamp/params.endTimestamp",
|
|
1434
1433
|
reason: "startTimestamp must be strictly less than endTimestamp",
|
|
@@ -1436,7 +1435,7 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1436
1435
|
})
|
|
1437
1436
|
);
|
|
1438
1437
|
}
|
|
1439
|
-
const [block, customFee, defaultFee,
|
|
1438
|
+
const [block, customFee, defaultFee, operatorRead] = await Promise.all([
|
|
1440
1439
|
this.publicClient.getBlock(),
|
|
1441
1440
|
this.getCustomFee(creator),
|
|
1442
1441
|
this.defaultGasFee(),
|
|
@@ -1445,12 +1444,26 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1445
1444
|
abi: chunkFWHYQZ5E_cjs.erc7984OperatorAbi,
|
|
1446
1445
|
functionName: "isOperator",
|
|
1447
1446
|
args: [creator, this.address]
|
|
1448
|
-
}) :
|
|
1447
|
+
}).then((v) => ({ ok: true, value: v })).catch((err) => {
|
|
1448
|
+
if (isNotErc7984Failure(err)) return { ok: false, err };
|
|
1449
|
+
throw err;
|
|
1450
|
+
}) : Promise.resolve({ ok: true, value: false })
|
|
1449
1451
|
]);
|
|
1452
|
+
const isFactoryOperator = operatorRead.ok ? operatorRead.value : false;
|
|
1453
|
+
if (!operatorRead.ok) {
|
|
1454
|
+
pushBlocker(
|
|
1455
|
+
new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1456
|
+
method: "createConfidentialAirdrop",
|
|
1457
|
+
argument: "params.token",
|
|
1458
|
+
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)",
|
|
1459
|
+
value: params.token
|
|
1460
|
+
})
|
|
1461
|
+
);
|
|
1462
|
+
}
|
|
1450
1463
|
const gasFee = customFee.enabled ? customFee.gasFee : defaultFee;
|
|
1451
1464
|
if (params.endTimestamp <= Number(block.timestamp)) {
|
|
1452
1465
|
pushBlocker(
|
|
1453
|
-
new
|
|
1466
|
+
new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1454
1467
|
method: "createConfidentialAirdrop",
|
|
1455
1468
|
argument: "params.endTimestamp",
|
|
1456
1469
|
reason: "must be in the future (the clone's initialize reverts with EndTimeInPast)",
|
|
@@ -1458,9 +1471,9 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1458
1471
|
})
|
|
1459
1472
|
);
|
|
1460
1473
|
}
|
|
1461
|
-
if (funding === true && !isFactoryOperator) {
|
|
1474
|
+
if (funding === true && tokenOk && operatorRead.ok && !isFactoryOperator) {
|
|
1462
1475
|
pushBlocker(
|
|
1463
|
-
new
|
|
1476
|
+
new chunk2RNW4MIJ_cjs.OperatorNotApprovedError({
|
|
1464
1477
|
method: "createAndFundConfidentialAirdrop",
|
|
1465
1478
|
contractAddress: this.address,
|
|
1466
1479
|
tokenAddress: params.token,
|
|
@@ -1482,7 +1495,7 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1482
1495
|
alreadyDeployed = bytecode !== void 0 && bytecode !== "0x";
|
|
1483
1496
|
if (alreadyDeployed) {
|
|
1484
1497
|
pushBlocker(
|
|
1485
|
-
new
|
|
1498
|
+
new chunk2RNW4MIJ_cjs.AlreadyInitializedError({
|
|
1486
1499
|
method: "createConfidentialAirdrop",
|
|
1487
1500
|
contractAddress: predictedAirdrop
|
|
1488
1501
|
})
|
|
@@ -1515,27 +1528,27 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1515
1528
|
});
|
|
1516
1529
|
const ours = events.filter((ev) => ev.address.toLowerCase() === this.address.toLowerCase());
|
|
1517
1530
|
if (ours.length === 0) {
|
|
1518
|
-
throw new
|
|
1531
|
+
throw new chunk2RNW4MIJ_cjs.TokenOpsSdkError(
|
|
1519
1532
|
`${method}: no ConfidentialAirdropCreated event from factory ${this.address} in tx ${hash}`
|
|
1520
1533
|
);
|
|
1521
1534
|
}
|
|
1522
1535
|
if (ours.length > 1) {
|
|
1523
|
-
throw new
|
|
1536
|
+
throw new chunk2RNW4MIJ_cjs.TokenOpsSdkError(
|
|
1524
1537
|
`${method}: ${ours.length} ConfidentialAirdropCreated events from factory ${this.address} in tx ${hash}; ambiguous result`
|
|
1525
1538
|
);
|
|
1526
1539
|
}
|
|
1527
|
-
return { hash:
|
|
1540
|
+
return { hash: chunk2RNW4MIJ_cjs.asTxHash(hash), airdrop: ours[0].args.airdrop };
|
|
1528
1541
|
}
|
|
1529
1542
|
#requireWallet(method) {
|
|
1530
1543
|
if (!this.walletClient) {
|
|
1531
|
-
throw new
|
|
1544
|
+
throw new chunk2RNW4MIJ_cjs.MissingWalletClientError(method);
|
|
1532
1545
|
}
|
|
1533
1546
|
return this.walletClient;
|
|
1534
1547
|
}
|
|
1535
1548
|
#resolveAccount(wallet, override, method) {
|
|
1536
1549
|
const acct = override ?? wallet.account;
|
|
1537
1550
|
if (!acct) {
|
|
1538
|
-
throw new
|
|
1551
|
+
throw new chunk2RNW4MIJ_cjs.MissingAccountError(method);
|
|
1539
1552
|
}
|
|
1540
1553
|
return acct;
|
|
1541
1554
|
}
|
|
@@ -1549,14 +1562,14 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1549
1562
|
const hasAmount = amount !== void 0;
|
|
1550
1563
|
const hasInput = preEncrypted !== void 0;
|
|
1551
1564
|
if (hasAmount && hasInput) {
|
|
1552
|
-
throw new
|
|
1565
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1553
1566
|
method,
|
|
1554
1567
|
argument: "amount/encryptedInput",
|
|
1555
1568
|
reason: "exactly one of `amount` (plaintext, SDK encrypts) or `encryptedInput` (pre-encrypted) must be supplied \u2014 got both"
|
|
1556
1569
|
});
|
|
1557
1570
|
}
|
|
1558
1571
|
if (!hasAmount && !hasInput) {
|
|
1559
|
-
throw new
|
|
1572
|
+
throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
|
|
1560
1573
|
method,
|
|
1561
1574
|
argument: "amount/encryptedInput",
|
|
1562
1575
|
reason: "exactly one of `amount` (plaintext, SDK encrypts) or `encryptedInput` (pre-encrypted) must be supplied \u2014 got neither"
|
|
@@ -1565,7 +1578,7 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1565
1578
|
if (hasInput) return preEncrypted;
|
|
1566
1579
|
const enc = encryptor ?? resolveEncryptor(this.encryptor);
|
|
1567
1580
|
if (!enc) {
|
|
1568
|
-
throw new
|
|
1581
|
+
throw new chunk2RNW4MIJ_cjs.MissingEncryptorError("encryptAmount", {
|
|
1569
1582
|
hint: "Pass `encryptor` to the call or the client config (eager or lazy factory)."
|
|
1570
1583
|
});
|
|
1571
1584
|
}
|
|
@@ -1594,7 +1607,7 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1594
1607
|
}
|
|
1595
1608
|
}
|
|
1596
1609
|
#mapRevert(method, err, account) {
|
|
1597
|
-
return
|
|
1610
|
+
return chunk43RFBQ73_cjs.mapContractRevert(err, {
|
|
1598
1611
|
method,
|
|
1599
1612
|
contractAddress: this.address,
|
|
1600
1613
|
abi: confidentialAirdropFactoryAbi,
|
|
@@ -1622,7 +1635,7 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1622
1635
|
...value !== void 0 ? { value } : {}
|
|
1623
1636
|
});
|
|
1624
1637
|
} catch (err) {
|
|
1625
|
-
if (
|
|
1638
|
+
if (chunk43RFBQ73_cjs.isContractRevert(err)) {
|
|
1626
1639
|
throw this.#mapRevert(method, err, accountAddress(account));
|
|
1627
1640
|
}
|
|
1628
1641
|
}
|
|
@@ -1640,6 +1653,11 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1640
1653
|
function createConfidentialAirdropFactoryClient(config) {
|
|
1641
1654
|
return new ConfidentialAirdropFactoryClient(config);
|
|
1642
1655
|
}
|
|
1656
|
+
function isNotErc7984Failure(err) {
|
|
1657
|
+
if (chunk43RFBQ73_cjs.isContractRevert(err)) return true;
|
|
1658
|
+
if (!(err instanceof viem.BaseError)) return false;
|
|
1659
|
+
return err.walk((e) => e instanceof viem.ContractFunctionZeroDataError) instanceof viem.ContractFunctionZeroDataError;
|
|
1660
|
+
}
|
|
1643
1661
|
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
1644
1662
|
function accountAddress(account) {
|
|
1645
1663
|
return typeof account === "string" ? account : account.address;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TokenOpsSdkError, InvalidArgumentError, DecryptionFailedError, EncryptionFailedError, RelayerUnreachableError, SigningFailedError, UserRejectedSignatureError, UserDecryptNotAllowedError } from './chunk-
|
|
1
|
+
import { TokenOpsSdkError, InvalidArgumentError, DecryptionFailedError, EncryptionFailedError, RelayerUnreachableError, SigningFailedError, UserRejectedSignatureError, UserDecryptNotAllowedError } from './chunk-DRSPMIZ7.js';
|
|
2
2
|
|
|
3
3
|
// src/core/zama-error-mapper.ts
|
|
4
4
|
function mapZamaError(error, args) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkLBWRFZR3_cjs = require('./chunk-LBWRFZR3.cjs');
|
|
4
4
|
|
|
5
5
|
// src/fhe-airdrop/advanced/factory-advanced.ts
|
|
6
|
-
var ConfidentialAirdropFactoryAdvancedClient = class extends
|
|
6
|
+
var ConfidentialAirdropFactoryAdvancedClient = class extends chunkLBWRFZR3_cjs.ConfidentialAirdropFactoryClient {
|
|
7
7
|
/**
|
|
8
8
|
* Compute the deterministic CREATE2 address for an airdrop clone without
|
|
9
9
|
* deploying it.
|
|
@@ -21,7 +21,7 @@ var ConfidentialAirdropFactoryAdvancedClient = class extends chunkTIUKIY5V_cjs.C
|
|
|
21
21
|
async predictAirdropAddress(args) {
|
|
22
22
|
return this.publicClient.readContract({
|
|
23
23
|
address: this.address,
|
|
24
|
-
abi:
|
|
24
|
+
abi: chunkLBWRFZR3_cjs.confidentialAirdropFactoryAbi,
|
|
25
25
|
functionName: "predictAirdropAddress",
|
|
26
26
|
args: [toAbiParams(args.params), args.userSalt, args.deployer, args.gasFee]
|
|
27
27
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { InvalidArgumentError } from './chunk-
|
|
1
|
+
import { InvalidArgumentError, asExternalInputProof, asEncryptedHandle } from './chunk-DRSPMIZ7.js';
|
|
2
|
+
import { bytesToHex } from 'viem';
|
|
2
3
|
|
|
3
4
|
// src/fhe/scale-ratio.ts
|
|
4
5
|
var FHE_SPLIT_DENOMINATOR = 90090000n;
|
|
@@ -131,5 +132,77 @@ function toIntegerBigInt(value, method, argument) {
|
|
|
131
132
|
}
|
|
132
133
|
return BigInt(value);
|
|
133
134
|
}
|
|
135
|
+
function resolveEncryptor(source) {
|
|
136
|
+
if (source === void 0) return void 0;
|
|
137
|
+
return typeof source === "function" ? source() : source;
|
|
138
|
+
}
|
|
139
|
+
var MAX_UINT642 = (1n << 64n) - 1n;
|
|
140
|
+
function assertUint64(value, label) {
|
|
141
|
+
if (value < 0n || value > MAX_UINT642) {
|
|
142
|
+
throw new InvalidArgumentError({
|
|
143
|
+
method: "encryptUint64",
|
|
144
|
+
argument: label,
|
|
145
|
+
reason: `does not fit in uint64 (0..2^64-1)`,
|
|
146
|
+
value
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async function encryptUint64({
|
|
151
|
+
encryptor,
|
|
152
|
+
contractAddress,
|
|
153
|
+
userAddress,
|
|
154
|
+
value
|
|
155
|
+
}) {
|
|
156
|
+
assertUint64(value, "value");
|
|
157
|
+
const { handles, inputProof } = await encryptor.encrypt({
|
|
158
|
+
values: [{ value, type: "euint64" }],
|
|
159
|
+
contractAddress,
|
|
160
|
+
userAddress
|
|
161
|
+
});
|
|
162
|
+
if (handles.length !== 1) {
|
|
163
|
+
throw new InvalidArgumentError({
|
|
164
|
+
method: "encryptUint64",
|
|
165
|
+
argument: "handles",
|
|
166
|
+
reason: `expected 1 handle, got ${handles.length}`,
|
|
167
|
+
value: handles.length
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
handle: asEncryptedHandle(bytesToHex(handles[0])),
|
|
172
|
+
inputProof: asExternalInputProof(bytesToHex(inputProof))
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
async function encryptUint64Batch({
|
|
176
|
+
encryptor,
|
|
177
|
+
contractAddress,
|
|
178
|
+
userAddress,
|
|
179
|
+
values
|
|
180
|
+
}) {
|
|
181
|
+
if (values.length === 0) {
|
|
182
|
+
throw new InvalidArgumentError({
|
|
183
|
+
method: "encryptUint64Batch",
|
|
184
|
+
argument: "values",
|
|
185
|
+
reason: "must be non-empty"
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
values.forEach((v, i) => assertUint64(v, `values[${i}]`));
|
|
189
|
+
const { handles, inputProof } = await encryptor.encrypt({
|
|
190
|
+
values: values.map((value) => ({ value, type: "euint64" })),
|
|
191
|
+
contractAddress,
|
|
192
|
+
userAddress
|
|
193
|
+
});
|
|
194
|
+
if (handles.length !== values.length) {
|
|
195
|
+
throw new InvalidArgumentError({
|
|
196
|
+
method: "encryptUint64Batch",
|
|
197
|
+
argument: "handles",
|
|
198
|
+
reason: `expected ${values.length} handles, got ${handles.length}`,
|
|
199
|
+
value: handles.length
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
handles: handles.map((h) => asEncryptedHandle(bytesToHex(h))),
|
|
204
|
+
inputProof: asExternalInputProof(bytesToHex(inputProof))
|
|
205
|
+
};
|
|
206
|
+
}
|
|
134
207
|
|
|
135
|
-
export { FHE_SPLIT_DENOMINATOR, scaleRatio, share };
|
|
208
|
+
export { FHE_SPLIT_DENOMINATOR, encryptUint64, encryptUint64Batch, resolveEncryptor, scaleRatio, share };
|