@zama-fhe/sdk 3.7.0-beta.2 → 3.7.0-beta.3

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.
Files changed (38) hide show
  1. package/dist/cjs/base-signer.cjs +1 -1
  2. package/dist/cjs/base-signer.cjs.map +1 -1
  3. package/dist/cjs/chains/index.cjs +1 -1
  4. package/dist/cjs/chains.cjs +1 -1
  5. package/dist/cjs/chains.cjs.map +1 -1
  6. package/dist/cjs/index.cjs +1 -1
  7. package/dist/cjs/node/index.cjs +1 -1
  8. package/dist/esm/{base-signer-DIYZwDnc.d.ts → base-signer-D902THgk.d.ts} +2 -2
  9. package/dist/esm/base-signer-ws-wq22y.js +2 -0
  10. package/dist/esm/{base-signer-D5Cwv7yb.js.map → base-signer-ws-wq22y.js.map} +1 -1
  11. package/dist/esm/chains/index.d.ts +2 -2
  12. package/dist/esm/chains/index.js +1 -1
  13. package/dist/esm/{chains-ByyCdrrd.js → chains-iPpnjXql.js} +2 -2
  14. package/dist/esm/{chains-ByyCdrrd.js.map → chains-iPpnjXql.js.map} +1 -1
  15. package/dist/esm/cleartext/index.d.ts +2 -2
  16. package/dist/esm/{cleartext-3HOk1BAg.d.ts → cleartext-B6vrnBzO.d.ts} +2 -2
  17. package/dist/esm/ethers/index.d.ts +4 -4
  18. package/dist/esm/ethers/index.js +1 -1
  19. package/dist/esm/{index-ijgDL4IC.d.ts → index-Cdbp_93f.d.ts} +24 -4
  20. package/dist/esm/{index-DJYq1rAB.d.ts → index-CnIEp8zv.d.ts} +1521 -1080
  21. package/dist/esm/{index-BHrjck_q.d.ts → index-CsuDB4UI.d.ts} +4 -4
  22. package/dist/esm/index.d.ts +99 -8
  23. package/dist/esm/index.js +1 -1
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/node/index.d.ts +5 -5
  26. package/dist/esm/node/index.js +1 -1
  27. package/dist/esm/node/index.js.map +1 -1
  28. package/dist/esm/query/index.d.ts +4 -495
  29. package/dist/esm/{types-Bz5-wHPv.d.ts → types-Crf7ymyj.d.ts} +2 -2
  30. package/dist/esm/{types-v0_sfkli.d.ts → types-CuldbZne.d.ts} +3 -3
  31. package/dist/esm/{types-CI6BtpB7.d.ts → types-DnJSNoEC.d.ts} +3 -3
  32. package/dist/esm/vaults/index.d.ts +2 -3
  33. package/dist/esm/viem/index.d.ts +4 -4
  34. package/dist/esm/viem/index.js +1 -1
  35. package/dist/esm/web/index.d.ts +1 -1
  36. package/package.json +1 -1
  37. package/dist/esm/base-signer-D5Cwv7yb.js +0 -2
  38. package/dist/esm/invalidation-CJ-pzOUG.d.ts +0 -46
