@zama-fhe/sdk 3.7.0-beta.8 → 3.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/base-signer.cjs +1 -1
- package/dist/cjs/base-signer.cjs.map +1 -1
- package/dist/cjs/chains/index.cjs +1 -1
- package/dist/cjs/chains.cjs +1 -1
- package/dist/cjs/chains.cjs.map +1 -1
- package/dist/cjs/erc165.cjs +1 -1
- package/dist/cjs/erc165.cjs.map +1 -1
- package/dist/cjs/fhevm-relayer.cjs +1 -1
- package/dist/cjs/fhevm-relayer.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/node/index.cjs +1 -1
- package/dist/cjs/telemetry.cjs +1 -1
- package/dist/cjs/telemetry.cjs.map +1 -1
- package/dist/cjs/token.cjs +1 -1
- package/dist/cjs/token.cjs.map +1 -1
- package/dist/cjs/vaults/index.cjs +1 -1
- package/dist/cjs/web/index.cjs +1 -1
- package/dist/cjs/wrapped-token.cjs +1 -1
- package/dist/esm/{base-signer-46j6PRq-.d.ts → base-signer-BxIDBDTF.d.ts} +2 -2
- package/dist/esm/base-signer-ClrhHzbm.js +2 -0
- package/dist/esm/base-signer-ClrhHzbm.js.map +1 -0
- package/dist/esm/chains/index.d.ts +2 -2
- package/dist/esm/chains/index.js +1 -1
- package/dist/esm/{chains-iPpnjXql.js → chains-BwlDI944.js} +2 -2
- package/dist/esm/chains-BwlDI944.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-DInZ0vz-.d.ts → cleartext-BnTAN4-g.d.ts} +2 -2
- package/dist/esm/{cleartext-C0ba9z6Z.js → cleartext-DBZq4E1O.js} +2 -2
- package/dist/esm/{cleartext-C0ba9z6Z.js.map → cleartext-DBZq4E1O.js.map} +1 -1
- package/dist/esm/erc165-BAd2z3ay.js +2 -0
- package/dist/esm/erc165-BAd2z3ay.js.map +1 -0
- package/dist/esm/ethers/index.d.ts +4 -4
- package/dist/esm/ethers/index.js +1 -1
- package/dist/esm/fhevm-relayer-BEQ31nmT.js +8 -0
- package/dist/esm/{fhevm-relayer-BWhXU1WB.js.map → fhevm-relayer-BEQ31nmT.js.map} +1 -1
- package/dist/esm/{index-DHMs4ZRb.d.ts → index-BlY7CCPB.d.ts} +7 -7
- package/dist/esm/{decryption-q0ODuDDS.d.ts → index-CD2sMpst.d.ts} +3 -7
- package/dist/esm/{index-Cdbp_93f.d.ts → index-D1Wtji3m.d.ts} +4 -26
- package/dist/esm/{index-C1clixw5.d.ts → index-fsWBYM8S.d.ts} +4 -4
- package/dist/esm/index.d.ts +9 -10
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node/index.d.ts +5 -5
- package/dist/esm/node/index.js +1 -1
- package/dist/esm/node/index.js.map +1 -1
- package/dist/esm/query/index.d.ts +5 -6
- package/dist/esm/query/index.js +1 -1
- package/dist/esm/telemetry-CBSzrmab.js +2 -0
- package/dist/esm/{telemetry-DvJV3oBk.js.map → telemetry-CBSzrmab.js.map} +1 -1
- package/dist/esm/token-CTvEGQmH.js +2 -0
- package/dist/esm/token-CTvEGQmH.js.map +1 -0
- package/dist/esm/{types-Bz42Emet.d.ts → types-C2ccCjoA.d.ts} +3 -3
- package/dist/esm/{types-BIgPY1yI.d.ts → types-CHepK8MK.d.ts} +2 -2
- package/dist/esm/{types-I9lJwH20.d.ts → types-Dc1fpXWt.d.ts} +3 -3
- package/dist/esm/vaults/index.d.ts +2 -3
- 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 +17 -2
- package/dist/esm/web/index.js +1 -1
- package/dist/esm/wrapped-token-IDUEFpZx.js +2 -0
- package/dist/esm/{wrapped-token-3usJd0oi.js.map → wrapped-token-IDUEFpZx.js.map} +1 -1
- package/package.json +1 -15
- package/dist/cjs/fatal-batch.cjs +0 -2
- package/dist/cjs/fatal-batch.cjs.map +0 -1
- package/dist/cjs/internal/index.cjs +0 -2
- package/dist/cjs/internal/index.cjs.map +0 -1
- package/dist/cjs/signing.cjs +0 -2
- package/dist/cjs/signing.cjs.map +0 -1
- package/dist/esm/base-signer-CNHZZnr2.js +0 -2
- package/dist/esm/base-signer-CNHZZnr2.js.map +0 -1
- package/dist/esm/chains-iPpnjXql.js.map +0 -1
- package/dist/esm/encrypt-worker-client-CKTlhAGI.d.ts +0 -19
- package/dist/esm/erc165-B8gx2luK.js +0 -2
- package/dist/esm/erc165-B8gx2luK.js.map +0 -1
- package/dist/esm/fatal-batch-BiiS7KdS.js +0 -2
- package/dist/esm/fatal-batch-BiiS7KdS.js.map +0 -1
- package/dist/esm/fhevm-relayer-BWhXU1WB.js +0 -8
- package/dist/esm/index-B09m_e9L.d.ts +0 -1
- package/dist/esm/internal/index.d.ts +0 -26
- package/dist/esm/internal/index.js +0 -2
- package/dist/esm/internal/index.js.map +0 -1
- package/dist/esm/signing-C6nbPCyd.js +0 -2
- package/dist/esm/signing-C6nbPCyd.js.map +0 -1
- package/dist/esm/telemetry-DvJV3oBk.js +0 -2
- package/dist/esm/token-g6sinwTx.js +0 -2
- package/dist/esm/token-g6sinwTx.js.map +0 -1
- package/dist/esm/wrapped-token-3usJd0oi.js +0 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./index-
|
|
2
|
-
import { c as GenericStorage, n as RelayerConfig, pn as RelayerOptions } from "./types-
|
|
3
|
-
import "./cleartext-
|
|
1
|
+
import "./index-D1Wtji3m.js";
|
|
2
|
+
import { c as GenericStorage, n as RelayerConfig, pn as RelayerOptions } from "./types-CHepK8MK.js";
|
|
3
|
+
import "./cleartext-BnTAN4-g.js";
|
|
4
4
|
//#region src/node/config.d.ts
|
|
5
5
|
/** Node transport — drives the FHE backend directly on the calling thread. */
|
|
6
6
|
interface NodeRelayerConfig extends RelayerConfig {
|
|
@@ -61,4 +61,4 @@ declare class AsyncLocalMapStorage implements GenericStorage {
|
|
|
61
61
|
declare const asyncLocalStorage: AsyncLocalMapStorage;
|
|
62
62
|
//#endregion
|
|
63
63
|
export { node as i, asyncLocalStorage as n, NodeRelayerConfig as r, AsyncLocalMapStorage as t };
|
|
64
|
-
//# sourceMappingURL=index-
|
|
64
|
+
//# sourceMappingURL=index-fsWBYM8S.d.ts.map
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { a as hoodi, c as
|
|
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 DelegationCooldownError, $t as
|
|
9
|
-
import "./index-B09m_e9L.js";
|
|
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-D1Wtji3m.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-CHepK8MK.js";
|
|
3
|
+
import { t as cleartext } from "./cleartext-BnTAN4-g.js";
|
|
4
|
+
import { t as ZamaConfigEthers } from "./types-C2ccCjoA.js";
|
|
5
|
+
import { n as MutableWalletAccountStore, r as createWalletAccountStore, t as BaseSigner } from "./base-signer-BxIDBDTF.js";
|
|
6
|
+
import { t as createConfig } from "./index-BlY7CCPB.js";
|
|
7
|
+
import { t as ZamaConfigViem } from "./types-Dc1fpXWt.js";
|
|
8
|
+
import { $ as DelegationCooldownError, $t as decimalsContract, A as TransactionRevertedError, At as TokenWrapperPair, B as ConfigurationError, Bt as getDelegationExpiryContract, C as Delegations, Ct as PreparedPermit, D as matchZamaError, Dt as SignedPreparedPermit, E as ErrorForCode, Et as SerializedTransportKeyPair, F as SignerRequiredError, Ft as getTokenPairsContract, G as InsufficientAllowanceError, Gt as ERC7984_INTERFACE_ID, H as BalanceCheckUnavailableError, Ht as revokeDelegationContract, I as WalletAccountNotReadyError, It as getTokenPairsLengthContract, J as DecryptionFailedError, Jt as isConfidentialWrapperContract, K as InsufficientConfidentialBalanceError, Kt as ERC7984_WRAPPER_INTERFACE_ID, L as WalletNotConnectedError, Lt as getTokenPairsSliceContract, M as SigningFailedError, Mt as getConfidentialTokenAddressContract, N as SigningRejectedError, Nt as getTokenAddressContract, O as UnshieldAlreadyFinalizedDetails, Ot as ChecksummedAddress, P as SignerNotConfiguredError, Pt as getTokenPairContract, Q as DelegationContractIsSelfError, Qt as balanceOfContract, R as RpcRateLimitError, Rt as isConfidentialTokenValidContract, S as Offline, St as PreparePermitRequest, T as Permits, Tt as SerializedPermitEip712, U as BalanceErrorDetails, Ut as transferAndCallContract, V as RelayerRequestFailedError, Vt as isHandleDelegatedContract, W as ERC20ReadFailedError, Wt as ERC1363_INTERFACE_ID, X as EncryptionFailedError, Xt as allowanceContract, Y as EncryptOffloadUnavailableError, Yt as supportsInterfaceContract, Z as AclPausedError, Zt as approveContract, _ as WrappersRegistryConfig, _t as ZamaError, a as DecryptResult, an as confidentialTransferFromContract, at as DelegationNotFoundError, b as BatchDecryptAsOptions, bt as retryAfterSeconds, cn as isOperatorContract, ct as InvalidTransportKeyPairError, dn as underlyingContract, dt as PreparedPermitChainMismatchError, en as nameContract, et as DelegationDelegateCannotBeWildcardError, f as ZamaSDK, fn as unwrapContract, ft as PreparedPermitExpiredError, g as WrappersRegistry, gt as ChainMismatchError, h as ListPairsOptions, hn as wrapContract, ht as TransportKeyPairExpiredError, i as DelegatedDecryptOptions, in as confidentialTransferContract, it as DelegationExpiryUnchangedError, j as SigningErrorMetadata, jt as TokenWrapperPairWithMetadata, k as UnshieldAlreadyFinalizedError, kt as PaginatedResult, ln as rateContract, lt as KeyWrappingError, m as DefaultRegistryAddresses, mn as unwrapRequesterContract, mt as TransportKeyPairChangedError, n as BatchDecryptItem, nn as confidentialBalanceOfContract, nt as DelegationExpirationTooSoonError, o as EncryptedInput, on as finalizeUnwrapContract, ot as DelegationNotPropagatedError, p as ZamaSDKOptions, pn as unwrapFromBalanceContract, pt as RevokedKmsContextError, q as InsufficientERC20BalanceError, qt as isConfidentialTokenContract, r as BatchDecryptResult, rn as confidentialTotalSupplyContract, rt as DelegationExpiredError, sn as inferredTotalSupplyContract, st as DelegationSelfNotAllowedError, t as Decryption, tn as symbolContract, tt as DelegationDelegateEqualsContractError, un as setOperatorContract, ut as NoCiphertextError, v as WrappedToken, vt as ZamaErrorCode, w as DelegationStatus, wt as SerializedPermit, x as Token, xt as Permission, y as BatchBalancesResult, yt as isRetryable, z as NotEntitledError, zt as delegateForUserDecryptionContract } from "./index-CD2sMpst.js";
|
|
10
9
|
import { Address, Hex } from "viem";
|
|
11
10
|
//#region src/contracts/constants.d.ts
|
|
12
11
|
/** uint64 max — represents a permanent (no-expiry) delegation. */
|
|
@@ -106,5 +105,5 @@ declare const ZERO_ENCRYPTED_VALUE: "0x00000000000000000000000000000000000000000
|
|
|
106
105
|
*/
|
|
107
106
|
declare function isEncryptedValueZero(encryptedValue: string): boolean;
|
|
108
107
|
//#endregion
|
|
109
|
-
export { ACL_TOPICS, type AclEvent, AclPausedError, AclTopics, type Address, type ApprovalStrategy, type ApproveUnderlyingRequest, type ApproveUnderlyingSubmittedEvent, type AtLeastOneChain, BalanceCheckUnavailableError, type BalanceErrorDetails, type BaseEvent, BaseSigner, type BatchBalancesResult, type BatchDecryptAsOptions, type BatchDecryptItem, type BatchDecryptResult, ChainMismatchError, type ChecksummedAddress, ChromeSessionStorage, type ClearValue, type CleartextRelayerConfig, type ConfidentialTransferEvent, type ConfidentialTransferFromRequest, type ConfidentialTransferRequest, ConfigurationError, type ContractAbi, type DecryptEndEvent, type DecryptErrorEvent, type EncryptedInput as DecryptInput, type DecryptPublicValuesResult, type DecryptResult, type DecryptStartEvent, type DecryptValuesParameters, Decryption, DecryptionFailedError, DefaultRegistryAddresses, type DelegateDecryptionRequest, type DelegatedDecryptOptions, type DelegatedForUserDecryptionEvent, DelegationContractIsSelfError, DelegationCooldownError, DelegationDelegateCannotBeWildcardError, DelegationDelegateEqualsContractError, DelegationExpirationTooSoonError, DelegationExpiredError, DelegationExpiryUnchangedError, DelegationNotFoundError, DelegationNotPropagatedError, DelegationSelfNotAllowedError, type DelegationStatus, type DelegationSubmittedEvent, Delegations, type EIP712TypedData, ERC1363_INTERFACE_ID, ERC20ReadFailedError, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, type EncryptEndEvent, type EncryptErrorEvent, type EncryptInput, EncryptOffloadUnavailableError, type EncryptParams, type EncryptResult, type EncryptStartEvent, type EncryptedValue, EncryptionFailedError, type ErrorForCode, type FheChain, type FheChainAuth, type FhevmClient, type FhevmClientOptions, type FhevmRelayerOptions, type FhevmRuntimeConfig, type FinalizeUnwrapRequest, type FinalizeUnwrapSubmittedEvent, type GenericLogger, type GenericProvider, type GenericSigner, type GenericStorage, type Hex, IndexedDBStorage, InsufficientAllowanceError, InsufficientConfidentialBalanceError, InsufficientERC20BalanceError, InvalidTransportKeyPairError, KeyWrappingError, type ListPairsOptions, MAX_UINT64, MemoryStorage, MutableWalletAccountStore, NoCiphertextError, NotEntitledError, Offline, type OnChainEvent, type PaginatedResult, type Permission, type PermitErrorEvent, type PermitOperation, Permits, type PrepareFees, type PrepareOptions, type PreparePermitRequest, type PrepareTransactionRequest, type PreparedFor, type PreparedPermit, PreparedPermitChainMismatchError, PreparedPermitExpiredError, type PreparedTransaction, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, type RelayerConfig, type RelayerOptions, RelayerRequestFailedError, type RelayerRequestOptions, type RelayerSDK, type RevokeDelegationRequest, type RevokeDelegationSubmittedEvent, type RevokedDelegationForUserDecryptionEvent, RevokedKmsContextError, RpcRateLimitError, type SerializedPermit, type SerializedPermitEip712, type SerializedTransportKeyPair, type SetOperatorRequest, type SetOperatorSubmittedEvent, type ShieldCallbacks, type ShieldOptions, type ShieldPath, type ShieldSubmittedEvent, type SignedPreparedPermit, SignerNotConfiguredError, SignerRequiredError, type SigningErrorMetadata, SigningFailedError, SigningRejectedError, TOKEN_TOPICS, Token, type TokenWrapperPair, type TokenWrapperPairWithMetadata, Topics, type TransactionErrorEvent, type TransactionKind, type TransactionOperation, type TransactionReceipt, type TransactionResult, TransactionRevertedError, type TransferAndCallRequest, type TransferCallbacks, type TransferFromSubmittedEvent, type TransferOptions, type TransferSubmittedEvent, TransportKeyPairChangedError, TransportKeyPairExpiredError, type TypedValue, type UnshieldAlreadyFinalizedDetails, UnshieldAlreadyFinalizedError, type UnshieldCallbacks, type UnshieldOptions, type UnshieldPhase1SubmittedEvent, type UnshieldPhase2StartedEvent, type UnshieldPhase2SubmittedEvent, type UnwrapAllRequest, type UnwrapFinalizedEvent, type UnwrapRequest, type UnwrapRequestedEvent, type UnwrapResult, type UnwrapSubmittedEvent, type VaultOperation, type VaultSubmittedEvent, WILDCARD_CONTRACT, type WalletAccount, type WalletAccountChange, type WalletAccountListener, WalletAccountNotReadyError, type WalletAccountStore, WalletNotConnectedError, type WrapEvent, type WrapOptions, type WrapRequest, type WrapSubmittedEvent, WrappedToken, WrappersRegistry, type WrappersRegistryConfig, type WriteContractArgs, type WriteContractConfig, type WriteFunctionName, ZERO_ENCRYPTED_VALUE, type ZamaConfig, type ZamaConfigBase, type ZamaConfigEthers, type ZamaConfigGeneric, type ZamaConfigViem, ZamaError, ZamaErrorCode, ZamaSDK, type ZamaSDKEvent, type ZamaSDKEventListener, type ZamaSDKEventType, ZamaSDKEvents, type ZamaSDKOptions, allowanceContract, anvil, approveContract, balanceOfContract, bscTestnet, chains, chromeSessionStorage, cleartext, confidentialBalanceOfContract, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, createConfig, createWalletAccountStore, decimalsContract, decodeAclEvent, decodeAclEvents, decodeConfidentialTransfer, decodeDelegatedForUserDecryption, decodeOnChainEvent, decodeOnChainEvents, decodeRevokedDelegationForUserDecryption, decodeUnwrapFinalized, decodeUnwrapRequested, decodeWrap, delegateForUserDecryptionContract, finalizeUnwrapContract, findDelegatedForUserDecryption, findRevokedDelegationForUserDecryption, findUnwrapRequested, findWrap, getConfidentialTokenAddressContract, getDelegationExpiryContract, getTokenAddressContract, getTokenPairContract, getTokenPairsContract, getTokenPairsLengthContract, getTokenPairsSliceContract, hardhat, hoodi, indexedDBStorage, inferredTotalSupplyContract,
|
|
108
|
+
export { ACL_TOPICS, type AclEvent, AclPausedError, AclTopics, type Address, type ApprovalStrategy, type ApproveUnderlyingRequest, type ApproveUnderlyingSubmittedEvent, type AtLeastOneChain, BalanceCheckUnavailableError, type BalanceErrorDetails, type BaseEvent, BaseSigner, type BatchBalancesResult, type BatchDecryptAsOptions, type BatchDecryptItem, type BatchDecryptResult, ChainMismatchError, type ChecksummedAddress, ChromeSessionStorage, type ClearValue, type CleartextRelayerConfig, type ConfidentialTransferEvent, type ConfidentialTransferFromRequest, type ConfidentialTransferRequest, ConfigurationError, type ContractAbi, type DecryptEndEvent, type DecryptErrorEvent, type EncryptedInput as DecryptInput, type DecryptPublicValuesResult, type DecryptResult, type DecryptStartEvent, type DecryptValuesParameters, Decryption, DecryptionFailedError, DefaultRegistryAddresses, type DelegateDecryptionRequest, type DelegatedDecryptOptions, type DelegatedForUserDecryptionEvent, DelegationContractIsSelfError, DelegationCooldownError, DelegationDelegateCannotBeWildcardError, DelegationDelegateEqualsContractError, DelegationExpirationTooSoonError, DelegationExpiredError, DelegationExpiryUnchangedError, DelegationNotFoundError, DelegationNotPropagatedError, DelegationSelfNotAllowedError, type DelegationStatus, type DelegationSubmittedEvent, Delegations, type EIP712TypedData, ERC1363_INTERFACE_ID, ERC20ReadFailedError, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, type EncryptEndEvent, type EncryptErrorEvent, type EncryptInput, EncryptOffloadUnavailableError, type EncryptParams, type EncryptResult, type EncryptStartEvent, type EncryptedValue, EncryptionFailedError, type ErrorForCode, type FheChain, type FheChainAuth, type FhevmClient, type FhevmClientOptions, type FhevmRelayerOptions, type FhevmRuntimeConfig, type FinalizeUnwrapRequest, type FinalizeUnwrapSubmittedEvent, type GenericLogger, type GenericProvider, type GenericSigner, type GenericStorage, type Hex, IndexedDBStorage, InsufficientAllowanceError, InsufficientConfidentialBalanceError, InsufficientERC20BalanceError, InvalidTransportKeyPairError, KeyWrappingError, type ListPairsOptions, MAX_UINT64, MemoryStorage, MutableWalletAccountStore, NoCiphertextError, NotEntitledError, Offline, type OnChainEvent, type PaginatedResult, type Permission, type PermitErrorEvent, type PermitOperation, Permits, type PrepareFees, type PrepareOptions, type PreparePermitRequest, type PrepareTransactionRequest, type PreparedFor, type PreparedPermit, PreparedPermitChainMismatchError, PreparedPermitExpiredError, type PreparedTransaction, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, type RelayerConfig, type RelayerOptions, RelayerRequestFailedError, type RelayerRequestOptions, type RelayerSDK, type RevokeDelegationRequest, type RevokeDelegationSubmittedEvent, type RevokedDelegationForUserDecryptionEvent, RevokedKmsContextError, RpcRateLimitError, type SerializedPermit, type SerializedPermitEip712, type SerializedTransportKeyPair, type SetOperatorRequest, type SetOperatorSubmittedEvent, type ShieldCallbacks, type ShieldOptions, type ShieldPath, type ShieldSubmittedEvent, type SignedPreparedPermit, SignerNotConfiguredError, SignerRequiredError, type SigningErrorMetadata, SigningFailedError, SigningRejectedError, TOKEN_TOPICS, Token, type TokenWrapperPair, type TokenWrapperPairWithMetadata, Topics, type TransactionErrorEvent, type TransactionKind, type TransactionOperation, type TransactionReceipt, type TransactionResult, TransactionRevertedError, type TransferAndCallRequest, type TransferCallbacks, type TransferFromSubmittedEvent, type TransferOptions, type TransferSubmittedEvent, TransportKeyPairChangedError, TransportKeyPairExpiredError, type TypedValue, type UnshieldAlreadyFinalizedDetails, UnshieldAlreadyFinalizedError, type UnshieldCallbacks, type UnshieldOptions, type UnshieldPhase1SubmittedEvent, type UnshieldPhase2StartedEvent, type UnshieldPhase2SubmittedEvent, type UnwrapAllRequest, type UnwrapFinalizedEvent, type UnwrapRequest, type UnwrapRequestedEvent, type UnwrapResult, type UnwrapSubmittedEvent, type VaultOperation, type VaultSubmittedEvent, WILDCARD_CONTRACT, type WalletAccount, type WalletAccountChange, type WalletAccountListener, WalletAccountNotReadyError, type WalletAccountStore, WalletNotConnectedError, type WrapEvent, type WrapOptions, type WrapRequest, type WrapSubmittedEvent, WrappedToken, WrappersRegistry, type WrappersRegistryConfig, type WriteContractArgs, type WriteContractConfig, type WriteFunctionName, ZERO_ENCRYPTED_VALUE, type ZamaConfig, type ZamaConfigBase, type ZamaConfigEthers, type ZamaConfigGeneric, type ZamaConfigViem, ZamaError, ZamaErrorCode, ZamaSDK, type ZamaSDKEvent, type ZamaSDKEventListener, type ZamaSDKEventType, ZamaSDKEvents, type ZamaSDKOptions, allowanceContract, anvil, approveContract, balanceOfContract, bscTestnet, chains, chromeSessionStorage, cleartext, confidentialBalanceOfContract, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, createConfig, createWalletAccountStore, decimalsContract, decodeAclEvent, decodeAclEvents, decodeConfidentialTransfer, decodeDelegatedForUserDecryption, decodeOnChainEvent, decodeOnChainEvents, decodeRevokedDelegationForUserDecryption, decodeUnwrapFinalized, decodeUnwrapRequested, decodeWrap, delegateForUserDecryptionContract, finalizeUnwrapContract, findDelegatedForUserDecryption, findRevokedDelegationForUserDecryption, findUnwrapRequested, findWrap, getConfidentialTokenAddressContract, getDelegationExpiryContract, getTokenAddressContract, getTokenPairContract, getTokenPairsContract, getTokenPairsLengthContract, getTokenPairsSliceContract, hardhat, hoodi, indexedDBStorage, inferredTotalSupplyContract, isConfidentialTokenContract, isConfidentialTokenValidContract, isConfidentialWrapperContract, isEncryptedValueZero, isHandleDelegatedContract, isOperatorContract, isRetryable, mainnet, matchZamaError, memoryStorage, nameContract, polygon, polygonAmoy, rateContract, retryAfterSeconds, revokeDelegationContract, sepolia, setOperatorContract, supportsInterfaceContract, symbolContract, transferAndCallContract, underlyingContract, unwrapContract, unwrapFromBalanceContract, unwrapRequesterContract, wrapContract, zenithTrexTestnet };
|
|
110
109
|
//# sourceMappingURL=index.d.ts.map
|
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-C3jVhqSK.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-C6nbPCyd.js";import{n as oe,r as x,t as S}from"./encryption-6AVd-82z.js";import{A as se,B as ce,C as le,D as ue,E as de,F as C,H as w,L as fe,M as pe,O as T,P as me,R as he,S as ge,T as E,V as D,a as _e,b as ve,c as ye,d as be,g as xe,h as Se,i as Ce,j as O,k as we,l as Te,m as Ee,n as De,p as Oe,r as ke,s as Ae,t as je,u as Me,v as Ne,w as Pe,x as Fe,z as Ie}from"./erc165-B8gx2luK.js";import{n as Le,r as k}from"./fatal-batch-BiiS7KdS.js";import{a as A,c as Re,d as ze,f as Be,h as Ve,l as He,m as Ue,n as We,o as Ge,p as Ke,r as qe,s as Je,t as Ye,u as Xe}from"./token-g6sinwTx.js";import{C as Ze,T as Qe,_ as $e,a as et,c as tt,d as nt,f as rt,g as it,h as at,i as ot,l as st,m as ct,n as lt,o as ut,p as dt,r as ft,s as pt,t as mt,u as ht,v as gt,w as _t,y as vt}from"./wrapped-token-3usJd0oi.js";import{r as j}from"./telemetry-DvJV3oBk.js";import{t as yt}from"./cleartext-C0ba9z6Z.js";import{a as bt,c as xt,d as St,f as Ct,i as wt,l as Tt,m as Et,n as Dt,o as M,p as Ot,r as kt,s as At,t as jt,u as Mt}from"./base-signer-CNHZZnr2.js";import{n as N,r as Nt,s as Pt,t as Ft}from"./primitives-Cym-3HKa.js";import{t as P}from"./validation-ClSvPh6P.js";import{a as It,i as Lt,n as Rt,o as zt,r as Bt,s as Vt,t as Ht}from"./wrappers-registry-Cm3JJeqx.js";import{a as Ut,c as Wt,d as Gt,i as Kt,l as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt,u as $t}from"./chains-iPpnjXql.js";import{getAddress as F,size as en}from"viem";import{z as I}from"zod/mini";function tn(e,t){if(e instanceof p){let n=t[e.code];if(n)return n(e)}return t._?.(e)}var L=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}},R=class extends p{constructor(e,t){super(c.DelegationSelfNotAllowed,e,t),this.name=`DelegationSelfNotAllowedError`}},nn=class extends p{constructor(e,t){super(c.DelegationCooldown,e,t),this.name=`DelegationCooldownError`}},z=class extends p{constructor(e,t){super(c.DelegationNotFound,e,t),this.name=`DelegationNotFoundError`}},B=class extends p{constructor(e,t){super(c.DelegationExpired,e,t),this.name=`DelegationExpiredError`}},V=class extends p{constructor(e,t){super(c.DelegationExpiryUnchanged,e,t),this.name=`DelegationExpiryUnchangedError`}},H=class extends p{constructor(e,t){super(c.DelegationDelegateEqualsContract,e,t),this.name=`DelegationDelegateEqualsContractError`}},U=class extends p{constructor(e,t){super(c.DelegationDelegateCannotBeWildcard,e,t),this.name=`DelegationDelegateCannotBeWildcardError`}},rn=class extends p{constructor(e,t){super(c.DelegationContractIsSelf,e,t),this.name=`DelegationContractIsSelfError`}},an=class extends p{constructor(e,t){super(c.AclPaused,e,t),this.name=`AclPausedError`}},W=class extends p{constructor(e,t){super(c.DelegationExpirationTooSoon,e,t),this.name=`DelegationExpirationTooSoonError`}},G=class extends p{constructor(e,t){super(c.DelegationNotPropagated,e,t),this.name=`DelegationNotPropagatedError`}};const on=[S,y,u,G,re,b,L,k,_,v];function K(e,n,c={}){if(on.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 G(`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 L({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 G(`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 sn(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 q=[{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 J(e,t,n,r){return{address:e,abi:q,functionName:`delegateForUserDecryption`,args:[t,n,r]}}function Y(e,t,n){return{address:e,abi:q,functionName:`revokeDelegationForUserDecryption`,args:[t,n]}}function cn(e,t,n,r){return{address:e,abi:q,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function ln(e,t,n,r,i){return{address:e,abi:q,functionName:`isHandleDelegatedForUserDecryption`,args:[t,n,r,i]}}const X=2n**64n-1n,Z=`0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF`;function un(e){return wt(e.signer,e.provider,e)}var dn=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 D(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 Ge(`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 Ge(`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=F((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=F((await A(`clear`,this.#e,this.#t)).address);try{await e.clearCredentials()}finally{await this.#c(t)}}async#c(e){await O(`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)}},fn=class{#e;#t;#n;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.delegationService}#r(e){return D(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)}},pn=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 D(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,j(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,j(r,`delegated-decrypt-values`))}async decryptPublicValues(e,t){if(e.length===0)return{clearValues:{},decryptionProof:`0x`,abiEncodedClearValues:`0x`};let n=j(t,`decrypt-public-values`);try{let t=await this.#n.relayer.decryptPublicValuesWithSignatures({encryptedValues:e,options:n}),r={};return t.checkSignaturesArgs.handlesList.forEach((e,n)=>{me(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 K(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`})}},mn=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)}},hn=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 gn=new hn,_n=I.union([I.bigint(),I.boolean(),N]),vn=I.array(I.string());var yn=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=_n.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=F(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}:${F(e)}:${F(t)}:${n.toLowerCase()}`}async#l(){let e=await this.#e.get(this.#r);if(e===null)return[];let t=vn.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 bn(e,t){let n=xn(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 xn(e,t){let n=Ft(t);return e.permissions.find(e=>e.contractAddresses.includes(n))}const Sn=e=>new Promise(t=>setTimeout(t,e));var Cn=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=F(t);return this.#s(e,{requesterAddress:r,errorMessage:`Failed to decrypt encrypted values`},n)}async delegatedDecryptValues(e,t,n,r,i){let a=F(t),o=F(n),s={spent:!1};return this.#a(i?.waitForPropagation??!0,()=>this.#s(e,{requesterAddress:F(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 G))throw t;await Sn(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:F(e.contractAddress)}));if(s.length===0)return{items:s};let c=F(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(Le(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:F(t)}),{items:s}}}let l=!1,u;if(await qe(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(Le(n)){l=!0,u??=n;return}e.error=this.#f(n,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:e.contractAddress,account:F(t)})}}),i),u!==void 0)throw u;return{items:s}}async#o(e,t,n,r){let i=bn(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:F(e.contractAddress)})),o={},s=[];for(let e of a)He(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 Re(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}),K(t,n.errorMessage,{isDelegated:n.delegator!==void 0})}}async#c(e,t,n,r,i){let a=(await qe(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 K(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:K(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 Q={AlreadyDelegatedOrRevokedInSameBlock:e=>new nn(`Only one delegate/revoke per (delegator, delegate, contract) per block. Wait for the next block before retrying.`,{cause:e}),SenderCannotBeContractAddress:e=>new rn(`The contract address cannot be the caller address.`,{cause:e}),EnforcedPause:e=>new an(`The ACL contract is paused. Delegation operations are temporarily disabled.`,{cause:e}),SenderCannotBeDelegate:e=>new R(`Cannot delegate to yourself (delegate === msg.sender).`,{cause:e}),DelegateCannotBeContractAddress:e=>new H(`Delegate address cannot be the same as the contract address.`,{cause:e}),DelegateCannotBeWildcard:e=>new U(`Delegate address cannot be the wildcard address; it can only be used as the contract address.`,{cause:e}),ExpirationDateBeforeOneHour:e=>new W(`Expiration date must be at least 1 hour in the future.`,{cause:e}),ExpirationDateAlreadySetToSameValue:e=>new V(`The new expiration date is the same as the current one.`,{cause:e}),NotDelegatedYet:e=>new z(`Cannot revoke: no active delegation exists.`,{cause:e})};function wn(e){return Object.hasOwn(Q,e)}function Tn(e,t){let n=Qe(e);if(n&&wn(n))return Q[n](t);let r=e instanceof Error?e.message:String(e);for(let[e,n]of Object.entries(Q))if(r.includes(e))return n(t);return null}var En=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 W(`Expiration date must be at least 1 hour in the future`);let a=F(t),o=F(n),s=F(r);if(o===s)throw new R(`Cannot delegate to yourself (delegate === msg.sender).`);if(o===F(`0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF`))throw new U(`Delegate address cannot be the wildcard address; it can only be used as the contract address.`);if(o===a)throw new H(`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)):X,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 V(`The new expiration date (${l}) is the same as the current one. No on-chain change needed.`);return a!==F(`0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF`)&&await this.#i({contractAddress:a,delegatorAddress:s,delegateAddress:o}),this.#s({operation:`delegateDecryption`,signer:e,contractAddress:a,config:J(c,o,a,l)})}async revokeDelegation(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r}){let i=F(t),a=F(n),o=F(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 z(`No active delegation found for delegate ${a} on contract ${i}.`);return this.#s({operation:`revokeDelegation`,signer:e,contractAddress:i,config:Y(s,a,i)})}async isDelegated(e){return(await this.getStatus(e)).isActive}async getStatus(e){let t=F(e.contractAddress)===Z,[n,r]=await Promise.all([this.getDelegationExpiry(e),t?Promise.resolve(0n):this.getDelegationExpiry({...e,contractAddress:Z})]),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:Z});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!==X}#o(e,t){return e===0n?{isActive:!1,expiryTimestamp:e}:e===X?{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(cn(r,F(t),F(n),F(e)))}async#s({operation:e,signer:t,contractAddress:n,config:r}){try{return await We({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 w))return;let t=Tn(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 z||t instanceof B){let n=F(e);r.set(n,t);return}throw t}})),r}async assertDelegationActive(e,t,n){let r=F(e),i=F(t),a=F(n),{isActive:o,expiryTimestamp:s}=await this.getStatus({contractAddress:r,delegatorAddress:i,delegateAddress:a});if(!o)throw s===0n?new z(`No active delegation from ${i} to ${a} for ${r}`):new B(`Delegation from ${i} to ${a} for ${r} has expired`)}},Dn=class{#e;#t;constructor({router:e,emitEvent:t}){this.#e=e,this.#t=t}async encryptValues(t,n){let r=Date.now(),i=F(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),sn(t,`Encryption failed`)}}},On=class{#e;#t;#n;#r;#i;#a=new Set;#o;constructor(e){this.#e=e.signer,this.#t=e.router,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger,this.#e&&(this.#o=this.#e.walletAccount.subscribe(e=>{this.#s(e).catch(e=>{this.#i.warn(`wallet account handler failed`,{error:e})})}))}onWalletAccountChange(e){return this.#a.add(e),()=>{this.#a.delete(e)}}dispose(){this.#o?.(),this.#o=void 0,this.#a.clear()}async#s(e){let t=e.previous,n=e.next,r=n?.chainId;r!==void 0&&await O(`switch relayer chain`,()=>this.#t.switchChain(r),this.#i);let i=this.#r;i&&await O(`credential wallet account change`,()=>i.handleWalletAccountChange(t,n),this.#i),t&&await O(`clear decrypt cache`,()=>this.#n.clearForRequester(t.address),this.#i),await Promise.all(Array.from(this.#a,t=>O(`wallet account listener`,()=>t(e),this.#i)))}};const kn=I.object({kind:I.literal(`ConfidentialTransfer`),from:N,token:N,to:N,amount:I.bigint()}),An=I.object({kind:I.literal(`ConfidentialTransferFrom`),from:N,token:N,owner:N,to:N,amount:I.bigint()}),jn=I.object({kind:I.literal(`SetOperator`),from:N,token:N,operator:N,until:Pt}),$=I.object({kind:I.literal(`Unwrap`),from:N,token:N,to:N,amount:I.bigint()}),Mn=I.object({kind:I.literal(`UnwrapAll`),from:N,token:N,to:N}),Nn=I.object({kind:I.literal(`FinalizeUnwrap`),from:N,wrapper:N,unwrapRequestIdOrAmount:Nt}),Pn=I.object({kind:I.literal(`ApproveUnderlying`),from:N,underlying:N,spender:N,amount:I.bigint()}),Fn=I.object({kind:I.literal(`Wrap`),from:N,wrapper:N,to:N,amount:I.bigint()}),In=Nt.check(I.refine(e=>e===`0x`||en(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`)),Ln=I.object({kind:I.literal(`TransferAndCall`),from:N,underlying:N,wrapper:N,amount:I.bigint(),recipientData:I.optional(In)}),Rn=I.object({kind:I.literal(`DelegateDecryption`),from:N,contractAddress:N,delegateAddress:N,expirationDate:I.optional(I.date())}),zn=I.object({kind:I.literal(`RevokeDelegation`),from:N,contractAddress:N,delegateAddress:N});I.discriminatedUnion(`kind`,[kn,An,jn,$,Mn,Nn,Pn,Fn,Ln,Rn,zn]);const Bn=I.strictObject({maxFeePerGas:I.bigint(),maxPriorityFeePerGas:I.bigint()}),Vn=I.object({nonce:I.optional(I.int().check(I.nonnegative())),gasLimit:I.optional(I.bigint()),fees:I.optional(Bn)}),Hn=I.object({address:N,abi:I.array(I.unknown()),functionName:I.string(),args:I.array(I.unknown()),value:I.optional(I.bigint()),gas:I.optional(I.bigint())}),Un=I.extend(Vn,{from:N,calldata:Hn});var Wn=class{#e;#t;#n;constructor(e){this.#e=e.provider,this.#t=e.router,this.#n=e.encryption}async prepare(e,t){t&&=P(Vn,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=P(Un,{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=P(kn,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 Ne(e.token,e.to,r,n)}async#a(e){e=P(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-from`}),r=t[0];if(!r)throw new x(`Encryption returned no handles for ConfidentialTransferFrom`);return ve(e.token,e.owner,e.to,r,n)}#o(e){return e=P(jn,e),E(e.token,e.operator,e.until)}async#s(e){e=P($,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 ue(e.token,e.from,e.to,r,n)}async#c(e){e=P(Mn,e);let t=await this.#e.readContract(Se(e.token,e.from));return T(e.token,e.from,e.to,t)}async#l(e){e=P(Nn,e);let t=await this.#t.relayer.decryptPublicValuesWithSignatures({encryptedValues:[e.unwrapRequestIdOrAmount],options:{operation:`offline-finalize-unwrap`}}).catch(e=>{throw K(e,`Public decryption failed during FinalizeUnwrap`)}),n=t.clearValues[0]?.value;return pe(n,`FinalizeUnwrap: decryptPublicValuesWithSignatures(handle).clearValue`),Fe(e.wrapper,e.unwrapRequestIdOrAmount,n,t.checkSignaturesArgs.decryptionProof)}#u(e){return e=P(Pn,e),Te(e.underlying,e.spender,e.amount)}#d(e){return e=P(Fn,e),se(e.wrapper,e.to,e.amount)}#f(e){return e=P(Ln,e),Ze(e.underlying,e.wrapper,e.amount,e.recipientData)}#p(e){if(e=P(Rn,e),e.expirationDate&&e.expirationDate.getTime()<Date.now()+36e5)throw new W(`Expiration date must be at least 1 hour in the future`);if(e.delegateAddress===e.from)throw new R(`Cannot delegate to yourself (delegate === msg.sender).`);if(e.delegateAddress===e.contractAddress)throw new H(`Delegate address cannot be the same as the contract address (${e.contractAddress}).`);let t=e.expirationDate?BigInt(Math.floor(e.expirationDate.getTime()/1e3)):X;return J(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress,t)}#m(e){return e=P(zn,e),Y(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress)}};function Gn(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 Kn(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 qn(e){if(e===void 0)return;let t=P(Tt,e);return new Mt(typeof t==`string`?t:new Uint8Array(t))}var Jn=class{#e;provider;signer;storage;registry;permits;delegations;decryption;offline;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;constructor(e,t={}){Gn(t),Kn(t.transportKeyPairDerivationSecret);let n=qn(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 yn(e.storage,this.#i),this.#u=new En({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 M({provider:this.provider,registryAddresses:r,registryTTL:e.registryTTL}),this.#n=r,this.#t=e.registryTTL,this.#l=new At({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 Cn({cache:this.#a,credentialService:this.#l,delegationService:this.#u,router:e.router,emitEvent:this.emitEvent.bind(this)})),this.#s=new Dn({router:e.router,emitEvent:this.emitEvent.bind(this)}),this.#o=new On({signer:e.signer,router:e.router,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.#d=new Wn({provider:this.provider,router:e.router,encryption:this.#s,emitEvent:(e,t)=>this.emitEvent(e,t)}),this.permits=new dn({signer:this.signer,provider:this.provider,cachingService:this.#a,credentialService:this.#l,logger:this.#i,emitEvent:this.emitEvent.bind(this)}),this.delegations=new fn({signer:this.signer,provider:this.provider,delegationService:this.#u}),this.decryption=new pn({signer:this.signer,provider:this.provider,router:e.router,decryptionService:this.#c}),this.offline=new mn(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 M({provider:this.provider,registryAddresses:{...this.#n,...e},registryTTL:this.#t})}async encrypt(e,t){return this.#s.encryptValues(e,j(t,`encrypt`))}createToken(e){return new Ye(this,e)}createWrappedToken(e){return new mt(this,e)}dispose(){this.#o.dispose(),this.#e.dispose()}terminate(){this.dispose(),this.signer?.dispose?.()}[Symbol.dispose](){this.terminate()}};export{lt as ACL_TOPICS,an as AclPausedError,ft as AclTopics,Xe as BalanceCheckUnavailableError,jt as BaseSigner,Ve as ChainMismatchError,hn as ChromeSessionStorage,h as ConfigurationError,pn as Decryption,S as DecryptionFailedError,bt as DefaultRegistryAddresses,rn as DelegationContractIsSelfError,nn as DelegationCooldownError,U as DelegationDelegateCannotBeWildcardError,H as DelegationDelegateEqualsContractError,W as DelegationExpirationTooSoonError,B as DelegationExpiredError,V as DelegationExpiryUnchangedError,z as DelegationNotFoundError,G as DelegationNotPropagatedError,R as DelegationSelfNotAllowedError,fn as Delegations,je as ERC1363_INTERFACE_ID,ze as ERC20ReadFailedError,De as ERC7984_INTERFACE_ID,ke as ERC7984_WRAPPER_INTERFACE_ID,oe as EncryptOffloadUnavailableError,x as EncryptionFailedError,Ot as IndexedDBStorage,Be as InsufficientAllowanceError,Ke as InsufficientConfidentialBalanceError,Ue as InsufficientERC20BalanceError,_ as InvalidTransportKeyPairError,g as KeyWrappingError,X as MAX_UINT64,St as MemoryStorage,Dt as MutableWalletAccountStore,y as NoCiphertextError,L as NotEntitledError,mn as Offline,dn as Permits,ie as PreparedPermitChainMismatchError,te as PreparedPermitExpiredError,u as RelayerRequestFailedError,v as RevokedKmsContextError,k as RpcRateLimitError,fe as SignerNotConfiguredError,he as SignerRequiredError,b as SigningFailedError,re as SigningRejectedError,ot as TOKEN_TOPICS,Ye as Token,et as Topics,w as TransactionRevertedError,ae as TransportKeyPairChangedError,ne as TransportKeyPairExpiredError,_t as UnshieldAlreadyFinalizedError,Z as WILDCARD_CONTRACT,Ie as WalletAccountNotReadyError,ce as WalletNotConnectedError,mt as WrappedToken,M as WrappersRegistry,Je as ZERO_ENCRYPTED_VALUE,p as ZamaError,c as ZamaErrorCode,Jn as ZamaSDK,C as ZamaSDKEvents,ye as allowanceContract,Qt as anvil,Te as approveContract,Me as balanceOfContract,Jt as bscTestnet,Xt as chains,gn as chromeSessionStorage,yt as cleartext,Se as confidentialBalanceOfContract,xe as confidentialTotalSupplyContract,Ne as confidentialTransferContract,ve as confidentialTransferFromContract,un as createConfig,kt as createWalletAccountStore,be as decimalsContract,ut as decodeAclEvent,pt as decodeAclEvents,tt as decodeConfidentialTransfer,st as decodeDelegatedForUserDecryption,ht as decodeOnChainEvent,nt as decodeOnChainEvents,rt as decodeRevokedDelegationForUserDecryption,dt as decodeUnwrapFinalized,ct as decodeUnwrapRequested,at as decodeWrap,J as delegateForUserDecryptionContract,Fe as finalizeUnwrapContract,it as findDelegatedForUserDecryption,$e as findRevokedDelegationForUserDecryption,gt as findUnwrapRequested,vt as findWrap,Ht as getConfidentialTokenAddressContract,cn as getDelegationExpiryContract,Rt as getTokenAddressContract,Bt as getTokenPairContract,Lt as getTokenPairsContract,It as getTokenPairsLengthContract,zt as getTokenPairsSliceContract,Kt as hardhat,Ut as hoodi,Et as indexedDBStorage,ge as inferredTotalSupplyContract,Yt as ingenTestnet,Ce as isConfidentialTokenContract,Vt as isConfidentialTokenValidContract,_e as isConfidentialWrapperContract,He as isEncryptedValueZero,ln as isHandleDelegatedContract,le as isOperatorContract,n as isRetryable,Zt as mainnet,tn as matchZamaError,Ct as memoryStorage,Oe as nameContract,xt as parsePreparedPermit,Wt as polygon,qt as polygonAmoy,Pe as rateContract,d as retryAfterSeconds,Y as revokeDelegationContract,$t as sepolia,E as setOperatorContract,Ae as supportsInterfaceContract,Ee as symbolContract,Ze as transferAndCallContract,de as underlyingContract,ue as unwrapContract,T as unwrapFromBalanceContract,we as unwrapRequesterContract,se as wrapContract,Gt 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-C3jVhqSK.js";import{$ as g,A as _,B as te,C as ne,D as re,E as ie,F as v,H as ae,J as y,K as b,L as oe,M as se,O as ce,P as le,Q as ue,R as de,S as fe,T as pe,U as x,V as S,W as C,X as me,Y as he,Z as w,a as ge,b as T,c as _e,d as ve,g as ye,h as be,i as xe,j as E,k as Se,l as D,m as Ce,n as we,p as Te,q as Ee,r as De,s as Oe,t as ke,u as Ae,v as je,w as Me,x as Ne,z as Pe}from"./erc165-BAd2z3ay.js";import{n as Fe,r as O,t as k}from"./encryption-6AVd-82z.js";import{_ as A,a as j,c as Ie,d as Le,f as Re,g as ze,h as Be,l as Ve,m as He,n as Ue,o as We,p as Ge,r as Ke,s as qe,t as Je,u as Ye}from"./token-CTvEGQmH.js";import{C as Xe,T as Ze,_ as Qe,a as $e,c as et,d as tt,f as nt,g as rt,h as it,i as at,l as ot,m as st,n as ct,o as lt,p as ut,r as dt,s as ft,t as pt,u as mt,v as ht,w as gt,y as _t}from"./wrapped-token-IDUEFpZx.js";import{r as M}from"./telemetry-CBSzrmab.js";import{t as vt}from"./cleartext-DBZq4E1O.js";import{a as yt,c as bt,d as xt,f as St,i as Ct,l as wt,n as Tt,o as N,p as Et,r as Dt,s as Ot,t as kt,u as At}from"./base-signer-ClrhHzbm.js";import{n as P,r as jt,s as Mt,t as Nt}from"./primitives-Cym-3HKa.js";import{t as F}from"./validation-ClSvPh6P.js";import{a as Pt,i as Ft,n as It,o as Lt,r as Rt,s as zt,t as Bt}from"./wrappers-registry-Cm3JJeqx.js";import{a as Vt,c as Ht,i as Ut,l as Wt,n as Gt,o as Kt,r as qt,s as Jt,t as Yt,u as Xt}from"./chains-BwlDI944.js";import{getAddress as I,size as Zt}from"viem";import{z as L}from"zod/mini";function Qt(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`}},$t=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`}},en=class extends p{constructor(e,t){super(c.DelegationContractIsSelf,e,t),this.name=`DelegationContractIsSelfError`}},tn=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 nn=[k,y,u,K,C,x,R,A,b,w];function q(e,n,c={}){if(nn.some(t=>e instanceof t))return e;let d=e instanceof Error?e.message:n;if(e instanceof Error&&f(e.message))return new b(e.message,{cause:e});if(t(e))return new w(`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 A(d,{cause:e,retryAfter:i(e)});let p=m(e);return p===void 0&&ee(e)?new A(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 k(n,{cause:e})}function rn(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 O(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 an(e,t,n,r){return{address:e,abi:J,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function on(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 sn(e){return Ct(e.signer,e.provider,e)}var cn=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 S(this.#r,e)}#s(e,t){throw this.#a({type:v.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 We(`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 We(`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 j(`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 j(`clear`,this.#e,this.#t)).address);try{await e.clearCredentials()}finally{await this.#c(t)}}async#c(e){await E(`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)}},ln=class{#e;#t;#n;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.delegationService}#r(e){return S(this.#e,e)}async delegateDecryption({contractAddress:e,delegateAddress:t,expirationDate:n}){let r=this.#r(`delegateDecryption`),i=await j(`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 j(`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)}},un=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 S(this.#r,e)}async decryptValues(e,t){let n=this.#i(`decryptValues`),r=await j(`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 j(`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)=>{le(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 j(`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`})}},dn=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)}},fn=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 pn=new fn,mn=L.union([L.bigint(),L.boolean(),P]),hn=L.array(L.string());var gn=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=mn.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=hn.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 _n(e,t){let n=vn(e,t);if(!n)throw new k(`No permit covers contract ${t} after allow()`);return{privateKey:e.keypair.privateKey,publicKey:e.keypair.publicKey,serializedPermit:n.serializedPermit}}function vn(e,t){let n=Nt(t);return e.permissions.find(e=>e.contractAddresses.includes(n))}const yn=e=>new Promise(t=>setTimeout(t,e));var bn=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 yn(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(Ye(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 Ke(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(Ye(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=_n(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)Ve(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 Ie(t))m.push({contractAddress:e,encryptedValues:n});let h=Date.now(),g=u.map(e=>e.encryptedValue);try{this.#i({type:v.DecryptStart,encryptedValues:g});try{await this.#c(n,d,m,o,r)}catch(e){if(!(e instanceof w)||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 x?new w(`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:v.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:v.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 Ke(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 w)??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 k(`${e.errorMessage}: relayer returned no clear value for ${s.length} of ${r.length} handle(s) on ${n}`,{cause:AggregateError(s.map(e=>new k(`No clear value for handle ${e} on ${n}`)),`${s.length} handle(s) missing a clear value on ${n}`)})}#u(e,t){return new A(`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 k(`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 k(`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 $t(`Only one delegate/revoke per (delegator, delegate, contract) per block. Wait for the next block before retrying.`,{cause:e}),SenderCannotBeContractAddress:e=>new en(`The contract address cannot be the caller address.`,{cause:e}),EnforcedPause:e=>new tn(`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 xn(e){return Object.hasOwn($,e)}function Sn(e,t){let n=Ze(e);if(n&&xn(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 Cn=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(an(r,I(t),I(n),I(e)))}async#s({operation:e,signer:t,contractAddress:n,config:r}){try{return await Ue({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 ae))return;let t=Sn(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`)}},wn=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:v.EncryptStart},i);let e=await this.#e.relayer.encryptValues({...t,options:n});return this.#t({type:v.EncryptEnd,durationMs:Date.now()-r},i),e}catch(t){throw this.#t({type:v.EncryptError,error:e(t),durationMs:Date.now()-r},i),rn(t,`Encryption failed`)}}},Tn=class{#e;#t;#n;#r;#i;#a=new Set;#o;constructor(e){this.#e=e.signer,this.#t=e.router,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger,this.#e&&(this.#o=this.#e.walletAccount.subscribe(e=>{this.#s(e).catch(e=>{this.#i.warn(`wallet account handler failed`,{error:e})})}))}onWalletAccountChange(e){return this.#a.add(e),()=>{this.#a.delete(e)}}dispose(){this.#o?.(),this.#o=void 0,this.#a.clear()}async#s(e){let t=e.previous,n=e.next,r=n?.chainId;r!==void 0&&await E(`switch relayer chain`,()=>this.#t.switchChain(r),this.#i);let i=this.#r;i&&await E(`credential wallet account change`,()=>i.handleWalletAccountChange(t,n),this.#i),t&&await E(`clear decrypt cache`,()=>this.#n.clearForRequester(t.address),this.#i),await Promise.all(Array.from(this.#a,t=>E(`wallet account listener`,()=>t(e),this.#i)))}};const En=L.object({kind:L.literal(`ConfidentialTransfer`),from:P,token:P,to:P,amount:L.bigint()}),Dn=L.object({kind:L.literal(`ConfidentialTransferFrom`),from:P,token:P,owner:P,to:P,amount:L.bigint()}),On=L.object({kind:L.literal(`SetOperator`),from:P,token:P,operator:P,until:Mt}),kn=L.object({kind:L.literal(`Unwrap`),from:P,token:P,to:P,amount:L.bigint()}),An=L.object({kind:L.literal(`UnwrapAll`),from:P,token:P,to:P}),jn=L.object({kind:L.literal(`FinalizeUnwrap`),from:P,wrapper:P,unwrapRequestIdOrAmount:jt}),Mn=L.object({kind:L.literal(`ApproveUnderlying`),from:P,underlying:P,spender:P,amount:L.bigint()}),Nn=L.object({kind:L.literal(`Wrap`),from:P,wrapper:P,to:P,amount:L.bigint()}),Pn=jt.check(L.refine(e=>e===`0x`||Zt(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`)),Fn=L.object({kind:L.literal(`TransferAndCall`),from:P,underlying:P,wrapper:P,amount:L.bigint(),recipientData:L.optional(Pn)}),In=L.object({kind:L.literal(`DelegateDecryption`),from:P,contractAddress:P,delegateAddress:P,expirationDate:L.optional(L.date())}),Ln=L.object({kind:L.literal(`RevokeDelegation`),from:P,contractAddress:P,delegateAddress:P});L.discriminatedUnion(`kind`,[En,Dn,On,kn,An,jn,Mn,Nn,Fn,In,Ln]);const Rn=L.strictObject({maxFeePerGas:L.bigint(),maxPriorityFeePerGas:L.bigint()}),zn=L.object({nonce:L.optional(L.int().check(L.nonnegative())),gasLimit:L.optional(L.bigint()),fees:L.optional(Rn)}),Bn=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())}),Vn=L.extend(zn,{from:P,calldata:Bn});var Hn=class{#e;#t;#n;constructor(e){this.#e=e.provider,this.#t=e.router,this.#n=e.encryption}async prepare(e,t){t&&=F(zn,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(Vn,{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(En,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 O(`Encryption returned no handles for ConfidentialTransfer`);return je(e.token,e.to,r,n)}async#a(e){e=F(Dn,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 O(`Encryption returned no handles for ConfidentialTransferFrom`);return T(e.token,e.owner,e.to,r,n)}#o(e){return e=F(On,e),pe(e.token,e.operator,e.until)}async#s(e){e=F(kn,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 O(`Encryption returned no handles for Unwrap`);return re(e.token,e.from,e.to,r,n)}async#c(e){e=F(An,e);let t=await this.#e.readContract(be(e.token,e.from));return ce(e.token,e.from,e.to,t)}async#l(e){e=F(jn,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 se(n,`FinalizeUnwrap: decryptPublicValuesWithSignatures(handle).clearValue`),Ne(e.wrapper,e.unwrapRequestIdOrAmount,n,t.checkSignaturesArgs.decryptionProof)}#u(e){return e=F(Mn,e),D(e.underlying,e.spender,e.amount)}#d(e){return e=F(Nn,e),_(e.wrapper,e.to,e.amount)}#f(e){return e=F(Fn,e),Xe(e.underlying,e.wrapper,e.amount,e.recipientData)}#p(e){if(e=F(In,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(Ln,e),X(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress)}};function Un(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 Wn(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 Gn(e){if(e===void 0)return;let t=F(bt,e);return new wt(typeof t==`string`?t:new Uint8Array(t))}var Kn=class{#e;provider;signer;storage;registry;permits;delegations;decryption;offline;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;constructor(e,t={}){Un(t),Wn(t.transportKeyPairDerivationSecret);let n=Gn(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 gn(e.storage,this.#i),this.#u=new Cn({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 Ot({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 bn({cache:this.#a,credentialService:this.#l,delegationService:this.#u,router:e.router,emitEvent:this.emitEvent.bind(this)})),this.#s=new wn({router:e.router,emitEvent:this.emitEvent.bind(this)}),this.#o=new Tn({signer:e.signer,router:e.router,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.#d=new Hn({provider:this.provider,router:e.router,encryption:this.#s,emitEvent:(e,t)=>this.emitEvent(e,t)}),this.permits=new cn({signer:this.signer,provider:this.provider,cachingService:this.#a,credentialService:this.#l,logger:this.#i,emitEvent:this.emitEvent.bind(this)}),this.delegations=new ln({signer:this.signer,provider:this.provider,delegationService:this.#u}),this.decryption=new un({signer:this.signer,provider:this.provider,router:e.router,decryptionService:this.#c}),this.offline=new dn(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 Je(this,e)}createWrappedToken(e){return new pt(this,e)}dispose(){this.#o.dispose(),this.#e.dispose()}terminate(){this.dispose(),this.signer?.dispose?.()}[Symbol.dispose](){this.terminate()}};export{ct as ACL_TOPICS,tn as AclPausedError,dt as AclTopics,Le as BalanceCheckUnavailableError,kt as BaseSigner,ze as ChainMismatchError,fn as ChromeSessionStorage,h as ConfigurationError,un as Decryption,k as DecryptionFailedError,yt as DefaultRegistryAddresses,en as DelegationContractIsSelfError,$t 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,ln as Delegations,ke as ERC1363_INTERFACE_ID,Re as ERC20ReadFailedError,we as ERC7984_INTERFACE_ID,De as ERC7984_WRAPPER_INTERFACE_ID,Fe as EncryptOffloadUnavailableError,O as EncryptionFailedError,St as IndexedDBStorage,Ge as InsufficientAllowanceError,He as InsufficientConfidentialBalanceError,Be as InsufficientERC20BalanceError,b as InvalidTransportKeyPairError,Ee as KeyWrappingError,Z as MAX_UINT64,At as MemoryStorage,Tt as MutableWalletAccountStore,y as NoCiphertextError,R as NotEntitledError,dn as Offline,cn as Permits,he as PreparedPermitChainMismatchError,me as PreparedPermitExpiredError,u as RelayerRequestFailedError,w as RevokedKmsContextError,A as RpcRateLimitError,oe as SignerNotConfiguredError,de as SignerRequiredError,x as SigningFailedError,C as SigningRejectedError,at as TOKEN_TOPICS,Je as Token,$e as Topics,ae as TransactionRevertedError,ue as TransportKeyPairChangedError,g as TransportKeyPairExpiredError,gt as UnshieldAlreadyFinalizedError,Q as WILDCARD_CONTRACT,Pe as WalletAccountNotReadyError,te as WalletNotConnectedError,pt as WrappedToken,N as WrappersRegistry,qe as ZERO_ENCRYPTED_VALUE,p as ZamaError,c as ZamaErrorCode,Kn as ZamaSDK,v as ZamaSDKEvents,_e as allowanceContract,Yt as anvil,D as approveContract,Ae as balanceOfContract,Gt as bscTestnet,qt as chains,pn as chromeSessionStorage,vt as cleartext,be as confidentialBalanceOfContract,ye as confidentialTotalSupplyContract,je as confidentialTransferContract,T as confidentialTransferFromContract,sn as createConfig,Dt as createWalletAccountStore,ve as decimalsContract,lt as decodeAclEvent,ft as decodeAclEvents,et as decodeConfidentialTransfer,ot as decodeDelegatedForUserDecryption,mt as decodeOnChainEvent,tt as decodeOnChainEvents,nt as decodeRevokedDelegationForUserDecryption,ut as decodeUnwrapFinalized,st as decodeUnwrapRequested,it as decodeWrap,Y as delegateForUserDecryptionContract,Ne as finalizeUnwrapContract,rt as findDelegatedForUserDecryption,Qe as findRevokedDelegationForUserDecryption,ht as findUnwrapRequested,_t as findWrap,Bt as getConfidentialTokenAddressContract,an as getDelegationExpiryContract,It as getTokenAddressContract,Rt as getTokenPairContract,Ft as getTokenPairsContract,Pt as getTokenPairsLengthContract,Lt as getTokenPairsSliceContract,Ut as hardhat,Vt as hoodi,Et as indexedDBStorage,fe as inferredTotalSupplyContract,xe as isConfidentialTokenContract,zt as isConfidentialTokenValidContract,ge as isConfidentialWrapperContract,Ve as isEncryptedValueZero,on as isHandleDelegatedContract,ne as isOperatorContract,n as isRetryable,Kt as mainnet,Qt as matchZamaError,xt as memoryStorage,Te as nameContract,Jt as polygon,Ht as polygonAmoy,Me as rateContract,d as retryAfterSeconds,X as revokeDelegationContract,Wt as sepolia,pe as setOperatorContract,Oe as supportsInterfaceContract,Ce as symbolContract,Xe as transferAndCallContract,ie as underlyingContract,re as unwrapContract,ce as unwrapFromBalanceContract,Se as unwrapRequesterContract,_ as wrapContract,Xt as zenithTrexTestnet};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|