@zama-fhe/sdk 3.8.0-beta.11 → 3.8.0-beta.13
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/dist/cjs/chains.cjs +1 -1
- package/dist/cjs/chains.cjs.map +1 -1
- package/dist/cjs/telemetry.cjs +1 -1
- package/dist/esm/{base-signer-Box6coKm.js → base-signer-6YPpqhw9.js} +2 -2
- package/dist/esm/{base-signer-Box6coKm.js.map → base-signer-6YPpqhw9.js.map} +1 -1
- package/dist/esm/{base-signer-CNqEVbj7.d.ts → base-signer-DKHbbrIT.d.ts} +2 -2
- package/dist/esm/chains/index.d.ts +1 -1
- package/dist/esm/chains/index.js +1 -1
- package/dist/esm/chains-CF-Hzs9R.js +2 -0
- package/dist/esm/chains-CF-Hzs9R.js.map +1 -0
- package/dist/esm/cleartext/index.d.ts +2 -2
- package/dist/esm/cleartext/index.js +1 -1
- package/dist/esm/{cleartext-BcM98zhR.d.ts → cleartext-C--gPqhI.d.ts} +2 -2
- package/dist/esm/{cleartext-CB7zavwB.js → cleartext-RqXnz7I6.js} +2 -2
- package/dist/esm/{cleartext-CB7zavwB.js.map → cleartext-RqXnz7I6.js.map} +1 -1
- package/dist/esm/{encrypt-worker-client-9SUUIpLM.d.ts → encrypt-worker-client-BlQ06ILZ.d.ts} +2 -2
- package/dist/esm/ethers/index.d.ts +4 -4
- package/dist/esm/ethers/index.js +1 -1
- package/dist/esm/{fhevm-relayer-DYbhIoiY.js → fhevm-relayer-DF4uuzDF.js} +2 -2
- package/dist/esm/{fhevm-relayer-DYbhIoiY.js.map → fhevm-relayer-DF4uuzDF.js.map} +1 -1
- package/dist/esm/{index-BwANiTpY.d.ts → index-B-bk_RhJ.d.ts} +2 -2
- package/dist/esm/{index-DwwNymCc.d.ts → index-CnxoTnTi.d.ts} +4 -4
- package/dist/esm/{index-COgydmiZ.d.ts → index-CyVD1zLr.d.ts} +19 -19
- package/dist/esm/{index-BNA1OOfi.d.ts → index-DrTWm3Aw.d.ts} +7 -7
- package/dist/esm/index.d.ts +8 -8
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/index.d.ts +4 -4
- package/dist/esm/internal/index.js +1 -1
- package/dist/esm/node/index.d.ts +4 -4
- package/dist/esm/node/index.js +1 -1
- package/dist/esm/query/index.d.ts +5 -5
- package/dist/esm/{telemetry-qilFi8ed.js → telemetry-D9Mf59ts.js} +2 -2
- package/dist/esm/{telemetry-qilFi8ed.js.map → telemetry-D9Mf59ts.js.map} +1 -1
- package/dist/esm/{types-BQHRdNY-.d.ts → types-BF5HtmsQ.d.ts} +3 -3
- package/dist/esm/{types-D-rp-sGq.d.ts → types-BR69mm5U.d.ts} +3 -3
- package/dist/esm/{types-hWhlvqxC.d.ts → types-CKtpO41S.d.ts} +2 -2
- package/dist/esm/vaults/index.d.ts +2 -2
- package/dist/esm/vaults/index.js +1 -1
- package/dist/esm/viem/index.d.ts +4 -4
- package/dist/esm/viem/index.js +1 -1
- package/dist/esm/web/index.d.ts +2 -2
- package/dist/esm/web/index.js +1 -1
- package/package.json +1 -1
- package/dist/esm/chains-CefvVW4j.js +0 -2
- package/dist/esm/chains-CefvVW4j.js.map +0 -1
|
@@ -62,7 +62,7 @@ type AtLeastOneChain = readonly [FheChain, ...FheChain[]];
|
|
|
62
62
|
/**
|
|
63
63
|
* Mainnet network configuration (chainId 1).
|
|
64
64
|
*/
|
|
65
|
-
declare const mainnet: {
|
|
65
|
+
declare const mainnet: Readonly<{
|
|
66
66
|
readonly id: 1;
|
|
67
67
|
readonly gatewayChainId: 261131;
|
|
68
68
|
readonly relayerUrl: "https://relayer.mainnet.zama.org";
|
|
@@ -73,11 +73,11 @@ declare const mainnet: {
|
|
|
73
73
|
readonly verifyingContractAddressDecryption: "0x0f6024a97684f7d90ddb0fAAD79cB15F2C888D24";
|
|
74
74
|
readonly verifyingContractAddressInputVerification: "0xcB1bB072f38bdAF0F328CdEf1Fc6eDa1DF029287";
|
|
75
75
|
readonly registryAddress: "0xeb5015fF021DB115aCe010f23F55C2591059bBA0";
|
|
76
|
-
}
|
|
76
|
+
}>;
|
|
77
77
|
/**
|
|
78
78
|
* Polygon mainnet network configuration (chainId 137).
|
|
79
79
|
*/
|
|
80
|
-
declare const polygon: {
|
|
80
|
+
declare const polygon: Readonly<{
|
|
81
81
|
readonly id: 137;
|
|
82
82
|
readonly gatewayChainId: 261131;
|
|
83
83
|
readonly relayerUrl: "https://relayer.mainnet.zama.org";
|
|
@@ -88,11 +88,11 @@ declare const polygon: {
|
|
|
88
88
|
readonly verifyingContractAddressDecryption: "0x0f6024a97684f7d90ddb0fAAD79cB15F2C888D24";
|
|
89
89
|
readonly verifyingContractAddressInputVerification: "0xcB1bB072f38bdAF0F328CdEf1Fc6eDa1DF029287";
|
|
90
90
|
readonly registryAddress: "0xc8908569868758dAF814B5a8b96bBc44D1653d54";
|
|
91
|
-
}
|
|
91
|
+
}>;
|
|
92
92
|
/**
|
|
93
93
|
* Sepolia testnet network configuration (chainId 11155111).
|
|
94
94
|
*/
|
|
95
|
-
declare const sepolia: {
|
|
95
|
+
declare const sepolia: Readonly<{
|
|
96
96
|
readonly id: 11155111;
|
|
97
97
|
readonly gatewayChainId: 10901;
|
|
98
98
|
readonly relayerUrl: "https://relayer.testnet.zama.org";
|
|
@@ -103,14 +103,14 @@ declare const sepolia: {
|
|
|
103
103
|
readonly verifyingContractAddressDecryption: "0x5D8BD78e2ea6bbE41f26dFe9fdaEAa349e077478";
|
|
104
104
|
readonly verifyingContractAddressInputVerification: "0x483b9dE06E4E4C7D35CCf5837A1668487406D955";
|
|
105
105
|
readonly registryAddress: "0x2f0750Bbb0A246059d80e94c454586a7F27a128e";
|
|
106
|
-
}
|
|
106
|
+
}>;
|
|
107
107
|
/**
|
|
108
108
|
* Polygon Amoy testnet network configuration (chainId 80002).
|
|
109
109
|
*
|
|
110
110
|
* Ships without a wrappers registry: set `registryAddress` to your own
|
|
111
111
|
* deployment to use token operations.
|
|
112
112
|
*/
|
|
113
|
-
declare const polygonAmoy: {
|
|
113
|
+
declare const polygonAmoy: Readonly<{
|
|
114
114
|
readonly id: 80002;
|
|
115
115
|
readonly gatewayChainId: 10901;
|
|
116
116
|
readonly relayerUrl: "https://relayer.testnet.zama.org";
|
|
@@ -121,14 +121,14 @@ declare const polygonAmoy: {
|
|
|
121
121
|
readonly verifyingContractAddressDecryption: "0x5D8BD78e2ea6bbE41f26dFe9fdaEAa349e077478";
|
|
122
122
|
readonly verifyingContractAddressInputVerification: "0x483b9dE06E4E4C7D35CCf5837A1668487406D955";
|
|
123
123
|
readonly registryAddress: undefined;
|
|
124
|
-
}
|
|
124
|
+
}>;
|
|
125
125
|
/**
|
|
126
126
|
* Hoodi testnet configuration (chainId 560048).
|
|
127
127
|
*
|
|
128
128
|
* Hoodi does not have full FHE infrastructure — use with `cleartext()` transport.
|
|
129
129
|
* Contract addresses match the cleartext deployment.
|
|
130
130
|
*/
|
|
131
|
-
declare const hoodi: {
|
|
131
|
+
declare const hoodi: Readonly<{
|
|
132
132
|
readonly id: 560048;
|
|
133
133
|
readonly gatewayChainId: 10901;
|
|
134
134
|
readonly relayerUrl: "";
|
|
@@ -140,7 +140,7 @@ declare const hoodi: {
|
|
|
140
140
|
readonly verifyingContractAddressInputVerification: "0x812b06e1CDCE800494b79fFE4f925A504a9A9810";
|
|
141
141
|
readonly registryAddress: "0x1807aE2f693F8530DFB126D0eF98F2F2518F292f";
|
|
142
142
|
readonly executorAddress: "0xC316692627de536368d82e9121F1D44a550894E6";
|
|
143
|
-
}
|
|
143
|
+
}>;
|
|
144
144
|
/**
|
|
145
145
|
* T-Rex Zenith testnet configuration (chainId 936486).
|
|
146
146
|
*
|
|
@@ -148,7 +148,7 @@ declare const hoodi: {
|
|
|
148
148
|
* finality) — a separate chain from Zenith's shared testnet (chainId 936485).
|
|
149
149
|
* It does not have full FHE infrastructure — use with `cleartext()` transport.
|
|
150
150
|
*/
|
|
151
|
-
declare const zenithTrexTestnet: {
|
|
151
|
+
declare const zenithTrexTestnet: Readonly<{
|
|
152
152
|
readonly id: 936486;
|
|
153
153
|
readonly gatewayChainId: 10901;
|
|
154
154
|
readonly relayerUrl: "";
|
|
@@ -160,14 +160,14 @@ declare const zenithTrexTestnet: {
|
|
|
160
160
|
readonly verifyingContractAddressInputVerification: "0x812b06e1CDCE800494b79fFE4f925A504a9A9810";
|
|
161
161
|
readonly registryAddress: "0xde2e3948d35ef9C406A7317eAF332F3c2786a566";
|
|
162
162
|
readonly executorAddress: "0x6C5036A4ad55DBA8007ae82c4e9C123F143e53ab";
|
|
163
|
-
}
|
|
163
|
+
}>;
|
|
164
164
|
/**
|
|
165
165
|
* BNB Smart Chain testnet configuration (chainId 97, Chapel).
|
|
166
166
|
*
|
|
167
167
|
* BSC testnet does not have full FHE infrastructure — use with `cleartext()` transport.
|
|
168
168
|
* Contract addresses match the cleartext deployment.
|
|
169
169
|
*/
|
|
170
|
-
declare const bscTestnet: {
|
|
170
|
+
declare const bscTestnet: Readonly<{
|
|
171
171
|
readonly id: 97;
|
|
172
172
|
readonly gatewayChainId: 10901;
|
|
173
173
|
readonly relayerUrl: "";
|
|
@@ -179,13 +179,13 @@ declare const bscTestnet: {
|
|
|
179
179
|
readonly verifyingContractAddressInputVerification: "0x812b06e1CDCE800494b79fFE4f925A504a9A9810";
|
|
180
180
|
readonly registryAddress: "0xc0E8B73b1C58D846e1d4f8fAE2E1466C85BCeAeC";
|
|
181
181
|
readonly executorAddress: "0x5985e48689550c1b2893ABfBbe4cc0eE3A22cc54";
|
|
182
|
-
}
|
|
182
|
+
}>;
|
|
183
183
|
/**
|
|
184
184
|
* Hardhat local network configuration (chainId 31337).
|
|
185
185
|
*
|
|
186
186
|
* The addresses in this configuration must match those of your deployment.
|
|
187
187
|
*/
|
|
188
|
-
declare const hardhat: {
|
|
188
|
+
declare const hardhat: Readonly<{
|
|
189
189
|
readonly id: 31337;
|
|
190
190
|
readonly gatewayChainId: 10901;
|
|
191
191
|
readonly relayerUrl: "";
|
|
@@ -197,9 +197,9 @@ declare const hardhat: {
|
|
|
197
197
|
readonly verifyingContractAddressInputVerification: "0x812b06e1CDCE800494b79fFE4f925A504a9A9810";
|
|
198
198
|
readonly registryAddress: undefined;
|
|
199
199
|
readonly executorAddress: "0xe3a9105a3a932253A70F126eb1E3b589C643dD24";
|
|
200
|
-
}
|
|
200
|
+
}>;
|
|
201
201
|
/** Alias for {@link hardhat}. */
|
|
202
|
-
declare const anvil: {
|
|
202
|
+
declare const anvil: Readonly<{
|
|
203
203
|
readonly id: 31337;
|
|
204
204
|
readonly gatewayChainId: 10901;
|
|
205
205
|
readonly relayerUrl: "";
|
|
@@ -211,11 +211,11 @@ declare const anvil: {
|
|
|
211
211
|
readonly verifyingContractAddressInputVerification: "0x812b06e1CDCE800494b79fFE4f925A504a9A9810";
|
|
212
212
|
readonly registryAddress: undefined;
|
|
213
213
|
readonly executorAddress: "0xe3a9105a3a932253A70F126eb1E3b589C643dD24";
|
|
214
|
-
}
|
|
214
|
+
}>;
|
|
215
215
|
/**
|
|
216
216
|
* Built-in chain configurations keyed by chain ID.
|
|
217
217
|
*/
|
|
218
218
|
declare const chains: Record<number, FheChain>;
|
|
219
219
|
//#endregion
|
|
220
220
|
export { hoodi as a, polygonAmoy as c, AtLeastOneChain as d, FheChain as f, hardhat as i, sepolia as l, bscTestnet as n, mainnet as o, FheChainAuth as p, chains as r, polygon as s, anvil as t, zenithTrexTestnet as u };
|
|
221
|
-
//# sourceMappingURL=index-
|
|
221
|
+
//# sourceMappingURL=index-CyVD1zLr.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { f as FheChain } from "./index-
|
|
2
|
-
import { i as ZamaConfig, o as ZamaConfigGeneric } from "./types-
|
|
3
|
-
import "./cleartext-
|
|
4
|
-
import "./types-
|
|
5
|
-
import "./types-
|
|
6
|
-
import "./index-
|
|
1
|
+
import { f as FheChain } from "./index-CyVD1zLr.js";
|
|
2
|
+
import { i as ZamaConfig, o as ZamaConfigGeneric } from "./types-CKtpO41S.js";
|
|
3
|
+
import "./cleartext-C--gPqhI.js";
|
|
4
|
+
import "./types-BR69mm5U.js";
|
|
5
|
+
import "./types-BF5HtmsQ.js";
|
|
6
|
+
import "./index-B-bk_RhJ.js";
|
|
7
7
|
//#region src/config/create.d.ts
|
|
8
8
|
/**
|
|
9
9
|
* Create a {@link ZamaConfig} from a custom {@link GenericSigner} and
|
|
@@ -31,4 +31,4 @@ import "./index-BwANiTpY.js";
|
|
|
31
31
|
declare function createConfig<const TChains extends readonly [FheChain, ...FheChain[]]>(params: ZamaConfigGeneric<TChains>): ZamaConfig;
|
|
32
32
|
//#endregion
|
|
33
33
|
export { createConfig as t };
|
|
34
|
-
//# sourceMappingURL=index-
|
|
34
|
+
//# sourceMappingURL=index-DrTWm3Aw.d.ts.map
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { a as hoodi, c as polygonAmoy, d as AtLeastOneChain, f as FheChain, i as hardhat, l as sepolia, n as bscTestnet, o as mainnet, p as FheChainAuth, r as chains, s as polygon, t as anvil, u as zenithTrexTestnet } from "./index-
|
|
2
|
-
import { $ as SetOperatorSubmittedEvent, $t as TransactionReceipt, A as WalletAccountListener, At as DelegatedForUserDecryptionEvent, B as ApproveUnderlyingSubmittedEvent, Bt as decodeConfidentialTransfer, C as TransferAndCallRequest, Ct as ShieldCallbacks, D as GenericSigner, Dt as AclEvent, E as WrapRequest, Et as ACL_TOPICS, F as ReadContractReturnType, Ft as UnwrapFinalizedEvent, G as DelegationSubmittedEvent, Gt as decodeUnwrapFinalized, H as DecryptEndEvent, Ht as decodeOnChainEvent, I as ReadFunctionName, It as UnwrapRequestedEvent, J as EncryptStartEvent, Jt as findDelegatedForUserDecryption, K as EncryptEndEvent, Kt as decodeUnwrapRequested, L as WriteContractArgs, Lt as WrapEvent, M as ContractAbi, Mt as RevokedDelegationForUserDecryptionEvent, N as ReadContractArgs, Nt as TOKEN_TOPICS, O as WalletAccount, Ot as AclTopics, P as ReadContractConfig, Pt as Topics, Q as RevokeDelegationSubmittedEvent, Qt as RawLog, R as WriteContractConfig, Rt as decodeAclEvent, S as TransactionKind, St as WrapOptions, T as UnwrapRequest, Tt as UnshieldCallbacks, U as DecryptErrorEvent, Ut as decodeOnChainEvents, V as BaseEvent, Vt as decodeDelegatedForUserDecryption, W as DecryptStartEvent, Wt as decodeRevokedDelegationForUserDecryption, X as PermitErrorEvent, Xt as findUnwrapRequested, Y as FinalizeUnwrapSubmittedEvent, Yt as findRevokedDelegationForUserDecryption, Z as PermitOperation, Zt as findWrap, _ as PrepareTransactionRequest, _t as ShieldOptions, a as ZamaConfigBase, an as EncryptInput, at as UnshieldPhase1SubmittedEvent, b as RevokeDelegationRequest, bt as UnshieldOptions, c as GenericStorage, cn as EncryptedValue, ct as UnwrapSubmittedEvent, d as ConfidentialTransferFromRequest, dn as FhevmRelayerOptions, dt as WrapSubmittedEvent, en as TransactionResult, et as ShieldSubmittedEvent, f as ConfidentialTransferRequest, fn as FhevmRuntimeConfig, ft as ZamaSDKEvent, g as PrepareOptions, gn as TypedValue, gt as ApprovalStrategy, h as PrepareFees, hn as RelayerSDK, ht as ZamaSDKEvents, i as ZamaConfig, in as EIP712TypedData, it as TransferSubmittedEvent, j as WalletAccountStore, jt as OnChainEvent, k as WalletAccountChange, kt as ConfidentialTransferEvent, l as GenericProvider, ln as FhevmClient, lt as VaultOperation, m as FinalizeUnwrapRequest, mn as RelayerRequestOptions, mt as ZamaSDKEventType, n as RelayerConfig, nn as DecryptPublicValuesResult, nt as TransactionOperation, o as ZamaConfigGeneric, on as EncryptParams, ot as UnshieldPhase2StartedEvent, p as DelegateDecryptionRequest, pn as RelayerOptions, pt as ZamaSDKEventListener, q as EncryptErrorEvent, qt as decodeWrap, rn as DecryptValuesParameters, rt as TransferFromSubmittedEvent, s as GenericLogger, sn as EncryptResult, st as UnshieldPhase2SubmittedEvent, t as CleartextRelayerConfig, tn as ClearValue, tt as TransactionErrorEvent, u as ApproveUnderlyingRequest, un as FhevmClientOptions, ut as VaultSubmittedEvent, v as PreparedFor, vt as ShieldPath, w as UnwrapAllRequest, wt as TransferCallbacks, x as SetOperatorRequest, xt as UnwrapResult, y as PreparedTransaction, yt as TransferOptions, z as WriteFunctionName, zt as decodeAclEvents } from "./types-
|
|
3
|
-
import { t as cleartext } from "./cleartext-
|
|
4
|
-
import { t as ZamaConfigEthers } from "./types-
|
|
5
|
-
import { n as MutableWalletAccountStore, r as createWalletAccountStore, t as BaseSigner } from "./base-signer-
|
|
6
|
-
import { t as createConfig } from "./index-
|
|
7
|
-
import { t as ZamaConfigViem } from "./types-
|
|
8
|
-
import { $ as UnshieldAlreadyFinalizedError, $t as ChecksummedAddress, A as ListPairsOptions, An as confidentialTransferFromContract, At as DelegationNotPropagatedError, B as DelegationStatus, Bn as wrapContract, Bt as ChainMismatchError, Cn as balanceOfContract, Ct as DelegationCooldownError, D as ZamaSDK, Dn as confidentialBalanceOfContract, Dt as DelegationExpiredError, En as symbolContract, Et as DelegationExpirationTooSoonError, F as BatchDecryptAsOptions, Fn as setOperatorContract, Ft as PreparedPermitChainMismatchError, G as DecryptResult, Gt as parsePreparedPermit, H as BatchDecryptItem, Ht as ZamaErrorCode, I as Token, In as underlyingContract, It as PreparedPermitExpiredError, Jt as PreparedPermit, K as EncryptedInput, Kt as Permission, L as Permits, Ln as unwrapContract, Lt as RevokedKmsContextError, M as WrappersRegistryConfig, Mn as inferredTotalSupplyContract, Mt as InvalidTransportKeyPairError, N as WrappedToken, Nn as isOperatorContract, Nt as KeyWrappingError, O as ZamaSDKOptions, On as confidentialTotalSupplyContract, Ot as DelegationExpiryUnchangedError, P as BatchBalancesResult, Pn as rateContract, Pt as NoCiphertextError, Q as UnshieldAlreadyFinalizedDetails, Qt as SignedPreparedPermit, R as Offline, Rn as unwrapFromBalanceContract, Rt as TransportKeyPairChangedError, Sn as approveContract, St as DelegationContractIsSelfError, Tn as nameContract, Tt as DelegationDelegateEqualsContractError, U as BatchDecryptResult, Ut as isRetryable, V as Decryption, Vt as ZamaError, W as DelegatedDecryptOptions, Wt as retryAfterSeconds, Xt as SerializedPermitEip712, Yt as SerializedPermit, Zt as SerializedTransportKeyPair, _n as ERC7984_WRAPPER_INTERFACE_ID, _t as InsufficientERC20BalanceError, a as VaultBatcherPausedDetails, an as getTokenPairContract, at as SignerRequiredError, bn as supportsInterfaceContract, bt as EncryptionFailedError, c as VaultGroupJoinUnconfirmedError, cn as getTokenPairsSliceContract, ct as RpcRateLimitError, dn as getDelegationExpiryContract, dt as RelayerRequestFailedError, en as PaginatedResult, et as TransactionRevertedError, f as VaultGroupJoin, fn as isHandleDelegatedContract, ft as BalanceCheckUnavailableError, gn as ERC7984_INTERFACE_ID, gt as InsufficientConfidentialBalanceError, hn as ERC1363_INTERFACE_ID, ht as InsufficientAllowanceError, i as UnlistedConfidentialTokenError, in as getTokenAddressContract, it as SignerNotConfiguredError, j as WrappersRegistry, jn as finalizeUnwrapContract, jt as DelegationSelfNotAllowedError, k as DefaultRegistryAddresses, kn as confidentialTransferContract, kt as DelegationNotFoundError, ln as isConfidentialTokenValidContract, lt as NotEntitledError, mn as transferAndCallContract, mt as ERC20ReadFailedError, n as matchZamaError, nn as TokenWrapperPairWithMetadata, nt as SigningFailedError, o as VaultBatcherPausedError, on as getTokenPairsContract, ot as WalletAccountNotReadyError, pn as revokeDelegationContract, pt as BalanceErrorDetails, qt as PreparePermitRequest, r as UnlistedConfidentialTokenDetails, rn as getConfidentialTokenAddressContract, rt as SigningRejectedError, s as VaultGroupJoinUnconfirmedDetails, sn as getTokenPairsLengthContract, st as WalletNotConnectedError, t as ErrorForCode, tn as TokenWrapperPair, tt as SigningErrorMetadata, un as delegateForUserDecryptionContract, ut as ConfigurationError, vn as isConfidentialTokenContract, vt as DecryptionFailedError, wn as decimalsContract, wt as DelegationDelegateCannotBeWildcardError, xn as allowanceContract, xt as AclPausedError, yn as isConfidentialWrapperContract, yt as EncryptOffloadUnavailableError, z as Delegations, zn as unwrapRequesterContract, zt as TransportKeyPairExpiredError } from "./index-
|
|
1
|
+
import { a as hoodi, c as polygonAmoy, d as AtLeastOneChain, f as FheChain, i as hardhat, l as sepolia, n as bscTestnet, o as mainnet, p as FheChainAuth, r as chains, s as polygon, t as anvil, u as zenithTrexTestnet } from "./index-CyVD1zLr.js";
|
|
2
|
+
import { $ as SetOperatorSubmittedEvent, $t as TransactionReceipt, A as WalletAccountListener, At as DelegatedForUserDecryptionEvent, B as ApproveUnderlyingSubmittedEvent, Bt as decodeConfidentialTransfer, C as TransferAndCallRequest, Ct as ShieldCallbacks, D as GenericSigner, Dt as AclEvent, E as WrapRequest, Et as ACL_TOPICS, F as ReadContractReturnType, Ft as UnwrapFinalizedEvent, G as DelegationSubmittedEvent, Gt as decodeUnwrapFinalized, H as DecryptEndEvent, Ht as decodeOnChainEvent, I as ReadFunctionName, It as UnwrapRequestedEvent, J as EncryptStartEvent, Jt as findDelegatedForUserDecryption, K as EncryptEndEvent, Kt as decodeUnwrapRequested, L as WriteContractArgs, Lt as WrapEvent, M as ContractAbi, Mt as RevokedDelegationForUserDecryptionEvent, N as ReadContractArgs, Nt as TOKEN_TOPICS, O as WalletAccount, Ot as AclTopics, P as ReadContractConfig, Pt as Topics, Q as RevokeDelegationSubmittedEvent, Qt as RawLog, R as WriteContractConfig, Rt as decodeAclEvent, S as TransactionKind, St as WrapOptions, T as UnwrapRequest, Tt as UnshieldCallbacks, U as DecryptErrorEvent, Ut as decodeOnChainEvents, V as BaseEvent, Vt as decodeDelegatedForUserDecryption, W as DecryptStartEvent, Wt as decodeRevokedDelegationForUserDecryption, X as PermitErrorEvent, Xt as findUnwrapRequested, Y as FinalizeUnwrapSubmittedEvent, Yt as findRevokedDelegationForUserDecryption, Z as PermitOperation, Zt as findWrap, _ as PrepareTransactionRequest, _t as ShieldOptions, a as ZamaConfigBase, an as EncryptInput, at as UnshieldPhase1SubmittedEvent, b as RevokeDelegationRequest, bt as UnshieldOptions, c as GenericStorage, cn as EncryptedValue, ct as UnwrapSubmittedEvent, d as ConfidentialTransferFromRequest, dn as FhevmRelayerOptions, dt as WrapSubmittedEvent, en as TransactionResult, et as ShieldSubmittedEvent, f as ConfidentialTransferRequest, fn as FhevmRuntimeConfig, ft as ZamaSDKEvent, g as PrepareOptions, gn as TypedValue, gt as ApprovalStrategy, h as PrepareFees, hn as RelayerSDK, ht as ZamaSDKEvents, i as ZamaConfig, in as EIP712TypedData, it as TransferSubmittedEvent, j as WalletAccountStore, jt as OnChainEvent, k as WalletAccountChange, kt as ConfidentialTransferEvent, l as GenericProvider, ln as FhevmClient, lt as VaultOperation, m as FinalizeUnwrapRequest, mn as RelayerRequestOptions, mt as ZamaSDKEventType, n as RelayerConfig, nn as DecryptPublicValuesResult, nt as TransactionOperation, o as ZamaConfigGeneric, on as EncryptParams, ot as UnshieldPhase2StartedEvent, p as DelegateDecryptionRequest, pn as RelayerOptions, pt as ZamaSDKEventListener, q as EncryptErrorEvent, qt as decodeWrap, rn as DecryptValuesParameters, rt as TransferFromSubmittedEvent, s as GenericLogger, sn as EncryptResult, st as UnshieldPhase2SubmittedEvent, t as CleartextRelayerConfig, tn as ClearValue, tt as TransactionErrorEvent, u as ApproveUnderlyingRequest, un as FhevmClientOptions, ut as VaultSubmittedEvent, v as PreparedFor, vt as ShieldPath, w as UnwrapAllRequest, wt as TransferCallbacks, x as SetOperatorRequest, xt as UnwrapResult, y as PreparedTransaction, yt as TransferOptions, z as WriteFunctionName, zt as decodeAclEvents } from "./types-CKtpO41S.js";
|
|
3
|
+
import { t as cleartext } from "./cleartext-C--gPqhI.js";
|
|
4
|
+
import { t as ZamaConfigEthers } from "./types-BR69mm5U.js";
|
|
5
|
+
import { n as MutableWalletAccountStore, r as createWalletAccountStore, t as BaseSigner } from "./base-signer-DKHbbrIT.js";
|
|
6
|
+
import { t as createConfig } from "./index-DrTWm3Aw.js";
|
|
7
|
+
import { t as ZamaConfigViem } from "./types-BF5HtmsQ.js";
|
|
8
|
+
import { $ as UnshieldAlreadyFinalizedError, $t as ChecksummedAddress, A as ListPairsOptions, An as confidentialTransferFromContract, At as DelegationNotPropagatedError, B as DelegationStatus, Bn as wrapContract, Bt as ChainMismatchError, Cn as balanceOfContract, Ct as DelegationCooldownError, D as ZamaSDK, Dn as confidentialBalanceOfContract, Dt as DelegationExpiredError, En as symbolContract, Et as DelegationExpirationTooSoonError, F as BatchDecryptAsOptions, Fn as setOperatorContract, Ft as PreparedPermitChainMismatchError, G as DecryptResult, Gt as parsePreparedPermit, H as BatchDecryptItem, Ht as ZamaErrorCode, I as Token, In as underlyingContract, It as PreparedPermitExpiredError, Jt as PreparedPermit, K as EncryptedInput, Kt as Permission, L as Permits, Ln as unwrapContract, Lt as RevokedKmsContextError, M as WrappersRegistryConfig, Mn as inferredTotalSupplyContract, Mt as InvalidTransportKeyPairError, N as WrappedToken, Nn as isOperatorContract, Nt as KeyWrappingError, O as ZamaSDKOptions, On as confidentialTotalSupplyContract, Ot as DelegationExpiryUnchangedError, P as BatchBalancesResult, Pn as rateContract, Pt as NoCiphertextError, Q as UnshieldAlreadyFinalizedDetails, Qt as SignedPreparedPermit, R as Offline, Rn as unwrapFromBalanceContract, Rt as TransportKeyPairChangedError, Sn as approveContract, St as DelegationContractIsSelfError, Tn as nameContract, Tt as DelegationDelegateEqualsContractError, U as BatchDecryptResult, Ut as isRetryable, V as Decryption, Vt as ZamaError, W as DelegatedDecryptOptions, Wt as retryAfterSeconds, Xt as SerializedPermitEip712, Yt as SerializedPermit, Zt as SerializedTransportKeyPair, _n as ERC7984_WRAPPER_INTERFACE_ID, _t as InsufficientERC20BalanceError, a as VaultBatcherPausedDetails, an as getTokenPairContract, at as SignerRequiredError, bn as supportsInterfaceContract, bt as EncryptionFailedError, c as VaultGroupJoinUnconfirmedError, cn as getTokenPairsSliceContract, ct as RpcRateLimitError, dn as getDelegationExpiryContract, dt as RelayerRequestFailedError, en as PaginatedResult, et as TransactionRevertedError, f as VaultGroupJoin, fn as isHandleDelegatedContract, ft as BalanceCheckUnavailableError, gn as ERC7984_INTERFACE_ID, gt as InsufficientConfidentialBalanceError, hn as ERC1363_INTERFACE_ID, ht as InsufficientAllowanceError, i as UnlistedConfidentialTokenError, in as getTokenAddressContract, it as SignerNotConfiguredError, j as WrappersRegistry, jn as finalizeUnwrapContract, jt as DelegationSelfNotAllowedError, k as DefaultRegistryAddresses, kn as confidentialTransferContract, kt as DelegationNotFoundError, ln as isConfidentialTokenValidContract, lt as NotEntitledError, mn as transferAndCallContract, mt as ERC20ReadFailedError, n as matchZamaError, nn as TokenWrapperPairWithMetadata, nt as SigningFailedError, o as VaultBatcherPausedError, on as getTokenPairsContract, ot as WalletAccountNotReadyError, pn as revokeDelegationContract, pt as BalanceErrorDetails, qt as PreparePermitRequest, r as UnlistedConfidentialTokenDetails, rn as getConfidentialTokenAddressContract, rt as SigningRejectedError, s as VaultGroupJoinUnconfirmedDetails, sn as getTokenPairsLengthContract, st as WalletNotConnectedError, t as ErrorForCode, tn as TokenWrapperPair, tt as SigningErrorMetadata, un as delegateForUserDecryptionContract, ut as ConfigurationError, vn as isConfidentialTokenContract, vt as DecryptionFailedError, wn as decimalsContract, wt as DelegationDelegateCannotBeWildcardError, xn as allowanceContract, xt as AclPausedError, yn as isConfidentialWrapperContract, yt as EncryptOffloadUnavailableError, z as Delegations, zn as unwrapRequesterContract, zt as TransportKeyPairExpiredError } from "./index-B-bk_RhJ.js";
|
|
9
9
|
import { Address, Hex } from "viem";
|
|
10
10
|
//#region src/contracts/constants.d.ts
|
|
11
11
|
/** uint64 max — represents a permanent (no-expiry) delegation. */
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{S as e,_ as t,a as n,b as r,c as i,d as a,g as o,h as s,i as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,v as ee}from"./relayer-ov8b_HOu.js";import{a as g,c as te,d as ne,i as _,l as v,n as re,o as y,s as ie,t as b,u as ae}from"./signing-CneT-WIV.js";import{n as oe,r as x,t as S}from"./encryption-ieCO6J5r.js";import{A as se,C as ce,D as le,F as ue,G as de,H as C,I as fe,J as w,K as pe,L as T,M as E,N as me,O as he,P as ge,R as D,S as _e,T as ve,V as ye,W as be,Y as xe,_ as Se,a as Ce,b as we,c as Te,d as Ee,f as De,g as O,h as Oe,i as ke,j as Ae,k as je,l as Me,m as Ne,n as Pe,o as Fe,q as Ie,r as Le,s as Re,t as ze,u as Be,v as Ve,x as He,z as Ue}from"./wrappers-registry-DnYVQ02R.js";import{n as We,r as k}from"./fatal-batch-CI1pes1q.js";import{a as A,c as Ge,d as Ke,f as qe,h as Je,l as Ye,m as Xe,n as Ze,o as Qe,p as $e,r as j,s as et,t as tt,u as nt}from"./token-DlsiZmg5.js";import{C as rt,D as it,E as at,O as ot,T as st,_ as ct,a as lt,c as ut,d as dt,f as ft,g as pt,h as mt,i as ht,l as gt,m as _t,n as vt,o as yt,p as bt,r as xt,s as St,t as Ct,u as wt,v as Tt,w as Et,y as Dt}from"./wrapped-token-C8eKid8W.js";import{r as M}from"./telemetry-qilFi8ed.js";import{t as Ot}from"./cleartext-CB7zavwB.js";import{a as kt,c as At,d as jt,f as Mt,i as Nt,l as Pt,m as Ft,n as It,o as N,p as Lt,r as Rt,s as zt,t as Bt,u as Vt}from"./base-signer-Box6coKm.js";import{n as P,r as Ht,s as Ut,t as Wt}from"./primitives-Cym-3HKa.js";import{t as F}from"./validation-ChQwNxaY.js";import{a as Gt,c as Kt,i as qt,l as Jt,n as Yt,o as Xt,r as Zt,s as Qt,t as $t,u as en}from"./chains-CefvVW4j.js";import{getAddress as I,size as tn}from"viem";import{z as L}from"zod/mini";function nn(e,t){if(e instanceof p){let n=t[e.code];if(n)return n(e)}return t._?.(e)}var R=class extends p{encryptedValue;contractAddress;account;constructor(e,t){super(c.NotEntitled,`Account ${e.account} is not entitled to decrypt encrypted value ${e.encryptedValue} on contract ${e.contractAddress}. This is not a transient failure — the account needs an on-chain ACL grant before it can decrypt this encrypted value.`,t),this.name=`NotEntitledError`,this.encryptedValue=e.encryptedValue,this.contractAddress=e.contractAddress,this.account=e.account}},z=class extends p{constructor(e,t){super(c.DelegationSelfNotAllowed,e,t),this.name=`DelegationSelfNotAllowedError`}},rn=class extends p{constructor(e,t){super(c.DelegationCooldown,e,t),this.name=`DelegationCooldownError`}},B=class extends p{constructor(e,t){super(c.DelegationNotFound,e,t),this.name=`DelegationNotFoundError`}},V=class extends p{constructor(e,t){super(c.DelegationExpired,e,t),this.name=`DelegationExpiredError`}},H=class extends p{constructor(e,t){super(c.DelegationExpiryUnchanged,e,t),this.name=`DelegationExpiryUnchangedError`}},U=class extends p{constructor(e,t){super(c.DelegationDelegateEqualsContract,e,t),this.name=`DelegationDelegateEqualsContractError`}},W=class extends p{constructor(e,t){super(c.DelegationDelegateCannotBeWildcard,e,t),this.name=`DelegationDelegateCannotBeWildcardError`}},an=class extends p{constructor(e,t){super(c.DelegationContractIsSelf,e,t),this.name=`DelegationContractIsSelfError`}},on=class extends p{constructor(e,t){super(c.AclPaused,e,t),this.name=`AclPausedError`}},G=class extends p{constructor(e,t){super(c.DelegationExpirationTooSoon,e,t),this.name=`DelegationExpirationTooSoonError`}},K=class extends p{constructor(e,t){super(c.DelegationNotPropagated,e,t),this.name=`DelegationNotPropagatedError`}};const sn=[S,y,u,K,re,b,R,k,_,v];function q(e,n,c={}){if(sn.some(t=>e instanceof t))return e;let d=e instanceof Error?e.message:n;if(e instanceof Error&&f(e.message))return new _(e.message,{cause:e});if(t(e))return new v(`The permit's KMS context has been revoked on-chain, so the permit is no longer usable. The SDK evicts the permit and re-grants automatically; if this error surfaced, the retry failed the same way. The on-chain validity check is cached for up to 15 minutes, so a just-revoked context can keep failing across that window. Retry after the window; the SDK re-runs the recovery on the next decrypt, no manual cleanup is needed.`,{cause:e});if(e instanceof Error&&l(e.message))return c.isDelegated?new K(`Delegated decryption was denied by the on-chain ACL check. This is most commonly caused by the delegation not having propagated yet, or by the RPC node serving a stale block. Propagation usually completes within ~10 blocks (a few seconds) and the SDK retries across that window; seeing this means it did not sync in time. Retry shortly (and prefer a fresh, low-lag RPC endpoint). If it persists, the delegator may genuinely lack the on-chain ACL grant.`,{cause:e}):new R({encryptedValue:r(e.message)??``,contractAddress:c.contractAddress??``,account:c.account??``},{cause:e});if(a(e))return new k(d,{cause:e,retryAfter:i(e)});let p=m(e);return p===void 0&&ee(e)?new k(d,{cause:e,retryAfter:i(e)}):p===400?new y(e instanceof Error?e.message:`No ciphertext for this account`,{cause:e}):c.isDelegated&&p===500?new K(`Delegated decryption failed with a server error. This is most commonly caused by the delegation not having propagated to the gateway yet. Cross-chain sync usually completes within ~10 blocks (a few seconds) and the SDK retries across that window; seeing this means it did not sync in time — retry shortly. If the error persists, the gateway or relayer may be experiencing an unrelated issue.`,{cause:e}):s(e)||p!==void 0?new u(d,p,{cause:e,retryAfter:i(e),retryable:o(e)||void 0}):new S(n,{cause:e})}function cn(e,t){if(e instanceof p)return e;let n=m(e),r=o(e);return n!==void 0||s(e)?new u(e instanceof Error?e.message:t,n,{cause:e,retryAfter:i(e),retryable:r||void 0}):new x(t,{cause:e})}const J=[{type:`function`,name:`allow`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`allowForDecryption`,inputs:[{name:`handlesList`,type:`bytes32[]`,internalType:`bytes32[]`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`allowTransient`,inputs:[{name:`ciphertext`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`cleanTransientStorage`,inputs:[],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`delegateForUserDecryption`,inputs:[{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`},{name:`expirationDate`,type:`uint64`,internalType:`uint64`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`getUserDecryptionDelegationExpirationDate`,inputs:[{name:`delegator`,type:`address`,internalType:`address`},{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint64`,internalType:`uint64`}],stateMutability:`view`},{type:`function`,name:`isAccountDenied`,inputs:[{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isAllowed`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isAllowedForDecryption`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isHandleDelegatedForUserDecryption`,inputs:[{name:`delegator`,type:`address`,internalType:`address`},{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`},{name:`handle`,type:`bytes32`,internalType:`bytes32`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`multicall`,inputs:[{name:`data`,type:`bytes[]`,internalType:`bytes[]`}],outputs:[{name:`results`,type:`bytes[]`,internalType:`bytes[]`}],stateMutability:`payable`},{type:`function`,name:`persistAllowed`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`revokeDelegationForUserDecryption`,inputs:[{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`}];function Y(e,t,n,r){return{address:e,abi:J,functionName:`delegateForUserDecryption`,args:[t,n,r]}}function X(e,t,n){return{address:e,abi:J,functionName:`revokeDelegationForUserDecryption`,args:[t,n]}}function ln(e,t,n,r){return{address:e,abi:J,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function un(e,t,n,r,i){return{address:e,abi:J,functionName:`isHandleDelegatedForUserDecryption`,args:[t,n,r,i]}}const Z=2n**64n-1n,Q=`0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF`;function dn(e){return Nt(e.signer,e.provider,e)}var fn=class{#e;#t;#n;#r;#i;#a;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger,this.#a=e.emitEvent}#o(e){return w(this.#r,e)}#s(e,t){throw this.#a({type:C.PermitError,operation:e,error:t instanceof Error?t:Error(String(t))}),t}async grantPermit(e){if(e.length===0)return;let t;try{t=this.#o(`grantPermit`),await Qe(`grantPermit`,this.#e,this.#t)}catch(e){this.#s(`grantPermit`,e)}await t.grantPermit(e)}async grantDelegationPermit(e,t){if(t.length===0)return;let n;try{n=this.#o(`grantDelegationPermit`),await Qe(`grantDelegationPermit`,this.#e,this.#t)}catch(e){this.#s(`grantDelegationPermit`,e)}await n.grantPermit(t,e)}async hasPermit(e){return this.#r?this.#r.hasPermit(e):!1}async hasDelegationPermit(e,t){return this.#r?this.#r.hasPermit(t,e):!1}async warmTransportKeyPair(){let e=this.#r;if(!e)return;let t=this.#e?.walletAccount.getSnapshot();t&&await e.warmTransportKeyPair(t.address)}registerPermit(e,t){return this.batchRegisterPermits([{prepared:e,signature:t}])}async batchRegisterPermits(e){let t;try{t=this.#o(`registerPermit`)}catch(e){this.#s(`registerPermit`,e)}await t.batchRegisterPermits(e),await Promise.all([...new Set(e.map(e=>e.prepared.signerAddress))].map(e=>this.#c(e)))}async revokePermits(e){let t=this.#o(`revokePermits`),n=I((await A(`revokePermits`,this.#e,this.#t)).address);try{await t.revokePermits(e)}finally{await this.#c(n)}}async clear(){let e=this.#o(`clear`),t=I((await A(`clear`,this.#e,this.#t)).address);try{await e.clearCredentials()}finally{await this.#c(t)}}async#c(e){await D(`clear decrypt cache`,()=>this.#n.clearForRequester(e),this.#i)}async revokeTransportKeyPair(e){await this.#o(`revokeTransportKeyPair`).revokeTransportKeyPair(e)}async warmTransportKeyPairScope(e){await this.#o(`warmTransportKeyPairScope`).warmTransportKeyPairScope(e)}},pn=class{#e;#t;#n;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.delegationService}#r(e){return w(this.#e,e)}async delegateDecryption({contractAddress:e,delegateAddress:t,expirationDate:n}){let r=this.#r(`delegateDecryption`),i=await A(`delegateDecryption`,this.#e,this.#t);return this.#n.delegateDecryption(r,{contractAddress:e,delegateAddress:t,delegatorAddress:i.address,expirationDate:n})}async revokeDelegation({contractAddress:e,delegateAddress:t}){let n=this.#r(`revokeDelegation`),r=await A(`revokeDelegation`,this.#e,this.#t);return this.#n.revokeDelegation(n,{contractAddress:e,delegateAddress:t,delegatorAddress:r.address})}async isActive(e){return this.#n.isDelegated(e)}async getExpiry(e){return this.#n.getDelegationExpiry(e)}async getStatus(e){return this.#n.getStatus(e)}},mn=class{#e;#t;#n;#r;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.router,this.#r=e.decryptionService}#i(e){return w(this.#r,e)}async decryptValues(e,t){let n=this.#i(`decryptValues`),r=await A(`decryptValues`,this.#e,this.#t);return n.decryptValues(e,r.address,M(t,`decrypt-values`))}async delegatedDecryptValues(e,t,n=t,r){let i=this.#i(`delegatedDecryptValues`),a=await A(`delegatedDecryptValues`,this.#e,this.#t);return i.delegatedDecryptValues(e,t,a.address,n,M(r,`delegated-decrypt-values`))}async decryptPublicValues(e,t){if(e.length===0)return{clearValues:{},decryptionProof:`0x`,abiEncodedClearValues:`0x`};let n=M(t,`decrypt-public-values`);try{let t=await this.#n.relayer.decryptPublicValuesWithSignatures({encryptedValues:e,options:n}),r={};return t.checkSignaturesArgs.handlesList.forEach((e,n)=>{ye(t.clearValues[n],`result.clearValues[${n}]`),r[e]=t.clearValues[n].value}),{clearValues:r,abiEncodedClearValues:t.checkSignaturesArgs.abiEncodedCleartexts,decryptionProof:t.checkSignaturesArgs.decryptionProof}}catch(e){throw q(e,`Public decryption failed`)}}async delegatedBatchDecryptValues({encryptedInputs:e,delegatorAddress:t,accountAddress:n=t,maxConcurrency:r,waitForPropagation:i,operation:a}){let o=this.#i(`delegatedBatchDecryptValues`),s=await A(`delegatedBatchDecryptValues`,this.#e,this.#t);return o.delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:s.address,accountAddress:n,maxConcurrency:r,waitForPropagation:i,operation:a??`delegated-batch-decrypt-values`})}},hn=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}prepare(e,t){return this.#e.prepare(e,t)}preparePermit(e){return this.#t.preparePermit(e)}batchPreparePermits(e){return this.#t.batchPreparePermits(e)}},gn=class{async get(e){return(await chrome.storage.session.get(e))[e]??null}async set(e,t){await chrome.storage.session.set({[e]:t})}async delete(e){await chrome.storage.session.remove(e)}};const _n=new gn,vn=L.union([L.bigint(),L.boolean(),P]),yn=L.array(L.string());var bn=class{#e;#t;#n=`zama:decrypt`;#r=`${this.#n}:keys`;#i=Promise.resolve();constructor(e,t){this.#e=e,this.#t=t}async get(e,t,n){try{let r=this.#c(e,t,n),i=await this.#e.get(r);if(i===null)return null;let a=vn.safeParse(i);return a.success?a.data:(await this.delete(e,t,n),null)}catch(e){return this.#t.warn(`CachingService.get failed`,{error:e}),null}}async set(e,t,n,r){try{let i=this.#c(e,t,n);await this.#e.set(i,r),this.#i=this.#i.then(()=>this.#u(i).catch(e=>{this.#t.warn(`CachingService index write failed`,{error:e})})),await this.#i}catch(e){this.#t.warn(`CachingService.set failed`,{error:e})}}async delete(e,t,n){let r=this.#c(e,t,n);this.#i=this.#i.then(()=>this.#a(r).catch(e=>{this.#t.warn(`CachingService.delete failed`,{error:e})})),await this.#i}async clearForRequester(e){this.#i=this.#i.then(()=>this.#o(e).catch(e=>{this.#t.warn(`CachingService.clearForRequester failed`,{error:e})})),await this.#i}async clearAll(){this.#i=this.#i.then(()=>this.#s().catch(e=>{this.#t.warn(`CachingService.clearAll failed`,{error:e})})),await this.#i}async#a(e){await this.#e.delete(e).catch(()=>{});let t=await this.#l(),n=t.filter(t=>t!==e);n.length!==t.length&&await this.#e.set(this.#r,n)}async#o(e){let t=I(e),n=`${this.#n}:${t}:`,r=await this.#l(),i=[],a=[];for(let e of r)e.startsWith(n)?i.push(e):a.push(e);await Promise.all(i.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.set(this.#r,a)}async#s(){let e=await this.#l();await Promise.all(e.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.delete(this.#r)}#c(e,t,n){return`${this.#n}:${I(e)}:${I(t)}:${n.toLowerCase()}`}async#l(){let e=await this.#e.get(this.#r);if(e===null)return[];let t=yn.safeParse(e);return t.success?t.data:(await this.#e.delete(this.#r).catch(()=>{}),[])}async#u(e){let t=await this.#l();t.includes(e)||(t.push(e),await this.#e.set(this.#r,t))}};function xn(e,t){let n=Sn(e,t);if(!n)throw new S(`No permit covers contract ${t} after allow()`);return{privateKey:e.keypair.privateKey,publicKey:e.keypair.publicKey,serializedPermit:n.serializedPermit}}function Sn(e,t){let n=Wt(t);return e.permissions.find(e=>e.contractAddresses.includes(n))}const Cn=e=>new Promise(t=>setTimeout(t,e));var wn=class{#e;#t;#n;#r;#i;constructor({cache:e,credentialService:t,delegationService:n,router:r,emitEvent:i}){this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#i=i}async decryptValues(e,t,n){let r=I(t);return this.#s(e,{requesterAddress:r,errorMessage:`Failed to decrypt encrypted values`},n)}async delegatedDecryptValues(e,t,n,r,i){let a=I(t),o=I(n),s={spent:!1};return this.#a(i?.waitForPropagation??!0,()=>this.#s(e,{requesterAddress:I(r),delegator:a,validate:e=>this.#m(e,{delegatorAddress:a,delegateAddress:o}),errorMessage:`Failed to decrypt delegated encrypted values`},{operation:i?.operation},s))}async#a(e,t){let n;for(let r=0;r<16;r++)try{return await t()}catch(t){if(n=t,!(r<15&&e&&t instanceof K))throw t;await Cn(2e3)}throw n}async delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:n,accountAddress:r,maxConcurrency:i=5,waitForPropagation:a=!0,operation:o}){let s=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:I(e.contractAddress)}));if(s.length===0)return{items:s};let c=I(r);try{let e=await this.delegatedDecryptValues(s.map(({encryptedValue:e,contractAddress:t})=>({encryptedValue:e,contractAddress:t})),t,n,c,{waitForPropagation:a,operation:o});for(let t of s)this.#d(t,e);return{items:s}}catch(e){if(We(e))throw e;if(s.length===1){let[n=this.#p()]=s;return n.error=this.#f(e,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:n.contractAddress,account:I(t)}),{items:s}}}let l=!1,u;if(await j(s.map(e=>async()=>{if(!l)try{let r=await this.delegatedDecryptValues([{encryptedValue:e.encryptedValue,contractAddress:e.contractAddress}],t,n,c,{waitForPropagation:!1,operation:o});this.#d(e,r)}catch(n){if(We(n)){l=!0,u??=n;return}e.error=this.#f(n,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:e.contractAddress,account:I(t)})}}),i),u!==void 0)throw u;return{items:s}}async#o(e,t,n,r){let i=xn(e,t),a;try{a=await this.#r.relayer.parseTransportKeyPair({publicKey:i.publicKey,privateKey:i.privateKey,tkmsVersion:e.keypair.tkmsVersion})}catch(e){throw e instanceof Error&&f(e.message)&&await this.#t.evictTransportKeyPair(),e}let o=await this.#r.relayer.parseSignedDecryptionPermit({transportKeyPair:a,serializedPermit:i.serializedPermit});return this.#r.relayer.decryptValues({transportKeyPair:a,signedPermit:o,encryptedValues:n,contractAddress:t,options:r})}async#s(t,n,r,i={spent:!1}){if(t.length===0)return{};let a=t.map(e=>({encryptedValue:e.encryptedValue,contractAddress:I(e.contractAddress)})),o={},s=[];for(let e of a)Ye(e.encryptedValue)?o[e.encryptedValue]=0n:s.push(e);if(s.length===0)return o;let c=Array.from(new Set(a.map(e=>e.contractAddress))),l=Array.from(new Set(s.map(e=>e.contractAddress)));if(n.validate)try{await n.validate(l)}catch(e){throw ee(e)?this.#u(e,`the delegation pre-check`):e}let u=[];for(let e of s){let t=await this.#e.get(n.requesterAddress,e.contractAddress,e.encryptedValue);t===null?u.push(e):o[e.encryptedValue]=t}if(u.length===0)return o;let d=await this.#t.grantPermit(c,n.delegator),f=new Map;for(let e of u){let t=f.get(e.contractAddress);t?t.push(e.encryptedValue):f.set(e.contractAddress,[e.encryptedValue])}let m=[];for(let[e,t]of f)for(let n of Ge(t))m.push({contractAddress:e,encryptedValues:n});let h=Date.now(),g=u.map(e=>e.encryptedValue);try{this.#i({type:C.DecryptStart,encryptedValues:g});try{await this.#c(n,d,m,o,r)}catch(e){if(!(e instanceof v)||i.spent)throw e;let t=d.permissions.map(e=>e.serializedPermit.signature);i.spent=!0;try{d=await this.#t.recoverPermits(c,n.delegator,t)}catch(e){throw e instanceof b?new v(`The permit's KMS context has been revoked on-chain and the automatic re-grant failed, so the decrypt cannot proceed. Establish a new permit for this scope and retry.`,{cause:e}):e}await this.#c(n,d,m.filter(({encryptedValues:e})=>e.some(e=>o[e]===void 0)),o,r)}let e={};for(let t of g){let n=o[t];n!==void 0&&(e[t]=n)}return this.#i({type:C.DecryptEnd,durationMs:Date.now()-h,encryptedValues:g,result:e}),o}catch(t){let r=t instanceof p&&t.cause instanceof Error?t.cause:t;throw this.#i({type:C.DecryptError,error:e(r),durationMs:Date.now()-h,encryptedValues:g}),q(t,n.errorMessage,{isDelegated:n.delegator!==void 0})}}async#c(e,t,n,r,i){let a=(await j(n.map(({contractAddress:n,encryptedValues:a})=>async()=>{try{await this.#l(e,t,n,a,r,i);return}catch(e){return e}}),5)).filter(e=>e!==void 0);if(a.length>0)throw a.find(e=>e instanceof v)??a[0]}async#l(e,t,n,r,i,a){let o;try{o=await this.#o(t,n,r,a)}catch(t){throw q(t,e.errorMessage,{isDelegated:e.delegator!==void 0,contractAddress:n,account:e.delegator??e.requesterAddress})}for(let t=0;t<r.length;t++){let a=r[t],s=o[t]?.value;a!==void 0&&s!==void 0&&(i[a]=s,await this.#e.set(e.requesterAddress,n,a,s))}let s=r.filter(e=>i[e]===void 0);if(s.length>0)throw new S(`${e.errorMessage}: relayer returned no clear value for ${s.length} of ${r.length} handle(s) on ${n}`,{cause:AggregateError(s.map(e=>new S(`No clear value for handle ${e} on ${n}`)),`${s.length} handle(s) missing a clear value on ${n}`)})}#u(e,t){return new k(`RPC provider rate-limited ${t}; retry with backoff.`,{cause:e,retryAfter:i(e)})}#d(e,t){let n=t[e.encryptedValue];if(n===void 0){e.error=new S(`Batch delegated decryption returned no value for encrypted value ${e.encryptedValue} on contract ${e.contractAddress}`);return}e.value=n}#f(e,t,n){return e instanceof p?e:q(e,t,n)}#p(){throw new S(`Batch delegated decryption invariant failed: missing item`)}async#m(e,{delegatorAddress:t,delegateAddress:n}){let r=await this.#n.findInactiveDelegations(e,t,n);if(r.size!==0)for(let e of r.values())throw e}};const $={AlreadyDelegatedOrRevokedInSameBlock:e=>new rn(`Only one delegate/revoke per (delegator, delegate, contract) per block. Wait for the next block before retrying.`,{cause:e}),SenderCannotBeContractAddress:e=>new an(`The contract address cannot be the caller address.`,{cause:e}),EnforcedPause:e=>new on(`The ACL contract is paused. Delegation operations are temporarily disabled.`,{cause:e}),SenderCannotBeDelegate:e=>new z(`Cannot delegate to yourself (delegate === msg.sender).`,{cause:e}),DelegateCannotBeContractAddress:e=>new U(`Delegate address cannot be the same as the contract address.`,{cause:e}),DelegateCannotBeWildcard:e=>new W(`Delegate address cannot be the wildcard address; it can only be used as the contract address.`,{cause:e}),ExpirationDateBeforeOneHour:e=>new G(`Expiration date must be at least 1 hour in the future.`,{cause:e}),ExpirationDateAlreadySetToSameValue:e=>new H(`The new expiration date is the same as the current one.`,{cause:e}),NotDelegatedYet:e=>new B(`Cannot revoke: no active delegation exists.`,{cause:e})};function Tn(e){return Object.hasOwn($,e)}function En(e,t){let n=ot(e);if(n&&Tn(n))return $[n](t);let r=e instanceof Error?e.message:String(e);for(let[e,n]of Object.entries($))if(r.includes(e))return n(t);return null}var Dn=class{#e;#t;#n;#r;constructor({provider:e,router:t,emitEvent:n=()=>{},logger:r}){this.#t=e,this.#e=t,this.#r=r,this.#n=n}async delegateDecryption(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r,expirationDate:i}){if(i&&i.getTime()<Date.now()+36e5)throw new G(`Expiration date must be at least 1 hour in the future`);let a=I(t),o=I(n),s=I(r);if(o===s)throw new z(`Cannot delegate to yourself (delegate === msg.sender).`);if(o===I(`0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF`))throw new W(`Delegate address cannot be the wildcard address; it can only be used as the contract address.`);if(o===a)throw new U(`Delegate address cannot be the same as the contract address (${a}).`);let c=this.#e.relayer.chain.aclContractAddress,l=i?BigInt(Math.floor(i.getTime()/1e3)):Z,u;try{u=await this.getDelegationExpiry({contractAddress:a,delegatorAddress:s,delegateAddress:o})}catch(e){this.#r.warn(`delegateDecryption: pre-flight expiry check failed`,{error:e}),u=-1n}if(u===l)throw new H(`The new expiration date (${l}) is the same as the current one. No on-chain change needed.`);return a!==I(`0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF`)&&await this.#i({contractAddress:a,delegatorAddress:s,delegateAddress:o}),this.#s({operation:`delegateDecryption`,signer:e,contractAddress:a,config:Y(c,o,a,l)})}async revokeDelegation(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r}){let i=I(t),a=I(n),o=I(r),s=this.#e.relayer.chain.aclContractAddress,c;try{c=await this.getDelegationExpiry({contractAddress:i,delegatorAddress:o,delegateAddress:a})}catch(e){this.#r.warn(`revokeDelegation: pre-flight expiry check failed`,{error:e}),c=1n}if(c===0n)throw new B(`No active delegation found for delegate ${a} on contract ${i}.`);return this.#s({operation:`revokeDelegation`,signer:e,contractAddress:i,config:X(s,a,i)})}async isDelegated(e){return(await this.getStatus(e)).isActive}async getStatus(e){let t=I(e.contractAddress)===Q,[n,r]=await Promise.all([this.getDelegationExpiry(e),t?Promise.resolve(0n):this.getDelegationExpiry({...e,contractAddress:Q})]),i=this.#a(n)||this.#a(r)?await this.#t.getBlockTimestamp():void 0,a=this.#o(n,i);if(a.isActive)return a;let o=this.#o(r,i);return o.isActive?o:n>=r?a:o}async#i(e){try{let{isActive:t}=await this.getStatus({...e,contractAddress:Q});t&&this.#r.warn(`delegateDecryption: ${e.delegateAddress} already holds an active wildcard delegation from ${e.delegatorAddress}; this grant for ${e.contractAddress} is redundant.`)}catch(e){this.#r.warn(`delegateDecryption: wildcard redundancy check failed`,{error:e})}}#a(e){return e!==0n&&e!==Z}#o(e,t){return e===0n?{isActive:!1,expiryTimestamp:e}:e===Z?{isActive:!0,expiryTimestamp:e}:{isActive:t!==void 0&&e>t,expiryTimestamp:e}}async getDelegationExpiry({contractAddress:e,delegatorAddress:t,delegateAddress:n}){let r=this.#e.relayer.chain.aclContractAddress;return this.#t.readContract(ln(r,I(t),I(n),I(e)))}async#s({operation:e,signer:t,contractAddress:n,config:r}){try{return await Ze({operation:e,signer:t,provider:this.#t,config:r,emit:e=>this.#n(e,n),logger:this.#r})}catch(e){throw this.#c(e),e}}#c(e){if(!(e instanceof xe))return;let t=En(e.cause??e,e);if(t)throw t}async findInactiveDelegations(e,t,n){let r=new Map;return await Promise.all(e.map(async e=>{try{await this.assertDelegationActive(e,t,n)}catch(t){if(t instanceof B||t instanceof V){let n=I(e);r.set(n,t);return}throw t}})),r}async assertDelegationActive(e,t,n){let r=I(e),i=I(t),a=I(n),{isActive:o,expiryTimestamp:s}=await this.getStatus({contractAddress:r,delegatorAddress:i,delegateAddress:a});if(!o)throw s===0n?new B(`No active delegation from ${i} to ${a} for ${r}`):new V(`Delegation from ${i} to ${a} for ${r} has expired`)}},On=class{#e;#t;constructor({router:e,emitEvent:t}){this.#e=e,this.#t=t}async encryptValues(t,n){let r=Date.now(),i=I(t.contractAddress);try{this.#t({type:C.EncryptStart},i);let e=await this.#e.relayer.encryptValues({...t,options:n});return this.#t({type:C.EncryptEnd,durationMs:Date.now()-r},i),e}catch(t){throw this.#t({type:C.EncryptError,error:e(t),durationMs:Date.now()-r},i),cn(t,`Encryption failed`)}}},kn=class{#e;#t;#n;#r;#i;#a;#o=new Set;#s;constructor(e){this.#e=e.signer,this.#t=e.router,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.clearCredentialsOnWalletChange,this.#a=e.logger,this.#e&&(this.#s=this.#e.walletAccount.subscribe(e=>{this.#c(e).catch(e=>{this.#a.warn(`wallet account handler failed`,{error:e})})}))}onWalletAccountChange(e){return this.#o.add(e),()=>{this.#o.delete(e)}}dispose(){this.#s?.(),this.#s=void 0,this.#o.clear()}async#c(e){let t=e.previous,n=e.next,r=n?.chainId;r!==void 0&&await D(`switch relayer chain`,()=>this.#t.switchChain(r),this.#a),this.#i&&await this.#l(t,n),await Promise.all(Array.from(this.#o,t=>D(`wallet account listener`,()=>t(e),this.#a)))}async#l(e,t){let n=this.#r;n&&await D(`credential wallet account change`,()=>n.handleWalletAccountChange(e,t),this.#a),e&&await D(`clear decrypt cache`,()=>this.#n.clearForRequester(e.address),this.#a)}};const An=L.object({kind:L.literal(`ConfidentialTransfer`),from:P,token:P,to:P,amount:L.bigint()}),jn=L.object({kind:L.literal(`ConfidentialTransferFrom`),from:P,token:P,owner:P,to:P,amount:L.bigint()}),Mn=L.object({kind:L.literal(`SetOperator`),from:P,token:P,operator:P,until:Ut}),Nn=L.object({kind:L.literal(`Unwrap`),from:P,token:P,to:P,amount:L.bigint()}),Pn=L.object({kind:L.literal(`UnwrapAll`),from:P,token:P,to:P}),Fn=L.object({kind:L.literal(`FinalizeUnwrap`),from:P,wrapper:P,unwrapRequestIdOrAmount:Ht}),In=L.object({kind:L.literal(`ApproveUnderlying`),from:P,underlying:P,spender:P,amount:L.bigint()}),Ln=L.object({kind:L.literal(`Wrap`),from:P,wrapper:P,to:P,amount:L.bigint()}),Rn=Ht.check(L.refine(e=>e===`0x`||tn(e)===20,`TransferAndCall.recipientData must be "0x" (self-shield to the sender) or a raw 20-byte address, not a 32-byte ABI-encoded value the wrapper would truncate to a garbage address`)),zn=L.object({kind:L.literal(`TransferAndCall`),from:P,underlying:P,wrapper:P,amount:L.bigint(),recipientData:L.optional(Rn)}),Bn=L.object({kind:L.literal(`DelegateDecryption`),from:P,contractAddress:P,delegateAddress:P,expirationDate:L.optional(L.date())}),Vn=L.object({kind:L.literal(`RevokeDelegation`),from:P,contractAddress:P,delegateAddress:P});L.discriminatedUnion(`kind`,[An,jn,Mn,Nn,Pn,Fn,In,Ln,zn,Bn,Vn]);const Hn=L.strictObject({maxFeePerGas:L.bigint(),maxPriorityFeePerGas:L.bigint()}),Un=L.object({nonce:L.optional(L.int().check(L.nonnegative())),gasLimit:L.optional(L.bigint()),fees:L.optional(Hn)}),Wn=L.object({address:P,abi:L.array(L.unknown()),functionName:L.string(),args:L.array(L.unknown()),value:L.optional(L.bigint()),gas:L.optional(L.bigint())}),Gn=L.extend(Un,{from:P,calldata:Wn});var Kn=class{#e;#t;#n;constructor(e){this.#e=e.provider,this.#t=e.router,this.#n=e.encryption}async prepare(e,t){t&&=F(Un,t);let n=await this.#e.getChainId(),r=this.#t.chain.id;if(n!==r)throw new h(`Offline.prepare: provider is on chain ${n} but the SDK is configured for chain ${r}. The prepared transaction's contract addresses and encrypted inputs are bound to chain ${r} — point the provider at the same chain.`);let i=F(Gn,{calldata:await this.#r(e),from:e.from,nonce:t?.nonce,gasLimit:t?.gasLimit,fees:t?.fees}),a=await this.#e.prepareTransaction(i);return{kind:e.kind,unsignedTx:a,from:i.from}}async#r(e){switch(e.kind){case`ConfidentialTransfer`:return this.#i(e);case`ConfidentialTransferFrom`:return this.#a(e);case`SetOperator`:return this.#o(e);case`Unwrap`:return this.#s(e);case`UnwrapAll`:return this.#c(e);case`FinalizeUnwrap`:return this.#l(e);case`ApproveUnderlying`:return this.#u(e);case`Wrap`:return this.#d(e);case`TransferAndCall`:return this.#f(e);case`DelegateDecryption`:return this.#p(e);case`RevokeDelegation`:return this.#m(e);default:throw new h(`OfflineService.prepare: unsupported transaction kind '${e.kind}'.`)}}async#i(e){e=F(An,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from},{operation:`offline-confidential-transfer`}),r=t[0];if(!r)throw new x(`Encryption returned no handles for ConfidentialTransfer`);return ve(e.token,e.to,r,n)}async#a(e){e=F(jn,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from},{operation:`offline-confidential-transfer-from`}),r=t[0];if(!r)throw new x(`Encryption returned no handles for ConfidentialTransferFrom`);return le(e.token,e.owner,e.to,r,n)}#o(e){return e=F(Mn,e),E(e.token,e.operator,e.until)}async#s(e){e=F(Nn,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from},{operation:`offline-unwrap`}),r=t[0];if(!r)throw new x(`Encryption returned no handles for Unwrap`);return ge(e.token,e.from,e.to,r,n)}async#c(e){e=F(Pn,e);let t=await this.#e.readContract(_e(e.token,e.from));return ue(e.token,e.from,e.to,t)}async#l(e){e=F(Fn,e);let t=await this.#t.relayer.decryptPublicValuesWithSignatures({encryptedValues:[e.unwrapRequestIdOrAmount],options:{operation:`offline-finalize-unwrap`}}).catch(e=>{throw q(e,`Public decryption failed during FinalizeUnwrap`)}),n=t.clearValues[0]?.value;return Ue(n,`FinalizeUnwrap: decryptPublicValuesWithSignatures(handle).clearValue`),he(e.wrapper,e.unwrapRequestIdOrAmount,n,t.checkSignaturesArgs.decryptionProof)}#u(e){return e=F(In,e),O(e.underlying,e.spender,e.amount)}#d(e){return e=F(Ln,e),T(e.wrapper,e.to,e.amount)}#f(e){return e=F(zn,e),rt(e.underlying,e.wrapper,e.amount,e.recipientData)}#p(e){if(e=F(Bn,e),e.expirationDate&&e.expirationDate.getTime()<Date.now()+36e5)throw new G(`Expiration date must be at least 1 hour in the future`);if(e.delegateAddress===e.from)throw new z(`Cannot delegate to yourself (delegate === msg.sender).`);if(e.delegateAddress===e.contractAddress)throw new U(`Delegate address cannot be the same as the contract address (${e.contractAddress}).`);let t=e.expirationDate?BigInt(Math.floor(e.expirationDate.getTime()/1e3)):Z;return Y(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress,t)}#m(e){return e=F(Vn,e),X(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress)}};function qn(e){if(!(!Object.hasOwn(e,`transportKeyPairDerivationSecret`)||e.transportKeyPairDerivationSecret!==void 0))throw new h(`transportKeyPairDerivationSecret was passed as undefined, which usually means the environment variable it reads is unset (e.g. process.env.ZAMA_DERIVATION_SECRET). Supply the secret, or omit the option entirely to persist transport key pairs in cleartext on purpose.`)}function Jn(e){if(e===void 0)return;let{importScripts:t}=globalThis;if(!(typeof window>`u`&&typeof document>`u`&&typeof t!=`function`))throw new h(`transportKeyPairDerivationSecret is supported in headless environments only (CLI tools, servers, agents). Remove the option: an environment with a platform keystore, or one that ships a bundle, must delegate at-rest security of the transport key pair to the storage backend.`)}function Yn(e){if(e===void 0)return;let t=F(Pt,e);return new Vt(typeof t==`string`?t:new Uint8Array(t))}var Xn=class{#e;provider;signer;storage;registry;permits;delegations;decryption;offline;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;constructor(e,t={}){qn(t),Jn(t.transportKeyPairDerivationSecret);let n=Yn(t.transportKeyPairDerivationSecret);this.#e=e.router,this.provider=e.provider,this.signer=e.signer,this.storage=e.storage,this.#r=e.onEvent??function(){},this.#i=e.logger,this.#a=new bn(e.storage,this.#i),this.#u=new Dn({provider:this.provider,router:e.router,emitEvent:this.emitEvent.bind(this),logger:this.#i});let r={};for(let t of e.chains)t.registryAddress&&(r[t.id]=t.registryAddress);this.registry=new N({provider:this.provider,registryAddresses:r,registryTTL:e.registryTTL}),this.#n=r,this.#t=e.registryTTL,this.#l=new zt({router:e.router,signer:e.signer,transportKeyPairTTL:e.transportKeyPairTTL,permitTTL:e.permitTTL,scope:e.transportKeyPairScope,derivationSecret:n,storage:this.storage,permitStorage:e.permitStorage,logger:this.#i,emitEvent:this.emitEvent.bind(this)}),e.signer&&(this.#c=new wn({cache:this.#a,credentialService:this.#l,delegationService:this.#u,router:e.router,emitEvent:this.emitEvent.bind(this)})),this.#s=new On({router:e.router,emitEvent:this.emitEvent.bind(this)}),this.#o=new kn({signer:e.signer,router:e.router,cachingService:this.#a,credentialService:this.#l,clearCredentialsOnWalletChange:e.clearCredentialsOnWalletChange,logger:this.#i}),this.#d=new Kn({provider:this.provider,router:e.router,encryption:this.#s,emitEvent:(e,t)=>this.emitEvent(e,t)}),this.permits=new fn({signer:this.signer,provider:this.provider,cachingService:this.#a,credentialService:this.#l,logger:this.#i,emitEvent:this.emitEvent.bind(this)}),this.delegations=new pn({signer:this.signer,provider:this.provider,delegationService:this.#u}),this.decryption=new mn({signer:this.signer,provider:this.provider,router:e.router,decryptionService:this.#c}),this.offline=new hn(this.#d,this.#l)}onWalletAccountChange(e){return this.#o.onWalletAccountChange(e)}get logger(){return this.#i}get relayer(){return this.#e.relayer}emitEvent(e,t){try{this.#r({...e,tokenAddress:t,timestamp:Date.now()})}catch(t){this.#i.warn(`${e.type} event listener silently failed`,{error:t})}}createWrappersRegistry(e){return new N({provider:this.provider,registryAddresses:{...this.#n,...e},registryTTL:this.#t})}async encrypt(e,t){return this.#s.encryptValues(e,M(t,`encrypt`))}createToken(e){return new tt(this,e)}createWrappedToken(e){return new Ct(this,e)}dispose(){this.#o.dispose(),this.#e.dispose()}terminate(){this.dispose(),this.signer?.dispose?.()}[Symbol.dispose](){this.terminate()}};export{vt as ACL_TOPICS,on as AclPausedError,xt as AclTopics,nt as BalanceCheckUnavailableError,Bt as BaseSigner,Je as ChainMismatchError,gn as ChromeSessionStorage,h as ConfigurationError,mn as Decryption,S as DecryptionFailedError,kt as DefaultRegistryAddresses,an as DelegationContractIsSelfError,rn as DelegationCooldownError,W as DelegationDelegateCannotBeWildcardError,U as DelegationDelegateEqualsContractError,G as DelegationExpirationTooSoonError,V as DelegationExpiredError,H as DelegationExpiryUnchangedError,B as DelegationNotFoundError,K as DelegationNotPropagatedError,z as DelegationSelfNotAllowedError,pn as Delegations,Te as ERC1363_INTERFACE_ID,Ke as ERC20ReadFailedError,Me as ERC7984_INTERFACE_ID,Be as ERC7984_WRAPPER_INTERFACE_ID,oe as EncryptOffloadUnavailableError,x as EncryptionFailedError,Lt as IndexedDBStorage,qe as InsufficientAllowanceError,$e as InsufficientConfidentialBalanceError,Xe as InsufficientERC20BalanceError,_ as InvalidTransportKeyPairError,g as KeyWrappingError,Z as MAX_UINT64,jt as MemoryStorage,It as MutableWalletAccountStore,y as NoCiphertextError,R as NotEntitledError,hn as Offline,fn as Permits,ie as PreparedPermitChainMismatchError,te as PreparedPermitExpiredError,u as RelayerRequestFailedError,v as RevokedKmsContextError,k as RpcRateLimitError,be as SignerNotConfiguredError,de as SignerRequiredError,b as SigningFailedError,re as SigningRejectedError,ht as TOKEN_TOPICS,tt as Token,lt as Topics,xe as TransactionRevertedError,ae as TransportKeyPairChangedError,ne as TransportKeyPairExpiredError,Et as UnlistedConfidentialTokenError,it as UnshieldAlreadyFinalizedError,st as VaultBatcherPausedError,at as VaultGroupJoinUnconfirmedError,Q as WILDCARD_CONTRACT,pe as WalletAccountNotReadyError,Ie as WalletNotConnectedError,Ct as WrappedToken,N as WrappersRegistry,et as ZERO_ENCRYPTED_VALUE,p as ZamaError,c as ZamaErrorCode,Xn as ZamaSDK,C as ZamaSDKEvents,Oe as allowanceContract,$t as anvil,O as approveContract,Se as balanceOfContract,Yt as bscTestnet,Zt as chains,_n as chromeSessionStorage,Ot as cleartext,_e as confidentialBalanceOfContract,ce as confidentialTotalSupplyContract,ve as confidentialTransferContract,le as confidentialTransferFromContract,dn as createConfig,Rt as createWalletAccountStore,Ve as decimalsContract,yt as decodeAclEvent,St as decodeAclEvents,ut as decodeConfidentialTransfer,gt as decodeDelegatedForUserDecryption,wt as decodeOnChainEvent,dt as decodeOnChainEvents,ft as decodeRevokedDelegationForUserDecryption,bt as decodeUnwrapFinalized,_t as decodeUnwrapRequested,mt as decodeWrap,Y as delegateForUserDecryptionContract,he as finalizeUnwrapContract,pt as findDelegatedForUserDecryption,ct as findRevokedDelegationForUserDecryption,Tt as findUnwrapRequested,Dt as findWrap,ze as getConfidentialTokenAddressContract,ln as getDelegationExpiryContract,Pe as getTokenAddressContract,Le as getTokenPairContract,ke as getTokenPairsContract,Ce as getTokenPairsLengthContract,Fe as getTokenPairsSliceContract,qt as hardhat,Gt as hoodi,Ft as indexedDBStorage,je as inferredTotalSupplyContract,Ee as isConfidentialTokenContract,Re as isConfidentialTokenValidContract,De as isConfidentialWrapperContract,Ye as isEncryptedValueZero,un as isHandleDelegatedContract,se as isOperatorContract,n as isRetryable,Xt as mainnet,nn as matchZamaError,Mt as memoryStorage,we as nameContract,At as parsePreparedPermit,Qt as polygon,Kt as polygonAmoy,Ae as rateContract,d as retryAfterSeconds,X as revokeDelegationContract,Jt as sepolia,E as setOperatorContract,Ne as supportsInterfaceContract,He as symbolContract,rt as transferAndCallContract,me as underlyingContract,ge as unwrapContract,ue as unwrapFromBalanceContract,fe as unwrapRequesterContract,T as wrapContract,en as zenithTrexTestnet};
|
|
1
|
+
import{S as e,_ as t,a as n,b as r,c as i,d as a,g as o,h as s,i as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,v as ee}from"./relayer-ov8b_HOu.js";import{a as g,c as te,d as ne,i as _,l as v,n as re,o as y,s as ie,t as b,u as ae}from"./signing-CneT-WIV.js";import{n as oe,r as x,t as S}from"./encryption-ieCO6J5r.js";import{A as se,C as ce,D as le,F as ue,G as de,H as C,I as fe,J as w,K as pe,L as T,M as E,N as me,O as he,P as ge,R as D,S as _e,T as ve,V as ye,W as be,Y as xe,_ as Se,a as Ce,b as we,c as Te,d as Ee,f as De,g as O,h as Oe,i as ke,j as Ae,k as je,l as Me,m as Ne,n as Pe,o as Fe,q as Ie,r as Le,s as Re,t as ze,u as Be,v as Ve,x as He,z as Ue}from"./wrappers-registry-DnYVQ02R.js";import{n as We,r as k}from"./fatal-batch-CI1pes1q.js";import{a as A,c as Ge,d as Ke,f as qe,h as Je,l as Ye,m as Xe,n as Ze,o as Qe,p as $e,r as j,s as et,t as tt,u as nt}from"./token-DlsiZmg5.js";import{C as rt,D as it,E as at,O as ot,T as st,_ as ct,a as lt,c as ut,d as dt,f as ft,g as pt,h as mt,i as ht,l as gt,m as _t,n as vt,o as yt,p as bt,r as xt,s as St,t as Ct,u as wt,v as Tt,w as Et,y as Dt}from"./wrapped-token-C8eKid8W.js";import{r as M}from"./telemetry-D9Mf59ts.js";import{t as Ot}from"./cleartext-RqXnz7I6.js";import{a as kt,c as At,d as jt,f as Mt,i as Nt,l as Pt,m as Ft,n as It,o as N,p as Lt,r as Rt,s as zt,t as Bt,u as Vt}from"./base-signer-6YPpqhw9.js";import{n as P,r as Ht,s as Ut,t as Wt}from"./primitives-Cym-3HKa.js";import{t as F}from"./validation-ChQwNxaY.js";import{a as Gt,c as Kt,i as qt,l as Jt,n as Yt,o as Xt,r as Zt,s as Qt,t as $t,u as en}from"./chains-CF-Hzs9R.js";import{getAddress as I,size as tn}from"viem";import{z as L}from"zod/mini";function nn(e,t){if(e instanceof p){let n=t[e.code];if(n)return n(e)}return t._?.(e)}var R=class extends p{encryptedValue;contractAddress;account;constructor(e,t){super(c.NotEntitled,`Account ${e.account} is not entitled to decrypt encrypted value ${e.encryptedValue} on contract ${e.contractAddress}. This is not a transient failure — the account needs an on-chain ACL grant before it can decrypt this encrypted value.`,t),this.name=`NotEntitledError`,this.encryptedValue=e.encryptedValue,this.contractAddress=e.contractAddress,this.account=e.account}},z=class extends p{constructor(e,t){super(c.DelegationSelfNotAllowed,e,t),this.name=`DelegationSelfNotAllowedError`}},rn=class extends p{constructor(e,t){super(c.DelegationCooldown,e,t),this.name=`DelegationCooldownError`}},B=class extends p{constructor(e,t){super(c.DelegationNotFound,e,t),this.name=`DelegationNotFoundError`}},V=class extends p{constructor(e,t){super(c.DelegationExpired,e,t),this.name=`DelegationExpiredError`}},H=class extends p{constructor(e,t){super(c.DelegationExpiryUnchanged,e,t),this.name=`DelegationExpiryUnchangedError`}},U=class extends p{constructor(e,t){super(c.DelegationDelegateEqualsContract,e,t),this.name=`DelegationDelegateEqualsContractError`}},W=class extends p{constructor(e,t){super(c.DelegationDelegateCannotBeWildcard,e,t),this.name=`DelegationDelegateCannotBeWildcardError`}},an=class extends p{constructor(e,t){super(c.DelegationContractIsSelf,e,t),this.name=`DelegationContractIsSelfError`}},on=class extends p{constructor(e,t){super(c.AclPaused,e,t),this.name=`AclPausedError`}},G=class extends p{constructor(e,t){super(c.DelegationExpirationTooSoon,e,t),this.name=`DelegationExpirationTooSoonError`}},K=class extends p{constructor(e,t){super(c.DelegationNotPropagated,e,t),this.name=`DelegationNotPropagatedError`}};const sn=[S,y,u,K,re,b,R,k,_,v];function q(e,n,c={}){if(sn.some(t=>e instanceof t))return e;let d=e instanceof Error?e.message:n;if(e instanceof Error&&f(e.message))return new _(e.message,{cause:e});if(t(e))return new v(`The permit's KMS context has been revoked on-chain, so the permit is no longer usable. The SDK evicts the permit and re-grants automatically; if this error surfaced, the retry failed the same way. The on-chain validity check is cached for up to 15 minutes, so a just-revoked context can keep failing across that window. Retry after the window; the SDK re-runs the recovery on the next decrypt, no manual cleanup is needed.`,{cause:e});if(e instanceof Error&&l(e.message))return c.isDelegated?new K(`Delegated decryption was denied by the on-chain ACL check. This is most commonly caused by the delegation not having propagated yet, or by the RPC node serving a stale block. Propagation usually completes within ~10 blocks (a few seconds) and the SDK retries across that window; seeing this means it did not sync in time. Retry shortly (and prefer a fresh, low-lag RPC endpoint). If it persists, the delegator may genuinely lack the on-chain ACL grant.`,{cause:e}):new R({encryptedValue:r(e.message)??``,contractAddress:c.contractAddress??``,account:c.account??``},{cause:e});if(a(e))return new k(d,{cause:e,retryAfter:i(e)});let p=m(e);return p===void 0&&ee(e)?new k(d,{cause:e,retryAfter:i(e)}):p===400?new y(e instanceof Error?e.message:`No ciphertext for this account`,{cause:e}):c.isDelegated&&p===500?new K(`Delegated decryption failed with a server error. This is most commonly caused by the delegation not having propagated to the gateway yet. Cross-chain sync usually completes within ~10 blocks (a few seconds) and the SDK retries across that window; seeing this means it did not sync in time — retry shortly. If the error persists, the gateway or relayer may be experiencing an unrelated issue.`,{cause:e}):s(e)||p!==void 0?new u(d,p,{cause:e,retryAfter:i(e),retryable:o(e)||void 0}):new S(n,{cause:e})}function cn(e,t){if(e instanceof p)return e;let n=m(e),r=o(e);return n!==void 0||s(e)?new u(e instanceof Error?e.message:t,n,{cause:e,retryAfter:i(e),retryable:r||void 0}):new x(t,{cause:e})}const J=[{type:`function`,name:`allow`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`allowForDecryption`,inputs:[{name:`handlesList`,type:`bytes32[]`,internalType:`bytes32[]`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`allowTransient`,inputs:[{name:`ciphertext`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`cleanTransientStorage`,inputs:[],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`delegateForUserDecryption`,inputs:[{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`},{name:`expirationDate`,type:`uint64`,internalType:`uint64`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`getUserDecryptionDelegationExpirationDate`,inputs:[{name:`delegator`,type:`address`,internalType:`address`},{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint64`,internalType:`uint64`}],stateMutability:`view`},{type:`function`,name:`isAccountDenied`,inputs:[{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isAllowed`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isAllowedForDecryption`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isHandleDelegatedForUserDecryption`,inputs:[{name:`delegator`,type:`address`,internalType:`address`},{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`},{name:`handle`,type:`bytes32`,internalType:`bytes32`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`multicall`,inputs:[{name:`data`,type:`bytes[]`,internalType:`bytes[]`}],outputs:[{name:`results`,type:`bytes[]`,internalType:`bytes[]`}],stateMutability:`payable`},{type:`function`,name:`persistAllowed`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`revokeDelegationForUserDecryption`,inputs:[{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`}];function Y(e,t,n,r){return{address:e,abi:J,functionName:`delegateForUserDecryption`,args:[t,n,r]}}function X(e,t,n){return{address:e,abi:J,functionName:`revokeDelegationForUserDecryption`,args:[t,n]}}function ln(e,t,n,r){return{address:e,abi:J,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function un(e,t,n,r,i){return{address:e,abi:J,functionName:`isHandleDelegatedForUserDecryption`,args:[t,n,r,i]}}const Z=2n**64n-1n,Q=`0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF`;function dn(e){return Nt(e.signer,e.provider,e)}var fn=class{#e;#t;#n;#r;#i;#a;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger,this.#a=e.emitEvent}#o(e){return w(this.#r,e)}#s(e,t){throw this.#a({type:C.PermitError,operation:e,error:t instanceof Error?t:Error(String(t))}),t}async grantPermit(e){if(e.length===0)return;let t;try{t=this.#o(`grantPermit`),await Qe(`grantPermit`,this.#e,this.#t)}catch(e){this.#s(`grantPermit`,e)}await t.grantPermit(e)}async grantDelegationPermit(e,t){if(t.length===0)return;let n;try{n=this.#o(`grantDelegationPermit`),await Qe(`grantDelegationPermit`,this.#e,this.#t)}catch(e){this.#s(`grantDelegationPermit`,e)}await n.grantPermit(t,e)}async hasPermit(e){return this.#r?this.#r.hasPermit(e):!1}async hasDelegationPermit(e,t){return this.#r?this.#r.hasPermit(t,e):!1}async warmTransportKeyPair(){let e=this.#r;if(!e)return;let t=this.#e?.walletAccount.getSnapshot();t&&await e.warmTransportKeyPair(t.address)}registerPermit(e,t){return this.batchRegisterPermits([{prepared:e,signature:t}])}async batchRegisterPermits(e){let t;try{t=this.#o(`registerPermit`)}catch(e){this.#s(`registerPermit`,e)}await t.batchRegisterPermits(e),await Promise.all([...new Set(e.map(e=>e.prepared.signerAddress))].map(e=>this.#c(e)))}async revokePermits(e){let t=this.#o(`revokePermits`),n=I((await A(`revokePermits`,this.#e,this.#t)).address);try{await t.revokePermits(e)}finally{await this.#c(n)}}async clear(){let e=this.#o(`clear`),t=I((await A(`clear`,this.#e,this.#t)).address);try{await e.clearCredentials()}finally{await this.#c(t)}}async#c(e){await D(`clear decrypt cache`,()=>this.#n.clearForRequester(e),this.#i)}async revokeTransportKeyPair(e){await this.#o(`revokeTransportKeyPair`).revokeTransportKeyPair(e)}async warmTransportKeyPairScope(e){await this.#o(`warmTransportKeyPairScope`).warmTransportKeyPairScope(e)}},pn=class{#e;#t;#n;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.delegationService}#r(e){return w(this.#e,e)}async delegateDecryption({contractAddress:e,delegateAddress:t,expirationDate:n}){let r=this.#r(`delegateDecryption`),i=await A(`delegateDecryption`,this.#e,this.#t);return this.#n.delegateDecryption(r,{contractAddress:e,delegateAddress:t,delegatorAddress:i.address,expirationDate:n})}async revokeDelegation({contractAddress:e,delegateAddress:t}){let n=this.#r(`revokeDelegation`),r=await A(`revokeDelegation`,this.#e,this.#t);return this.#n.revokeDelegation(n,{contractAddress:e,delegateAddress:t,delegatorAddress:r.address})}async isActive(e){return this.#n.isDelegated(e)}async getExpiry(e){return this.#n.getDelegationExpiry(e)}async getStatus(e){return this.#n.getStatus(e)}},mn=class{#e;#t;#n;#r;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.router,this.#r=e.decryptionService}#i(e){return w(this.#r,e)}async decryptValues(e,t){let n=this.#i(`decryptValues`),r=await A(`decryptValues`,this.#e,this.#t);return n.decryptValues(e,r.address,M(t,`decrypt-values`))}async delegatedDecryptValues(e,t,n=t,r){let i=this.#i(`delegatedDecryptValues`),a=await A(`delegatedDecryptValues`,this.#e,this.#t);return i.delegatedDecryptValues(e,t,a.address,n,M(r,`delegated-decrypt-values`))}async decryptPublicValues(e,t){if(e.length===0)return{clearValues:{},decryptionProof:`0x`,abiEncodedClearValues:`0x`};let n=M(t,`decrypt-public-values`);try{let t=await this.#n.relayer.decryptPublicValuesWithSignatures({encryptedValues:e,options:n}),r={};return t.checkSignaturesArgs.handlesList.forEach((e,n)=>{ye(t.clearValues[n],`result.clearValues[${n}]`),r[e]=t.clearValues[n].value}),{clearValues:r,abiEncodedClearValues:t.checkSignaturesArgs.abiEncodedCleartexts,decryptionProof:t.checkSignaturesArgs.decryptionProof}}catch(e){throw q(e,`Public decryption failed`)}}async delegatedBatchDecryptValues({encryptedInputs:e,delegatorAddress:t,accountAddress:n=t,maxConcurrency:r,waitForPropagation:i,operation:a}){let o=this.#i(`delegatedBatchDecryptValues`),s=await A(`delegatedBatchDecryptValues`,this.#e,this.#t);return o.delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:s.address,accountAddress:n,maxConcurrency:r,waitForPropagation:i,operation:a??`delegated-batch-decrypt-values`})}},hn=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}prepare(e,t){return this.#e.prepare(e,t)}preparePermit(e){return this.#t.preparePermit(e)}batchPreparePermits(e){return this.#t.batchPreparePermits(e)}},gn=class{async get(e){return(await chrome.storage.session.get(e))[e]??null}async set(e,t){await chrome.storage.session.set({[e]:t})}async delete(e){await chrome.storage.session.remove(e)}};const _n=new gn,vn=L.union([L.bigint(),L.boolean(),P]),yn=L.array(L.string());var bn=class{#e;#t;#n=`zama:decrypt`;#r=`${this.#n}:keys`;#i=Promise.resolve();constructor(e,t){this.#e=e,this.#t=t}async get(e,t,n){try{let r=this.#c(e,t,n),i=await this.#e.get(r);if(i===null)return null;let a=vn.safeParse(i);return a.success?a.data:(await this.delete(e,t,n),null)}catch(e){return this.#t.warn(`CachingService.get failed`,{error:e}),null}}async set(e,t,n,r){try{let i=this.#c(e,t,n);await this.#e.set(i,r),this.#i=this.#i.then(()=>this.#u(i).catch(e=>{this.#t.warn(`CachingService index write failed`,{error:e})})),await this.#i}catch(e){this.#t.warn(`CachingService.set failed`,{error:e})}}async delete(e,t,n){let r=this.#c(e,t,n);this.#i=this.#i.then(()=>this.#a(r).catch(e=>{this.#t.warn(`CachingService.delete failed`,{error:e})})),await this.#i}async clearForRequester(e){this.#i=this.#i.then(()=>this.#o(e).catch(e=>{this.#t.warn(`CachingService.clearForRequester failed`,{error:e})})),await this.#i}async clearAll(){this.#i=this.#i.then(()=>this.#s().catch(e=>{this.#t.warn(`CachingService.clearAll failed`,{error:e})})),await this.#i}async#a(e){await this.#e.delete(e).catch(()=>{});let t=await this.#l(),n=t.filter(t=>t!==e);n.length!==t.length&&await this.#e.set(this.#r,n)}async#o(e){let t=I(e),n=`${this.#n}:${t}:`,r=await this.#l(),i=[],a=[];for(let e of r)e.startsWith(n)?i.push(e):a.push(e);await Promise.all(i.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.set(this.#r,a)}async#s(){let e=await this.#l();await Promise.all(e.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.delete(this.#r)}#c(e,t,n){return`${this.#n}:${I(e)}:${I(t)}:${n.toLowerCase()}`}async#l(){let e=await this.#e.get(this.#r);if(e===null)return[];let t=yn.safeParse(e);return t.success?t.data:(await this.#e.delete(this.#r).catch(()=>{}),[])}async#u(e){let t=await this.#l();t.includes(e)||(t.push(e),await this.#e.set(this.#r,t))}};function xn(e,t){let n=Sn(e,t);if(!n)throw new S(`No permit covers contract ${t} after allow()`);return{privateKey:e.keypair.privateKey,publicKey:e.keypair.publicKey,serializedPermit:n.serializedPermit}}function Sn(e,t){let n=Wt(t);return e.permissions.find(e=>e.contractAddresses.includes(n))}const Cn=e=>new Promise(t=>setTimeout(t,e));var wn=class{#e;#t;#n;#r;#i;constructor({cache:e,credentialService:t,delegationService:n,router:r,emitEvent:i}){this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#i=i}async decryptValues(e,t,n){let r=I(t);return this.#s(e,{requesterAddress:r,errorMessage:`Failed to decrypt encrypted values`},n)}async delegatedDecryptValues(e,t,n,r,i){let a=I(t),o=I(n),s={spent:!1};return this.#a(i?.waitForPropagation??!0,()=>this.#s(e,{requesterAddress:I(r),delegator:a,validate:e=>this.#m(e,{delegatorAddress:a,delegateAddress:o}),errorMessage:`Failed to decrypt delegated encrypted values`},{operation:i?.operation},s))}async#a(e,t){let n;for(let r=0;r<16;r++)try{return await t()}catch(t){if(n=t,!(r<15&&e&&t instanceof K))throw t;await Cn(2e3)}throw n}async delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:n,accountAddress:r,maxConcurrency:i=5,waitForPropagation:a=!0,operation:o}){let s=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:I(e.contractAddress)}));if(s.length===0)return{items:s};let c=I(r);try{let e=await this.delegatedDecryptValues(s.map(({encryptedValue:e,contractAddress:t})=>({encryptedValue:e,contractAddress:t})),t,n,c,{waitForPropagation:a,operation:o});for(let t of s)this.#d(t,e);return{items:s}}catch(e){if(We(e))throw e;if(s.length===1){let[n=this.#p()]=s;return n.error=this.#f(e,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:n.contractAddress,account:I(t)}),{items:s}}}let l=!1,u;if(await j(s.map(e=>async()=>{if(!l)try{let r=await this.delegatedDecryptValues([{encryptedValue:e.encryptedValue,contractAddress:e.contractAddress}],t,n,c,{waitForPropagation:!1,operation:o});this.#d(e,r)}catch(n){if(We(n)){l=!0,u??=n;return}e.error=this.#f(n,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:e.contractAddress,account:I(t)})}}),i),u!==void 0)throw u;return{items:s}}async#o(e,t,n,r){let i=xn(e,t),a;try{a=await this.#r.relayer.parseTransportKeyPair({publicKey:i.publicKey,privateKey:i.privateKey,tkmsVersion:e.keypair.tkmsVersion})}catch(e){throw e instanceof Error&&f(e.message)&&await this.#t.evictTransportKeyPair(),e}let o=await this.#r.relayer.parseSignedDecryptionPermit({transportKeyPair:a,serializedPermit:i.serializedPermit});return this.#r.relayer.decryptValues({transportKeyPair:a,signedPermit:o,encryptedValues:n,contractAddress:t,options:r})}async#s(t,n,r,i={spent:!1}){if(t.length===0)return{};let a=t.map(e=>({encryptedValue:e.encryptedValue,contractAddress:I(e.contractAddress)})),o={},s=[];for(let e of a)Ye(e.encryptedValue)?o[e.encryptedValue]=0n:s.push(e);if(s.length===0)return o;let c=Array.from(new Set(a.map(e=>e.contractAddress))),l=Array.from(new Set(s.map(e=>e.contractAddress)));if(n.validate)try{await n.validate(l)}catch(e){throw ee(e)?this.#u(e,`the delegation pre-check`):e}let u=[];for(let e of s){let t=await this.#e.get(n.requesterAddress,e.contractAddress,e.encryptedValue);t===null?u.push(e):o[e.encryptedValue]=t}if(u.length===0)return o;let d=await this.#t.grantPermit(c,n.delegator),f=new Map;for(let e of u){let t=f.get(e.contractAddress);t?t.push(e.encryptedValue):f.set(e.contractAddress,[e.encryptedValue])}let m=[];for(let[e,t]of f)for(let n of Ge(t))m.push({contractAddress:e,encryptedValues:n});let h=Date.now(),g=u.map(e=>e.encryptedValue);try{this.#i({type:C.DecryptStart,encryptedValues:g});try{await this.#c(n,d,m,o,r)}catch(e){if(!(e instanceof v)||i.spent)throw e;let t=d.permissions.map(e=>e.serializedPermit.signature);i.spent=!0;try{d=await this.#t.recoverPermits(c,n.delegator,t)}catch(e){throw e instanceof b?new v(`The permit's KMS context has been revoked on-chain and the automatic re-grant failed, so the decrypt cannot proceed. Establish a new permit for this scope and retry.`,{cause:e}):e}await this.#c(n,d,m.filter(({encryptedValues:e})=>e.some(e=>o[e]===void 0)),o,r)}let e={};for(let t of g){let n=o[t];n!==void 0&&(e[t]=n)}return this.#i({type:C.DecryptEnd,durationMs:Date.now()-h,encryptedValues:g,result:e}),o}catch(t){let r=t instanceof p&&t.cause instanceof Error?t.cause:t;throw this.#i({type:C.DecryptError,error:e(r),durationMs:Date.now()-h,encryptedValues:g}),q(t,n.errorMessage,{isDelegated:n.delegator!==void 0})}}async#c(e,t,n,r,i){let a=(await j(n.map(({contractAddress:n,encryptedValues:a})=>async()=>{try{await this.#l(e,t,n,a,r,i);return}catch(e){return e}}),5)).filter(e=>e!==void 0);if(a.length>0)throw a.find(e=>e instanceof v)??a[0]}async#l(e,t,n,r,i,a){let o;try{o=await this.#o(t,n,r,a)}catch(t){throw q(t,e.errorMessage,{isDelegated:e.delegator!==void 0,contractAddress:n,account:e.delegator??e.requesterAddress})}for(let t=0;t<r.length;t++){let a=r[t],s=o[t]?.value;a!==void 0&&s!==void 0&&(i[a]=s,await this.#e.set(e.requesterAddress,n,a,s))}let s=r.filter(e=>i[e]===void 0);if(s.length>0)throw new S(`${e.errorMessage}: relayer returned no clear value for ${s.length} of ${r.length} handle(s) on ${n}`,{cause:AggregateError(s.map(e=>new S(`No clear value for handle ${e} on ${n}`)),`${s.length} handle(s) missing a clear value on ${n}`)})}#u(e,t){return new k(`RPC provider rate-limited ${t}; retry with backoff.`,{cause:e,retryAfter:i(e)})}#d(e,t){let n=t[e.encryptedValue];if(n===void 0){e.error=new S(`Batch delegated decryption returned no value for encrypted value ${e.encryptedValue} on contract ${e.contractAddress}`);return}e.value=n}#f(e,t,n){return e instanceof p?e:q(e,t,n)}#p(){throw new S(`Batch delegated decryption invariant failed: missing item`)}async#m(e,{delegatorAddress:t,delegateAddress:n}){let r=await this.#n.findInactiveDelegations(e,t,n);if(r.size!==0)for(let e of r.values())throw e}};const $={AlreadyDelegatedOrRevokedInSameBlock:e=>new rn(`Only one delegate/revoke per (delegator, delegate, contract) per block. Wait for the next block before retrying.`,{cause:e}),SenderCannotBeContractAddress:e=>new an(`The contract address cannot be the caller address.`,{cause:e}),EnforcedPause:e=>new on(`The ACL contract is paused. Delegation operations are temporarily disabled.`,{cause:e}),SenderCannotBeDelegate:e=>new z(`Cannot delegate to yourself (delegate === msg.sender).`,{cause:e}),DelegateCannotBeContractAddress:e=>new U(`Delegate address cannot be the same as the contract address.`,{cause:e}),DelegateCannotBeWildcard:e=>new W(`Delegate address cannot be the wildcard address; it can only be used as the contract address.`,{cause:e}),ExpirationDateBeforeOneHour:e=>new G(`Expiration date must be at least 1 hour in the future.`,{cause:e}),ExpirationDateAlreadySetToSameValue:e=>new H(`The new expiration date is the same as the current one.`,{cause:e}),NotDelegatedYet:e=>new B(`Cannot revoke: no active delegation exists.`,{cause:e})};function Tn(e){return Object.hasOwn($,e)}function En(e,t){let n=ot(e);if(n&&Tn(n))return $[n](t);let r=e instanceof Error?e.message:String(e);for(let[e,n]of Object.entries($))if(r.includes(e))return n(t);return null}var Dn=class{#e;#t;#n;#r;constructor({provider:e,router:t,emitEvent:n=()=>{},logger:r}){this.#t=e,this.#e=t,this.#r=r,this.#n=n}async delegateDecryption(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r,expirationDate:i}){if(i&&i.getTime()<Date.now()+36e5)throw new G(`Expiration date must be at least 1 hour in the future`);let a=I(t),o=I(n),s=I(r);if(o===s)throw new z(`Cannot delegate to yourself (delegate === msg.sender).`);if(o===I(`0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF`))throw new W(`Delegate address cannot be the wildcard address; it can only be used as the contract address.`);if(o===a)throw new U(`Delegate address cannot be the same as the contract address (${a}).`);let c=this.#e.relayer.chain.aclContractAddress,l=i?BigInt(Math.floor(i.getTime()/1e3)):Z,u;try{u=await this.getDelegationExpiry({contractAddress:a,delegatorAddress:s,delegateAddress:o})}catch(e){this.#r.warn(`delegateDecryption: pre-flight expiry check failed`,{error:e}),u=-1n}if(u===l)throw new H(`The new expiration date (${l}) is the same as the current one. No on-chain change needed.`);return a!==I(`0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF`)&&await this.#i({contractAddress:a,delegatorAddress:s,delegateAddress:o}),this.#s({operation:`delegateDecryption`,signer:e,contractAddress:a,config:Y(c,o,a,l)})}async revokeDelegation(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r}){let i=I(t),a=I(n),o=I(r),s=this.#e.relayer.chain.aclContractAddress,c;try{c=await this.getDelegationExpiry({contractAddress:i,delegatorAddress:o,delegateAddress:a})}catch(e){this.#r.warn(`revokeDelegation: pre-flight expiry check failed`,{error:e}),c=1n}if(c===0n)throw new B(`No active delegation found for delegate ${a} on contract ${i}.`);return this.#s({operation:`revokeDelegation`,signer:e,contractAddress:i,config:X(s,a,i)})}async isDelegated(e){return(await this.getStatus(e)).isActive}async getStatus(e){let t=I(e.contractAddress)===Q,[n,r]=await Promise.all([this.getDelegationExpiry(e),t?Promise.resolve(0n):this.getDelegationExpiry({...e,contractAddress:Q})]),i=this.#a(n)||this.#a(r)?await this.#t.getBlockTimestamp():void 0,a=this.#o(n,i);if(a.isActive)return a;let o=this.#o(r,i);return o.isActive?o:n>=r?a:o}async#i(e){try{let{isActive:t}=await this.getStatus({...e,contractAddress:Q});t&&this.#r.warn(`delegateDecryption: ${e.delegateAddress} already holds an active wildcard delegation from ${e.delegatorAddress}; this grant for ${e.contractAddress} is redundant.`)}catch(e){this.#r.warn(`delegateDecryption: wildcard redundancy check failed`,{error:e})}}#a(e){return e!==0n&&e!==Z}#o(e,t){return e===0n?{isActive:!1,expiryTimestamp:e}:e===Z?{isActive:!0,expiryTimestamp:e}:{isActive:t!==void 0&&e>t,expiryTimestamp:e}}async getDelegationExpiry({contractAddress:e,delegatorAddress:t,delegateAddress:n}){let r=this.#e.relayer.chain.aclContractAddress;return this.#t.readContract(ln(r,I(t),I(n),I(e)))}async#s({operation:e,signer:t,contractAddress:n,config:r}){try{return await Ze({operation:e,signer:t,provider:this.#t,config:r,emit:e=>this.#n(e,n),logger:this.#r})}catch(e){throw this.#c(e),e}}#c(e){if(!(e instanceof xe))return;let t=En(e.cause??e,e);if(t)throw t}async findInactiveDelegations(e,t,n){let r=new Map;return await Promise.all(e.map(async e=>{try{await this.assertDelegationActive(e,t,n)}catch(t){if(t instanceof B||t instanceof V){let n=I(e);r.set(n,t);return}throw t}})),r}async assertDelegationActive(e,t,n){let r=I(e),i=I(t),a=I(n),{isActive:o,expiryTimestamp:s}=await this.getStatus({contractAddress:r,delegatorAddress:i,delegateAddress:a});if(!o)throw s===0n?new B(`No active delegation from ${i} to ${a} for ${r}`):new V(`Delegation from ${i} to ${a} for ${r} has expired`)}},On=class{#e;#t;constructor({router:e,emitEvent:t}){this.#e=e,this.#t=t}async encryptValues(t,n){let r=Date.now(),i=I(t.contractAddress);try{this.#t({type:C.EncryptStart},i);let e=await this.#e.relayer.encryptValues({...t,options:n});return this.#t({type:C.EncryptEnd,durationMs:Date.now()-r},i),e}catch(t){throw this.#t({type:C.EncryptError,error:e(t),durationMs:Date.now()-r},i),cn(t,`Encryption failed`)}}},kn=class{#e;#t;#n;#r;#i;#a;#o=new Set;#s;constructor(e){this.#e=e.signer,this.#t=e.router,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.clearCredentialsOnWalletChange,this.#a=e.logger,this.#e&&(this.#s=this.#e.walletAccount.subscribe(e=>{this.#c(e).catch(e=>{this.#a.warn(`wallet account handler failed`,{error:e})})}))}onWalletAccountChange(e){return this.#o.add(e),()=>{this.#o.delete(e)}}dispose(){this.#s?.(),this.#s=void 0,this.#o.clear()}async#c(e){let t=e.previous,n=e.next,r=n?.chainId;r!==void 0&&await D(`switch relayer chain`,()=>this.#t.switchChain(r),this.#a),this.#i&&await this.#l(t,n),await Promise.all(Array.from(this.#o,t=>D(`wallet account listener`,()=>t(e),this.#a)))}async#l(e,t){let n=this.#r;n&&await D(`credential wallet account change`,()=>n.handleWalletAccountChange(e,t),this.#a),e&&await D(`clear decrypt cache`,()=>this.#n.clearForRequester(e.address),this.#a)}};const An=L.object({kind:L.literal(`ConfidentialTransfer`),from:P,token:P,to:P,amount:L.bigint()}),jn=L.object({kind:L.literal(`ConfidentialTransferFrom`),from:P,token:P,owner:P,to:P,amount:L.bigint()}),Mn=L.object({kind:L.literal(`SetOperator`),from:P,token:P,operator:P,until:Ut}),Nn=L.object({kind:L.literal(`Unwrap`),from:P,token:P,to:P,amount:L.bigint()}),Pn=L.object({kind:L.literal(`UnwrapAll`),from:P,token:P,to:P}),Fn=L.object({kind:L.literal(`FinalizeUnwrap`),from:P,wrapper:P,unwrapRequestIdOrAmount:Ht}),In=L.object({kind:L.literal(`ApproveUnderlying`),from:P,underlying:P,spender:P,amount:L.bigint()}),Ln=L.object({kind:L.literal(`Wrap`),from:P,wrapper:P,to:P,amount:L.bigint()}),Rn=Ht.check(L.refine(e=>e===`0x`||tn(e)===20,`TransferAndCall.recipientData must be "0x" (self-shield to the sender) or a raw 20-byte address, not a 32-byte ABI-encoded value the wrapper would truncate to a garbage address`)),zn=L.object({kind:L.literal(`TransferAndCall`),from:P,underlying:P,wrapper:P,amount:L.bigint(),recipientData:L.optional(Rn)}),Bn=L.object({kind:L.literal(`DelegateDecryption`),from:P,contractAddress:P,delegateAddress:P,expirationDate:L.optional(L.date())}),Vn=L.object({kind:L.literal(`RevokeDelegation`),from:P,contractAddress:P,delegateAddress:P});L.discriminatedUnion(`kind`,[An,jn,Mn,Nn,Pn,Fn,In,Ln,zn,Bn,Vn]);const Hn=L.strictObject({maxFeePerGas:L.bigint(),maxPriorityFeePerGas:L.bigint()}),Un=L.object({nonce:L.optional(L.int().check(L.nonnegative())),gasLimit:L.optional(L.bigint()),fees:L.optional(Hn)}),Wn=L.object({address:P,abi:L.array(L.unknown()),functionName:L.string(),args:L.array(L.unknown()),value:L.optional(L.bigint()),gas:L.optional(L.bigint())}),Gn=L.extend(Un,{from:P,calldata:Wn});var Kn=class{#e;#t;#n;constructor(e){this.#e=e.provider,this.#t=e.router,this.#n=e.encryption}async prepare(e,t){t&&=F(Un,t);let n=await this.#e.getChainId(),r=this.#t.chain.id;if(n!==r)throw new h(`Offline.prepare: provider is on chain ${n} but the SDK is configured for chain ${r}. The prepared transaction's contract addresses and encrypted inputs are bound to chain ${r} — point the provider at the same chain.`);let i=F(Gn,{calldata:await this.#r(e),from:e.from,nonce:t?.nonce,gasLimit:t?.gasLimit,fees:t?.fees}),a=await this.#e.prepareTransaction(i);return{kind:e.kind,unsignedTx:a,from:i.from}}async#r(e){switch(e.kind){case`ConfidentialTransfer`:return this.#i(e);case`ConfidentialTransferFrom`:return this.#a(e);case`SetOperator`:return this.#o(e);case`Unwrap`:return this.#s(e);case`UnwrapAll`:return this.#c(e);case`FinalizeUnwrap`:return this.#l(e);case`ApproveUnderlying`:return this.#u(e);case`Wrap`:return this.#d(e);case`TransferAndCall`:return this.#f(e);case`DelegateDecryption`:return this.#p(e);case`RevokeDelegation`:return this.#m(e);default:throw new h(`OfflineService.prepare: unsupported transaction kind '${e.kind}'.`)}}async#i(e){e=F(An,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from},{operation:`offline-confidential-transfer`}),r=t[0];if(!r)throw new x(`Encryption returned no handles for ConfidentialTransfer`);return ve(e.token,e.to,r,n)}async#a(e){e=F(jn,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from},{operation:`offline-confidential-transfer-from`}),r=t[0];if(!r)throw new x(`Encryption returned no handles for ConfidentialTransferFrom`);return le(e.token,e.owner,e.to,r,n)}#o(e){return e=F(Mn,e),E(e.token,e.operator,e.until)}async#s(e){e=F(Nn,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from},{operation:`offline-unwrap`}),r=t[0];if(!r)throw new x(`Encryption returned no handles for Unwrap`);return ge(e.token,e.from,e.to,r,n)}async#c(e){e=F(Pn,e);let t=await this.#e.readContract(_e(e.token,e.from));return ue(e.token,e.from,e.to,t)}async#l(e){e=F(Fn,e);let t=await this.#t.relayer.decryptPublicValuesWithSignatures({encryptedValues:[e.unwrapRequestIdOrAmount],options:{operation:`offline-finalize-unwrap`}}).catch(e=>{throw q(e,`Public decryption failed during FinalizeUnwrap`)}),n=t.clearValues[0]?.value;return Ue(n,`FinalizeUnwrap: decryptPublicValuesWithSignatures(handle).clearValue`),he(e.wrapper,e.unwrapRequestIdOrAmount,n,t.checkSignaturesArgs.decryptionProof)}#u(e){return e=F(In,e),O(e.underlying,e.spender,e.amount)}#d(e){return e=F(Ln,e),T(e.wrapper,e.to,e.amount)}#f(e){return e=F(zn,e),rt(e.underlying,e.wrapper,e.amount,e.recipientData)}#p(e){if(e=F(Bn,e),e.expirationDate&&e.expirationDate.getTime()<Date.now()+36e5)throw new G(`Expiration date must be at least 1 hour in the future`);if(e.delegateAddress===e.from)throw new z(`Cannot delegate to yourself (delegate === msg.sender).`);if(e.delegateAddress===e.contractAddress)throw new U(`Delegate address cannot be the same as the contract address (${e.contractAddress}).`);let t=e.expirationDate?BigInt(Math.floor(e.expirationDate.getTime()/1e3)):Z;return Y(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress,t)}#m(e){return e=F(Vn,e),X(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress)}};function qn(e){if(!(!Object.hasOwn(e,`transportKeyPairDerivationSecret`)||e.transportKeyPairDerivationSecret!==void 0))throw new h(`transportKeyPairDerivationSecret was passed as undefined, which usually means the environment variable it reads is unset (e.g. process.env.ZAMA_DERIVATION_SECRET). Supply the secret, or omit the option entirely to persist transport key pairs in cleartext on purpose.`)}function Jn(e){if(e===void 0)return;let{importScripts:t}=globalThis;if(!(typeof window>`u`&&typeof document>`u`&&typeof t!=`function`))throw new h(`transportKeyPairDerivationSecret is supported in headless environments only (CLI tools, servers, agents). Remove the option: an environment with a platform keystore, or one that ships a bundle, must delegate at-rest security of the transport key pair to the storage backend.`)}function Yn(e){if(e===void 0)return;let t=F(Pt,e);return new Vt(typeof t==`string`?t:new Uint8Array(t))}var Xn=class{#e;provider;signer;storage;registry;permits;delegations;decryption;offline;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;constructor(e,t={}){qn(t),Jn(t.transportKeyPairDerivationSecret);let n=Yn(t.transportKeyPairDerivationSecret);this.#e=e.router,this.provider=e.provider,this.signer=e.signer,this.storage=e.storage,this.#r=e.onEvent??function(){},this.#i=e.logger,this.#a=new bn(e.storage,this.#i),this.#u=new Dn({provider:this.provider,router:e.router,emitEvent:this.emitEvent.bind(this),logger:this.#i});let r={};for(let t of e.chains)t.registryAddress&&(r[t.id]=t.registryAddress);this.registry=new N({provider:this.provider,registryAddresses:r,registryTTL:e.registryTTL}),this.#n=r,this.#t=e.registryTTL,this.#l=new zt({router:e.router,signer:e.signer,transportKeyPairTTL:e.transportKeyPairTTL,permitTTL:e.permitTTL,scope:e.transportKeyPairScope,derivationSecret:n,storage:this.storage,permitStorage:e.permitStorage,logger:this.#i,emitEvent:this.emitEvent.bind(this)}),e.signer&&(this.#c=new wn({cache:this.#a,credentialService:this.#l,delegationService:this.#u,router:e.router,emitEvent:this.emitEvent.bind(this)})),this.#s=new On({router:e.router,emitEvent:this.emitEvent.bind(this)}),this.#o=new kn({signer:e.signer,router:e.router,cachingService:this.#a,credentialService:this.#l,clearCredentialsOnWalletChange:e.clearCredentialsOnWalletChange,logger:this.#i}),this.#d=new Kn({provider:this.provider,router:e.router,encryption:this.#s,emitEvent:(e,t)=>this.emitEvent(e,t)}),this.permits=new fn({signer:this.signer,provider:this.provider,cachingService:this.#a,credentialService:this.#l,logger:this.#i,emitEvent:this.emitEvent.bind(this)}),this.delegations=new pn({signer:this.signer,provider:this.provider,delegationService:this.#u}),this.decryption=new mn({signer:this.signer,provider:this.provider,router:e.router,decryptionService:this.#c}),this.offline=new hn(this.#d,this.#l)}onWalletAccountChange(e){return this.#o.onWalletAccountChange(e)}get logger(){return this.#i}get relayer(){return this.#e.relayer}emitEvent(e,t){try{this.#r({...e,tokenAddress:t,timestamp:Date.now()})}catch(t){this.#i.warn(`${e.type} event listener silently failed`,{error:t})}}createWrappersRegistry(e){return new N({provider:this.provider,registryAddresses:{...this.#n,...e},registryTTL:this.#t})}async encrypt(e,t){return this.#s.encryptValues(e,M(t,`encrypt`))}createToken(e){return new tt(this,e)}createWrappedToken(e){return new Ct(this,e)}dispose(){this.#o.dispose(),this.#e.dispose()}terminate(){this.dispose(),this.signer?.dispose?.()}[Symbol.dispose](){this.terminate()}};export{vt as ACL_TOPICS,on as AclPausedError,xt as AclTopics,nt as BalanceCheckUnavailableError,Bt as BaseSigner,Je as ChainMismatchError,gn as ChromeSessionStorage,h as ConfigurationError,mn as Decryption,S as DecryptionFailedError,kt as DefaultRegistryAddresses,an as DelegationContractIsSelfError,rn as DelegationCooldownError,W as DelegationDelegateCannotBeWildcardError,U as DelegationDelegateEqualsContractError,G as DelegationExpirationTooSoonError,V as DelegationExpiredError,H as DelegationExpiryUnchangedError,B as DelegationNotFoundError,K as DelegationNotPropagatedError,z as DelegationSelfNotAllowedError,pn as Delegations,Te as ERC1363_INTERFACE_ID,Ke as ERC20ReadFailedError,Me as ERC7984_INTERFACE_ID,Be as ERC7984_WRAPPER_INTERFACE_ID,oe as EncryptOffloadUnavailableError,x as EncryptionFailedError,Lt as IndexedDBStorage,qe as InsufficientAllowanceError,$e as InsufficientConfidentialBalanceError,Xe as InsufficientERC20BalanceError,_ as InvalidTransportKeyPairError,g as KeyWrappingError,Z as MAX_UINT64,jt as MemoryStorage,It as MutableWalletAccountStore,y as NoCiphertextError,R as NotEntitledError,hn as Offline,fn as Permits,ie as PreparedPermitChainMismatchError,te as PreparedPermitExpiredError,u as RelayerRequestFailedError,v as RevokedKmsContextError,k as RpcRateLimitError,be as SignerNotConfiguredError,de as SignerRequiredError,b as SigningFailedError,re as SigningRejectedError,ht as TOKEN_TOPICS,tt as Token,lt as Topics,xe as TransactionRevertedError,ae as TransportKeyPairChangedError,ne as TransportKeyPairExpiredError,Et as UnlistedConfidentialTokenError,it as UnshieldAlreadyFinalizedError,st as VaultBatcherPausedError,at as VaultGroupJoinUnconfirmedError,Q as WILDCARD_CONTRACT,pe as WalletAccountNotReadyError,Ie as WalletNotConnectedError,Ct as WrappedToken,N as WrappersRegistry,et as ZERO_ENCRYPTED_VALUE,p as ZamaError,c as ZamaErrorCode,Xn as ZamaSDK,C as ZamaSDKEvents,Oe as allowanceContract,$t as anvil,O as approveContract,Se as balanceOfContract,Yt as bscTestnet,Zt as chains,_n as chromeSessionStorage,Ot as cleartext,_e as confidentialBalanceOfContract,ce as confidentialTotalSupplyContract,ve as confidentialTransferContract,le as confidentialTransferFromContract,dn as createConfig,Rt as createWalletAccountStore,Ve as decimalsContract,yt as decodeAclEvent,St as decodeAclEvents,ut as decodeConfidentialTransfer,gt as decodeDelegatedForUserDecryption,wt as decodeOnChainEvent,dt as decodeOnChainEvents,ft as decodeRevokedDelegationForUserDecryption,bt as decodeUnwrapFinalized,_t as decodeUnwrapRequested,mt as decodeWrap,Y as delegateForUserDecryptionContract,he as finalizeUnwrapContract,pt as findDelegatedForUserDecryption,ct as findRevokedDelegationForUserDecryption,Tt as findUnwrapRequested,Dt as findWrap,ze as getConfidentialTokenAddressContract,ln as getDelegationExpiryContract,Pe as getTokenAddressContract,Le as getTokenPairContract,ke as getTokenPairsContract,Ce as getTokenPairsLengthContract,Fe as getTokenPairsSliceContract,qt as hardhat,Gt as hoodi,Ft as indexedDBStorage,je as inferredTotalSupplyContract,Ee as isConfidentialTokenContract,Re as isConfidentialTokenValidContract,De as isConfidentialWrapperContract,Ye as isEncryptedValueZero,un as isHandleDelegatedContract,se as isOperatorContract,n as isRetryable,Xt as mainnet,nn as matchZamaError,Mt as memoryStorage,we as nameContract,At as parsePreparedPermit,Qt as polygon,Kt as polygonAmoy,Ae as rateContract,d as retryAfterSeconds,X as revokeDelegationContract,Jt as sepolia,E as setOperatorContract,Ne as supportsInterfaceContract,He as symbolContract,rt as transferAndCallContract,me as underlyingContract,ge as unwrapContract,ue as unwrapFromBalanceContract,fe as unwrapRequesterContract,T as wrapContract,en as zenithTrexTestnet};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { f as FheChain } from "../index-
|
|
2
|
-
import { A as WalletAccountListener, dn as FhevmRelayerOptions, in as EIP712TypedData } from "../types-
|
|
3
|
-
import { D as ZamaSDK, Ht as ZamaErrorCode, Vt as ZamaError } from "../index-
|
|
4
|
-
import "../encrypt-worker-client-
|
|
1
|
+
import { f as FheChain } from "../index-CyVD1zLr.js";
|
|
2
|
+
import { A as WalletAccountListener, dn as FhevmRelayerOptions, in as EIP712TypedData } from "../types-CKtpO41S.js";
|
|
3
|
+
import { D as ZamaSDK, Ht as ZamaErrorCode, Vt as ZamaError } from "../index-B-bk_RhJ.js";
|
|
4
|
+
import "../encrypt-worker-client-BlQ06ILZ.js";
|
|
5
5
|
import { TypedDataDefinition } from "viem";
|
|
6
6
|
//#region src/errors/revive.d.ts
|
|
7
7
|
/** Restores callback failures whose class identity controls batch termination. */
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e,r as t,y as n}from"../relayer-ov8b_HOu.js";import{t as r}from"../fatal-batch-CI1pes1q.js";import{n as i}from"../fhevm-relayer-
|
|
1
|
+
import{i as e,r as t,y as n}from"../relayer-ov8b_HOu.js";import{t as r}from"../fatal-batch-CI1pes1q.js";import{n as i}from"../fhevm-relayer-DF4uuzDF.js";import{t as a}from"../typed-data-eAgGr9V-.js";const o=r;function s(r,i,a){let s=o[r],c=s?new s(i):new t(r,i,r===e.RelayerRequestFailed?{retryable:a.retryable}:void 0);return c.retryable&&n(a.retryAfter)?Object.assign(c,{retryAfter:a.retryAfter}):c}function c(e,t){return e.onWalletAccountChange(t)}export{s as reviveZamaError,c as subscribeWalletAccountChanges,i as toFhevmAuth,a as toViemTypedData};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/node/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as hoodi, c as polygonAmoy, f as FheChain, i as hardhat, l as sepolia, n as bscTestnet, o as mainnet, p as FheChainAuth, r as chains, s as polygon, t as anvil, u as zenithTrexTestnet } from "../index-
|
|
2
|
-
import { an as EncryptInput, c as GenericStorage, cn as EncryptedValue, dn as FhevmRelayerOptions, fn as FhevmRuntimeConfig, in as EIP712TypedData, n as RelayerConfig, nn as DecryptPublicValuesResult, on as EncryptParams, pn as RelayerOptions, s as GenericLogger, t as CleartextRelayerConfig, tn as ClearValue, un as FhevmClientOptions } from "../types-
|
|
3
|
-
import { t as cleartext } from "../cleartext-
|
|
4
|
-
import { i as node, n as asyncLocalStorage, r as NodeRelayerConfig, t as AsyncLocalMapStorage } from "../index-
|
|
1
|
+
import { a as hoodi, c as polygonAmoy, f as FheChain, i as hardhat, l as sepolia, n as bscTestnet, o as mainnet, p as FheChainAuth, r as chains, s as polygon, t as anvil, u as zenithTrexTestnet } from "../index-CyVD1zLr.js";
|
|
2
|
+
import { an as EncryptInput, c as GenericStorage, cn as EncryptedValue, dn as FhevmRelayerOptions, fn as FhevmRuntimeConfig, in as EIP712TypedData, n as RelayerConfig, nn as DecryptPublicValuesResult, on as EncryptParams, pn as RelayerOptions, s as GenericLogger, t as CleartextRelayerConfig, tn as ClearValue, un as FhevmClientOptions } from "../types-CKtpO41S.js";
|
|
3
|
+
import { t as cleartext } from "../cleartext-C--gPqhI.js";
|
|
4
|
+
import { i as node, n as asyncLocalStorage, r as NodeRelayerConfig, t as AsyncLocalMapStorage } from "../index-CnxoTnTi.js";
|
|
5
5
|
export { AsyncLocalMapStorage, type ClearValue, type CleartextRelayerConfig, type DecryptPublicValuesResult, type EIP712TypedData, type EncryptInput, type EncryptParams, type EncryptedValue, type FheChain, type FheChainAuth, type FhevmClientOptions, type FhevmRelayerOptions, type FhevmRuntimeConfig, type GenericLogger, type GenericStorage, type NodeRelayerConfig, type RelayerConfig, type RelayerOptions, anvil, asyncLocalStorage, bscTestnet, chains, cleartext, hardhat, hoodi, mainnet, node, polygon, polygonAmoy, sepolia, zenithTrexTestnet };
|
package/dist/esm/node/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"../fhevm-relayer-
|
|
1
|
+
import{t as e}from"../fhevm-relayer-DF4uuzDF.js";import{t}from"../telemetry-D9Mf59ts.js";import{t as n}from"../cleartext-RqXnz7I6.js";import{a as r,c as i,i as a,l as o,n as s,o as c,r as l,s as u,t as d,u as f}from"../chains-CF-Hzs9R.js";import{AsyncLocalStorage as p}from"node:async_hooks";function m(n){return{type:`node`,createRelayer:(r,i,a)=>{let o=t(globalThis.process?.env?.ZAMA_SDK_TELEMETRY)??a?.mode;return new e({chain:r,options:n,logger:i,telemetry:a&&o!==void 0&&o!==`off`?{state:a,runtime:`node`,mode:o}:void 0})}}}var h=class{#e=new p;run(e){return this.#e.run(new Map,e)}async get(e){return this.#e.getStore()?.get(e)??null}async set(e,t){this.#e.getStore()?.set(e,t)}async delete(e){this.#e.getStore()?.delete(e)}};const g=new h;export{h as AsyncLocalMapStorage,d as anvil,g as asyncLocalStorage,s as bscTestnet,l as chains,n as cleartext,a as hardhat,r as hoodi,c as mainnet,m as node,u as polygon,i as polygonAmoy,o as sepolia,f as zenithTrexTestnet};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { f as FheChain, p as FheChainAuth } from "../index-
|
|
2
|
-
import { $ as SetOperatorSubmittedEvent, $t as TransactionReceipt, A as WalletAccountListener, B as ApproveUnderlyingSubmittedEvent, C as TransferAndCallRequest, Ct as ShieldCallbacks, D as GenericSigner, E as WrapRequest, F as ReadContractReturnType, Ft as UnwrapFinalizedEvent, G as DelegationSubmittedEvent, H as DecryptEndEvent, I as ReadFunctionName, It as UnwrapRequestedEvent, J as EncryptStartEvent, K as EncryptEndEvent, L as WriteContractArgs, Lt as WrapEvent, M as ContractAbi, N as ReadContractArgs, O as WalletAccount, P as ReadContractConfig, Q as RevokeDelegationSubmittedEvent, Qt as RawLog, R as WriteContractConfig, S as TransactionKind, St as WrapOptions, T as UnwrapRequest, Tt as UnshieldCallbacks, U as DecryptErrorEvent, V as BaseEvent, W as DecryptStartEvent, X as PermitErrorEvent, Y as FinalizeUnwrapSubmittedEvent, Z as PermitOperation, _ as PrepareTransactionRequest, _t as ShieldOptions, an as EncryptInput, at as UnshieldPhase1SubmittedEvent, b as RevokeDelegationRequest, bt as UnshieldOptions, c as GenericStorage, cn as EncryptedValue, ct as UnwrapSubmittedEvent, d as ConfidentialTransferFromRequest, dn as FhevmRelayerOptions, dt as WrapSubmittedEvent, en as TransactionResult, et as ShieldSubmittedEvent, f as ConfidentialTransferRequest, fn as FhevmRuntimeConfig, ft as ZamaSDKEvent, g as PrepareOptions, gt as ApprovalStrategy, h as PrepareFees, hn as RelayerSDK, ht as ZamaSDKEvents, i as ZamaConfig, in as EIP712TypedData, it as TransferSubmittedEvent, j as WalletAccountStore, jt as OnChainEvent, k as WalletAccountChange, kt as ConfidentialTransferEvent, l as GenericProvider, ln as FhevmClient, m as FinalizeUnwrapRequest, mn as RelayerRequestOptions, nn as DecryptPublicValuesResult, nt as TransactionOperation, on as EncryptParams, ot as UnshieldPhase2StartedEvent, p as DelegateDecryptionRequest, pt as ZamaSDKEventListener, q as EncryptErrorEvent, rt as TransferFromSubmittedEvent, s as GenericLogger, sn as EncryptResult, st as UnshieldPhase2SubmittedEvent, tn as ClearValue, tt as TransactionErrorEvent, u as ApproveUnderlyingRequest, v as PreparedFor, vt as ShieldPath, w as UnwrapAllRequest, wt as TransferCallbacks, x as SetOperatorRequest, xt as UnwrapResult, y as PreparedTransaction, yt as TransferOptions, z as WriteFunctionName } from "../types-
|
|
3
|
-
import "../index-
|
|
4
|
-
import { $t as ChecksummedAddress, A as ListPairsOptions, B as DelegationStatus, D as ZamaSDK, F as BatchDecryptAsOptions, G as DecryptResult, H as BatchDecryptItem, Ht as ZamaErrorCode, I as Token, J as SignerQueryContext, Jt as PreparedPermit, K as EncryptedInput, L as Permits, M as WrappersRegistryConfig, N as WrappedToken, O as ZamaSDKOptions, P as BatchBalancesResult, Qt as SignedPreparedPermit, R as Offline, U as BatchDecryptResult, V as Decryption, Vt as ZamaError, W as DelegatedDecryptOptions, X as MutationFactoryOptions, Xt as SerializedPermitEip712, Y as zamaQueryKeys, Z as QueryFactoryOptions, Zt as SerializedTransportKeyPair, en as PaginatedResult, j as WrappersRegistry, nn as TokenWrapperPairWithMetadata, q as decryptValuesQueryOptions, qt as PreparePermitRequest, tn as TokenWrapperPair, z as Delegations } from "../index-
|
|
5
|
-
import "../index-
|
|
1
|
+
import { f as FheChain, p as FheChainAuth } from "../index-CyVD1zLr.js";
|
|
2
|
+
import { $ as SetOperatorSubmittedEvent, $t as TransactionReceipt, A as WalletAccountListener, B as ApproveUnderlyingSubmittedEvent, C as TransferAndCallRequest, Ct as ShieldCallbacks, D as GenericSigner, E as WrapRequest, F as ReadContractReturnType, Ft as UnwrapFinalizedEvent, G as DelegationSubmittedEvent, H as DecryptEndEvent, I as ReadFunctionName, It as UnwrapRequestedEvent, J as EncryptStartEvent, K as EncryptEndEvent, L as WriteContractArgs, Lt as WrapEvent, M as ContractAbi, N as ReadContractArgs, O as WalletAccount, P as ReadContractConfig, Q as RevokeDelegationSubmittedEvent, Qt as RawLog, R as WriteContractConfig, S as TransactionKind, St as WrapOptions, T as UnwrapRequest, Tt as UnshieldCallbacks, U as DecryptErrorEvent, V as BaseEvent, W as DecryptStartEvent, X as PermitErrorEvent, Y as FinalizeUnwrapSubmittedEvent, Z as PermitOperation, _ as PrepareTransactionRequest, _t as ShieldOptions, an as EncryptInput, at as UnshieldPhase1SubmittedEvent, b as RevokeDelegationRequest, bt as UnshieldOptions, c as GenericStorage, cn as EncryptedValue, ct as UnwrapSubmittedEvent, d as ConfidentialTransferFromRequest, dn as FhevmRelayerOptions, dt as WrapSubmittedEvent, en as TransactionResult, et as ShieldSubmittedEvent, f as ConfidentialTransferRequest, fn as FhevmRuntimeConfig, ft as ZamaSDKEvent, g as PrepareOptions, gt as ApprovalStrategy, h as PrepareFees, hn as RelayerSDK, ht as ZamaSDKEvents, i as ZamaConfig, in as EIP712TypedData, it as TransferSubmittedEvent, j as WalletAccountStore, jt as OnChainEvent, k as WalletAccountChange, kt as ConfidentialTransferEvent, l as GenericProvider, ln as FhevmClient, m as FinalizeUnwrapRequest, mn as RelayerRequestOptions, nn as DecryptPublicValuesResult, nt as TransactionOperation, on as EncryptParams, ot as UnshieldPhase2StartedEvent, p as DelegateDecryptionRequest, pt as ZamaSDKEventListener, q as EncryptErrorEvent, rt as TransferFromSubmittedEvent, s as GenericLogger, sn as EncryptResult, st as UnshieldPhase2SubmittedEvent, tn as ClearValue, tt as TransactionErrorEvent, u as ApproveUnderlyingRequest, v as PreparedFor, vt as ShieldPath, w as UnwrapAllRequest, wt as TransferCallbacks, x as SetOperatorRequest, xt as UnwrapResult, y as PreparedTransaction, yt as TransferOptions, z as WriteFunctionName } from "../types-CKtpO41S.js";
|
|
3
|
+
import "../index-DrTWm3Aw.js";
|
|
4
|
+
import { $t as ChecksummedAddress, A as ListPairsOptions, B as DelegationStatus, D as ZamaSDK, F as BatchDecryptAsOptions, G as DecryptResult, H as BatchDecryptItem, Ht as ZamaErrorCode, I as Token, J as SignerQueryContext, Jt as PreparedPermit, K as EncryptedInput, L as Permits, M as WrappersRegistryConfig, N as WrappedToken, O as ZamaSDKOptions, P as BatchBalancesResult, Qt as SignedPreparedPermit, R as Offline, U as BatchDecryptResult, V as Decryption, Vt as ZamaError, W as DelegatedDecryptOptions, X as MutationFactoryOptions, Xt as SerializedPermitEip712, Y as zamaQueryKeys, Z as QueryFactoryOptions, Zt as SerializedTransportKeyPair, en as PaginatedResult, j as WrappersRegistry, nn as TokenWrapperPairWithMetadata, q as decryptValuesQueryOptions, qt as PreparePermitRequest, tn as TokenWrapperPair, z as Delegations } from "../index-B-bk_RhJ.js";
|
|
5
|
+
import "../index-CnxoTnTi.js";
|
|
6
6
|
import { a as invalidateAfterSetOperator, c as invalidateAfterUnshield, d as invalidateAfterWrap, f as invalidateBalanceQueries, i as invalidateAfterApproveUnderlying, l as invalidateAfterUnshieldSettled, m as invalidateWalletLifecycleQueries, n as QueryFilterLike, o as invalidateAfterShield, p as invalidateWagmiBalanceQueries, r as QueryLike, s as invalidateAfterTransfer, t as QueryClientLike, u as invalidateAfterUnwrap } from "../invalidation-CJ-pzOUG.js";
|
|
7
7
|
import { Address, Hex } from "viem";
|
|
8
8
|
//#region src/query/utils.d.ts
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t){let n=Object.entries({version:`3.8.0-beta.
|
|
2
|
-
//# sourceMappingURL=telemetry-
|
|
1
|
+
function e(e,t){let n=Object.entries({version:`3.8.0-beta.13`,layer:e.state.layer,runtime:e.runtime,...t!==void 0&&{operation:t}}),r=e=>Object.fromEntries(n.map(([t,n])=>[`${e}${t}`,n]));return e.mode===`query`?{query:r(`zama_sdk_`)}:{headers:r(`x-zama-sdk-`)}}function t(e,t){return Object.assign({},e,{operation:e?.operation??t})}function n(e){if(typeof e==`boolean`)return e?`header`:`off`;let t=typeof e==`string`?e.trim().toLowerCase():void 0;return t===`0`||t===`false`?`off`:t===`header`||t===`query`||t===`off`?t:void 0}export{e as n,t as r,n as t};
|
|
2
|
+
//# sourceMappingURL=telemetry-D9Mf59ts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry-
|
|
1
|
+
{"version":3,"file":"telemetry-D9Mf59ts.js","names":["packageJson.version"],"sources":["../../package.json","../../src/version.ts","../../src/telemetry.ts"],"sourcesContent":["","import packageJson from \"../package.json\" with { type: \"json\" };\n\nexport const SDK_VERSION: string = packageJson.version;\n","import { SDK_VERSION } from \"./version\";\n\n// No telemetry field may carry a wallet address, encrypted value, amount or identifier.\n\nexport type TelemetryLayer = \"core\" | \"react\";\n\nexport type TelemetryRuntime = \"web\" | \"node\";\n\nexport type TelemetryMode = \"header\" | \"query\" | \"off\";\n\n/** Values are frozen once shipped, so that dashboards keyed on them survive method renames. */\nexport type TelemetryOperation =\n | \"balance-of\"\n | \"decrypt-balance-as\"\n | \"batch-balances-of\"\n | \"batch-decrypt-balances-as\"\n | \"confidential-transfer\"\n | \"confidential-transfer-from\"\n | \"confidential-transfer-and-call\"\n | \"confidential-transfer-from-and-call\"\n | \"unshield\"\n | \"unshield-all\"\n | \"resume-unshield\"\n | \"unwrap\"\n | \"finalize-unwrap\"\n | \"vault-deposit\"\n | \"vault-redeem\"\n | \"vault-join\"\n | \"vault-group-deposit\"\n | \"vault-group-redeem\"\n | \"vault-deposit-of\"\n | \"encrypt\"\n | \"decrypt-values\"\n | \"delegated-decrypt-values\"\n | \"delegated-batch-decrypt-values\"\n | \"decrypt-public-values\"\n | \"offline-confidential-transfer\"\n | \"offline-confidential-transfer-from\"\n | \"offline-unwrap\"\n | \"offline-finalize-unwrap\";\n\n/**\n * Shared by every relayer of a config. `layer` flips to `react` once\n * `ZamaProvider` marks the config, after the relayers exist.\n *\n * @internal\n */\nexport interface TelemetryState {\n layer: TelemetryLayer;\n readonly mode: Exclude<TelemetryMode, \"off\">;\n}\n\nexport interface RelayerTelemetry {\n readonly state: TelemetryState;\n readonly runtime: TelemetryRuntime;\n /** The config's `mode`, unless `ZAMA_SDK_TELEMETRY` overrode it on Node. */\n readonly mode: Exclude<TelemetryMode, \"off\">;\n}\n\nexport function telemetryRequestOptions(\n telemetry: RelayerTelemetry,\n operation: TelemetryOperation | undefined,\n): { headers?: Record<string, string>; query?: Record<string, string> } {\n const fields = Object.entries({\n version: SDK_VERSION,\n layer: telemetry.state.layer,\n runtime: telemetry.runtime,\n ...(operation !== undefined && { operation }),\n });\n const prefixed = (prefix: string) =>\n Object.fromEntries(fields.map(([name, value]) => [`${prefix}${name}`, value]));\n return telemetry.mode === \"query\"\n ? { query: prefixed(\"zama_sdk_\") }\n : { headers: prefixed(\"x-zama-sdk-\") };\n}\n\n/** `options` labelled with `operation`, unless the caller already labelled it. */\nexport function withOperation<T extends { readonly operation?: TelemetryOperation }>(\n options: T | undefined,\n operation: TelemetryOperation,\n): Partial<T> & { readonly operation: TelemetryOperation } {\n return Object.assign({}, options, { operation: options?.operation ?? operation });\n}\n\nexport function parseTelemetryMode(value: string | boolean | undefined): TelemetryMode | undefined {\n if (typeof value === \"boolean\") {\n return value ? \"header\" : \"off\";\n }\n // JavaScript callers can pass anything; only a string can name a mode.\n const mode = typeof value === \"string\" ? value.trim().toLowerCase() : undefined;\n // `0` and `false` predate the named modes and still mean off.\n if (mode === \"0\" || mode === \"false\") {\n return \"off\";\n }\n return mode === \"header\" || mode === \"query\" || mode === \"off\" ? mode : undefined;\n}\n"],"mappings":"AE2DA,SAAgB,EACd,EACA,EACsE,CACtE,IAAM,EAAS,OAAO,QAAQ,CAC5B,QAAS,gBACT,MAAO,EAAU,MAAM,MACvB,QAAS,EAAU,QACnB,GAAI,IAAc,IAAA,IAAa,CAAE,WAAU,CAC7C,CAAC,EACK,EAAY,GAChB,OAAO,YAAY,EAAO,KAAK,CAAC,EAAM,KAAW,CAAC,GAAG,IAAS,IAAQ,CAAK,CAAC,CAAC,EAC/E,OAAO,EAAU,OAAS,QACtB,CAAE,MAAO,EAAS,WAAW,CAAE,EAC/B,CAAE,QAAS,EAAS,aAAa,CAAE,CACzC,CAGA,SAAgB,EACd,EACA,EACyD,CACzD,OAAO,OAAO,OAAO,CAAC,EAAG,EAAS,CAAE,UAAW,GAAS,WAAa,CAAU,CAAC,CAClF,CAEA,SAAgB,EAAmB,EAAgE,CACjG,GAAI,OAAO,GAAU,UACnB,OAAO,EAAQ,SAAW,MAG5B,IAAM,EAAO,OAAO,GAAU,SAAW,EAAM,KAAK,CAAC,CAAC,YAAY,EAAI,IAAA,GAKtE,OAHI,IAAS,KAAO,IAAS,QACpB,MAEF,IAAS,UAAY,IAAS,SAAW,IAAS,MAAQ,EAAO,IAAA,EAC1E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as AtLeastOneChain } from "./index-
|
|
2
|
-
import { a as ZamaConfigBase } from "./types-
|
|
1
|
+
import { d as AtLeastOneChain } from "./index-CyVD1zLr.js";
|
|
2
|
+
import { a as ZamaConfigBase } from "./types-CKtpO41S.js";
|
|
3
3
|
import { EIP1193Provider, PublicClient, WalletClient } from "viem";
|
|
4
4
|
//#region src/viem/types.d.ts
|
|
5
5
|
/** Viem config — pass native viem clients directly. */
|
|
@@ -13,4 +13,4 @@ interface ZamaConfigViem<TChains extends AtLeastOneChain = AtLeastOneChain> exte
|
|
|
13
13
|
}
|
|
14
14
|
//#endregion
|
|
15
15
|
export { ZamaConfigViem as t };
|
|
16
|
-
//# sourceMappingURL=types-
|
|
16
|
+
//# sourceMappingURL=types-BF5HtmsQ.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as AtLeastOneChain } from "./index-
|
|
2
|
-
import { a as ZamaConfigBase } from "./types-
|
|
1
|
+
import { d as AtLeastOneChain } from "./index-CyVD1zLr.js";
|
|
2
|
+
import { a as ZamaConfigBase } from "./types-CKtpO41S.js";
|
|
3
3
|
import { EIP1193Provider } from "viem";
|
|
4
4
|
import { Provider, Signer } from "ethers";
|
|
5
5
|
//#region src/ethers/types.d.ts
|
|
@@ -26,4 +26,4 @@ type ZamaConfigEthers<TChains extends AtLeastOneChain = AtLeastOneChain> = ZamaC
|
|
|
26
26
|
});
|
|
27
27
|
//#endregion
|
|
28
28
|
export { ZamaConfigEthers as t };
|
|
29
|
-
//# sourceMappingURL=types-
|
|
29
|
+
//# sourceMappingURL=types-BR69mm5U.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as AtLeastOneChain, f as FheChain } from "./index-
|
|
1
|
+
import { d as AtLeastOneChain, f as FheChain } from "./index-CyVD1zLr.js";
|
|
2
2
|
import { Abi, Address, ContractFunctionArgs, ContractFunctionName, ContractFunctionReturnType, Hex } from "viem";
|
|
3
3
|
import { CreateUnsignedLegacyDecryptionPermitEip712Parameters, CreateUnsignedLegacyDecryptionPermitEip712ReturnType } from "@fhevm/sdk/actions/base";
|
|
4
4
|
import { createFhevmClient, setFhevmRuntimeConfig } from "@fhevm/sdk/viem";
|
|
@@ -1385,4 +1385,4 @@ type ZamaConfig = {
|
|
|
1385
1385
|
};
|
|
1386
1386
|
//#endregion
|
|
1387
1387
|
export { SetOperatorSubmittedEvent as $, TransactionReceipt as $t, WalletAccountListener as A, DelegatedForUserDecryptionEvent as At, ApproveUnderlyingSubmittedEvent as B, decodeConfidentialTransfer as Bt, TransferAndCallRequest as C, ShieldCallbacks as Ct, GenericSigner as D, AclEvent as Dt, WrapRequest as E, ACL_TOPICS as Et, ReadContractReturnType as F, UnwrapFinalizedEvent as Ft, DelegationSubmittedEvent as G, decodeUnwrapFinalized as Gt, DecryptEndEvent as H, decodeOnChainEvent as Ht, ReadFunctionName as I, UnwrapRequestedEvent as It, EncryptStartEvent as J, findDelegatedForUserDecryption as Jt, EncryptEndEvent as K, decodeUnwrapRequested as Kt, WriteContractArgs as L, WrapEvent as Lt, ContractAbi as M, RevokedDelegationForUserDecryptionEvent as Mt, ReadContractArgs as N, TOKEN_TOPICS as Nt, WalletAccount as O, AclTopics as Ot, ReadContractConfig as P, Topics as Pt, RevokeDelegationSubmittedEvent as Q, RawLog as Qt, WriteContractConfig as R, decodeAclEvent as Rt, TransactionKind as S, WrapOptions as St, UnwrapRequest as T, UnshieldCallbacks as Tt, DecryptErrorEvent as U, decodeOnChainEvents as Ut, BaseEvent as V, decodeDelegatedForUserDecryption as Vt, DecryptStartEvent as W, decodeRevokedDelegationForUserDecryption as Wt, PermitErrorEvent as X, findUnwrapRequested as Xt, FinalizeUnwrapSubmittedEvent as Y, findRevokedDelegationForUserDecryption as Yt, PermitOperation as Z, findWrap as Zt, PrepareTransactionRequest as _, ShieldOptions as _t, ZamaConfigBase as a, EncryptInput as an, UnshieldPhase1SubmittedEvent as at, RevokeDelegationRequest as b, UnshieldOptions as bt, GenericStorage as c, EncryptedValue as cn, UnwrapSubmittedEvent as ct, ConfidentialTransferFromRequest as d, FhevmRelayerOptions as dn, WrapSubmittedEvent as dt, TransactionResult as en, ShieldSubmittedEvent as et, ConfidentialTransferRequest as f, FhevmRuntimeConfig as fn, ZamaSDKEvent as ft, PrepareOptions as g, TypedValue$1 as gn, ApprovalStrategy as gt, PrepareFees as h, RelayerSDK as hn, ZamaSDKEvents as ht, ZamaConfig as i, EIP712TypedData as in, TransferSubmittedEvent as it, WalletAccountStore as j, OnChainEvent as jt, WalletAccountChange as k, ConfidentialTransferEvent as kt, GenericProvider as l, FhevmClient as ln, VaultOperation as lt, FinalizeUnwrapRequest as m, RelayerRequestOptions as mn, ZamaSDKEventType as mt, RelayerConfig as n, DecryptPublicValuesResult as nn, TransactionOperation as nt, ZamaConfigGeneric as o, EncryptParams as on, UnshieldPhase2StartedEvent as ot, DelegateDecryptionRequest as p, RelayerOptions as pn, ZamaSDKEventListener as pt, EncryptErrorEvent as q, decodeWrap as qt, WebRelayerConfig as r, DecryptValuesParameters as rn, TransferFromSubmittedEvent as rt, GenericLogger as s, EncryptResult as sn, UnshieldPhase2SubmittedEvent as st, CleartextRelayerConfig as t, ClearValue as tn, TransactionErrorEvent as tt, ApproveUnderlyingRequest as u, FhevmClientOptions as un, VaultSubmittedEvent as ut, PreparedFor as v, ShieldPath as vt, UnwrapAllRequest as w, TransferCallbacks as wt, SetOperatorRequest as x, UnwrapResult as xt, PreparedTransaction as y, TransferOptions as yt, WriteFunctionName as z, decodeAclEvents as zt };
|
|
1388
|
-
//# sourceMappingURL=types-
|
|
1388
|
+
//# sourceMappingURL=types-CKtpO41S.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Qt as RawLog, cn as EncryptedValue, en as TransactionResult } from "../types-
|
|
2
|
-
import { C as JoinOptions, E as VaultJoinOptions, S as BatchState, T as VaultAddresses, X as MutationFactoryOptions, Z as QueryFactoryOptions, _ as createVaultGroup, b as VaultBatcher, d as VaultGroupConfig, f as VaultGroupJoin, g as VaultMemberConfig, h as VaultGroupRedeemOptions, l as MAX_GROUP_VAULTS, m as VaultGroupMember, p as VaultGroupJoinResult, u as VaultGroup, v as Vault, w as JoinResult, x as createVaultBatcher, y as createVault } from "../index-
|
|
1
|
+
import { Qt as RawLog, cn as EncryptedValue, en as TransactionResult } from "../types-CKtpO41S.js";
|
|
2
|
+
import { C as JoinOptions, E as VaultJoinOptions, S as BatchState, T as VaultAddresses, X as MutationFactoryOptions, Z as QueryFactoryOptions, _ as createVaultGroup, b as VaultBatcher, d as VaultGroupConfig, f as VaultGroupJoin, g as VaultMemberConfig, h as VaultGroupRedeemOptions, l as MAX_GROUP_VAULTS, m as VaultGroupMember, p as VaultGroupJoinResult, u as VaultGroup, v as Vault, w as JoinResult, x as createVaultBatcher, y as createVault } from "../index-B-bk_RhJ.js";
|
|
3
3
|
import { t as QueryClientLike } from "../invalidation-CJ-pzOUG.js";
|
|
4
4
|
import { Address, Hex } from "viem";
|
|
5
5
|
//#region src/vaults/events.d.ts
|