@@ -1,6 +1,6 @@
1
- import "./index-ijgDL4IC.js";
2
- import { c as GenericStorage, n as RelayerConfig, pn as RelayerOptions } from "./types-Bz5-wHPv.js";
3
- import "./cleartext-3HOk1BAg.js";
1
+ import "./index-Cdbp_93f.js";
2
+ import { c as GenericStorage, n as RelayerConfig, pn as RelayerOptions } from "./types-Crf7ymyj.js";
3
+ import "./cleartext-B6vrnBzO.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 {
@@ -58,4 +58,4 @@ declare class AsyncLocalMapStorage implements GenericStorage {
58
58
  declare const asyncLocalStorage: AsyncLocalMapStorage;
59
59
  //#endregion
60
60
  export { node as i, asyncLocalStorage as n, NodeRelayerConfig as r, AsyncLocalMapStorage as t };
61
- //# sourceMappingURL=index-BHrjck_q.d.ts.map
61
+ //# sourceMappingURL=index-CsuDB4UI.d.ts.map
@@ -1,8 +1,99 @@
1
- import { a as hoodi, c as polygon, d as AtLeastOneChain, f as FheChain, i as hardhat, l as polygonAmoy, n as bscTestnet, o as ingenTestnet, p as FheChainAuth, r as chains, s as mainnet, t as anvil, u as sepolia } from "./index-ijgDL4IC.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, gt as ApprovalStrategy, h as PrepareFees, hn as TypedValue, 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 RelayerSDK, 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-Bz5-wHPv.js";
3
- import { t as cleartext } from "./cleartext-3HOk1BAg.js";
4
- import { t as ZamaConfigEthers } from "./types-v0_sfkli.js";
5
- import { n as MutableWalletAccountStore, r as createWalletAccountStore, t as BaseSigner } from "./base-signer-DIYZwDnc.js";
6
- import { $ as BalanceErrorDetails, $t as ERC7984_INTERFACE_ID, A as BatchDecryptAsOptions, At as Permission, B as TransactionRevertedError, Bt as getConfidentialTokenAddressContract, C as ZamaSDKOptions, Cn as wrapContract, Ct as TransportKeyPairChangedError, D as WrappersRegistryConfig, Dt as ZamaErrorCode, E as WrappersRegistry, Et as ZamaError, F as Permits, Ft as SerializedTransportKeyPair, G as SignerRequiredError, Gt as getTokenPairsSliceContract, H as SigningFailedError, Ht as getTokenPairContract, I as ErrorForCode, It as ChecksummedAddress, J as RpcRateLimitError, Jt as getDelegationExpiryContract, K as WalletAccountNotReadyError, Kt as isConfidentialTokenValidContract, L as matchZamaError, Lt as PaginatedResult, M as Offline, Mt as PreparedPermit, N as Delegations, Nt as SerializedPermit, O as WrappedToken, Ot as isRetryable, P as DelegationStatus, Pt as SerializedPermitEip712, Q as BalanceCheckUnavailableError, Qt as ERC1363_INTERFACE_ID, R as UnshieldAlreadyFinalizedDetails, Rt as TokenWrapperPair, S as ZamaSDK, Sn as unwrapRequesterContract, St as RevokedKmsContextError, T as ListPairsOptions, Tt as ChainMismatchError, U as SigningRejectedError, Ut as getTokenPairsContract, V as SigningErrorMetadata, Vt as getTokenAddressContract, W as SignerNotConfiguredError, Wt as getTokenPairsLengthContract, X as ConfigurationError, Xt as revokeDelegationContract, Y as NotEntitledError, Yt as isHandleDelegatedContract, Z as RelayerRequestFailedError, Zt as transferAndCallContract, _n as rateContract, _t as InvalidTransportKeyPairError, a as ChromeSessionStorage, an as approveContract, at as EncryptOffloadUnavailableError, bn as unwrapContract, bt as PreparedPermitChainMismatchError, c as indexedDBStorage, cn as nameContract, ct as DelegationContractIsSelfError, d as Decryption, dn as confidentialTotalSupplyContract, dt as DelegationExpirationTooSoonError, en as ERC7984_WRAPPER_INTERFACE_ID, et as ERC20ReadFailedError, f as BatchDecryptItem, fn as confidentialTransferContract, ft as DelegationExpiredError, g as EncryptedInput, gn as isOperatorContract, gt as DelegationSelfNotAllowedError, h as DecryptResult, hn as inferredTotalSupplyContract, ht as DelegationNotPropagatedError, i as isEncryptedValueZero, in as allowanceContract, it as DecryptionFailedError, j as Token, jt as PreparePermitRequest, k as BatchBalancesResult, kt as retryAfterSeconds, l as MemoryStorage, ln as symbolContract, lt as DelegationCooldownError, m as DelegatedDecryptOptions, mn as finalizeUnwrapContract, mt as DelegationNotFoundError, n as Hex, nn as isConfidentialWrapperContract, nt as InsufficientConfidentialBalanceError, o as chromeSessionStorage, on as balanceOfContract, ot as EncryptionFailedError, p as BatchDecryptResult, pn as confidentialTransferFromContract, pt as DelegationExpiryUnchangedError, q as WalletNotConnectedError, qt as delegateForUserDecryptionContract, r as ZERO_ENCRYPTED_VALUE, rn as supportsInterfaceContract, rt as InsufficientERC20BalanceError, s as IndexedDBStorage, sn as decimalsContract, st as AclPausedError, t as Address, tn as isConfidentialTokenContract, tt as InsufficientAllowanceError, u as memoryStorage, un as confidentialBalanceOfContract, ut as DelegationDelegateEqualsContractError, vn as setOperatorContract, vt as KeyWrappingError, w as DefaultRegistryAddresses, wn as createConfig, wt as TransportKeyPairExpiredError, xn as unwrapFromBalanceContract, xt as PreparedPermitExpiredError, yn as underlyingContract, yt as NoCiphertextError, z as UnshieldAlreadyFinalizedError, zt as TokenWrapperPairWithMetadata } from "./index-DJYq1rAB.js";
7
- import { t as ZamaConfigViem } from "./types-CI6BtpB7.js";
8
- 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, 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, 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 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, 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, 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, ingenTestnet, 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 };
1
+ import { a as hoodi, c as polygon, d as zenithTrexTestnet, f as AtLeastOneChain, i as hardhat, l as polygonAmoy, m as FheChainAuth, n as bscTestnet, o as ingenTestnet, p as FheChain, r as chains, s as mainnet, t as anvil, u as sepolia } from "./index-Cdbp_93f.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, gt as ApprovalStrategy, h as PrepareFees, hn as TypedValue, 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 RelayerSDK, 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-Crf7ymyj.js";
3
+ import { t as cleartext } from "./cleartext-B6vrnBzO.js";
4
+ import { t as ZamaConfigEthers } from "./types-CuldbZne.js";
5
+ import { n as MutableWalletAccountStore, r as createWalletAccountStore, t as BaseSigner } from "./base-signer-D902THgk.js";
6
+ import { $n as DelegationSelfNotAllowedError, $r as isOperatorContract, An as WalletNotConnectedError, Ar as delegateForUserDecryptionContract, Bn as InsufficientERC20BalanceError, Br as supportsInterfaceContract, Bt as WrappersRegistryConfig, Cn as TransactionRevertedError, Cr as getConfidentialTokenAddressContract, Dn as SignerNotConfiguredError, Dr as getTokenPairsLengthContract, Dt as BatchDecryptAsOptions, En as SigningRejectedError, Er as getTokenPairsContract, Et as BatchBalancesResult, Fn as BalanceCheckUnavailableError, Fr as ERC1363_INTERFACE_ID, Gn as DelegationContractIsSelfError, Gr as nameContract, Hn as EncryptOffloadUnavailableError, Hr as approveContract, In as BalanceErrorDetails, Ir as ERC7984_INTERFACE_ID, Jn as DelegationExpirationTooSoonError, Jr as confidentialTotalSupplyContract, Kn as DelegationCooldownError, Kr as symbolContract, Ln as ERC20ReadFailedError, Lr as ERC7984_WRAPPER_INTERFACE_ID, Lt as DefaultRegistryAddresses, Mn as NotEntitledError, Mr as isHandleDelegatedContract, Nn as ConfigurationError, Nr as revokeDelegationContract, On as SignerRequiredError, Or as getTokenPairsSliceContract, Ot as Token, Pn as RelayerRequestFailedError, Pr as transferAndCallContract, Qn as DelegationNotPropagatedError, Qr as inferredTotalSupplyContract, Rn as InsufficientAllowanceError, Rr as isConfidentialTokenContract, Rt as ListPairsOptions, Sn as UnshieldAlreadyFinalizedError, Sr as TokenWrapperPairWithMetadata, Tn as SigningFailedError, Tr as getTokenPairContract, Tt as WrappedToken, Un as EncryptionFailedError, Ur as balanceOfContract, Vn as DecryptionFailedError, Vr as allowanceContract, Wn as AclPausedError, Wr as decimalsContract, Xn as DelegationExpiryUnchangedError, Xr as confidentialTransferFromContract, Yn as DelegationExpiredError, Yr as confidentialTransferContract, Zn as DelegationNotFoundError, Zr as finalizeUnwrapContract, _n as DelegationStatus, _r as SerializedPermitEip712, a as ZamaSDK, ai as unwrapRequesterContract, ar as RevokedKmsContextError, bn as matchZamaError, br as PaginatedResult, c as BatchDecryptItem, cr as ChainMismatchError, dr as isRetryable, ei as rateContract, er as InvalidTransportKeyPairError, fr as retryAfterSeconds, gn as Delegations, gr as SerializedPermit, hr as PreparedPermit, ii as unwrapFromBalanceContract, ir as PreparedPermitExpiredError, jn as RpcRateLimitError, jr as getDelegationExpiryContract, kn as WalletAccountNotReadyError, kr as isConfidentialTokenValidContract, l as BatchDecryptResult, lr as ZamaError, mr as PreparePermitRequest, n as DecryptResult, ni as underlyingContract, nr as NoCiphertextError, o as ZamaSDKOptions, oi as wrapContract, or as TransportKeyPairChangedError, pr as Permission, qn as DelegationDelegateEqualsContractError, qr as confidentialBalanceOfContract, r as EncryptedInput, ri as unwrapContract, rr as PreparedPermitChainMismatchError, s as Offline, si as createConfig, sr as TransportKeyPairExpiredError, t as Decryption, ti as setOperatorContract, tr as KeyWrappingError, u as DelegatedDecryptOptions, ur as ZamaErrorCode, vn as Permits, vr as SerializedTransportKeyPair, wn as SigningErrorMetadata, wr as getTokenAddressContract, xn as UnshieldAlreadyFinalizedDetails, xr as TokenWrapperPair, yn as ErrorForCode, yr as ChecksummedAddress, zn as InsufficientConfidentialBalanceError, zr as isConfidentialWrapperContract, zt as WrappersRegistry } from "./index-CnIEp8zv.js";
7
+ import { t as ZamaConfigViem } from "./types-DnJSNoEC.js";
8
+ import { Address, Hex } from "viem";
9
+ //#region src/storage/memory-storage.d.ts
10
+ /** In-memory credential store. Credentials are lost on page reload. */
11
+ declare class MemoryStorage implements GenericStorage {
12
+ #private;
13
+ /**
14
+ * Retrieve a value by key.
15
+ * @returns The stored value, or `null` if the key does not exist.
16
+ */
17
+ get<T = unknown>(key: string): Promise<T | null>;
18
+ /** Store a value under the given key, overwriting any existing entry. */
19
+ set<T = unknown>(key: string, value: T): Promise<void>;
20
+ /** Remove the entry for the given key (no-op if absent). */
21
+ delete(key: string): Promise<void>;
22
+ }
23
+ /** Default singleton for application-wide use. */
24
+ declare const memoryStorage: MemoryStorage;
25
+ //#endregion
26
+ //#region src/storage/indexeddb-storage.d.ts
27
+ /**
28
+ * IndexedDB-backed {@link GenericStorage}.
29
+ *
30
+ * Stores keypair and permit objects keyed by a hashed wallet address. The
31
+ * SDK delegates security to the storage backend — values are persisted
32
+ * verbatim with no SDK-layer encryption.
33
+ */
34
+ declare class IndexedDBStorage implements GenericStorage {
35
+ #private;
36
+ constructor(dbName?: string, dbVersion?: number, storeName?: string);
37
+ /**
38
+ * Retrieve a value by key.
39
+ * @returns The stored value, or `null` if the key does not exist.
40
+ */
41
+ get<T = unknown>(key: string): Promise<T | null>;
42
+ /** Store a value under the given key, overwriting any existing entry. */
43
+ set<T = unknown>(key: string, value: T): Promise<void>;
44
+ /** Remove the entry for the given key (no-op if absent). */
45
+ delete(key: string): Promise<void>;
46
+ /** Remove all stored entries. */
47
+ clear(): Promise<void>;
48
+ }
49
+ /** Default singleton for application-wide use. */
50
+ declare const indexedDBStorage: IndexedDBStorage;
51
+ //#endregion
52
+ //#region src/storage/chrome-session-storage.d.ts
53
+ /**
54
+ * {@link GenericStorage} backed by `chrome.storage.session`.
55
+ *
56
+ * Use this in MV3 web extensions so the wallet signature survives
57
+ * service worker restarts and is shared across popup, background,
58
+ * and content script contexts.
59
+ *
60
+ * @example
61
+ * ```ts
62
+ * import { ZamaSDK, indexedDBStorage, chromeSessionStorage } from "@zama-fhe/sdk";
63
+ * import { createConfig } from "@zama-fhe/sdk/viem";
64
+ *
65
+ * const config = createConfig({
66
+ * chains: [mySepolia],
67
+ * publicClient,
68
+ * walletClient,
69
+ * relayers: { [mySepolia.id]: web() },
70
+ * storage: indexedDBStorage, // encrypted transport key pair — persistent
71
+ * permitStorage: chromeSessionStorage, // signed permits — ephemeral
72
+ * });
73
+ * const sdk = new ZamaSDK(config);
74
+ * ```
75
+ */
76
+ declare class ChromeSessionStorage implements GenericStorage {
77
+ /**
78
+ * Retrieve a value by key.
79
+ * @returns The stored value, or `null` if the key does not exist.
80
+ */
81
+ get<T = unknown>(key: string): Promise<T | null>;
82
+ /** Store a value under the given key, overwriting any existing entry. */
83
+ set(key: string, value: unknown): Promise<void>;
84
+ /** Remove the entry for the given key (no-op if absent). */
85
+ delete(key: string): Promise<void>;
86
+ }
87
+ /** Default singleton for application-wide use. */
88
+ declare const chromeSessionStorage: ChromeSessionStorage;
89
+ //#endregion
90
+ //#region src/utils/handles.d.ts
91
+ /** All-zero encrypted-value sentinel — a 32-byte zero handle representing the cleartext value `0`. */
92
+ declare const ZERO_ENCRYPTED_VALUE: "0x0000000000000000000000000000000000000000000000000000000000000000";
93
+ /**
94
+ * Check whether an encrypted value represents the zero value.
95
+ */
96
+ declare function isEncryptedValueZero(encryptedValue: string): boolean;
97
+ //#endregion
98
+ 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, 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, 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 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, 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, 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, ingenTestnet, 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 };
99
+ //# 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-CVKO9GmQ.js";import{A as g,B as _,C as te,D as v,E as ne,F as re,G as y,I as ie,J as b,K as ae,L as oe,M as x,O as se,P as ce,R as S,S as le,T as ue,U as C,V as de,W as fe,X as pe,Y as me,a as he,b as ge,c as _e,d as ve,g as ye,h as be,i as xe,j as w,k as Se,l as T,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 E,w as je,x as D,z as O}from"./erc165-DbMOt-s6.js";import{n as Me,r as k,t as A}from"./encryption-BKoalB4o.js";import{_ as j,a as M,c as Ne,d as Pe,f as Fe,g as Ie,h as Le,l as Re,m as ze,n as Be,o as Ve,p as He,r as Ue,s as We,t as Ge,u as Ke}from"./token-CRJ8eCr7.js";import{C as qe,T as Je,_ as Ye,a as Xe,c as Ze,d as Qe,f as $e,g as et,h as tt,i as nt,l as rt,m as it,n as at,o as ot,p as st,r as ct,s as lt,t as ut,u as dt,v as ft,w as pt,y as mt}from"./wrapped-token-BOtzaSAY.js";import{t as ht}from"./cleartext-PCpNqRGV.js";import{a as gt,c as _t,d as vt,f as yt,i as bt,l as xt,n as St,o as N,p as Ct,r as wt,s as Tt,t as Et,u as Dt}from"./base-signer-D5Cwv7yb.js";import{n as P,r as Ot,s as kt,t as At}from"./primitives-Cym-3HKa.js";import{t as F}from"./validation-BRu06AM_.js";import{a as jt,i as Mt,n as Nt,o as Pt,r as Ft,s as It,t as Lt}from"./wrappers-registry-Cm3JJeqx.js";import{a as Rt,c as zt,i as Bt,l as Vt,n as Ht,o as Ut,r as Wt,s as Gt,t as Kt,u as qt}from"./chains-ByyCdrrd.js";import{r as Jt,t as Yt}from"./assertions-Ca1ePdRJ.js";import{getAddress as I,size as Xt}from"viem";import{z as L}from"zod/mini";function Zt(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`}},B=class extends p{constructor(e,t){super(c.DelegationCooldown,e,t),this.name=`DelegationCooldownError`}},V=class extends p{constructor(e,t){super(c.DelegationNotFound,e,t),this.name=`DelegationNotFoundError`}},H=class extends p{constructor(e,t){super(c.DelegationExpired,e,t),this.name=`DelegationExpiredError`}},U=class extends p{constructor(e,t){super(c.DelegationExpiryUnchanged,e,t),this.name=`DelegationExpiryUnchangedError`}},W=class extends p{constructor(e,t){super(c.DelegationDelegateEqualsContract,e,t),this.name=`DelegationDelegateEqualsContractError`}},Qt=class extends p{constructor(e,t){super(c.DelegationContractIsSelf,e,t),this.name=`DelegationContractIsSelfError`}},$t=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 en=[A,y,u,K,de,_,R,j,C,b];function q(e,n,c={}){if(en.some(t=>e instanceof t))return e;let d=e instanceof Error?e.message:n;if(e instanceof Error&&f(e.message))return new C(e.message,{cause:e});if(t(e))return new b(`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 j(d,{cause:e,retryAfter:i(e)});let p=m(e);return p===void 0&&ee(e)?new j(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 A(n,{cause:e})}function tn(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 k(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 nn(e,t,n,r){return{address:e,abi:J,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function rn(e,t,n,r,i){return{address:e,abi:J,functionName:`isHandleDelegatedForUserDecryption`,args:[t,n,r,i]}}const Z=2n**64n-1n;function an(e){return bt(e.signer,e.provider,e)}var on=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:x.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 Ve(`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 Ve(`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)}async registerPermit(e,t){let n;try{n=this.#o(`registerPermit`)}catch(e){this.#s(`registerPermit`,e)}await n.registerPermit(e,t),await this.#c(e.signerAddress)}async revokePermits(e){let t=this.#o(`revokePermits`),n=I((await M(`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 M(`clear`,this.#e,this.#t)).address);try{await e.clearCredentials()}finally{await this.#c(t)}}async#c(e){await w(`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)}},sn=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 M(`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 M(`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)}},cn=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 M(`decryptValues`,this.#e,this.#t);return n.decryptValues(e,r.address,t)}async delegatedDecryptValues(e,t,n=t,r){let i=this.#i(`delegatedDecryptValues`),a=await M(`delegatedDecryptValues`,this.#e,this.#t);return i.delegatedDecryptValues(e,t,a.address,n,r)}async decryptPublicValues(e,t){if(e.length===0)return{clearValues:{},decryptionProof:`0x`,abiEncodedClearValues:`0x`};try{let n=await this.#n.relayer.decryptPublicValuesWithSignatures({encryptedValues:e,options:t}),r={};return n.checkSignaturesArgs.handlesList.forEach((e,t)=>{Jt(n.clearValues[t],`result.clearValues[${t}]`),r[e]=n.clearValues[t].value}),{clearValues:r,abiEncodedClearValues:n.checkSignaturesArgs.abiEncodedCleartexts,decryptionProof:n.checkSignaturesArgs.decryptionProof}}catch(e){throw q(e,`Public decryption failed`)}}async delegatedBatchDecryptValues({encryptedInputs:e,delegatorAddress:t,accountAddress:n=t,maxConcurrency:r,waitForPropagation:i}){let a=this.#i(`delegatedBatchDecryptValues`),o=await M(`delegatedBatchDecryptValues`,this.#e,this.#t);return a.delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:o.address,accountAddress:n,maxConcurrency:r,waitForPropagation:i})}},ln=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)}},un=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 dn=new un,fn=L.union([L.bigint(),L.boolean(),P]),pn=L.array(L.string());var mn=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=fn.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=pn.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 hn(e,t){let n=gn(e,t);if(!n)throw new A(`No permit covers contract ${t} after allow()`);return{privateKey:e.keypair.privateKey,publicKey:e.keypair.publicKey,serializedPermit:n.serializedPermit}}function gn(e,t){let n=At(t);return e.permissions.find(e=>e.contractAddresses.includes(n))}const _n=e=>new Promise(t=>setTimeout(t,e));var vn=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`},void 0,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 _n(2e3)}throw n}async delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:n,accountAddress:r,maxConcurrency:i=5,waitForPropagation:a=!0}){let o=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:I(e.contractAddress)}));if(o.length===0)return{items:o};let s=I(r);try{let e=await this.delegatedDecryptValues(o.map(({encryptedValue:e,contractAddress:t})=>({encryptedValue:e,contractAddress:t})),t,n,s,{waitForPropagation:a});for(let t of o)this.#d(t,e);return{items:o}}catch(e){if(Ke(e))throw e;if(o.length===1){let[n=this.#p()]=o;return n.error=this.#f(e,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:n.contractAddress,account:I(t)}),{items:o}}}let c=!1,l;if(await Ue(o.map(e=>async()=>{if(!c)try{let r=await this.delegatedDecryptValues([{encryptedValue:e.encryptedValue,contractAddress:e.contractAddress}],t,n,s,{waitForPropagation:!1});this.#d(e,r)}catch(n){if(Ke(n)){c=!0,l??=n;return}e.error=this.#f(n,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:e.contractAddress,account:I(t)})}}),i),l!==void 0)throw l;return{items:o}}async#o(e,t,n,r){let i=hn(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)Re(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 Ne(t))m.push({contractAddress:e,encryptedValues:n});let h=Date.now(),g=u.map(e=>e.encryptedValue);try{this.#i({type:x.DecryptStart,encryptedValues:g});try{await this.#c(n,d,m,o,r)}catch(e){if(!(e instanceof b)||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 _?new b(`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:x.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:x.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 Ue(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 b)??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 A(`${e.errorMessage}: relayer returned no clear value for ${s.length} of ${r.length} handle(s) on ${n}`,{cause:AggregateError(s.map(e=>new A(`No clear value for handle ${e} on ${n}`)),`${s.length} handle(s) missing a clear value on ${n}`)})}#u(e,t){return new j(`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 A(`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 A(`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 B(`Only one delegate/revoke per (delegator, delegate, contract) per block. Wait for the next block before retrying.`,{cause:e}),SenderCannotBeContractAddress:e=>new Qt(`The contract address cannot be the caller address.`,{cause:e}),EnforcedPause:e=>new $t(`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 W(`Delegate address cannot be the same 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 U(`The new expiration date is the same as the current one.`,{cause:e}),NotDelegatedYet:e=>new V(`Cannot revoke: no active delegation exists.`,{cause:e})};function yn(e){return Object.hasOwn(Q,e)}function bn(e,t){let n=Je(e);if(n&&yn(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 xn=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===a)throw new W(`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 U(`The new expiration date (${l}) is the same as the current one. No on-chain change needed.`);return this.#i({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 V(`No active delegation found for delegate ${a} on contract ${i}.`);return this.#i({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=await this.getDelegationExpiry(e);return t===0n?{isActive:!1,expiryTimestamp:t}:t===Z?{isActive:!0,expiryTimestamp:t}:{isActive:t>await this.#t.getBlockTimestamp(),expiryTimestamp:t}}async getDelegationExpiry({contractAddress:e,delegatorAddress:t,delegateAddress:n}){let r=this.#e.relayer.chain.aclContractAddress;return this.#t.readContract(nn(r,I(t),I(n),I(e)))}async#i({operation:e,signer:t,contractAddress:n,config:r}){try{return await Be({operation:e,signer:t,provider:this.#t,config:r,emit:e=>this.#n(e,n),logger:this.#r})}catch(e){throw this.#a(e),e}}#a(e){if(!(e instanceof O))return;let t=bn(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 V||t instanceof H){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 V(`No active delegation from ${i} to ${a} for ${r}`):new H(`Delegation from ${i} to ${a} for ${r} has expired`)}},Sn=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:x.EncryptStart},i);let e=await this.#e.relayer.encryptValues({...t,options:n});return this.#t({type:x.EncryptEnd,durationMs:Date.now()-r},i),e}catch(t){throw this.#t({type:x.EncryptError,error:e(t),durationMs:Date.now()-r},i),tn(t,`Encryption failed`)}}},Cn=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 w(`switch relayer chain`,()=>this.#t.switchChain(r),this.#i);let i=this.#r;i&&await w(`credential wallet account change`,()=>i.handleWalletAccountChange(t,n),this.#i),t&&await w(`clear decrypt cache`,()=>this.#n.clearForRequester(t.address),this.#i),await Promise.all(Array.from(this.#a,t=>w(`wallet account listener`,()=>t(e),this.#i)))}};const $=L.object({kind:L.literal(`ConfidentialTransfer`),from:P,token:P,to:P,amount:L.bigint()}),wn=L.object({kind:L.literal(`ConfidentialTransferFrom`),from:P,token:P,owner:P,to:P,amount:L.bigint()}),Tn=L.object({kind:L.literal(`SetOperator`),from:P,token:P,operator:P,until:kt}),En=L.object({kind:L.literal(`Unwrap`),from:P,token:P,to:P,amount:L.bigint()}),Dn=L.object({kind:L.literal(`UnwrapAll`),from:P,token:P,to:P}),On=L.object({kind:L.literal(`FinalizeUnwrap`),from:P,wrapper:P,unwrapRequestIdOrAmount:Ot}),kn=L.object({kind:L.literal(`ApproveUnderlying`),from:P,underlying:P,spender:P,amount:L.bigint()}),An=L.object({kind:L.literal(`Wrap`),from:P,wrapper:P,to:P,amount:L.bigint()}),jn=Ot.check(L.refine(e=>e===`0x`||Xt(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`)),Mn=L.object({kind:L.literal(`TransferAndCall`),from:P,underlying:P,wrapper:P,amount:L.bigint(),recipientData:L.optional(jn)}),Nn=L.object({kind:L.literal(`DelegateDecryption`),from:P,contractAddress:P,delegateAddress:P,expirationDate:L.optional(L.date())}),Pn=L.object({kind:L.literal(`RevokeDelegation`),from:P,contractAddress:P,delegateAddress:P});L.discriminatedUnion(`kind`,[$,wn,Tn,En,Dn,On,kn,An,Mn,Nn,Pn]);const Fn=L.strictObject({maxFeePerGas:L.bigint(),maxPriorityFeePerGas:L.bigint()}),In=L.object({nonce:L.optional(L.int().check(L.nonnegative())),gasLimit:L.optional(L.bigint()),fees:L.optional(Fn)}),Ln=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())}),Rn=L.extend(In,{from:P,calldata:Ln});var zn=class{#e;#t;#n;constructor(e){this.#e=e.provider,this.#t=e.router,this.#n=e.encryption}async prepare(e,t){t&&=F(In,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(Rn,{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($,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from}),r=t[0];if(!r)throw new k(`Encryption returned no handles for ConfidentialTransfer`);return E(e.token,e.to,r,n)}async#a(e){e=F(wn,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from}),r=t[0];if(!r)throw new k(`Encryption returned no handles for ConfidentialTransferFrom`);return ge(e.token,e.owner,e.to,r,n)}#o(e){return e=F(Tn,e),ue(e.token,e.operator,e.until)}async#s(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}),r=t[0];if(!r)throw new k(`Encryption returned no handles for Unwrap`);return v(e.token,e.from,e.to,r,n)}async#c(e){e=F(Dn,e);let t=await this.#e.readContract(be(e.token,e.from));return se(e.token,e.from,e.to,t)}async#l(e){e=F(On,e);let t=await this.#t.relayer.decryptPublicValuesWithSignatures({encryptedValues:[e.unwrapRequestIdOrAmount]}).catch(e=>{throw q(e,`Public decryption failed during FinalizeUnwrap`)}),n=t.clearValues[0]?.value;return Yt(n,`FinalizeUnwrap: decryptPublicValuesWithSignatures(handle).clearValue`),D(e.wrapper,e.unwrapRequestIdOrAmount,n,t.checkSignaturesArgs.decryptionProof)}#u(e){return e=F(kn,e),T(e.underlying,e.spender,e.amount)}#d(e){return e=F(An,e),g(e.wrapper,e.to,e.amount)}#f(e){return e=F(Mn,e),qe(e.underlying,e.wrapper,e.amount,e.recipientData)}#p(e){if(e=F(Nn,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 W(`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(Pn,e),X(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress)}};function Bn(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 Vn(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 Hn(e){if(e===void 0)return;let t=F(_t,e);return new xt(typeof t==`string`?t:new Uint8Array(t))}var Un=class{#e;provider;signer;storage;registry;permits;delegations;decryption;offline;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;constructor(e,t={}){Bn(t),Vn(t.transportKeyPairDerivationSecret);let n=Hn(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 mn(e.storage,this.#i),this.#u=new xn({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 Tt({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 vn({cache:this.#a,credentialService:this.#l,delegationService:this.#u,router:e.router,emitEvent:this.emitEvent.bind(this)})),this.#s=new Sn({router:e.router,emitEvent:this.emitEvent.bind(this)}),this.#o=new Cn({signer:e.signer,router:e.router,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.#d=new zn({provider:this.provider,router:e.router,encryption:this.#s,emitEvent:(e,t)=>this.emitEvent(e,t)}),this.permits=new on({signer:this.signer,provider:this.provider,cachingService:this.#a,credentialService:this.#l,logger:this.#i,emitEvent:this.emitEvent.bind(this)}),this.delegations=new sn({signer:this.signer,provider:this.provider,delegationService:this.#u}),this.decryption=new cn({signer:this.signer,provider:this.provider,router:e.router,decryptionService:this.#c}),this.offline=new ln(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,t)}createToken(e){return new Ge(this,e)}createWrappedToken(e){return new ut(this,e)}dispose(){this.#o.dispose(),this.#e.dispose()}terminate(){this.dispose(),this.signer?.dispose?.()}[Symbol.dispose](){this.terminate()}};export{at as ACL_TOPICS,$t as AclPausedError,ct as AclTopics,Pe as BalanceCheckUnavailableError,Et as BaseSigner,Ie as ChainMismatchError,un as ChromeSessionStorage,h as ConfigurationError,cn as Decryption,A as DecryptionFailedError,gt as DefaultRegistryAddresses,Qt as DelegationContractIsSelfError,B as DelegationCooldownError,W as DelegationDelegateEqualsContractError,G as DelegationExpirationTooSoonError,H as DelegationExpiredError,U as DelegationExpiryUnchangedError,V as DelegationNotFoundError,K as DelegationNotPropagatedError,z as DelegationSelfNotAllowedError,sn as Delegations,ke as ERC1363_INTERFACE_ID,Fe as ERC20ReadFailedError,we as ERC7984_INTERFACE_ID,De as ERC7984_WRAPPER_INTERFACE_ID,Me as EncryptOffloadUnavailableError,k as EncryptionFailedError,yt as IndexedDBStorage,He as InsufficientAllowanceError,ze as InsufficientConfidentialBalanceError,Le as InsufficientERC20BalanceError,C as InvalidTransportKeyPairError,fe as KeyWrappingError,Dt as MemoryStorage,St as MutableWalletAccountStore,y as NoCiphertextError,R as NotEntitledError,ln as Offline,on as Permits,ae as PreparedPermitChainMismatchError,Ee as PreparedPermitExpiredError,u as RelayerRequestFailedError,b as RevokedKmsContextError,j as RpcRateLimitError,ce as SignerNotConfiguredError,re as SignerRequiredError,_ as SigningFailedError,de as SigningRejectedError,nt as TOKEN_TOPICS,Ge as Token,Xe as Topics,O as TransactionRevertedError,me as TransportKeyPairChangedError,pe as TransportKeyPairExpiredError,pt as UnshieldAlreadyFinalizedError,ie as WalletAccountNotReadyError,oe as WalletNotConnectedError,ut as WrappedToken,N as WrappersRegistry,We as ZERO_ENCRYPTED_VALUE,p as ZamaError,c as ZamaErrorCode,Un as ZamaSDK,x as ZamaSDKEvents,_e as allowanceContract,Kt as anvil,T as approveContract,Ae as balanceOfContract,Ht as bscTestnet,Wt as chains,dn as chromeSessionStorage,ht as cleartext,be as confidentialBalanceOfContract,ye as confidentialTotalSupplyContract,E as confidentialTransferContract,ge as confidentialTransferFromContract,an as createConfig,wt as createWalletAccountStore,ve as decimalsContract,ot as decodeAclEvent,lt as decodeAclEvents,Ze as decodeConfidentialTransfer,rt as decodeDelegatedForUserDecryption,dt as decodeOnChainEvent,Qe as decodeOnChainEvents,$e as decodeRevokedDelegationForUserDecryption,st as decodeUnwrapFinalized,it as decodeUnwrapRequested,tt as decodeWrap,Y as delegateForUserDecryptionContract,D as finalizeUnwrapContract,et as findDelegatedForUserDecryption,Ye as findRevokedDelegationForUserDecryption,ft as findUnwrapRequested,mt as findWrap,Lt as getConfidentialTokenAddressContract,nn as getDelegationExpiryContract,Nt as getTokenAddressContract,Ft as getTokenPairContract,Mt as getTokenPairsContract,jt as getTokenPairsLengthContract,Pt as getTokenPairsSliceContract,Bt as hardhat,Rt as hoodi,Ct as indexedDBStorage,le as inferredTotalSupplyContract,Ut as ingenTestnet,xe as isConfidentialTokenContract,It as isConfidentialTokenValidContract,he as isConfidentialWrapperContract,Re as isEncryptedValueZero,rn as isHandleDelegatedContract,te as isOperatorContract,n as isRetryable,Gt as mainnet,Zt as matchZamaError,vt as memoryStorage,Te as nameContract,zt as polygon,Vt as polygonAmoy,je as rateContract,d as retryAfterSeconds,X as revokeDelegationContract,qt as sepolia,ue as setOperatorContract,Oe as supportsInterfaceContract,Ce as symbolContract,qe as transferAndCallContract,ne as underlyingContract,v as unwrapContract,se as unwrapFromBalanceContract,Se as unwrapRequesterContract,g as wrapContract};
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-CVKO9GmQ.js";import{A as g,B as _,C as te,D as ne,E as re,F as ie,G as v,I as ae,J as y,K as oe,L as se,M as b,O as ce,P as le,R as x,S as ue,T as de,U as S,V as fe,W as pe,X as me,Y as he,a as ge,b as _e,c as ve,d as ye,g as be,h as xe,i as Se,j as C,k as Ce,l as we,m as Te,n as Ee,p as De,q as Oe,r as ke,s as Ae,t as je,u as Me,v as w,w as Ne,x as T,z as E}from"./erc165-DbMOt-s6.js";import{n as Pe,r as D,t as O}from"./encryption-BKoalB4o.js";import{_ as k,a as A,c as Fe,d as Ie,f as Le,g as Re,h as ze,l as j,m as Be,n as Ve,o as M,p as He,r as N,s as Ue,t as We,u as Ge}from"./token-CRJ8eCr7.js";import{C as Ke,T as qe,_ as Je,a as Ye,c as Xe,d as Ze,f as Qe,g as $e,h as et,i as tt,l as nt,m as rt,n as it,o as at,p as ot,r as st,s as ct,t as lt,u as ut,v as dt,w as ft,y as pt}from"./wrapped-token-BOtzaSAY.js";import{t as mt}from"./cleartext-PCpNqRGV.js";import{a as ht,c as gt,d as _t,f as vt,i as yt,l as bt,n as xt,o as P,p as St,r as Ct,s as wt,t as Tt,u as Et}from"./base-signer-ws-wq22y.js";import{n as F,r as Dt,s as Ot,t as kt}from"./primitives-Cym-3HKa.js";import{t as I}from"./validation-BRu06AM_.js";import{a as At,i as jt,n as Mt,o as Nt,r as Pt,s as Ft,t as It}from"./wrappers-registry-Cm3JJeqx.js";import{a as Lt,c as Rt,d as zt,i as Bt,l as Vt,n as Ht,o as Ut,r as Wt,s as Gt,t as Kt,u as qt}from"./chains-iPpnjXql.js";import{r as Jt,t as Yt}from"./assertions-Ca1ePdRJ.js";import{getAddress as L,size as Xt}from"viem";import{z as R}from"zod/mini";function Zt(e,t){if(e instanceof p){let n=t[e.code];if(n)return n(e)}return t._?.(e)}var z=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}},B=class extends p{constructor(e,t){super(c.DelegationSelfNotAllowed,e,t),this.name=`DelegationSelfNotAllowedError`}},Qt=class extends p{constructor(e,t){super(c.DelegationCooldown,e,t),this.name=`DelegationCooldownError`}},V=class extends p{constructor(e,t){super(c.DelegationNotFound,e,t),this.name=`DelegationNotFoundError`}},H=class extends p{constructor(e,t){super(c.DelegationExpired,e,t),this.name=`DelegationExpiredError`}},U=class extends p{constructor(e,t){super(c.DelegationExpiryUnchanged,e,t),this.name=`DelegationExpiryUnchangedError`}},W=class extends p{constructor(e,t){super(c.DelegationDelegateEqualsContract,e,t),this.name=`DelegationDelegateEqualsContractError`}},$t=class extends p{constructor(e,t){super(c.DelegationContractIsSelf,e,t),this.name=`DelegationContractIsSelfError`}},en=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 tn=[O,v,u,K,fe,_,z,k,S,y];function q(e,n,c={}){if(tn.some(t=>e instanceof t))return e;let d=e instanceof Error?e.message:n;if(e instanceof Error&&f(e.message))return new S(e.message,{cause:e});if(t(e))return new y(`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 z({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 v(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 O(n,{cause:e})}function nn(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 D(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 rn(e,t,n,r){return{address:e,abi:J,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function an(e,t,n,r,i){return{address:e,abi:J,functionName:`isHandleDelegatedForUserDecryption`,args:[t,n,r,i]}}const Z=2n**64n-1n;function on(e){return yt(e.signer,e.provider,e)}var sn=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 x(this.#r,e)}#s(e,t){throw this.#a({type:b.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 M(`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 M(`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)}async registerPermit(e,t){let n;try{n=this.#o(`registerPermit`)}catch(e){this.#s(`registerPermit`,e)}await n.registerPermit(e,t),await this.#c(e.signerAddress)}async revokePermits(e){let t=this.#o(`revokePermits`),n=L((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=L((await A(`clear`,this.#e,this.#t)).address);try{await e.clearCredentials()}finally{await this.#c(t)}}async#c(e){await C(`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)}},cn=class{#e;#t;#n;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.delegationService}#r(e){return x(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)}},ln=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 x(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,t)}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,r)}async decryptPublicValues(e,t){if(e.length===0)return{clearValues:{},decryptionProof:`0x`,abiEncodedClearValues:`0x`};try{let n=await this.#n.relayer.decryptPublicValuesWithSignatures({encryptedValues:e,options:t}),r={};return n.checkSignaturesArgs.handlesList.forEach((e,t)=>{Jt(n.clearValues[t],`result.clearValues[${t}]`),r[e]=n.clearValues[t].value}),{clearValues:r,abiEncodedClearValues:n.checkSignaturesArgs.abiEncodedCleartexts,decryptionProof:n.checkSignaturesArgs.decryptionProof}}catch(e){throw q(e,`Public decryption failed`)}}async delegatedBatchDecryptValues({encryptedInputs:e,delegatorAddress:t,accountAddress:n=t,maxConcurrency:r,waitForPropagation:i}){let a=this.#i(`delegatedBatchDecryptValues`),o=await A(`delegatedBatchDecryptValues`,this.#e,this.#t);return a.delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:o.address,accountAddress:n,maxConcurrency:r,waitForPropagation:i})}},un=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)}},dn=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 fn=new dn,pn=R.union([R.bigint(),R.boolean(),F]),mn=R.array(R.string());var hn=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=pn.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=L(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}:${L(e)}:${L(t)}:${n.toLowerCase()}`}async#l(){let e=await this.#e.get(this.#r);if(e===null)return[];let t=mn.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 gn(e,t){let n=_n(e,t);if(!n)throw new O(`No permit covers contract ${t} after allow()`);return{privateKey:e.keypair.privateKey,publicKey:e.keypair.publicKey,serializedPermit:n.serializedPermit}}function _n(e,t){let n=kt(t);return e.permissions.find(e=>e.contractAddresses.includes(n))}const vn=e=>new Promise(t=>setTimeout(t,e));var yn=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=L(t);return this.#s(e,{requesterAddress:r,errorMessage:`Failed to decrypt encrypted values`},n)}async delegatedDecryptValues(e,t,n,r,i){let a=L(t),o=L(n),s={spent:!1};return this.#a(i?.waitForPropagation??!0,()=>this.#s(e,{requesterAddress:L(r),delegator:a,validate:e=>this.#m(e,{delegatorAddress:a,delegateAddress:o}),errorMessage:`Failed to decrypt delegated encrypted values`},void 0,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 vn(2e3)}throw n}async delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:n,accountAddress:r,maxConcurrency:i=5,waitForPropagation:a=!0}){let o=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:L(e.contractAddress)}));if(o.length===0)return{items:o};let s=L(r);try{let e=await this.delegatedDecryptValues(o.map(({encryptedValue:e,contractAddress:t})=>({encryptedValue:e,contractAddress:t})),t,n,s,{waitForPropagation:a});for(let t of o)this.#d(t,e);return{items:o}}catch(e){if(Ge(e))throw e;if(o.length===1){let[n=this.#p()]=o;return n.error=this.#f(e,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:n.contractAddress,account:L(t)}),{items:o}}}let c=!1,l;if(await N(o.map(e=>async()=>{if(!c)try{let r=await this.delegatedDecryptValues([{encryptedValue:e.encryptedValue,contractAddress:e.contractAddress}],t,n,s,{waitForPropagation:!1});this.#d(e,r)}catch(n){if(Ge(n)){c=!0,l??=n;return}e.error=this.#f(n,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:e.contractAddress,account:L(t)})}}),i),l!==void 0)throw l;return{items:o}}async#o(e,t,n,r){let i=gn(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:L(e.contractAddress)})),o={},s=[];for(let e of a)j(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 Fe(t))m.push({contractAddress:e,encryptedValues:n});let h=Date.now(),g=u.map(e=>e.encryptedValue);try{this.#i({type:b.DecryptStart,encryptedValues:g});try{await this.#c(n,d,m,o,r)}catch(e){if(!(e instanceof y)||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 _?new y(`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:b.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:b.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 N(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 y)??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 O(`${e.errorMessage}: relayer returned no clear value for ${s.length} of ${r.length} handle(s) on ${n}`,{cause:AggregateError(s.map(e=>new O(`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 O(`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 O(`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 Qt(`Only one delegate/revoke per (delegator, delegate, contract) per block. Wait for the next block before retrying.`,{cause:e}),SenderCannotBeContractAddress:e=>new $t(`The contract address cannot be the caller address.`,{cause:e}),EnforcedPause:e=>new en(`The ACL contract is paused. Delegation operations are temporarily disabled.`,{cause:e}),SenderCannotBeDelegate:e=>new B(`Cannot delegate to yourself (delegate === msg.sender).`,{cause:e}),DelegateCannotBeContractAddress:e=>new W(`Delegate address cannot be the same 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 U(`The new expiration date is the same as the current one.`,{cause:e}),NotDelegatedYet:e=>new V(`Cannot revoke: no active delegation exists.`,{cause:e})};function bn(e){return Object.hasOwn(Q,e)}function xn(e,t){let n=qe(e);if(n&&bn(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 Sn=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=L(t),o=L(n),s=L(r);if(o===s)throw new B(`Cannot delegate to yourself (delegate === msg.sender).`);if(o===a)throw new W(`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 U(`The new expiration date (${l}) is the same as the current one. No on-chain change needed.`);return this.#i({operation:`delegateDecryption`,signer:e,contractAddress:a,config:Y(c,o,a,l)})}async revokeDelegation(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r}){let i=L(t),a=L(n),o=L(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 V(`No active delegation found for delegate ${a} on contract ${i}.`);return this.#i({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=await this.getDelegationExpiry(e);return t===0n?{isActive:!1,expiryTimestamp:t}:t===Z?{isActive:!0,expiryTimestamp:t}:{isActive:t>await this.#t.getBlockTimestamp(),expiryTimestamp:t}}async getDelegationExpiry({contractAddress:e,delegatorAddress:t,delegateAddress:n}){let r=this.#e.relayer.chain.aclContractAddress;return this.#t.readContract(rn(r,L(t),L(n),L(e)))}async#i({operation:e,signer:t,contractAddress:n,config:r}){try{return await Ve({operation:e,signer:t,provider:this.#t,config:r,emit:e=>this.#n(e,n),logger:this.#r})}catch(e){throw this.#a(e),e}}#a(e){if(!(e instanceof E))return;let t=xn(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 V||t instanceof H){let n=L(e);r.set(n,t);return}throw t}})),r}async assertDelegationActive(e,t,n){let r=L(e),i=L(t),a=L(n),{isActive:o,expiryTimestamp:s}=await this.getStatus({contractAddress:r,delegatorAddress:i,delegateAddress:a});if(!o)throw s===0n?new V(`No active delegation from ${i} to ${a} for ${r}`):new H(`Delegation from ${i} to ${a} for ${r} has expired`)}},Cn=class{#e;#t;constructor({router:e,emitEvent:t}){this.#e=e,this.#t=t}async encryptValues(t,n){let r=Date.now(),i=L(t.contractAddress);try{this.#t({type:b.EncryptStart},i);let e=await this.#e.relayer.encryptValues({...t,options:n});return this.#t({type:b.EncryptEnd,durationMs:Date.now()-r},i),e}catch(t){throw this.#t({type:b.EncryptError,error:e(t),durationMs:Date.now()-r},i),nn(t,`Encryption failed`)}}},wn=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 C(`switch relayer chain`,()=>this.#t.switchChain(r),this.#i);let i=this.#r;i&&await C(`credential wallet account change`,()=>i.handleWalletAccountChange(t,n),this.#i),t&&await C(`clear decrypt cache`,()=>this.#n.clearForRequester(t.address),this.#i),await Promise.all(Array.from(this.#a,t=>C(`wallet account listener`,()=>t(e),this.#i)))}};const Tn=R.object({kind:R.literal(`ConfidentialTransfer`),from:F,token:F,to:F,amount:R.bigint()}),En=R.object({kind:R.literal(`ConfidentialTransferFrom`),from:F,token:F,owner:F,to:F,amount:R.bigint()}),$=R.object({kind:R.literal(`SetOperator`),from:F,token:F,operator:F,until:Ot}),Dn=R.object({kind:R.literal(`Unwrap`),from:F,token:F,to:F,amount:R.bigint()}),On=R.object({kind:R.literal(`UnwrapAll`),from:F,token:F,to:F}),kn=R.object({kind:R.literal(`FinalizeUnwrap`),from:F,wrapper:F,unwrapRequestIdOrAmount:Dt}),An=R.object({kind:R.literal(`ApproveUnderlying`),from:F,underlying:F,spender:F,amount:R.bigint()}),jn=R.object({kind:R.literal(`Wrap`),from:F,wrapper:F,to:F,amount:R.bigint()}),Mn=Dt.check(R.refine(e=>e===`0x`||Xt(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`)),Nn=R.object({kind:R.literal(`TransferAndCall`),from:F,underlying:F,wrapper:F,amount:R.bigint(),recipientData:R.optional(Mn)}),Pn=R.object({kind:R.literal(`DelegateDecryption`),from:F,contractAddress:F,delegateAddress:F,expirationDate:R.optional(R.date())}),Fn=R.object({kind:R.literal(`RevokeDelegation`),from:F,contractAddress:F,delegateAddress:F});R.discriminatedUnion(`kind`,[Tn,En,$,Dn,On,kn,An,jn,Nn,Pn,Fn]);const In=R.strictObject({maxFeePerGas:R.bigint(),maxPriorityFeePerGas:R.bigint()}),Ln=R.object({nonce:R.optional(R.int().check(R.nonnegative())),gasLimit:R.optional(R.bigint()),fees:R.optional(In)}),Rn=R.object({address:F,abi:R.array(R.unknown()),functionName:R.string(),args:R.array(R.unknown()),value:R.optional(R.bigint()),gas:R.optional(R.bigint())}),zn=R.extend(Ln,{from:F,calldata:Rn});var Bn=class{#e;#t;#n;constructor(e){this.#e=e.provider,this.#t=e.router,this.#n=e.encryption}async prepare(e,t){t&&=I(Ln,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=I(zn,{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=I(Tn,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from}),r=t[0];if(!r)throw new D(`Encryption returned no handles for ConfidentialTransfer`);return w(e.token,e.to,r,n)}async#a(e){e=I(En,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from}),r=t[0];if(!r)throw new D(`Encryption returned no handles for ConfidentialTransferFrom`);return _e(e.token,e.owner,e.to,r,n)}#o(e){return e=I($,e),de(e.token,e.operator,e.until)}async#s(e){e=I(Dn,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from}),r=t[0];if(!r)throw new D(`Encryption returned no handles for Unwrap`);return ne(e.token,e.from,e.to,r,n)}async#c(e){e=I(On,e);let t=await this.#e.readContract(xe(e.token,e.from));return ce(e.token,e.from,e.to,t)}async#l(e){e=I(kn,e);let t=await this.#t.relayer.decryptPublicValuesWithSignatures({encryptedValues:[e.unwrapRequestIdOrAmount]}).catch(e=>{throw q(e,`Public decryption failed during FinalizeUnwrap`)}),n=t.clearValues[0]?.value;return Yt(n,`FinalizeUnwrap: decryptPublicValuesWithSignatures(handle).clearValue`),T(e.wrapper,e.unwrapRequestIdOrAmount,n,t.checkSignaturesArgs.decryptionProof)}#u(e){return e=I(An,e),we(e.underlying,e.spender,e.amount)}#d(e){return e=I(jn,e),g(e.wrapper,e.to,e.amount)}#f(e){return e=I(Nn,e),Ke(e.underlying,e.wrapper,e.amount,e.recipientData)}#p(e){if(e=I(Pn,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 B(`Cannot delegate to yourself (delegate === msg.sender).`);if(e.delegateAddress===e.contractAddress)throw new W(`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=I(Fn,e),X(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress)}};function Vn(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 Hn(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 Un(e){if(e===void 0)return;let t=I(gt,e);return new bt(typeof t==`string`?t:new Uint8Array(t))}var Wn=class{#e;provider;signer;storage;registry;permits;delegations;decryption;offline;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;constructor(e,t={}){Vn(t),Hn(t.transportKeyPairDerivationSecret);let n=Un(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 hn(e.storage,this.#i),this.#u=new Sn({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 P({provider:this.provider,registryAddresses:r,registryTTL:e.registryTTL}),this.#n=r,this.#t=e.registryTTL,this.#l=new wt({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 yn({cache:this.#a,credentialService:this.#l,delegationService:this.#u,router:e.router,emitEvent:this.emitEvent.bind(this)})),this.#s=new Cn({router:e.router,emitEvent:this.emitEvent.bind(this)}),this.#o=new wn({signer:e.signer,router:e.router,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.#d=new Bn({provider:this.provider,router:e.router,encryption:this.#s,emitEvent:(e,t)=>this.emitEvent(e,t)}),this.permits=new sn({signer:this.signer,provider:this.provider,cachingService:this.#a,credentialService:this.#l,logger:this.#i,emitEvent:this.emitEvent.bind(this)}),this.delegations=new cn({signer:this.signer,provider:this.provider,delegationService:this.#u}),this.decryption=new ln({signer:this.signer,provider:this.provider,router:e.router,decryptionService:this.#c}),this.offline=new un(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 P({provider:this.provider,registryAddresses:{...this.#n,...e},registryTTL:this.#t})}async encrypt(e,t){return this.#s.encryptValues(e,t)}createToken(e){return new We(this,e)}createWrappedToken(e){return new lt(this,e)}dispose(){this.#o.dispose(),this.#e.dispose()}terminate(){this.dispose(),this.signer?.dispose?.()}[Symbol.dispose](){this.terminate()}};export{it as ACL_TOPICS,en as AclPausedError,st as AclTopics,Ie as BalanceCheckUnavailableError,Tt as BaseSigner,Re as ChainMismatchError,dn as ChromeSessionStorage,h as ConfigurationError,ln as Decryption,O as DecryptionFailedError,ht as DefaultRegistryAddresses,$t as DelegationContractIsSelfError,Qt as DelegationCooldownError,W as DelegationDelegateEqualsContractError,G as DelegationExpirationTooSoonError,H as DelegationExpiredError,U as DelegationExpiryUnchangedError,V as DelegationNotFoundError,K as DelegationNotPropagatedError,B as DelegationSelfNotAllowedError,cn as Delegations,je as ERC1363_INTERFACE_ID,Le as ERC20ReadFailedError,Ee as ERC7984_INTERFACE_ID,ke as ERC7984_WRAPPER_INTERFACE_ID,Pe as EncryptOffloadUnavailableError,D as EncryptionFailedError,vt as IndexedDBStorage,He as InsufficientAllowanceError,Be as InsufficientConfidentialBalanceError,ze as InsufficientERC20BalanceError,S as InvalidTransportKeyPairError,pe as KeyWrappingError,Et as MemoryStorage,xt as MutableWalletAccountStore,v as NoCiphertextError,z as NotEntitledError,un as Offline,sn as Permits,oe as PreparedPermitChainMismatchError,Oe as PreparedPermitExpiredError,u as RelayerRequestFailedError,y as RevokedKmsContextError,k as RpcRateLimitError,le as SignerNotConfiguredError,ie as SignerRequiredError,_ as SigningFailedError,fe as SigningRejectedError,tt as TOKEN_TOPICS,We as Token,Ye as Topics,E as TransactionRevertedError,he as TransportKeyPairChangedError,me as TransportKeyPairExpiredError,ft as UnshieldAlreadyFinalizedError,ae as WalletAccountNotReadyError,se as WalletNotConnectedError,lt as WrappedToken,P as WrappersRegistry,Ue as ZERO_ENCRYPTED_VALUE,p as ZamaError,c as ZamaErrorCode,Wn as ZamaSDK,b as ZamaSDKEvents,ve as allowanceContract,Kt as anvil,we as approveContract,Me as balanceOfContract,Ht as bscTestnet,Wt as chains,fn as chromeSessionStorage,mt as cleartext,xe as confidentialBalanceOfContract,be as confidentialTotalSupplyContract,w as confidentialTransferContract,_e as confidentialTransferFromContract,on as createConfig,Ct as createWalletAccountStore,ye as decimalsContract,at as decodeAclEvent,ct as decodeAclEvents,Xe as decodeConfidentialTransfer,nt as decodeDelegatedForUserDecryption,ut as decodeOnChainEvent,Ze as decodeOnChainEvents,Qe as decodeRevokedDelegationForUserDecryption,ot as decodeUnwrapFinalized,rt as decodeUnwrapRequested,et as decodeWrap,Y as delegateForUserDecryptionContract,T as finalizeUnwrapContract,$e as findDelegatedForUserDecryption,Je as findRevokedDelegationForUserDecryption,dt as findUnwrapRequested,pt as findWrap,It as getConfidentialTokenAddressContract,rn as getDelegationExpiryContract,Mt as getTokenAddressContract,Pt as getTokenPairContract,jt as getTokenPairsContract,At as getTokenPairsLengthContract,Nt as getTokenPairsSliceContract,Bt as hardhat,Lt as hoodi,St as indexedDBStorage,ue as inferredTotalSupplyContract,Ut as ingenTestnet,Se as isConfidentialTokenContract,Ft as isConfidentialTokenValidContract,ge as isConfidentialWrapperContract,j as isEncryptedValueZero,an as isHandleDelegatedContract,te as isOperatorContract,n as isRetryable,Gt as mainnet,Zt as matchZamaError,_t as memoryStorage,De as nameContract,Rt as polygon,Vt as polygonAmoy,Ne as rateContract,d as retryAfterSeconds,X as revokeDelegationContract,qt as sepolia,de as setOperatorContract,Ae as supportsInterfaceContract,Te as symbolContract,Ke as transferAndCallContract,re as underlyingContract,ne as unwrapContract,ce as unwrapFromBalanceContract,Ce as unwrapRequesterContract,g as wrapContract,zt as zenithTrexTestnet};
2
2
  //# sourceMappingURL=index.js.map