@tokenops/sdk 1.0.0 → 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 +120 -26
- package/dist/{chunk-5SGMJADP.cjs → chunk-2NCLOQ56.cjs} +9 -9
- package/dist/{chunk-QIHZVLIK.js → chunk-2PWNH3UE.js} +35 -6
- package/dist/{chunk-T5LVV3KY.cjs → chunk-4WPGQSNT.cjs} +3 -3
- package/dist/{chunk-SUOG3BQS.cjs → chunk-5X5WL5CU.cjs} +266 -103
- 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-62DF53UQ.cjs → chunk-C7BRZXJA.cjs} +19 -21
- package/dist/{chunk-UOG4PJL5.js → chunk-DUZIIRPF.js} +181 -14
- package/dist/{chunk-Q7ARQSUH.cjs → chunk-FAXIIH5R.cjs} +3 -3
- package/dist/chunk-FT4LNBOS.js +11 -0
- package/dist/chunk-IJFQ5L4I.js +2171 -0
- package/dist/{chunk-52TC6BF7.js → chunk-IXLO7GO5.js} +210 -47
- 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-ECT3NL2L.js → chunk-NTZY6IB7.js} +4 -4
- package/dist/{chunk-ZHFLRKFY.js → chunk-ODLTEGHB.js} +1 -1
- package/dist/{chunk-HGXNRR25.js → chunk-ORFTDNFZ.js} +4 -4
- package/dist/{chunk-72YGZEQE.js → chunk-OXTLPTO3.js} +9 -11
- package/dist/{chunk-HTOMTEA3.cjs → chunk-PFXURMBZ.cjs} +77 -48
- package/dist/{chunk-OLDGMKW2.cjs → chunk-PUPKNW3R.cjs} +35 -2
- package/dist/{chunk-IVE3QEGD.js → chunk-QBJ7O2B4.js} +18 -1
- package/dist/{chunk-JFLEEXKP.js → chunk-SG65XWH7.js} +58 -2
- package/dist/{chunk-K6MFFDBJ.cjs → chunk-T46YXSBP.cjs} +11 -11
- package/dist/{chunk-NS44KBV5.cjs → chunk-TEBM66WA.cjs} +12 -12
- package/dist/{chunk-6ECAHP5O.cjs → chunk-TIUKIY5V.cjs} +200 -33
- package/dist/{chunk-QCA7O2Q5.cjs → chunk-V2PXZVBF.cjs} +4 -4
- package/dist/{chunk-JFR5J4FL.cjs → chunk-W7IGCOVL.cjs} +11 -11
- package/dist/chunk-WENHUPZC.cjs +2180 -0
- package/dist/{chunk-ZXCOJY2Z.js → chunk-WMACINXO.js} +1 -1
- package/dist/{chunk-COPFW5Z4.js → chunk-XGGTQQFH.js} +31 -2
- package/dist/{chunk-CMRETRZO.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/addresses.d.ts +22 -0
- package/dist/core/errors.d.ts +41 -1
- package/dist/core/revert-mapper.d.ts +77 -0
- package/dist/core/telemetry.d.ts +0 -3
- 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/operators.d.ts +1 -1
- 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/factory-advanced.d.ts +3 -3
- package/dist/fhe-airdrop/advanced/index.cjs +9 -8
- package/dist/fhe-airdrop/advanced/index.d.cts +2 -2
- package/dist/fhe-airdrop/advanced/index.d.ts +2 -2
- 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.d.cts +1 -1
- package/dist/fhe-airdrop/advanced/react/index.d.ts +1 -1
- 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 +94 -11
- 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 +8 -2
- 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/factory-advanced.d.ts +2 -2
- package/dist/fhe-vesting/advanced/index.cjs +8 -8
- package/dist/fhe-vesting/advanced/index.d.cts +2 -2
- package/dist/fhe-vesting/advanced/index.d.ts +2 -2
- 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.d.cts +1 -1
- package/dist/fhe-vesting/advanced/react/index.d.ts +1 -1
- package/dist/fhe-vesting/advanced/react/index.js +12 -11
- package/dist/fhe-vesting/encryption.d.ts +8 -0
- package/dist/fhe-vesting/factory.d.ts +6 -8
- 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 +101 -3
- 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 +7 -1
- 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 -2
- package/dist/index.cjs +73 -49
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/testnet-faucet/abis/confidential-test-token.d.ts +1039 -0
- package/dist/testnet-faucet/abis/index.d.ts +2 -0
- package/dist/testnet-faucet/abis/test-token.d.ts +253 -0
- package/dist/testnet-faucet/errors.d.ts +21 -0
- package/dist/testnet-faucet/faucet.d.ts +173 -0
- package/dist/testnet-faucet/index.cjs +212 -0
- package/dist/testnet-faucet/index.d.cts +8 -0
- package/dist/testnet-faucet/index.d.ts +8 -0
- package/dist/testnet-faucet/index.js +7 -0
- package/dist/testnet-faucet/react/_shared.d.ts +61 -0
- package/dist/testnet-faucet/react/index.cjs +384 -0
- package/dist/testnet-faucet/react/index.d.cts +39 -0
- package/dist/testnet-faucet/react/index.d.ts +39 -0
- package/dist/testnet-faucet/react/index.js +220 -0
- package/dist/testnet-faucet/react/useConfidentialBalance.d.ts +25 -0
- package/dist/testnet-faucet/react/useFaucetDecimals.d.ts +9 -0
- package/dist/testnet-faucet/react/useFaucetMetadata.d.ts +14 -0
- package/dist/testnet-faucet/react/useFaucetRate.d.ts +11 -0
- package/dist/testnet-faucet/react/useInferredTotalSupply.d.ts +11 -0
- package/dist/testnet-faucet/react/useMaxTotalSupply.d.ts +10 -0
- package/dist/testnet-faucet/react/useMintConfidential.d.ts +35 -0
- package/dist/testnet-faucet/react/useMintUnderlying.d.ts +31 -0
- package/dist/testnet-faucet/react/useUnderlyingBalance.d.ts +19 -0
- package/dist/testnet-faucet/react/useUnderlyingDecimals.d.ts +9 -0
- package/dist/testnet-faucet/react/useUnderlyingTokenAddress.d.ts +12 -0
- package/dist/testnet-faucet/types.d.ts +92 -0
- package/dist/testnet-faucet/validate.d.ts +44 -0
- package/package.json +79 -30
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk67OV5CX2_cjs = require('./chunk-67OV5CX2.cjs');
|
|
4
4
|
var chains = require('viem/chains');
|
|
5
5
|
|
|
6
6
|
var DEPLOYED_ADDRESSES = {
|
|
@@ -21,6 +21,23 @@ var DEPLOYED_ADDRESSES = {
|
|
|
21
21
|
[chains.mainnet.id]: "0x4fC0d28cBe4B82D512Ad0B42F6787480Cc98cC70",
|
|
22
22
|
[chains.sepolia.id]: "0x710dD9885Cc9986EfD234E7719483147a6d8DBb4"
|
|
23
23
|
}
|
|
24
|
+
},
|
|
25
|
+
// Testnet-only faucet token pair (see `/testnet-faucet`). The standard
|
|
26
|
+
// `TokenopsTestToken` (TTT, 18-decimal ERC-20, open mint) and its
|
|
27
|
+
// confidential ERC-7984 wrapper `ConfidentialTokenopsTestToken` (CTTT,
|
|
28
|
+
// 6-decimal, open backed faucet mint). Sepolia only — these mint value-less
|
|
29
|
+
// test tokens to anyone, so they MUST NOT appear on mainnet.
|
|
30
|
+
// `confidentialTestToken` is the UUPS *proxy* address; call it with the
|
|
31
|
+
// implementation ABI.
|
|
32
|
+
testnetFaucet: {
|
|
33
|
+
testToken: {
|
|
34
|
+
[chains.sepolia.id]: "0x37a057Fa8C201a7bf8caF32dfa9A0878f577D92b"
|
|
35
|
+
// mainnet omitted — testnet-only by design.
|
|
36
|
+
},
|
|
37
|
+
confidentialTestToken: {
|
|
38
|
+
[chains.sepolia.id]: "0x258F9D60dc023870e4E3109c894D834D5377361a"
|
|
39
|
+
// mainnet omitted — testnet-only by design.
|
|
40
|
+
}
|
|
24
41
|
}
|
|
25
42
|
};
|
|
26
43
|
function getDeployedAddress(product, contract, chainId) {
|
|
@@ -33,7 +50,7 @@ function requireDeployedAddress(product, contract, chainId) {
|
|
|
33
50
|
const contractEntry = productEntry[contract];
|
|
34
51
|
const entry = contractEntry?.[chainId];
|
|
35
52
|
if (entry) return entry;
|
|
36
|
-
throw new
|
|
53
|
+
throw new chunk67OV5CX2_cjs.DeploymentAddressUnavailableError({
|
|
37
54
|
reason: entry === null ? "registry-not-deployed" : "registry-unknown-chain",
|
|
38
55
|
product: String(product),
|
|
39
56
|
contract: String(contract),
|
|
@@ -58,6 +75,18 @@ function getFheDisperseSingletonAddress(chainId) {
|
|
|
58
75
|
function requireFheDisperseSingletonAddress(chainId) {
|
|
59
76
|
return requireDeployedAddress("fheDisperse", "disperseConfidentialSingleton", chainId);
|
|
60
77
|
}
|
|
78
|
+
function getTestTokenAddress(chainId) {
|
|
79
|
+
return getDeployedAddress("testnetFaucet", "testToken", chainId);
|
|
80
|
+
}
|
|
81
|
+
function requireTestTokenAddress(chainId) {
|
|
82
|
+
return requireDeployedAddress("testnetFaucet", "testToken", chainId);
|
|
83
|
+
}
|
|
84
|
+
function getConfidentialTestTokenAddress(chainId) {
|
|
85
|
+
return getDeployedAddress("testnetFaucet", "confidentialTestToken", chainId);
|
|
86
|
+
}
|
|
87
|
+
function requireConfidentialTestTokenAddress(chainId) {
|
|
88
|
+
return requireDeployedAddress("testnetFaucet", "confidentialTestToken", chainId);
|
|
89
|
+
}
|
|
61
90
|
function chainsWithKnownRegistryEntry(product) {
|
|
62
91
|
const productEntry = DEPLOYED_ADDRESSES[product];
|
|
63
92
|
const ids = /* @__PURE__ */ new Set();
|
|
@@ -84,10 +113,14 @@ function chainsWithDeployment(product) {
|
|
|
84
113
|
exports.DEPLOYED_ADDRESSES = DEPLOYED_ADDRESSES;
|
|
85
114
|
exports.chainsWithDeployment = chainsWithDeployment;
|
|
86
115
|
exports.chainsWithKnownRegistryEntry = chainsWithKnownRegistryEntry;
|
|
116
|
+
exports.getConfidentialTestTokenAddress = getConfidentialTestTokenAddress;
|
|
87
117
|
exports.getDeployedAddress = getDeployedAddress;
|
|
88
118
|
exports.getFheAirdropFactoryAddress = getFheAirdropFactoryAddress;
|
|
89
119
|
exports.getFheDisperseSingletonAddress = getFheDisperseSingletonAddress;
|
|
90
120
|
exports.getFheVestingFactoryAddress = getFheVestingFactoryAddress;
|
|
121
|
+
exports.getTestTokenAddress = getTestTokenAddress;
|
|
122
|
+
exports.requireConfidentialTestTokenAddress = requireConfidentialTestTokenAddress;
|
|
91
123
|
exports.requireFheAirdropFactoryAddress = requireFheAirdropFactoryAddress;
|
|
92
124
|
exports.requireFheDisperseSingletonAddress = requireFheDisperseSingletonAddress;
|
|
93
125
|
exports.requireFheVestingFactoryAddress = requireFheVestingFactoryAddress;
|
|
126
|
+
exports.requireTestTokenAddress = requireTestTokenAddress;
|
|
@@ -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;
|