@tokenops/sdk 1.1.1 → 1.5.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/README.md +18 -8
- package/dist/{chunk-5SGMJADP.cjs → chunk-2NCLOQ56.cjs} +9 -9
- package/dist/{chunk-FXCW7LVB.js → chunk-2PWNH3UE.js} +35 -6
- package/dist/{chunk-FPQBFIUW.cjs → chunk-4WPGQSNT.cjs} +3 -3
- package/dist/{chunk-OYLZEEHF.cjs → chunk-5X5WL5CU.cjs} +265 -101
- package/dist/{chunk-56UI7LUR.cjs → chunk-67OV5CX2.cjs} +19 -0
- package/dist/{chunk-WRCUDSUJ.js → chunk-6BMP4ICG.js} +2 -2
- package/dist/{chunk-XXXDQSHE.js → chunk-6R4KNAPK.js} +5 -3
- package/dist/{chunk-XSNLAS5M.js → chunk-AOP6HMPW.js} +1 -1
- package/dist/{chunk-SAGJIEQK.cjs → chunk-C7BRZXJA.cjs} +14 -14
- package/dist/{chunk-OQZAZIAS.js → chunk-DUZIIRPF.js} +174 -5
- package/dist/{chunk-Q7ARQSUH.cjs → chunk-FAXIIH5R.cjs} +3 -3
- package/dist/chunk-FT4LNBOS.js +11 -0
- package/dist/{chunk-QE7ZONJ2.js → chunk-IJFQ5L4I.js} +4 -4
- package/dist/{chunk-X56UVEXS.js → chunk-IXLO7GO5.js} +209 -45
- package/dist/{chunk-CQIPRNS7.cjs → chunk-JK4XMMKM.cjs} +3 -3
- package/dist/{chunk-ITQ7WKVC.cjs → chunk-JYOTGRSO.cjs} +8 -8
- package/dist/{chunk-VDXVNZCO.cjs → chunk-KLKI352M.cjs} +85 -29
- package/dist/{chunk-5SA2HF2W.cjs → chunk-MCRBVJGZ.cjs} +24 -22
- package/dist/{chunk-3PQ2RFPC.js → chunk-NTZY6IB7.js} +4 -4
- package/dist/{chunk-JJ4R5QXF.js → chunk-ODLTEGHB.js} +1 -1
- package/dist/{chunk-XWDVPV42.js → chunk-ORFTDNFZ.js} +4 -4
- package/dist/{chunk-IR5AK5U5.js → chunk-OXTLPTO3.js} +4 -4
- package/dist/{chunk-23F7JIK5.cjs → chunk-PFXURMBZ.cjs} +77 -48
- package/dist/{chunk-3ZRHDTEX.cjs → chunk-PUPKNW3R.cjs} +2 -2
- package/dist/{chunk-IVE3QEGD.js → chunk-QBJ7O2B4.js} +18 -1
- package/dist/{chunk-JFLEEXKP.js → chunk-SG65XWH7.js} +58 -2
- package/dist/{chunk-G7G75C46.cjs → chunk-T46YXSBP.cjs} +11 -11
- package/dist/{chunk-NS44KBV5.cjs → chunk-TEBM66WA.cjs} +12 -12
- package/dist/{chunk-SYHXDHWX.cjs → chunk-TIUKIY5V.cjs} +193 -24
- package/dist/{chunk-W7JHOK7G.cjs → chunk-V2PXZVBF.cjs} +4 -4
- package/dist/{chunk-SEKC7H5Y.cjs → chunk-W7IGCOVL.cjs} +11 -11
- package/dist/{chunk-5KHIQG7Y.cjs → chunk-WENHUPZC.cjs} +31 -31
- package/dist/{chunk-ZXCOJY2Z.js → chunk-WMACINXO.js} +1 -1
- package/dist/{chunk-M7V2EDPB.js → chunk-XGGTQQFH.js} +1 -1
- package/dist/{chunk-ITQBDRWX.js → chunk-YQIBBEFJ.js} +1 -1
- package/dist/{chunk-BE2AIZ3K.js → chunk-ZA673I3O.js} +1 -1
- package/dist/chunk-ZQUE2B3Q.cjs +33 -0
- package/dist/{chunk-FYQ2UW4T.js → chunk-ZWXJTBZO.js} +1 -1
- package/dist/core/errors.d.ts +41 -1
- package/dist/core/revert-mapper.d.ts +77 -0
- package/dist/core/wagmi-compat.d.ts +40 -0
- package/dist/fhe/index.cjs +112 -66
- package/dist/fhe/index.d.cts +1 -1
- package/dist/fhe/index.d.ts +1 -1
- package/dist/fhe/index.js +50 -8
- package/dist/fhe/react/index.cjs +7 -7
- package/dist/fhe/react/index.js +2 -2
- package/dist/fhe/sepolia-encryptor-web.d.ts +27 -1
- package/dist/fhe/sepolia-encryptor.d.ts +38 -0
- package/dist/fhe-airdrop/advanced/index.cjs +9 -8
- package/dist/fhe-airdrop/advanced/index.js +7 -6
- package/dist/fhe-airdrop/advanced/react/index.cjs +14 -13
- package/dist/fhe-airdrop/advanced/react/index.js +10 -9
- package/dist/fhe-airdrop/airdrop.d.ts +2 -0
- package/dist/fhe-airdrop/encryption.d.ts +8 -0
- package/dist/fhe-airdrop/factory.d.ts +86 -1
- package/dist/fhe-airdrop/index.cjs +61 -57
- package/dist/fhe-airdrop/index.d.cts +3 -3
- package/dist/fhe-airdrop/index.d.ts +3 -3
- package/dist/fhe-airdrop/index.js +7 -7
- package/dist/fhe-airdrop/react/index.cjs +163 -133
- package/dist/fhe-airdrop/react/index.d.cts +4 -3
- package/dist/fhe-airdrop/react/index.d.ts +4 -3
- package/dist/fhe-airdrop/react/index.js +38 -13
- package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +2 -0
- package/dist/fhe-airdrop/react/useAirdropIsSignatureValid.d.ts +3 -2
- package/dist/fhe-airdrop/react/useClaim.d.ts +2 -0
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +8 -0
- package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +8 -0
- package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +8 -0
- package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +51 -0
- package/dist/fhe-airdrop/types.d.ts +45 -0
- package/dist/fhe-disperse/encryption.d.ts +8 -0
- package/dist/fhe-disperse/index.cjs +69 -65
- 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 -8
- package/dist/fhe-disperse/react/index.cjs +90 -86
- package/dist/fhe-disperse/react/index.d.cts +1 -1
- package/dist/fhe-disperse/react/index.d.ts +1 -1
- package/dist/fhe-disperse/react/index.js +10 -10
- package/dist/fhe-disperse/react/useCalculateFee.d.ts +7 -0
- package/dist/fhe-disperse/react/useDisperse.d.ts +9 -0
- package/dist/fhe-disperse/react/usePreflightDisperse.d.ts +7 -0
- package/dist/fhe-disperse/react/useSingletonCalculateFee.d.ts +7 -0
- package/dist/fhe-disperse/react/useSingletonWithdrawTokenFee.d.ts +6 -0
- package/dist/fhe-disperse/react/useWithdrawTokenFee.d.ts +6 -0
- package/dist/fhe-disperse/singleton.d.ts +29 -0
- package/dist/fhe-disperse/subtotals.d.ts +6 -0
- package/dist/fhe-vesting/advanced/index.cjs +8 -8
- package/dist/fhe-vesting/advanced/index.js +6 -6
- package/dist/fhe-vesting/advanced/react/index.cjs +15 -14
- package/dist/fhe-vesting/advanced/react/index.js +12 -11
- package/dist/fhe-vesting/encryption.d.ts +8 -0
- package/dist/fhe-vesting/index.cjs +79 -75
- package/dist/fhe-vesting/index.d.cts +2 -2
- package/dist/fhe-vesting/index.d.ts +2 -2
- package/dist/fhe-vesting/index.js +9 -9
- package/dist/fhe-vesting/manager.d.ts +100 -1
- package/dist/fhe-vesting/react/index.cjs +241 -219
- package/dist/fhe-vesting/react/index.d.cts +3 -2
- package/dist/fhe-vesting/react/index.d.ts +3 -2
- package/dist/fhe-vesting/react/index.js +29 -12
- package/dist/fhe-vesting/react/useAdminClaim.d.ts +2 -0
- package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +2 -0
- package/dist/fhe-vesting/react/useBatchCreateVesting.d.ts +8 -0
- package/dist/fhe-vesting/react/useClaim.d.ts +2 -0
- package/dist/fhe-vesting/react/useCreateVesting.d.ts +8 -0
- package/dist/fhe-vesting/react/useManagerWithdrawTokenFee.d.ts +6 -0
- package/dist/fhe-vesting/react/usePartialClaim.d.ts +8 -0
- package/dist/fhe-vesting/react/usePreflightCreateVesting.d.ts +37 -0
- package/dist/fhe-vesting/react/useVestingClaim.d.ts +2 -0
- package/dist/fhe-vesting/react/useWithdrawAdmin.d.ts +6 -0
- package/dist/fhe-vesting/react/useWithdrawTokenFee.d.ts +6 -0
- package/dist/fhe-vesting/types.d.ts +34 -0
- package/dist/index.cjs +61 -53
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/testnet-faucet/index.cjs +58 -54
- package/dist/testnet-faucet/index.d.cts +1 -1
- package/dist/testnet-faucet/index.d.ts +1 -1
- package/dist/testnet-faucet/index.js +5 -5
- package/dist/testnet-faucet/react/index.cjs +60 -55
- package/dist/testnet-faucet/react/index.d.cts +3 -2
- package/dist/testnet-faucet/react/index.d.ts +3 -2
- package/dist/testnet-faucet/react/index.js +11 -10
- package/dist/testnet-faucet/react/useConfidentialBalance.d.ts +3 -2
- package/dist/testnet-faucet/react/useUnderlyingBalance.d.ts +2 -2
- package/package.json +3 -2
|
@@ -206,6 +206,23 @@ var AccessDeniedError = class extends TokenOpsSdkError {
|
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
208
|
};
|
|
209
|
+
var OPERATOR_NOT_APPROVED_REMEDIATION = "The token has not approved this contract as an operator. Call `setOperator()` (see `/fhe` operators) before this transaction.";
|
|
210
|
+
var OperatorNotApprovedError = class extends TokenOpsSdkError {
|
|
211
|
+
name = "OperatorNotApprovedError";
|
|
212
|
+
constructor(args) {
|
|
213
|
+
super(OPERATOR_NOT_APPROVED_REMEDIATION, {
|
|
214
|
+
code: "TOKENOPS_OPERATOR_NOT_APPROVED",
|
|
215
|
+
cause: args.cause,
|
|
216
|
+
context: {
|
|
217
|
+
method: args.method,
|
|
218
|
+
contractAddress: args.contractAddress,
|
|
219
|
+
tokenAddress: args.tokenAddress,
|
|
220
|
+
holder: args.holder,
|
|
221
|
+
spender: args.spender
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
};
|
|
209
226
|
var InsufficientFeeError = class extends TokenOpsSdkError {
|
|
210
227
|
name = "InsufficientFeeError";
|
|
211
228
|
constructor(args) {
|
|
@@ -475,4 +492,4 @@ var TokenOpsContractError = class extends TokenOpsSdkError {
|
|
|
475
492
|
}
|
|
476
493
|
};
|
|
477
494
|
|
|
478
|
-
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 };
|
|
495
|
+
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, isTokenOpsSdkError };
|
|
@@ -1,8 +1,51 @@
|
|
|
1
|
-
import { TokenOpsSdkError, ContractRevertError, InvalidArgumentError, InvalidSignatureError, FheHandleNotAllowedError, TransferFailedError, FeatureDisabledError, BatchTooLargeError, InsufficientBalanceError, InsufficientFeeError, ReentrancyError, AlreadyInitializedError, AccessDeniedError, PausedError, UnknownWriteFailureError, WalletRejectedError, WalletChainMismatchError, InsufficientGasFundsError, NetworkError } from './chunk-
|
|
1
|
+
import { TokenOpsSdkError, ContractRevertError, InvalidArgumentError, OperatorNotApprovedError, InvalidSignatureError, FheHandleNotAllowedError, TransferFailedError, FeatureDisabledError, BatchTooLargeError, InsufficientBalanceError, InsufficientFeeError, ReentrancyError, AlreadyInitializedError, AccessDeniedError, PausedError, UnknownWriteFailureError, WalletRejectedError, WalletChainMismatchError, InsufficientGasFundsError, NetworkError } from './chunk-QBJ7O2B4.js';
|
|
2
2
|
import { decodeErrorResult, BaseError, ContractFunctionRevertedError, UserRejectedRequestError, TransactionRejectedRpcError, ChainMismatchError, InsufficientFundsError, HttpRequestError, TimeoutError } from 'viem';
|
|
3
3
|
|
|
4
4
|
// src/core/version.ts
|
|
5
5
|
var SDK_VERSION = "1.0.0";
|
|
6
|
+
var ERC7984_ERRORS_ABI = [
|
|
7
|
+
{
|
|
8
|
+
type: "error",
|
|
9
|
+
name: "ERC7984UnauthorizedSpender",
|
|
10
|
+
inputs: [
|
|
11
|
+
{ name: "holder", type: "address" },
|
|
12
|
+
{ name: "spender", type: "address" }
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
type: "error",
|
|
17
|
+
name: "ERC7984UnauthorizedCaller",
|
|
18
|
+
inputs: [{ name: "caller", type: "address" }]
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
type: "error",
|
|
22
|
+
name: "ERC7984UnauthorizedUseOfEncryptedAmount",
|
|
23
|
+
inputs: [
|
|
24
|
+
{ name: "amount", type: "bytes32" },
|
|
25
|
+
{ name: "user", type: "address" }
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: "error",
|
|
30
|
+
name: "ERC7984InvalidReceiver",
|
|
31
|
+
inputs: [{ name: "receiver", type: "address" }]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: "error",
|
|
35
|
+
name: "ERC7984InvalidSender",
|
|
36
|
+
inputs: [{ name: "sender", type: "address" }]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: "error",
|
|
40
|
+
name: "ERC7984ZeroBalance",
|
|
41
|
+
inputs: [{ name: "holder", type: "address" }]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: "error",
|
|
45
|
+
name: "ERC7984InvalidGatewayRequest",
|
|
46
|
+
inputs: [{ name: "requestId", type: "uint256" }]
|
|
47
|
+
}
|
|
48
|
+
];
|
|
6
49
|
function mapContractRevert(error, args) {
|
|
7
50
|
if (error instanceof TokenOpsSdkError) return error;
|
|
8
51
|
const ctx = {
|
|
@@ -22,7 +65,10 @@ function mapContractRevert(error, args) {
|
|
|
22
65
|
if (revertName === void 0 && rawRevertData !== void 0 && rawRevertData.length >= 10) {
|
|
23
66
|
revertSelector = rawRevertData.slice(0, 10);
|
|
24
67
|
try {
|
|
25
|
-
const decoded = decodeErrorResult({
|
|
68
|
+
const decoded = decodeErrorResult({
|
|
69
|
+
abi: [...args.abi, ...ERC7984_ERRORS_ABI],
|
|
70
|
+
data: rawRevertData
|
|
71
|
+
});
|
|
26
72
|
revertName = decoded.errorName;
|
|
27
73
|
revertArgs = decoded.args;
|
|
28
74
|
} catch {
|
|
@@ -120,6 +166,16 @@ function defaultRevertNameMapper(name, errArgs, ctx, account) {
|
|
|
120
166
|
}
|
|
121
167
|
case "InvalidSignature":
|
|
122
168
|
return new InvalidSignatureError(ctx);
|
|
169
|
+
case "ERC7984UnauthorizedSpender": {
|
|
170
|
+
const holder = errArgs?.[0];
|
|
171
|
+
const spender = errArgs?.[1];
|
|
172
|
+
return new OperatorNotApprovedError({
|
|
173
|
+
method: ctx.method,
|
|
174
|
+
contractAddress: ctx.contractAddress,
|
|
175
|
+
holder,
|
|
176
|
+
spender
|
|
177
|
+
});
|
|
178
|
+
}
|
|
123
179
|
// Range / arg-validation reverts the SDK should already have caught in
|
|
124
180
|
// preflight or input validation. If they slip through, surface them as
|
|
125
181
|
// structural `InvalidArgumentError` so consumers see `TOKENOPS_INVALID_ARGUMENT`
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunkMCRBVJGZ_cjs = require('./chunk-MCRBVJGZ.cjs');
|
|
4
|
+
var chunkTIUKIY5V_cjs = require('./chunk-TIUKIY5V.cjs');
|
|
5
|
+
var chunkPUPKNW3R_cjs = require('./chunk-PUPKNW3R.cjs');
|
|
6
|
+
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
7
7
|
var react = require('react');
|
|
8
8
|
var wagmi = require('wagmi');
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ var FHE_AIRDROP_NAMESPACE = "fhe-airdrop";
|
|
|
12
12
|
function tryResolveFactoryAddress(override, chainId) {
|
|
13
13
|
if (override) return override;
|
|
14
14
|
if (chainId === void 0) return void 0;
|
|
15
|
-
return
|
|
15
|
+
return chunkPUPKNW3R_cjs.getFheAirdropFactoryAddress(chainId);
|
|
16
16
|
}
|
|
17
17
|
function useMemoFactoryClient(opts = {}) {
|
|
18
18
|
const publicClient = wagmi.usePublicClient({ chainId: opts.chainId });
|
|
@@ -25,14 +25,14 @@ function useMemoFactoryClient(opts = {}) {
|
|
|
25
25
|
const client = react.useMemo(() => {
|
|
26
26
|
if (!publicClient) return void 0;
|
|
27
27
|
if (!resolvedAddress) return void 0;
|
|
28
|
-
return
|
|
28
|
+
return chunkTIUKIY5V_cjs.createConfidentialAirdropFactoryClient({
|
|
29
29
|
publicClient,
|
|
30
30
|
...walletClient ? { walletClient } : {},
|
|
31
31
|
address: resolvedAddress,
|
|
32
32
|
...chainId !== void 0 ? { chainId } : {},
|
|
33
33
|
// Lazy — invoked per-encryption inside the headless client. Picks up
|
|
34
34
|
// whichever EncryptorSource the consumer last passed in.
|
|
35
|
-
encryptor: () =>
|
|
35
|
+
encryptor: () => chunkTIUKIY5V_cjs.resolveEncryptor(encryptorSourceRef.current)
|
|
36
36
|
});
|
|
37
37
|
}, [publicClient, walletClient, resolvedAddress, chainId]);
|
|
38
38
|
return {
|
|
@@ -47,16 +47,16 @@ function useMemoFactoryClient(opts = {}) {
|
|
|
47
47
|
function computeFactoryResolutionError(override, chainId) {
|
|
48
48
|
if (override) return void 0;
|
|
49
49
|
if (chainId === void 0) {
|
|
50
|
-
return new
|
|
50
|
+
return new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
|
|
51
51
|
reason: "chain-id-missing",
|
|
52
52
|
product: "fheAirdrop",
|
|
53
53
|
contract: "confidentialAirdropFactory",
|
|
54
54
|
clientLabel: "ConfidentialAirdropFactoryClient"
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
const resolved =
|
|
57
|
+
const resolved = chunkPUPKNW3R_cjs.getFheAirdropFactoryAddress(chainId);
|
|
58
58
|
if (!resolved) {
|
|
59
|
-
return new
|
|
59
|
+
return new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
|
|
60
60
|
reason: "registry-not-deployed",
|
|
61
61
|
product: "fheAirdrop",
|
|
62
62
|
contract: "confidentialAirdropFactory",
|
|
@@ -73,7 +73,7 @@ function useMemoAirdropClient(opts) {
|
|
|
73
73
|
const client = react.useMemo(() => {
|
|
74
74
|
if (!publicClient) return void 0;
|
|
75
75
|
if (!opts.address) return void 0;
|
|
76
|
-
return
|
|
76
|
+
return chunkMCRBVJGZ_cjs.createConfidentialAirdropClient({
|
|
77
77
|
publicClient,
|
|
78
78
|
...walletClient ? { walletClient } : {},
|
|
79
79
|
address: opts.address,
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
4
4
|
|
|
5
5
|
// src/core/zama-error-mapper.ts
|
|
6
6
|
function mapZamaError(error, args) {
|
|
7
|
-
if (error instanceof
|
|
7
|
+
if (error instanceof chunk67OV5CX2_cjs.TokenOpsSdkError) return error;
|
|
8
8
|
const zama = readZamaError(error);
|
|
9
9
|
if (zama?.code) {
|
|
10
10
|
switch (zama.code) {
|
|
11
11
|
case "SIGNING_REJECTED":
|
|
12
|
-
return new
|
|
12
|
+
return new chunk67OV5CX2_cjs.UserRejectedSignatureError({ ...args, cause: error });
|
|
13
13
|
case "SIGNING_FAILED":
|
|
14
|
-
return new
|
|
14
|
+
return new chunk67OV5CX2_cjs.SigningFailedError({ ...args, cause: error });
|
|
15
15
|
case "RELAYER_REQUEST_FAILED":
|
|
16
|
-
return new
|
|
16
|
+
return new chunk67OV5CX2_cjs.RelayerUnreachableError({
|
|
17
17
|
...args,
|
|
18
18
|
statusCode: zama.statusCode,
|
|
19
19
|
cause: error
|
|
20
20
|
});
|
|
21
21
|
case "ENCRYPTION_FAILED":
|
|
22
|
-
return new
|
|
22
|
+
return new chunk67OV5CX2_cjs.EncryptionFailedError({ ...args, cause: error });
|
|
23
23
|
case "DECRYPTION_FAILED":
|
|
24
|
-
return new
|
|
24
|
+
return new chunk67OV5CX2_cjs.DecryptionFailedError({ ...args, cause: error });
|
|
25
25
|
case "CONFIGURATION":
|
|
26
|
-
return new
|
|
26
|
+
return new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
27
27
|
method: args.method,
|
|
28
28
|
argument: "config",
|
|
29
29
|
reason: "Zama SDK configuration is invalid (chain id, type, or signer state).",
|
|
@@ -34,13 +34,13 @@ function mapZamaError(error, args) {
|
|
|
34
34
|
const message = readMessage(error);
|
|
35
35
|
if (message) {
|
|
36
36
|
if (USER_REJECTION_PATTERNS.some((pat) => pat.test(message))) {
|
|
37
|
-
return new
|
|
37
|
+
return new chunk67OV5CX2_cjs.UserRejectedSignatureError({ ...args, cause: error });
|
|
38
38
|
}
|
|
39
39
|
if (USER_DECRYPT_NOT_ALLOWED_PATTERNS.some((pat) => pat.test(message))) {
|
|
40
|
-
return new
|
|
40
|
+
return new chunk67OV5CX2_cjs.UserDecryptNotAllowedError({ method: args.method, cause: error });
|
|
41
41
|
}
|
|
42
42
|
if (INVALID_INPUT_PATTERNS.some((pat) => pat.test(message))) {
|
|
43
|
-
return new
|
|
43
|
+
return new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
44
44
|
method: args.method,
|
|
45
45
|
argument: "input",
|
|
46
46
|
reason: "encrypted input value rejected by FHE SDK \u2014 see `error.cause` for details",
|
|
@@ -48,7 +48,7 @@ function mapZamaError(error, args) {
|
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
return args.operation === "encrypt" ? new
|
|
51
|
+
return args.operation === "encrypt" ? new chunk67OV5CX2_cjs.EncryptionFailedError({ ...args, cause: error }) : new chunk67OV5CX2_cjs.DecryptionFailedError({ ...args, cause: error });
|
|
52
52
|
}
|
|
53
53
|
function readZamaError(err) {
|
|
54
54
|
if (typeof err !== "object" || err === null) return void 0;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkFWHYQZ5E_cjs = require('./chunk-FWHYQZ5E.cjs');
|
|
4
|
+
var chunkKLKI352M_cjs = require('./chunk-KLKI352M.cjs');
|
|
5
|
+
var chunkPUPKNW3R_cjs = require('./chunk-PUPKNW3R.cjs');
|
|
6
|
+
var chunkJK4XMMKM_cjs = require('./chunk-JK4XMMKM.cjs');
|
|
6
7
|
var chunkVJKZWYYJ_cjs = require('./chunk-VJKZWYYJ.cjs');
|
|
7
8
|
var chunk66IHPTOK_cjs = require('./chunk-66IHPTOK.cjs');
|
|
8
|
-
var
|
|
9
|
+
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
9
10
|
var viem = require('viem');
|
|
10
11
|
|
|
11
12
|
// src/fhe-airdrop/abis/factory.ts
|
|
@@ -935,7 +936,7 @@ function resolveEncryptor(source) {
|
|
|
935
936
|
var MAX_UINT64 = (1n << 64n) - 1n;
|
|
936
937
|
function assertUint64(value, label) {
|
|
937
938
|
if (value < 0n || value > MAX_UINT64) {
|
|
938
|
-
throw new
|
|
939
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
939
940
|
method: "encryptUint64",
|
|
940
941
|
argument: label,
|
|
941
942
|
reason: "exceeds uint64 range (0..2^64-1)",
|
|
@@ -956,7 +957,7 @@ async function encryptUint64({
|
|
|
956
957
|
userAddress
|
|
957
958
|
});
|
|
958
959
|
if (handles.length !== 1) {
|
|
959
|
-
throw new
|
|
960
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
960
961
|
method: "encryptUint64",
|
|
961
962
|
argument: "handles",
|
|
962
963
|
reason: `expected 1 handle, got ${handles.length}`,
|
|
@@ -975,7 +976,7 @@ async function encryptUint64Batch({
|
|
|
975
976
|
values
|
|
976
977
|
}) {
|
|
977
978
|
if (values.length === 0) {
|
|
978
|
-
throw new
|
|
979
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
979
980
|
method: "encryptUint64Batch",
|
|
980
981
|
argument: "values",
|
|
981
982
|
reason: "must be non-empty"
|
|
@@ -988,7 +989,7 @@ async function encryptUint64Batch({
|
|
|
988
989
|
userAddress
|
|
989
990
|
});
|
|
990
991
|
if (handles.length !== values.length) {
|
|
991
|
-
throw new
|
|
992
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
992
993
|
method: "encryptUint64Batch",
|
|
993
994
|
argument: "handles",
|
|
994
995
|
reason: `expected ${values.length} handles, got ${handles.length}`,
|
|
@@ -1002,17 +1003,17 @@ async function encryptUint64Batch({
|
|
|
1002
1003
|
}
|
|
1003
1004
|
async function signClaimAuthorization(args) {
|
|
1004
1005
|
if (args.encryptedAmountHandle.length !== 66) {
|
|
1005
|
-
throw new
|
|
1006
|
+
throw new chunk67OV5CX2_cjs.TokenOpsSdkError(
|
|
1006
1007
|
`signClaimAuthorization: encryptedAmountHandle must be a 32-byte hex string (0x + 64 chars), got length ${args.encryptedAmountHandle.length}`
|
|
1007
1008
|
);
|
|
1008
1009
|
}
|
|
1009
1010
|
const account = args.walletClient.account;
|
|
1010
1011
|
if (!account) {
|
|
1011
|
-
throw new
|
|
1012
|
+
throw new chunk67OV5CX2_cjs.MissingAccountError("signClaimAuthorization");
|
|
1012
1013
|
}
|
|
1013
1014
|
const chainId = args.walletClient.chain?.id;
|
|
1014
1015
|
if (!chainId) {
|
|
1015
|
-
throw new
|
|
1016
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
1016
1017
|
method: "signClaimAuthorization",
|
|
1017
1018
|
argument: "walletClient.chain.id",
|
|
1018
1019
|
reason: "required for EIP712 chainId binding; pass a walletClient constructed with a known chain (e.g. `createWalletClient({ chain: sepolia, ... })`)."
|
|
@@ -1052,10 +1053,10 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1052
1053
|
this.walletClient = config.walletClient;
|
|
1053
1054
|
this.encryptor = config.encryptor;
|
|
1054
1055
|
const chainId = config.chainId ?? config.publicClient.chain?.id;
|
|
1055
|
-
const addressOverride = config.address ?
|
|
1056
|
-
const resolved = addressOverride ?? (chainId === void 0 ? void 0 :
|
|
1056
|
+
const addressOverride = config.address ? chunkJK4XMMKM_cjs.normaliseAddress(config.address) : void 0;
|
|
1057
|
+
const resolved = addressOverride ?? (chainId === void 0 ? void 0 : chunkPUPKNW3R_cjs.getFheAirdropFactoryAddress(chainId));
|
|
1057
1058
|
if (!resolved) {
|
|
1058
|
-
throw new
|
|
1059
|
+
throw new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
|
|
1059
1060
|
reason: chainId === void 0 ? "chain-id-missing" : "registry-not-deployed",
|
|
1060
1061
|
product: "fheAirdrop",
|
|
1061
1062
|
contract: "confidentialAirdropFactory",
|
|
@@ -1071,7 +1072,7 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1071
1072
|
hasWallet: !!this.walletClient,
|
|
1072
1073
|
aclResolved: true,
|
|
1073
1074
|
// factory has no ACL dependency; constant for funnel-shape parity with client.
|
|
1074
|
-
sdkVersion:
|
|
1075
|
+
sdkVersion: chunkKLKI352M_cjs.SDK_VERSION
|
|
1075
1076
|
});
|
|
1076
1077
|
}
|
|
1077
1078
|
// ----------------------- writes -----------------------
|
|
@@ -1118,6 +1119,14 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1118
1119
|
* Prerequisites: caller must have set this factory as an operator on the
|
|
1119
1120
|
* token: `token.setOperator(factoryAddress, deadline)`.
|
|
1120
1121
|
*
|
|
1122
|
+
* **Silent-zero transfers.** ERC-7984 transfers do not revert when the sender's encrypted balance is insufficient — the transfer succeeds and moves an encrypted zero instead. This is by design: reverting would leak balance information. The transaction receipt alone cannot tell you whether value actually moved.
|
|
1123
|
+
*
|
|
1124
|
+
* **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
|
|
1125
|
+
* convention (1 token = 1_000_000 base units), not the 18 decimals typical of
|
|
1126
|
+
* ERC-20. Amount parameters are base units of the token's actual decimals:
|
|
1127
|
+
* for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
|
|
1128
|
+
* transparent TTT test token uses 18 decimals.
|
|
1129
|
+
*
|
|
1121
1130
|
* Symmetric with {@link ConfidentialAirdropFactoryClient.createConfidentialAirdrop}
|
|
1122
1131
|
* — both return `{ hash, airdrop }` parsed from the
|
|
1123
1132
|
* `ConfidentialAirdropCreated` event.
|
|
@@ -1180,6 +1189,14 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1180
1189
|
* Prerequisites: caller must have set this factory as an operator on the token:
|
|
1181
1190
|
* `token.setOperator(factoryAddress, deadline)`
|
|
1182
1191
|
*
|
|
1192
|
+
* **Silent-zero transfers.** ERC-7984 transfers do not revert when the sender's encrypted balance is insufficient — the transfer succeeds and moves an encrypted zero instead. This is by design: reverting would leak balance information. The transaction receipt alone cannot tell you whether value actually moved.
|
|
1193
|
+
*
|
|
1194
|
+
* **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
|
|
1195
|
+
* convention (1 token = 1_000_000 base units), not the 18 decimals typical of
|
|
1196
|
+
* ERC-20. Amount parameters are base units of the token's actual decimals:
|
|
1197
|
+
* for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
|
|
1198
|
+
* transparent TTT test token uses 18 decimals.
|
|
1199
|
+
*
|
|
1183
1200
|
* @returns Transaction hash.
|
|
1184
1201
|
*/
|
|
1185
1202
|
async fundConfidentialAirdrop(args) {
|
|
@@ -1249,6 +1266,14 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1249
1266
|
* Symmetry with {@link ConfidentialAirdropFactoryClient.createConfidentialAirdropAndGetAddress}
|
|
1250
1267
|
* — use this when you also need to seed the pool in the same transaction.
|
|
1251
1268
|
*
|
|
1269
|
+
* **Silent-zero transfers.** ERC-7984 transfers do not revert when the sender's encrypted balance is insufficient — the transfer succeeds and moves an encrypted zero instead. This is by design: reverting would leak balance information. The transaction receipt alone cannot tell you whether value actually moved.
|
|
1270
|
+
*
|
|
1271
|
+
* **Amount units:** TokenOps confidential (ERC-7984) tokens use a 6-decimals
|
|
1272
|
+
* convention (1 token = 1_000_000 base units), not the 18 decimals typical of
|
|
1273
|
+
* ERC-20. Amount parameters are base units of the token's actual decimals:
|
|
1274
|
+
* for the CTTT test token (6 decimals) `1_000_000n` = 1 CTTT, while the
|
|
1275
|
+
* transparent TTT test token uses 18 decimals.
|
|
1276
|
+
*
|
|
1252
1277
|
* Internally: {@link ConfidentialAirdropFactoryClient.createAndFundConfidentialAirdrop} →
|
|
1253
1278
|
* {@link PublicClient.waitForTransactionReceipt} →
|
|
1254
1279
|
* `parseEventLogs({ eventName: "ConfidentialAirdropCreated" })`.
|
|
@@ -1331,6 +1356,149 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1331
1356
|
async getInitCodeHash(args) {
|
|
1332
1357
|
return this.#read("getInitCodeHash", [toAbiParams(args.params), args.gasFee]);
|
|
1333
1358
|
}
|
|
1359
|
+
// ----------------------- preflight -----------------------
|
|
1360
|
+
/**
|
|
1361
|
+
* Read-only preflight for {@link createConfidentialAirdrop} /
|
|
1362
|
+
* {@link createAndFundConfidentialAirdrop}. Runs the
|
|
1363
|
+
* deterministic-from-off-chain checks and reports blockers both as
|
|
1364
|
+
* human-readable strings (`blockers`) and as typed {@link TokenOpsSdkError}s
|
|
1365
|
+
* (`blockerErrors`), index-aligned.
|
|
1366
|
+
*
|
|
1367
|
+
* Preflight is **opt-in**. Consumers who have already validated state can
|
|
1368
|
+
* skip this call and invoke the write directly — they'll receive the same
|
|
1369
|
+
* typed errors at write time via the revert mapper.
|
|
1370
|
+
*
|
|
1371
|
+
* Report fields: `isFactoryOperator`, `gasFee`, `predictedAirdrop`,
|
|
1372
|
+
* `alreadyDeployed`, `ready`, `blockers`, `blockerErrors` — see
|
|
1373
|
+
* {@link CreateAirdropPreflightReport} for the meaning of each.
|
|
1374
|
+
*
|
|
1375
|
+
* Checks performed (all read-only, no gas):
|
|
1376
|
+
* - Structural `params` validation mirroring the factory + clone
|
|
1377
|
+
* `initialize` requirements (`InvalidArgumentError` blockers): `token` and
|
|
1378
|
+
* `admin` are checksummed non-zero addresses,
|
|
1379
|
+
* `startTimestamp < endTimestamp`, and `endTimestamp` is in the future
|
|
1380
|
+
* (the clone's `initialize` reverts with `EndTimeInPast`).
|
|
1381
|
+
* - Operator: creator has approved this factory as an ERC-7984 operator on
|
|
1382
|
+
* `params.token` — a blocker only when `funding: true`
|
|
1383
|
+
* ({@link OperatorNotApprovedError}); otherwise informational via
|
|
1384
|
+
* `isFactoryOperator`.
|
|
1385
|
+
* - Collision (only when `userSalt` is supplied): bytecode already at the
|
|
1386
|
+
* predicted CREATE2 address means a repeat create with the same
|
|
1387
|
+
* `(params, userSalt, gasFee)` would revert
|
|
1388
|
+
* ({@link AlreadyInitializedError} blocker).
|
|
1389
|
+
*
|
|
1390
|
+
* **Not preflight-detectable — read before trusting `ready: true`:** the
|
|
1391
|
+
* creator's confidential token balance is an encrypted `euint64` the SDK
|
|
1392
|
+
* cannot read in plaintext, and an underfunded `createAndFund` does **not**
|
|
1393
|
+
* revert — the ERC-7984 transfer silently moves an encrypted zero. Confirm
|
|
1394
|
+
* the creator's balance covers the pool before submitting.
|
|
1395
|
+
*
|
|
1396
|
+
* @param args See {@link PreflightCreateAirdropArgs}.
|
|
1397
|
+
* @returns A {@link CreateAirdropPreflightReport}.
|
|
1398
|
+
*/
|
|
1399
|
+
async preflightCreateAirdrop(args) {
|
|
1400
|
+
const { params, creator, userSalt, funding } = args;
|
|
1401
|
+
const blockers = [];
|
|
1402
|
+
const blockerErrors = [];
|
|
1403
|
+
const pushBlocker = (err) => {
|
|
1404
|
+
blockerErrors.push(err);
|
|
1405
|
+
blockers.push(err.message);
|
|
1406
|
+
};
|
|
1407
|
+
const tokenOk = viem.isAddress(params.token, { strict: true }) && params.token !== ZERO_ADDRESS;
|
|
1408
|
+
if (!tokenOk) {
|
|
1409
|
+
pushBlocker(
|
|
1410
|
+
new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
1411
|
+
method: "createConfidentialAirdrop",
|
|
1412
|
+
argument: "params.token",
|
|
1413
|
+
reason: "must be a valid, non-zero EIP-55 checksummed address",
|
|
1414
|
+
value: params.token
|
|
1415
|
+
})
|
|
1416
|
+
);
|
|
1417
|
+
}
|
|
1418
|
+
const adminOk = viem.isAddress(params.admin, { strict: true }) && params.admin !== ZERO_ADDRESS;
|
|
1419
|
+
if (!adminOk) {
|
|
1420
|
+
pushBlocker(
|
|
1421
|
+
new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
1422
|
+
method: "createConfidentialAirdrop",
|
|
1423
|
+
argument: "params.admin",
|
|
1424
|
+
reason: "must be a valid, non-zero EIP-55 checksummed address",
|
|
1425
|
+
value: params.admin
|
|
1426
|
+
})
|
|
1427
|
+
);
|
|
1428
|
+
}
|
|
1429
|
+
if (params.startTimestamp >= params.endTimestamp) {
|
|
1430
|
+
pushBlocker(
|
|
1431
|
+
new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
1432
|
+
method: "createConfidentialAirdrop",
|
|
1433
|
+
argument: "params.startTimestamp/params.endTimestamp",
|
|
1434
|
+
reason: "startTimestamp must be strictly less than endTimestamp",
|
|
1435
|
+
value: { startTimestamp: params.startTimestamp, endTimestamp: params.endTimestamp }
|
|
1436
|
+
})
|
|
1437
|
+
);
|
|
1438
|
+
}
|
|
1439
|
+
const [block, customFee, defaultFee, isFactoryOperator] = await Promise.all([
|
|
1440
|
+
this.publicClient.getBlock(),
|
|
1441
|
+
this.getCustomFee(creator),
|
|
1442
|
+
this.defaultGasFee(),
|
|
1443
|
+
tokenOk ? this.publicClient.readContract({
|
|
1444
|
+
address: params.token,
|
|
1445
|
+
abi: chunkFWHYQZ5E_cjs.erc7984OperatorAbi,
|
|
1446
|
+
functionName: "isOperator",
|
|
1447
|
+
args: [creator, this.address]
|
|
1448
|
+
}) : Promise.resolve(false)
|
|
1449
|
+
]);
|
|
1450
|
+
const gasFee = customFee.enabled ? customFee.gasFee : defaultFee;
|
|
1451
|
+
if (params.endTimestamp <= Number(block.timestamp)) {
|
|
1452
|
+
pushBlocker(
|
|
1453
|
+
new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
1454
|
+
method: "createConfidentialAirdrop",
|
|
1455
|
+
argument: "params.endTimestamp",
|
|
1456
|
+
reason: "must be in the future (the clone's initialize reverts with EndTimeInPast)",
|
|
1457
|
+
value: params.endTimestamp
|
|
1458
|
+
})
|
|
1459
|
+
);
|
|
1460
|
+
}
|
|
1461
|
+
if (funding === true && !isFactoryOperator) {
|
|
1462
|
+
pushBlocker(
|
|
1463
|
+
new chunk67OV5CX2_cjs.OperatorNotApprovedError({
|
|
1464
|
+
method: "createAndFundConfidentialAirdrop",
|
|
1465
|
+
contractAddress: this.address,
|
|
1466
|
+
tokenAddress: params.token,
|
|
1467
|
+
holder: creator,
|
|
1468
|
+
spender: this.address
|
|
1469
|
+
})
|
|
1470
|
+
);
|
|
1471
|
+
}
|
|
1472
|
+
let predictedAirdrop;
|
|
1473
|
+
let alreadyDeployed;
|
|
1474
|
+
if (userSalt !== void 0 && tokenOk && adminOk) {
|
|
1475
|
+
predictedAirdrop = await this.#read("predictAirdropAddress", [
|
|
1476
|
+
toAbiParams(params),
|
|
1477
|
+
userSalt,
|
|
1478
|
+
creator,
|
|
1479
|
+
gasFee
|
|
1480
|
+
]);
|
|
1481
|
+
const bytecode = await this.publicClient.getCode({ address: predictedAirdrop });
|
|
1482
|
+
alreadyDeployed = bytecode !== void 0 && bytecode !== "0x";
|
|
1483
|
+
if (alreadyDeployed) {
|
|
1484
|
+
pushBlocker(
|
|
1485
|
+
new chunk67OV5CX2_cjs.AlreadyInitializedError({
|
|
1486
|
+
method: "createConfidentialAirdrop",
|
|
1487
|
+
contractAddress: predictedAirdrop
|
|
1488
|
+
})
|
|
1489
|
+
);
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
return {
|
|
1493
|
+
isFactoryOperator,
|
|
1494
|
+
gasFee,
|
|
1495
|
+
predictedAirdrop,
|
|
1496
|
+
alreadyDeployed,
|
|
1497
|
+
ready: blockers.length === 0,
|
|
1498
|
+
blockers,
|
|
1499
|
+
blockerErrors
|
|
1500
|
+
};
|
|
1501
|
+
}
|
|
1334
1502
|
// ----------------------- internals -----------------------
|
|
1335
1503
|
/**
|
|
1336
1504
|
* Wait for the receipt of a clone-deploy tx and parse the
|
|
@@ -1347,12 +1515,12 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1347
1515
|
});
|
|
1348
1516
|
const ours = events.filter((ev) => ev.address.toLowerCase() === this.address.toLowerCase());
|
|
1349
1517
|
if (ours.length === 0) {
|
|
1350
|
-
throw new
|
|
1518
|
+
throw new chunk67OV5CX2_cjs.TokenOpsSdkError(
|
|
1351
1519
|
`${method}: no ConfidentialAirdropCreated event from factory ${this.address} in tx ${hash}`
|
|
1352
1520
|
);
|
|
1353
1521
|
}
|
|
1354
1522
|
if (ours.length > 1) {
|
|
1355
|
-
throw new
|
|
1523
|
+
throw new chunk67OV5CX2_cjs.TokenOpsSdkError(
|
|
1356
1524
|
`${method}: ${ours.length} ConfidentialAirdropCreated events from factory ${this.address} in tx ${hash}; ambiguous result`
|
|
1357
1525
|
);
|
|
1358
1526
|
}
|
|
@@ -1360,14 +1528,14 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1360
1528
|
}
|
|
1361
1529
|
#requireWallet(method) {
|
|
1362
1530
|
if (!this.walletClient) {
|
|
1363
|
-
throw new
|
|
1531
|
+
throw new chunk67OV5CX2_cjs.MissingWalletClientError(method);
|
|
1364
1532
|
}
|
|
1365
1533
|
return this.walletClient;
|
|
1366
1534
|
}
|
|
1367
1535
|
#resolveAccount(wallet, override, method) {
|
|
1368
1536
|
const acct = override ?? wallet.account;
|
|
1369
1537
|
if (!acct) {
|
|
1370
|
-
throw new
|
|
1538
|
+
throw new chunk67OV5CX2_cjs.MissingAccountError(method);
|
|
1371
1539
|
}
|
|
1372
1540
|
return acct;
|
|
1373
1541
|
}
|
|
@@ -1381,14 +1549,14 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1381
1549
|
const hasAmount = amount !== void 0;
|
|
1382
1550
|
const hasInput = preEncrypted !== void 0;
|
|
1383
1551
|
if (hasAmount && hasInput) {
|
|
1384
|
-
throw new
|
|
1552
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
1385
1553
|
method,
|
|
1386
1554
|
argument: "amount/encryptedInput",
|
|
1387
1555
|
reason: "exactly one of `amount` (plaintext, SDK encrypts) or `encryptedInput` (pre-encrypted) must be supplied \u2014 got both"
|
|
1388
1556
|
});
|
|
1389
1557
|
}
|
|
1390
1558
|
if (!hasAmount && !hasInput) {
|
|
1391
|
-
throw new
|
|
1559
|
+
throw new chunk67OV5CX2_cjs.InvalidArgumentError({
|
|
1392
1560
|
method,
|
|
1393
1561
|
argument: "amount/encryptedInput",
|
|
1394
1562
|
reason: "exactly one of `amount` (plaintext, SDK encrypts) or `encryptedInput` (pre-encrypted) must be supplied \u2014 got neither"
|
|
@@ -1397,7 +1565,7 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1397
1565
|
if (hasInput) return preEncrypted;
|
|
1398
1566
|
const enc = encryptor ?? resolveEncryptor(this.encryptor);
|
|
1399
1567
|
if (!enc) {
|
|
1400
|
-
throw new
|
|
1568
|
+
throw new chunk67OV5CX2_cjs.MissingEncryptorError("encryptAmount", {
|
|
1401
1569
|
hint: "Pass `encryptor` to the call or the client config (eager or lazy factory)."
|
|
1402
1570
|
});
|
|
1403
1571
|
}
|
|
@@ -1426,7 +1594,7 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1426
1594
|
}
|
|
1427
1595
|
}
|
|
1428
1596
|
#mapRevert(method, err, account) {
|
|
1429
|
-
return
|
|
1597
|
+
return chunkKLKI352M_cjs.mapContractRevert(err, {
|
|
1430
1598
|
method,
|
|
1431
1599
|
contractAddress: this.address,
|
|
1432
1600
|
abi: confidentialAirdropFactoryAbi,
|
|
@@ -1454,7 +1622,7 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1454
1622
|
...value !== void 0 ? { value } : {}
|
|
1455
1623
|
});
|
|
1456
1624
|
} catch (err) {
|
|
1457
|
-
if (
|
|
1625
|
+
if (chunkKLKI352M_cjs.isContractRevert(err)) {
|
|
1458
1626
|
throw this.#mapRevert(method, err, accountAddress(account));
|
|
1459
1627
|
}
|
|
1460
1628
|
}
|
|
@@ -1472,6 +1640,7 @@ var ConfidentialAirdropFactoryClient = class {
|
|
|
1472
1640
|
function createConfidentialAirdropFactoryClient(config) {
|
|
1473
1641
|
return new ConfidentialAirdropFactoryClient(config);
|
|
1474
1642
|
}
|
|
1643
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
1475
1644
|
function accountAddress(account) {
|
|
1476
1645
|
return typeof account === "string" ? account : account.address;
|
|
1477
1646
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkC7BRZXJA_cjs = require('./chunk-C7BRZXJA.cjs');
|
|
4
4
|
|
|
5
5
|
// src/fhe-vesting/advanced/factory-advanced.ts
|
|
6
|
-
var ConfidentialVestingFactoryAdvancedClient = class extends
|
|
6
|
+
var ConfidentialVestingFactoryAdvancedClient = class extends chunkC7BRZXJA_cjs.ConfidentialVestingFactoryClient {
|
|
7
7
|
/**
|
|
8
8
|
* Compute the deterministic CREATE2 clone address as the factory would have
|
|
9
9
|
* computed it at `args.blockNumber`.
|
|
@@ -20,7 +20,7 @@ var ConfidentialVestingFactoryAdvancedClient = class extends chunkSAGJIEQK_cjs.C
|
|
|
20
20
|
if (hasOptions) {
|
|
21
21
|
return this.publicClient.readContract({
|
|
22
22
|
address: this.address,
|
|
23
|
-
abi:
|
|
23
|
+
abi: chunkC7BRZXJA_cjs.confidentialVestingFactoryAbi,
|
|
24
24
|
functionName: "predictManagerAddressWithOptions",
|
|
25
25
|
args: [
|
|
26
26
|
args.token,
|
|
@@ -34,7 +34,7 @@ var ConfidentialVestingFactoryAdvancedClient = class extends chunkSAGJIEQK_cjs.C
|
|
|
34
34
|
}
|
|
35
35
|
return this.publicClient.readContract({
|
|
36
36
|
address: this.address,
|
|
37
|
-
abi:
|
|
37
|
+
abi: chunkC7BRZXJA_cjs.confidentialVestingFactoryAbi,
|
|
38
38
|
functionName: "predictManagerAddress",
|
|
39
39
|
args: [args.token, args.userSalt, args.deployer],
|
|
40
40
|
blockNumber: args.blockNumber
|