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

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 (90) 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/erc165.cjs +1 -1
  7. package/dist/cjs/erc165.cjs.map +1 -1
  8. package/dist/cjs/fatal-batch.cjs +2 -0
  9. package/dist/cjs/fatal-batch.cjs.map +1 -0
  10. package/dist/cjs/fhevm-relayer.cjs +1 -1
  11. package/dist/cjs/fhevm-relayer.cjs.map +1 -1
  12. package/dist/cjs/index.cjs +1 -1
  13. package/dist/cjs/index.cjs.map +1 -1
  14. package/dist/cjs/internal/index.cjs +2 -0
  15. package/dist/cjs/internal/index.cjs.map +1 -0
  16. package/dist/cjs/node/index.cjs +1 -1
  17. package/dist/cjs/signing.cjs +2 -0
  18. package/dist/cjs/signing.cjs.map +1 -0
  19. package/dist/cjs/telemetry.cjs +1 -1
  20. package/dist/cjs/telemetry.cjs.map +1 -1
  21. package/dist/cjs/token.cjs +1 -1
  22. package/dist/cjs/token.cjs.map +1 -1
  23. package/dist/cjs/vaults/index.cjs +1 -1
  24. package/dist/cjs/web/index.cjs +1 -1
  25. package/dist/cjs/wrapped-token.cjs +1 -1
  26. package/dist/esm/base-signer-BoBsvn5Q.js +2 -0
  27. package/dist/esm/base-signer-BoBsvn5Q.js.map +1 -0
  28. package/dist/esm/{base-signer-46j6PRq-.d.ts → base-signer-BxIDBDTF.d.ts} +2 -2
  29. package/dist/esm/chains/index.d.ts +2 -2
  30. package/dist/esm/chains/index.js +1 -1
  31. package/dist/esm/{chains-iPpnjXql.js → chains-BwlDI944.js} +2 -2
  32. package/dist/esm/chains-BwlDI944.js.map +1 -0
  33. package/dist/esm/cleartext/index.d.ts +2 -2
  34. package/dist/esm/cleartext/index.js +1 -1
  35. package/dist/esm/{cleartext-DInZ0vz-.d.ts → cleartext-BnTAN4-g.d.ts} +2 -2
  36. package/dist/esm/{cleartext-CiE1gO7Y.js → cleartext-CvCakQal.js} +2 -2
  37. package/dist/esm/{cleartext-CiE1gO7Y.js.map → cleartext-CvCakQal.js.map} +1 -1
  38. package/dist/esm/{index-CpQK8U4F.d.ts → decryption-B0mY2M8N.d.ts} +7 -3
  39. package/dist/esm/encrypt-worker-client-BW88njEe.d.ts +19 -0
  40. package/dist/esm/erc165-B8gx2luK.js +2 -0
  41. package/dist/esm/erc165-B8gx2luK.js.map +1 -0
  42. package/dist/esm/ethers/index.d.ts +4 -4
  43. package/dist/esm/ethers/index.js +1 -1
  44. package/dist/esm/fatal-batch-BiiS7KdS.js +2 -0
  45. package/dist/esm/fatal-batch-BiiS7KdS.js.map +1 -0
  46. package/dist/esm/fhevm-relayer-CGvejcdJ.js +8 -0
  47. package/dist/esm/{fhevm-relayer-DXLb4mIw.js.map → fhevm-relayer-CGvejcdJ.js.map} +1 -1
  48. package/dist/esm/{index-Cdbp_93f.d.ts → index-D1Wtji3m.d.ts} +4 -26
  49. package/dist/esm/{index-BKMce5ya.d.ts → index-DXCcwJ77.d.ts} +7 -7
  50. package/dist/esm/index-DkN4q5Cm.d.ts +1 -0
  51. package/dist/esm/{index-C1clixw5.d.ts → index-fsWBYM8S.d.ts} +4 -4
  52. package/dist/esm/index.d.ts +10 -9
  53. package/dist/esm/index.js +1 -1
  54. package/dist/esm/index.js.map +1 -1
  55. package/dist/esm/internal/index.d.ts +26 -0
  56. package/dist/esm/internal/index.js +2 -0
  57. package/dist/esm/internal/index.js.map +1 -0
  58. package/dist/esm/node/index.d.ts +5 -5
  59. package/dist/esm/node/index.js +1 -1
  60. package/dist/esm/node/index.js.map +1 -1
  61. package/dist/esm/query/index.d.ts +6 -5
  62. package/dist/esm/query/index.js +1 -1
  63. package/dist/esm/signing-C6nbPCyd.js +2 -0
  64. package/dist/esm/signing-C6nbPCyd.js.map +1 -0
  65. package/dist/esm/telemetry-BDnhC-vh.js +2 -0
  66. package/dist/esm/{telemetry-Dll0Swdj.js.map → telemetry-BDnhC-vh.js.map} +1 -1
  67. package/dist/esm/token-g6sinwTx.js +2 -0
  68. package/dist/esm/token-g6sinwTx.js.map +1 -0
  69. package/dist/esm/{types-Bz42Emet.d.ts → types-C2ccCjoA.d.ts} +3 -3
  70. package/dist/esm/{types-BIgPY1yI.d.ts → types-CHepK8MK.d.ts} +2 -2
  71. package/dist/esm/{types-I9lJwH20.d.ts → types-Dc1fpXWt.d.ts} +3 -3
  72. package/dist/esm/vaults/index.d.ts +3 -2
  73. package/dist/esm/vaults/index.js +1 -1
  74. package/dist/esm/viem/index.d.ts +4 -4
  75. package/dist/esm/viem/index.js +1 -1
  76. package/dist/esm/web/index.d.ts +2 -17
  77. package/dist/esm/web/index.js +1 -1
  78. package/dist/esm/wrapped-token-3usJd0oi.js +2 -0
  79. package/dist/esm/{wrapped-token-IDUEFpZx.js.map → wrapped-token-3usJd0oi.js.map} +1 -1
  80. package/package.json +15 -1
  81. package/dist/esm/base-signer-b1ff2VPI.js +0 -2
  82. package/dist/esm/base-signer-b1ff2VPI.js.map +0 -1
  83. package/dist/esm/chains-iPpnjXql.js.map +0 -1
  84. package/dist/esm/erc165-BAd2z3ay.js +0 -2
  85. package/dist/esm/erc165-BAd2z3ay.js.map +0 -1
  86. package/dist/esm/fhevm-relayer-DXLb4mIw.js +0 -8
  87. package/dist/esm/telemetry-Dll0Swdj.js +0 -2
  88. package/dist/esm/token-CTvEGQmH.js +0 -2
  89. package/dist/esm/token-CTvEGQmH.js.map +0 -1
  90. package/dist/esm/wrapped-token-IDUEFpZx.js +0 -2
@@ -1,11 +1,12 @@
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, gn as TypedValue, gt as ApprovalStrategy, h as PrepareFees, hn as RelayerSDK, ht as ZamaSDKEvents, i as ZamaConfig, in as EIP712TypedData, it as TransferSubmittedEvent, j as WalletAccountStore, jt as OnChainEvent, k as WalletAccountChange, kt as ConfidentialTransferEvent, l as GenericProvider, ln as FhevmClient, lt as VaultOperation, m as FinalizeUnwrapRequest, mn as RelayerRequestOptions, mt as ZamaSDKEventType, n as RelayerConfig, nn as DecryptPublicValuesResult, nt as TransactionOperation, o as ZamaConfigGeneric, on as EncryptParams, ot as UnshieldPhase2StartedEvent, p as DelegateDecryptionRequest, pn as RelayerOptions, pt as ZamaSDKEventListener, q as EncryptErrorEvent, qt as decodeWrap, rn as DecryptValuesParameters, rt as TransferFromSubmittedEvent, s as GenericLogger, sn as EncryptResult, st as UnshieldPhase2SubmittedEvent, t as CleartextRelayerConfig, tn as ClearValue, tt as TransactionErrorEvent, u as ApproveUnderlyingRequest, un as FhevmClientOptions, ut as VaultSubmittedEvent, v as PreparedFor, vt as ShieldPath, w as UnwrapAllRequest, wt as TransferCallbacks, x as SetOperatorRequest, xt as UnwrapResult, y as PreparedTransaction, yt as TransferOptions, z as WriteFunctionName, zt as decodeAclEvents } from "./types-BIgPY1yI.js";
3
- import { t as cleartext } from "./cleartext-DInZ0vz-.js";
4
- import { t as ZamaConfigEthers } from "./types-Bz42Emet.js";
5
- import { n as MutableWalletAccountStore, r as createWalletAccountStore, t as BaseSigner } from "./base-signer-46j6PRq-.js";
6
- import { t as createConfig } from "./index-BKMce5ya.js";
7
- import { t as ZamaConfigViem } from "./types-I9lJwH20.js";
8
- import { $ as DelegationCooldownError, $t as decimalsContract, A as TransactionRevertedError, At as TokenWrapperPair, B as ConfigurationError, Bt as getDelegationExpiryContract, C as Delegations, Ct as PreparedPermit, D as matchZamaError, Dt as SignedPreparedPermit, E as ErrorForCode, Et as SerializedTransportKeyPair, F as SignerRequiredError, Ft as getTokenPairsContract, G as InsufficientAllowanceError, Gt as ERC7984_INTERFACE_ID, H as BalanceCheckUnavailableError, Ht as revokeDelegationContract, I as WalletAccountNotReadyError, It as getTokenPairsLengthContract, J as DecryptionFailedError, Jt as isConfidentialWrapperContract, K as InsufficientConfidentialBalanceError, Kt as ERC7984_WRAPPER_INTERFACE_ID, L as WalletNotConnectedError, Lt as getTokenPairsSliceContract, M as SigningFailedError, Mt as getConfidentialTokenAddressContract, N as SigningRejectedError, Nt as getTokenAddressContract, O as UnshieldAlreadyFinalizedDetails, Ot as ChecksummedAddress, P as SignerNotConfiguredError, Pt as getTokenPairContract, Q as DelegationContractIsSelfError, Qt as balanceOfContract, R as RpcRateLimitError, Rt as isConfidentialTokenValidContract, S as Offline, St as PreparePermitRequest, T as Permits, Tt as SerializedPermitEip712, U as BalanceErrorDetails, Ut as transferAndCallContract, V as RelayerRequestFailedError, Vt as isHandleDelegatedContract, W as ERC20ReadFailedError, Wt as ERC1363_INTERFACE_ID, X as EncryptionFailedError, Xt as allowanceContract, Y as EncryptOffloadUnavailableError, Yt as supportsInterfaceContract, Z as AclPausedError, Zt as approveContract, _ as WrappersRegistryConfig, _t as ZamaError, a as DecryptResult, an as confidentialTransferFromContract, at as DelegationNotFoundError, b as BatchDecryptAsOptions, bt as retryAfterSeconds, cn as isOperatorContract, ct as InvalidTransportKeyPairError, dn as underlyingContract, dt as PreparedPermitChainMismatchError, en as nameContract, et as DelegationDelegateCannotBeWildcardError, f as ZamaSDK, fn as unwrapContract, ft as PreparedPermitExpiredError, g as WrappersRegistry, gt as ChainMismatchError, h as ListPairsOptions, hn as wrapContract, ht as TransportKeyPairExpiredError, i as DelegatedDecryptOptions, in as confidentialTransferContract, it as DelegationExpiryUnchangedError, j as SigningErrorMetadata, jt as TokenWrapperPairWithMetadata, k as UnshieldAlreadyFinalizedError, kt as PaginatedResult, ln as rateContract, lt as KeyWrappingError, m as DefaultRegistryAddresses, mn as unwrapRequesterContract, mt as TransportKeyPairChangedError, n as BatchDecryptItem, nn as confidentialBalanceOfContract, nt as DelegationExpirationTooSoonError, o as EncryptedInput, on as finalizeUnwrapContract, ot as DelegationNotPropagatedError, p as ZamaSDKOptions, pn as unwrapFromBalanceContract, pt as RevokedKmsContextError, q as InsufficientERC20BalanceError, qt as isConfidentialTokenContract, r as BatchDecryptResult, rn as confidentialTotalSupplyContract, rt as DelegationExpiredError, sn as inferredTotalSupplyContract, st as DelegationSelfNotAllowedError, t as Decryption, tn as symbolContract, tt as DelegationDelegateEqualsContractError, un as setOperatorContract, ut as NoCiphertextError, v as WrappedToken, vt as ZamaErrorCode, w as DelegationStatus, wt as SerializedPermit, x as Token, xt as Permission, y as BatchBalancesResult, yt as isRetryable, z as NotEntitledError, zt as delegateForUserDecryptionContract } from "./index-CpQK8U4F.js";
1
+ import { a as hoodi, c as polygonAmoy, d as AtLeastOneChain, f as FheChain, i as hardhat, l as sepolia, n as bscTestnet, o as mainnet, p as FheChainAuth, r as chains, s as polygon, t as anvil, u as zenithTrexTestnet } from "./index-D1Wtji3m.js";
2
+ import { $ as SetOperatorSubmittedEvent, $t as TransactionReceipt, A as WalletAccountListener, At as DelegatedForUserDecryptionEvent, B as ApproveUnderlyingSubmittedEvent, Bt as decodeConfidentialTransfer, C as TransferAndCallRequest, Ct as ShieldCallbacks, D as GenericSigner, Dt as AclEvent, E as WrapRequest, Et as ACL_TOPICS, F as ReadContractReturnType, Ft as UnwrapFinalizedEvent, G as DelegationSubmittedEvent, Gt as decodeUnwrapFinalized, H as DecryptEndEvent, Ht as decodeOnChainEvent, I as ReadFunctionName, It as UnwrapRequestedEvent, J as EncryptStartEvent, Jt as findDelegatedForUserDecryption, K as EncryptEndEvent, Kt as decodeUnwrapRequested, L as WriteContractArgs, Lt as WrapEvent, M as ContractAbi, Mt as RevokedDelegationForUserDecryptionEvent, N as ReadContractArgs, Nt as TOKEN_TOPICS, O as WalletAccount, Ot as AclTopics, P as ReadContractConfig, Pt as Topics, Q as RevokeDelegationSubmittedEvent, Qt as RawLog, R as WriteContractConfig, Rt as decodeAclEvent, S as TransactionKind, St as WrapOptions, T as UnwrapRequest, Tt as UnshieldCallbacks, U as DecryptErrorEvent, Ut as decodeOnChainEvents, V as BaseEvent, Vt as decodeDelegatedForUserDecryption, W as DecryptStartEvent, Wt as decodeRevokedDelegationForUserDecryption, X as PermitErrorEvent, Xt as findUnwrapRequested, Y as FinalizeUnwrapSubmittedEvent, Yt as findRevokedDelegationForUserDecryption, Z as PermitOperation, Zt as findWrap, _ as PrepareTransactionRequest, _t as ShieldOptions, a as ZamaConfigBase, an as EncryptInput, at as UnshieldPhase1SubmittedEvent, b as RevokeDelegationRequest, bt as UnshieldOptions, c as GenericStorage, cn as EncryptedValue, ct as UnwrapSubmittedEvent, d as ConfidentialTransferFromRequest, dn as FhevmRelayerOptions, dt as WrapSubmittedEvent, en as TransactionResult, et as ShieldSubmittedEvent, f as ConfidentialTransferRequest, fn as FhevmRuntimeConfig, ft as ZamaSDKEvent, g as PrepareOptions, gn as TypedValue, gt as ApprovalStrategy, h as PrepareFees, hn as RelayerSDK, ht as ZamaSDKEvents, i as ZamaConfig, in as EIP712TypedData, it as TransferSubmittedEvent, j as WalletAccountStore, jt as OnChainEvent, k as WalletAccountChange, kt as ConfidentialTransferEvent, l as GenericProvider, ln as FhevmClient, lt as VaultOperation, m as FinalizeUnwrapRequest, mn as RelayerRequestOptions, mt as ZamaSDKEventType, n as RelayerConfig, nn as DecryptPublicValuesResult, nt as TransactionOperation, o as ZamaConfigGeneric, on as EncryptParams, ot as UnshieldPhase2StartedEvent, p as DelegateDecryptionRequest, pn as RelayerOptions, pt as ZamaSDKEventListener, q as EncryptErrorEvent, qt as decodeWrap, rn as DecryptValuesParameters, rt as TransferFromSubmittedEvent, s as GenericLogger, sn as EncryptResult, st as UnshieldPhase2SubmittedEvent, t as CleartextRelayerConfig, tn as ClearValue, tt as TransactionErrorEvent, u as ApproveUnderlyingRequest, un as FhevmClientOptions, ut as VaultSubmittedEvent, v as PreparedFor, vt as ShieldPath, w as UnwrapAllRequest, wt as TransferCallbacks, x as SetOperatorRequest, xt as UnwrapResult, y as PreparedTransaction, yt as TransferOptions, z as WriteFunctionName, zt as decodeAclEvents } from "./types-CHepK8MK.js";
3
+ import { t as cleartext } from "./cleartext-BnTAN4-g.js";
4
+ import { t as ZamaConfigEthers } from "./types-C2ccCjoA.js";
5
+ import { n as MutableWalletAccountStore, r as createWalletAccountStore, t as BaseSigner } from "./base-signer-BxIDBDTF.js";
6
+ import { t as createConfig } from "./index-DXCcwJ77.js";
7
+ import { t as ZamaConfigViem } from "./types-Dc1fpXWt.js";
8
+ import { $ as DelegationCooldownError, $t as balanceOfContract, A as TransactionRevertedError, At as PaginatedResult, B as ConfigurationError, Bt as delegateForUserDecryptionContract, C as Delegations, Ct as PreparePermitRequest, D as matchZamaError, Dt as SerializedTransportKeyPair, E as ErrorForCode, Et as SerializedPermitEip712, F as SignerRequiredError, Ft as getTokenPairContract, G as InsufficientAllowanceError, Gt as ERC1363_INTERFACE_ID, H as BalanceCheckUnavailableError, Ht as isHandleDelegatedContract, I as WalletAccountNotReadyError, It as getTokenPairsContract, J as DecryptionFailedError, Jt as isConfidentialTokenContract, K as InsufficientConfidentialBalanceError, Kt as ERC7984_INTERFACE_ID, L as WalletNotConnectedError, Lt as getTokenPairsLengthContract, M as SigningFailedError, Mt as TokenWrapperPairWithMetadata, N as SigningRejectedError, Nt as getConfidentialTokenAddressContract, O as UnshieldAlreadyFinalizedDetails, Ot as SignedPreparedPermit, P as SignerNotConfiguredError, Pt as getTokenAddressContract, Q as DelegationContractIsSelfError, Qt as approveContract, R as RpcRateLimitError, Rt as getTokenPairsSliceContract, S as Offline, St as Permission, T as Permits, Tt as SerializedPermit, U as BalanceErrorDetails, Ut as revokeDelegationContract, V as RelayerRequestFailedError, Vt as getDelegationExpiryContract, W as ERC20ReadFailedError, Wt as transferAndCallContract, X as EncryptionFailedError, Xt as supportsInterfaceContract, Y as EncryptOffloadUnavailableError, Yt as isConfidentialWrapperContract, Z as AclPausedError, Zt as allowanceContract, _ as WrappersRegistryConfig, _t as ZamaError, a as DecryptResult, an as confidentialTransferContract, at as DelegationNotFoundError, b as BatchDecryptAsOptions, bt as retryAfterSeconds, cn as inferredTotalSupplyContract, ct as InvalidTransportKeyPairError, dn as setOperatorContract, dt as PreparedPermitChainMismatchError, en as decimalsContract, et as DelegationDelegateCannotBeWildcardError, f as ZamaSDK, fn as underlyingContract, ft as PreparedPermitExpiredError, g as WrappersRegistry, gn as wrapContract, gt as ChainMismatchError, h as ListPairsOptions, hn as unwrapRequesterContract, ht as TransportKeyPairExpiredError, i as DelegatedDecryptOptions, in as confidentialTotalSupplyContract, it as DelegationExpiryUnchangedError, j as SigningErrorMetadata, jt as TokenWrapperPair, k as UnshieldAlreadyFinalizedError, kt as ChecksummedAddress, ln as isOperatorContract, lt as KeyWrappingError, m as DefaultRegistryAddresses, mn as unwrapFromBalanceContract, mt as TransportKeyPairChangedError, n as BatchDecryptItem, nn as symbolContract, nt as DelegationExpirationTooSoonError, o as EncryptedInput, on as confidentialTransferFromContract, ot as DelegationNotPropagatedError, p as ZamaSDKOptions, pn as unwrapContract, pt as RevokedKmsContextError, q as InsufficientERC20BalanceError, qt as ERC7984_WRAPPER_INTERFACE_ID, r as BatchDecryptResult, rn as confidentialBalanceOfContract, rt as DelegationExpiredError, sn as finalizeUnwrapContract, st as DelegationSelfNotAllowedError, t as Decryption, tn as nameContract, tt as DelegationDelegateEqualsContractError, un as rateContract, ut as NoCiphertextError, v as WrappedToken, vt as ZamaErrorCode, w as DelegationStatus, wt as PreparedPermit, x as Token, xt as parsePreparedPermit, y as BatchBalancesResult, yt as isRetryable, z as NotEntitledError, zt as isConfidentialTokenValidContract } from "./decryption-B0mY2M8N.js";
9
+ import "./index-DkN4q5Cm.js";
9
10
  import { Address, Hex } from "viem";
10
11
  //#region src/contracts/constants.d.ts
11
12
  /** uint64 max — represents a permanent (no-expiry) delegation. */
@@ -105,5 +106,5 @@ declare const ZERO_ENCRYPTED_VALUE: "0x00000000000000000000000000000000000000000
105
106
  */
106
107
  declare function isEncryptedValueZero(encryptedValue: string): boolean;
107
108
  //#endregion
108
- export { ACL_TOPICS, type AclEvent, AclPausedError, AclTopics, type Address, type ApprovalStrategy, type ApproveUnderlyingRequest, type ApproveUnderlyingSubmittedEvent, type AtLeastOneChain, BalanceCheckUnavailableError, type BalanceErrorDetails, type BaseEvent, BaseSigner, type BatchBalancesResult, type BatchDecryptAsOptions, type BatchDecryptItem, type BatchDecryptResult, ChainMismatchError, type ChecksummedAddress, ChromeSessionStorage, type ClearValue, type CleartextRelayerConfig, type ConfidentialTransferEvent, type ConfidentialTransferFromRequest, type ConfidentialTransferRequest, ConfigurationError, type ContractAbi, type DecryptEndEvent, type DecryptErrorEvent, type EncryptedInput as DecryptInput, type DecryptPublicValuesResult, type DecryptResult, type DecryptStartEvent, type DecryptValuesParameters, Decryption, DecryptionFailedError, DefaultRegistryAddresses, type DelegateDecryptionRequest, type DelegatedDecryptOptions, type DelegatedForUserDecryptionEvent, DelegationContractIsSelfError, DelegationCooldownError, DelegationDelegateCannotBeWildcardError, DelegationDelegateEqualsContractError, DelegationExpirationTooSoonError, DelegationExpiredError, DelegationExpiryUnchangedError, DelegationNotFoundError, DelegationNotPropagatedError, DelegationSelfNotAllowedError, type DelegationStatus, type DelegationSubmittedEvent, Delegations, type EIP712TypedData, ERC1363_INTERFACE_ID, ERC20ReadFailedError, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, type EncryptEndEvent, type EncryptErrorEvent, type EncryptInput, EncryptOffloadUnavailableError, type EncryptParams, type EncryptResult, type EncryptStartEvent, type EncryptedValue, EncryptionFailedError, type ErrorForCode, type FheChain, type FheChainAuth, type FhevmClient, type FhevmClientOptions, type FhevmRelayerOptions, type FhevmRuntimeConfig, type FinalizeUnwrapRequest, type FinalizeUnwrapSubmittedEvent, type GenericLogger, type GenericProvider, type GenericSigner, type GenericStorage, type Hex, IndexedDBStorage, InsufficientAllowanceError, InsufficientConfidentialBalanceError, InsufficientERC20BalanceError, InvalidTransportKeyPairError, KeyWrappingError, type ListPairsOptions, MAX_UINT64, MemoryStorage, MutableWalletAccountStore, NoCiphertextError, NotEntitledError, Offline, type OnChainEvent, type PaginatedResult, type Permission, type PermitErrorEvent, type PermitOperation, Permits, type PrepareFees, type PrepareOptions, type PreparePermitRequest, type PrepareTransactionRequest, type PreparedFor, type PreparedPermit, PreparedPermitChainMismatchError, PreparedPermitExpiredError, type PreparedTransaction, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, type RelayerConfig, type RelayerOptions, RelayerRequestFailedError, type RelayerRequestOptions, type RelayerSDK, type RevokeDelegationRequest, type RevokeDelegationSubmittedEvent, type RevokedDelegationForUserDecryptionEvent, RevokedKmsContextError, RpcRateLimitError, type SerializedPermit, type SerializedPermitEip712, type SerializedTransportKeyPair, type SetOperatorRequest, type SetOperatorSubmittedEvent, type ShieldCallbacks, type ShieldOptions, type ShieldPath, type ShieldSubmittedEvent, type SignedPreparedPermit, SignerNotConfiguredError, SignerRequiredError, type SigningErrorMetadata, SigningFailedError, SigningRejectedError, TOKEN_TOPICS, Token, type TokenWrapperPair, type TokenWrapperPairWithMetadata, Topics, type TransactionErrorEvent, type TransactionKind, type TransactionOperation, type TransactionReceipt, type TransactionResult, TransactionRevertedError, type TransferAndCallRequest, type TransferCallbacks, type TransferFromSubmittedEvent, type TransferOptions, type TransferSubmittedEvent, TransportKeyPairChangedError, TransportKeyPairExpiredError, type TypedValue, type UnshieldAlreadyFinalizedDetails, UnshieldAlreadyFinalizedError, type UnshieldCallbacks, type UnshieldOptions, type UnshieldPhase1SubmittedEvent, type UnshieldPhase2StartedEvent, type UnshieldPhase2SubmittedEvent, type UnwrapAllRequest, type UnwrapFinalizedEvent, type UnwrapRequest, type UnwrapRequestedEvent, type UnwrapResult, type UnwrapSubmittedEvent, type VaultOperation, type VaultSubmittedEvent, WILDCARD_CONTRACT, type WalletAccount, type WalletAccountChange, type WalletAccountListener, WalletAccountNotReadyError, type WalletAccountStore, WalletNotConnectedError, type WrapEvent, type WrapOptions, type WrapRequest, type WrapSubmittedEvent, WrappedToken, WrappersRegistry, type WrappersRegistryConfig, type WriteContractArgs, type WriteContractConfig, type WriteFunctionName, ZERO_ENCRYPTED_VALUE, type ZamaConfig, type ZamaConfigBase, type ZamaConfigEthers, type ZamaConfigGeneric, type ZamaConfigViem, ZamaError, ZamaErrorCode, ZamaSDK, type ZamaSDKEvent, type ZamaSDKEventListener, type ZamaSDKEventType, ZamaSDKEvents, type ZamaSDKOptions, allowanceContract, anvil, approveContract, balanceOfContract, bscTestnet, chains, chromeSessionStorage, cleartext, confidentialBalanceOfContract, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, createConfig, createWalletAccountStore, decimalsContract, decodeAclEvent, decodeAclEvents, decodeConfidentialTransfer, decodeDelegatedForUserDecryption, decodeOnChainEvent, decodeOnChainEvents, decodeRevokedDelegationForUserDecryption, decodeUnwrapFinalized, decodeUnwrapRequested, decodeWrap, delegateForUserDecryptionContract, finalizeUnwrapContract, findDelegatedForUserDecryption, findRevokedDelegationForUserDecryption, findUnwrapRequested, findWrap, getConfidentialTokenAddressContract, getDelegationExpiryContract, getTokenAddressContract, getTokenPairContract, getTokenPairsContract, getTokenPairsLengthContract, getTokenPairsSliceContract, hardhat, hoodi, indexedDBStorage, inferredTotalSupplyContract, 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 };
109
+ export { ACL_TOPICS, type AclEvent, AclPausedError, AclTopics, type Address, type ApprovalStrategy, type ApproveUnderlyingRequest, type ApproveUnderlyingSubmittedEvent, type AtLeastOneChain, BalanceCheckUnavailableError, type BalanceErrorDetails, type BaseEvent, BaseSigner, type BatchBalancesResult, type BatchDecryptAsOptions, type BatchDecryptItem, type BatchDecryptResult, ChainMismatchError, type ChecksummedAddress, ChromeSessionStorage, type ClearValue, type CleartextRelayerConfig, type ConfidentialTransferEvent, type ConfidentialTransferFromRequest, type ConfidentialTransferRequest, ConfigurationError, type ContractAbi, type DecryptEndEvent, type DecryptErrorEvent, type EncryptedInput as DecryptInput, type DecryptPublicValuesResult, type DecryptResult, type DecryptStartEvent, type DecryptValuesParameters, Decryption, DecryptionFailedError, DefaultRegistryAddresses, type DelegateDecryptionRequest, type DelegatedDecryptOptions, type DelegatedForUserDecryptionEvent, DelegationContractIsSelfError, DelegationCooldownError, DelegationDelegateCannotBeWildcardError, DelegationDelegateEqualsContractError, DelegationExpirationTooSoonError, DelegationExpiredError, DelegationExpiryUnchangedError, DelegationNotFoundError, DelegationNotPropagatedError, DelegationSelfNotAllowedError, type DelegationStatus, type DelegationSubmittedEvent, Delegations, type EIP712TypedData, ERC1363_INTERFACE_ID, ERC20ReadFailedError, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, type EncryptEndEvent, type EncryptErrorEvent, type EncryptInput, EncryptOffloadUnavailableError, type EncryptParams, type EncryptResult, type EncryptStartEvent, type EncryptedValue, EncryptionFailedError, type ErrorForCode, type FheChain, type FheChainAuth, type FhevmClient, type FhevmClientOptions, type FhevmRelayerOptions, type FhevmRuntimeConfig, type FinalizeUnwrapRequest, type FinalizeUnwrapSubmittedEvent, type GenericLogger, type GenericProvider, type GenericSigner, type GenericStorage, type Hex, IndexedDBStorage, InsufficientAllowanceError, InsufficientConfidentialBalanceError, InsufficientERC20BalanceError, InvalidTransportKeyPairError, KeyWrappingError, type ListPairsOptions, MAX_UINT64, MemoryStorage, MutableWalletAccountStore, NoCiphertextError, NotEntitledError, Offline, type OnChainEvent, type PaginatedResult, type Permission, type PermitErrorEvent, type PermitOperation, Permits, type PrepareFees, type PrepareOptions, type PreparePermitRequest, type PrepareTransactionRequest, type PreparedFor, type PreparedPermit, PreparedPermitChainMismatchError, PreparedPermitExpiredError, type PreparedTransaction, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, type RelayerConfig, type RelayerOptions, RelayerRequestFailedError, type RelayerRequestOptions, type RelayerSDK, type RevokeDelegationRequest, type RevokeDelegationSubmittedEvent, type RevokedDelegationForUserDecryptionEvent, RevokedKmsContextError, RpcRateLimitError, type SerializedPermit, type SerializedPermitEip712, type SerializedTransportKeyPair, type SetOperatorRequest, type SetOperatorSubmittedEvent, type ShieldCallbacks, type ShieldOptions, type ShieldPath, type ShieldSubmittedEvent, type SignedPreparedPermit, SignerNotConfiguredError, SignerRequiredError, type SigningErrorMetadata, SigningFailedError, SigningRejectedError, TOKEN_TOPICS, Token, type TokenWrapperPair, type TokenWrapperPairWithMetadata, Topics, type TransactionErrorEvent, type TransactionKind, type TransactionOperation, type TransactionReceipt, type TransactionResult, TransactionRevertedError, type TransferAndCallRequest, type TransferCallbacks, type TransferFromSubmittedEvent, type TransferOptions, type TransferSubmittedEvent, TransportKeyPairChangedError, TransportKeyPairExpiredError, type TypedValue, type UnshieldAlreadyFinalizedDetails, UnshieldAlreadyFinalizedError, type UnshieldCallbacks, type UnshieldOptions, type UnshieldPhase1SubmittedEvent, type UnshieldPhase2StartedEvent, type UnshieldPhase2SubmittedEvent, type UnwrapAllRequest, type UnwrapFinalizedEvent, type UnwrapRequest, type UnwrapRequestedEvent, type UnwrapResult, type UnwrapSubmittedEvent, type VaultOperation, type VaultSubmittedEvent, WILDCARD_CONTRACT, type WalletAccount, type WalletAccountChange, type WalletAccountListener, WalletAccountNotReadyError, type WalletAccountStore, WalletNotConnectedError, type WrapEvent, type WrapOptions, type WrapRequest, type WrapSubmittedEvent, WrappedToken, WrappersRegistry, type WrappersRegistryConfig, type WriteContractArgs, type WriteContractConfig, type WriteFunctionName, ZERO_ENCRYPTED_VALUE, type ZamaConfig, type ZamaConfigBase, type ZamaConfigEthers, type ZamaConfigGeneric, type ZamaConfigViem, ZamaError, ZamaErrorCode, ZamaSDK, type ZamaSDKEvent, type ZamaSDKEventListener, type ZamaSDKEventType, ZamaSDKEvents, type ZamaSDKOptions, allowanceContract, anvil, approveContract, balanceOfContract, bscTestnet, chains, chromeSessionStorage, cleartext, confidentialBalanceOfContract, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, createConfig, createWalletAccountStore, decimalsContract, decodeAclEvent, decodeAclEvents, decodeConfidentialTransfer, decodeDelegatedForUserDecryption, decodeOnChainEvent, decodeOnChainEvents, decodeRevokedDelegationForUserDecryption, decodeUnwrapFinalized, decodeUnwrapRequested, decodeWrap, delegateForUserDecryptionContract, finalizeUnwrapContract, findDelegatedForUserDecryption, findRevokedDelegationForUserDecryption, findUnwrapRequested, findWrap, getConfidentialTokenAddressContract, getDelegationExpiryContract, getTokenAddressContract, getTokenPairContract, getTokenPairsContract, getTokenPairsLengthContract, getTokenPairsSliceContract, hardhat, hoodi, indexedDBStorage, inferredTotalSupplyContract, isConfidentialTokenContract, isConfidentialTokenValidContract, isConfidentialWrapperContract, isEncryptedValueZero, isHandleDelegatedContract, isOperatorContract, isRetryable, mainnet, matchZamaError, memoryStorage, nameContract, parsePreparedPermit, polygon, polygonAmoy, rateContract, retryAfterSeconds, revokeDelegationContract, sepolia, setOperatorContract, supportsInterfaceContract, symbolContract, transferAndCallContract, underlyingContract, unwrapContract, unwrapFromBalanceContract, unwrapRequesterContract, wrapContract, zenithTrexTestnet };
109
110
  //# sourceMappingURL=index.d.ts.map
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{S as e,_ as t,a as n,b as r,c as i,d as a,g as o,h as s,i as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,v as ee}from"./relayer-C3jVhqSK.js";import{$ as g,A as te,B as ne,C as re,D as ie,E as ae,F as _,H as v,J as y,K as b,L as oe,M as se,O as ce,P as le,Q as ue,R as de,S as fe,T as pe,U as x,V as S,W as me,X as he,Y as ge,Z as C,a as _e,b as ve,c as ye,d as be,g as xe,h as Se,i as Ce,j as w,k as we,l as Te,m as Ee,n as De,p as Oe,q as ke,r as Ae,s as je,t as Me,u as Ne,v as Pe,w as Fe,x as T,z as Ie}from"./erc165-BAd2z3ay.js";import{n as Le,r as E,t as D}from"./encryption-6AVd-82z.js";import{_ as O,a as k,c as Re,d as ze,f as Be,g as Ve,h as He,l as Ue,m as We,n as Ge,o as Ke,p as qe,r as Je,s as Ye,t as Xe,u as Ze}from"./token-CTvEGQmH.js";import{C as Qe,T as $e,_ as et,a as tt,c as nt,d as rt,f as it,g as at,h as ot,i as st,l as ct,m as lt,n as ut,o as dt,p as ft,r as pt,s as mt,t as ht,u as gt,v as _t,w as vt,y as yt}from"./wrapped-token-IDUEFpZx.js";import{r as A}from"./telemetry-Dll0Swdj.js";import{t as bt}from"./cleartext-CiE1gO7Y.js";import{a as xt,c as St,d as Ct,f as wt,i as Tt,l as Et,n as Dt,o as j,p as Ot,r as kt,s as At,t as jt,u as Mt}from"./base-signer-b1ff2VPI.js";import{n as M,r as Nt,s as Pt,t as Ft}from"./primitives-Cym-3HKa.js";import{t as N}from"./validation-ClSvPh6P.js";import{a as It,i as Lt,n as Rt,o as zt,r as Bt,s as Vt,t as Ht}from"./wrappers-registry-Cm3JJeqx.js";import{a as Ut,c as Wt,d as Gt,i as Kt,l as qt,n as Jt,o as Yt,r as Xt,s as Zt,t as Qt,u as $t}from"./chains-iPpnjXql.js";import{getAddress as P,size as en}from"viem";import{z as F}from"zod/mini";function tn(e,t){if(e instanceof p){let n=t[e.code];if(n)return n(e)}return t._?.(e)}var I=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}},L=class extends p{constructor(e,t){super(c.DelegationSelfNotAllowed,e,t),this.name=`DelegationSelfNotAllowedError`}},nn=class extends p{constructor(e,t){super(c.DelegationCooldown,e,t),this.name=`DelegationCooldownError`}},R=class extends p{constructor(e,t){super(c.DelegationNotFound,e,t),this.name=`DelegationNotFoundError`}},z=class extends p{constructor(e,t){super(c.DelegationExpired,e,t),this.name=`DelegationExpiredError`}},B=class extends p{constructor(e,t){super(c.DelegationExpiryUnchanged,e,t),this.name=`DelegationExpiryUnchangedError`}},V=class extends p{constructor(e,t){super(c.DelegationDelegateEqualsContract,e,t),this.name=`DelegationDelegateEqualsContractError`}},H=class extends p{constructor(e,t){super(c.DelegationDelegateCannotBeWildcard,e,t),this.name=`DelegationDelegateCannotBeWildcardError`}},rn=class extends p{constructor(e,t){super(c.DelegationContractIsSelf,e,t),this.name=`DelegationContractIsSelfError`}},an=class extends p{constructor(e,t){super(c.AclPaused,e,t),this.name=`AclPausedError`}},U=class extends p{constructor(e,t){super(c.DelegationExpirationTooSoon,e,t),this.name=`DelegationExpirationTooSoonError`}},W=class extends p{constructor(e,t){super(c.DelegationNotPropagated,e,t),this.name=`DelegationNotPropagatedError`}};const on=[D,y,u,W,me,x,I,O,b,C];function G(e,n,c={}){if(on.some(t=>e instanceof t))return e;let d=e instanceof Error?e.message:n;if(e instanceof Error&&f(e.message))return new b(e.message,{cause:e});if(t(e))return new C(`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 W(`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 I({encryptedValue:r(e.message)??``,contractAddress:c.contractAddress??``,account:c.account??``},{cause:e});if(a(e))return new O(d,{cause:e,retryAfter:i(e)});let p=m(e);return p===void 0&&ee(e)?new O(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 W(`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 D(n,{cause:e})}function sn(e,t){if(e instanceof p)return e;let n=m(e),r=o(e);return n!==void 0||s(e)?new u(e instanceof Error?e.message:t,n,{cause:e,retryAfter:i(e),retryable:r||void 0}):new E(t,{cause:e})}const K=[{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 q(e,t,n,r){return{address:e,abi:K,functionName:`delegateForUserDecryption`,args:[t,n,r]}}function J(e,t,n){return{address:e,abi:K,functionName:`revokeDelegationForUserDecryption`,args:[t,n]}}function cn(e,t,n,r){return{address:e,abi:K,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function ln(e,t,n,r,i){return{address:e,abi:K,functionName:`isHandleDelegatedForUserDecryption`,args:[t,n,r,i]}}const Y=2n**64n-1n,X=`0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF`;function un(e){return Tt(e.signer,e.provider,e)}var dn=class{#e;#t;#n;#r;#i;#a;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger,this.#a=e.emitEvent}#o(e){return S(this.#r,e)}#s(e,t){throw this.#a({type:_.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 Ke(`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 Ke(`grantDelegationPermit`,this.#e,this.#t)}catch(e){this.#s(`grantDelegationPermit`,e)}await n.grantPermit(t,e)}async hasPermit(e){return this.#r?this.#r.hasPermit(e):!1}async hasDelegationPermit(e,t){return this.#r?this.#r.hasPermit(t,e):!1}async warmTransportKeyPair(){let e=this.#r;if(!e)return;let t=this.#e?.walletAccount.getSnapshot();t&&await e.warmTransportKeyPair(t.address)}registerPermit(e,t){return this.batchRegisterPermits([{prepared:e,signature:t}])}async batchRegisterPermits(e){let t;try{t=this.#o(`registerPermit`)}catch(e){this.#s(`registerPermit`,e)}await t.batchRegisterPermits(e),await Promise.all([...new Set(e.map(e=>e.prepared.signerAddress))].map(e=>this.#c(e)))}async revokePermits(e){let t=this.#o(`revokePermits`),n=P((await k(`revokePermits`,this.#e,this.#t)).address);try{await t.revokePermits(e)}finally{await this.#c(n)}}async clear(){let e=this.#o(`clear`),t=P((await k(`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)}},fn=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 k(`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 k(`revokeDelegation`,this.#e,this.#t);return this.#n.revokeDelegation(n,{contractAddress:e,delegateAddress:t,delegatorAddress:r.address})}async isActive(e){return this.#n.isDelegated(e)}async getExpiry(e){return this.#n.getDelegationExpiry(e)}async getStatus(e){return this.#n.getStatus(e)}},pn=class{#e;#t;#n;#r;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.router,this.#r=e.decryptionService}#i(e){return S(this.#r,e)}async decryptValues(e,t){let n=this.#i(`decryptValues`),r=await k(`decryptValues`,this.#e,this.#t);return n.decryptValues(e,r.address,A(t,`decrypt-values`))}async delegatedDecryptValues(e,t,n=t,r){let i=this.#i(`delegatedDecryptValues`),a=await k(`delegatedDecryptValues`,this.#e,this.#t);return i.delegatedDecryptValues(e,t,a.address,n,A(r,`delegated-decrypt-values`))}async decryptPublicValues(e,t){if(e.length===0)return{clearValues:{},decryptionProof:`0x`,abiEncodedClearValues:`0x`};let n=A(t,`decrypt-public-values`);try{let t=await this.#n.relayer.decryptPublicValuesWithSignatures({encryptedValues:e,options:n}),r={};return t.checkSignaturesArgs.handlesList.forEach((e,n)=>{le(t.clearValues[n],`result.clearValues[${n}]`),r[e]=t.clearValues[n].value}),{clearValues:r,abiEncodedClearValues:t.checkSignaturesArgs.abiEncodedCleartexts,decryptionProof:t.checkSignaturesArgs.decryptionProof}}catch(e){throw G(e,`Public decryption failed`)}}async delegatedBatchDecryptValues({encryptedInputs:e,delegatorAddress:t,accountAddress:n=t,maxConcurrency:r,waitForPropagation:i,operation:a}){let o=this.#i(`delegatedBatchDecryptValues`),s=await k(`delegatedBatchDecryptValues`,this.#e,this.#t);return o.delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:s.address,accountAddress:n,maxConcurrency:r,waitForPropagation:i,operation:a??`delegated-batch-decrypt-values`})}},mn=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}prepare(e,t){return this.#e.prepare(e,t)}preparePermit(e){return this.#t.preparePermit(e)}batchPreparePermits(e){return this.#t.batchPreparePermits(e)}},hn=class{async get(e){return(await chrome.storage.session.get(e))[e]??null}async set(e,t){await chrome.storage.session.set({[e]:t})}async delete(e){await chrome.storage.session.remove(e)}};const gn=new hn,_n=F.union([F.bigint(),F.boolean(),M]),vn=F.array(F.string());var yn=class{#e;#t;#n=`zama:decrypt`;#r=`${this.#n}:keys`;#i=Promise.resolve();constructor(e,t){this.#e=e,this.#t=t}async get(e,t,n){try{let r=this.#c(e,t,n),i=await this.#e.get(r);if(i===null)return null;let a=_n.safeParse(i);return a.success?a.data:(await this.delete(e,t,n),null)}catch(e){return this.#t.warn(`CachingService.get failed`,{error:e}),null}}async set(e,t,n,r){try{let i=this.#c(e,t,n);await this.#e.set(i,r),this.#i=this.#i.then(()=>this.#u(i).catch(e=>{this.#t.warn(`CachingService index write failed`,{error:e})})),await this.#i}catch(e){this.#t.warn(`CachingService.set failed`,{error:e})}}async delete(e,t,n){let r=this.#c(e,t,n);this.#i=this.#i.then(()=>this.#a(r).catch(e=>{this.#t.warn(`CachingService.delete failed`,{error:e})})),await this.#i}async clearForRequester(e){this.#i=this.#i.then(()=>this.#o(e).catch(e=>{this.#t.warn(`CachingService.clearForRequester failed`,{error:e})})),await this.#i}async clearAll(){this.#i=this.#i.then(()=>this.#s().catch(e=>{this.#t.warn(`CachingService.clearAll failed`,{error:e})})),await this.#i}async#a(e){await this.#e.delete(e).catch(()=>{});let t=await this.#l(),n=t.filter(t=>t!==e);n.length!==t.length&&await this.#e.set(this.#r,n)}async#o(e){let t=P(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}:${P(e)}:${P(t)}:${n.toLowerCase()}`}async#l(){let e=await this.#e.get(this.#r);if(e===null)return[];let t=vn.safeParse(e);return t.success?t.data:(await this.#e.delete(this.#r).catch(()=>{}),[])}async#u(e){let t=await this.#l();t.includes(e)||(t.push(e),await this.#e.set(this.#r,t))}};function bn(e,t){let n=xn(e,t);if(!n)throw new D(`No permit covers contract ${t} after allow()`);return{privateKey:e.keypair.privateKey,publicKey:e.keypair.publicKey,serializedPermit:n.serializedPermit}}function xn(e,t){let n=Ft(t);return e.permissions.find(e=>e.contractAddresses.includes(n))}const Sn=e=>new Promise(t=>setTimeout(t,e));var Cn=class{#e;#t;#n;#r;#i;constructor({cache:e,credentialService:t,delegationService:n,router:r,emitEvent:i}){this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#i=i}async decryptValues(e,t,n){let r=P(t);return this.#s(e,{requesterAddress:r,errorMessage:`Failed to decrypt encrypted values`},n)}async delegatedDecryptValues(e,t,n,r,i){let a=P(t),o=P(n),s={spent:!1};return this.#a(i?.waitForPropagation??!0,()=>this.#s(e,{requesterAddress:P(r),delegator:a,validate:e=>this.#m(e,{delegatorAddress:a,delegateAddress:o}),errorMessage:`Failed to decrypt delegated encrypted values`},{operation:i?.operation},s))}async#a(e,t){let n;for(let r=0;r<16;r++)try{return await t()}catch(t){if(n=t,!(r<15&&e&&t instanceof W))throw t;await Sn(2e3)}throw n}async delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:n,accountAddress:r,maxConcurrency:i=5,waitForPropagation:a=!0,operation:o}){let s=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:P(e.contractAddress)}));if(s.length===0)return{items:s};let c=P(r);try{let e=await this.delegatedDecryptValues(s.map(({encryptedValue:e,contractAddress:t})=>({encryptedValue:e,contractAddress:t})),t,n,c,{waitForPropagation:a,operation:o});for(let t of s)this.#d(t,e);return{items:s}}catch(e){if(Ze(e))throw e;if(s.length===1){let[n=this.#p()]=s;return n.error=this.#f(e,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:n.contractAddress,account:P(t)}),{items:s}}}let l=!1,u;if(await Je(s.map(e=>async()=>{if(!l)try{let r=await this.delegatedDecryptValues([{encryptedValue:e.encryptedValue,contractAddress:e.contractAddress}],t,n,c,{waitForPropagation:!1,operation:o});this.#d(e,r)}catch(n){if(Ze(n)){l=!0,u??=n;return}e.error=this.#f(n,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:e.contractAddress,account:P(t)})}}),i),u!==void 0)throw u;return{items:s}}async#o(e,t,n,r){let i=bn(e,t),a;try{a=await this.#r.relayer.parseTransportKeyPair({publicKey:i.publicKey,privateKey:i.privateKey,tkmsVersion:e.keypair.tkmsVersion})}catch(e){throw e instanceof Error&&f(e.message)&&await this.#t.evictTransportKeyPair(),e}let o=await this.#r.relayer.parseSignedDecryptionPermit({transportKeyPair:a,serializedPermit:i.serializedPermit});return this.#r.relayer.decryptValues({transportKeyPair:a,signedPermit:o,encryptedValues:n,contractAddress:t,options:r})}async#s(t,n,r,i={spent:!1}){if(t.length===0)return{};let a=t.map(e=>({encryptedValue:e.encryptedValue,contractAddress:P(e.contractAddress)})),o={},s=[];for(let e of a)Ue(e.encryptedValue)?o[e.encryptedValue]=0n:s.push(e);if(s.length===0)return o;let c=Array.from(new Set(a.map(e=>e.contractAddress))),l=Array.from(new Set(s.map(e=>e.contractAddress)));if(n.validate)try{await n.validate(l)}catch(e){throw ee(e)?this.#u(e,`the delegation pre-check`):e}let u=[];for(let e of s){let t=await this.#e.get(n.requesterAddress,e.contractAddress,e.encryptedValue);t===null?u.push(e):o[e.encryptedValue]=t}if(u.length===0)return o;let d=await this.#t.grantPermit(c,n.delegator),f=new Map;for(let e of u){let t=f.get(e.contractAddress);t?t.push(e.encryptedValue):f.set(e.contractAddress,[e.encryptedValue])}let m=[];for(let[e,t]of f)for(let n of Re(t))m.push({contractAddress:e,encryptedValues:n});let h=Date.now(),g=u.map(e=>e.encryptedValue);try{this.#i({type:_.DecryptStart,encryptedValues:g});try{await this.#c(n,d,m,o,r)}catch(e){if(!(e instanceof C)||i.spent)throw e;let t=d.permissions.map(e=>e.serializedPermit.signature);i.spent=!0;try{d=await this.#t.recoverPermits(c,n.delegator,t)}catch(e){throw e instanceof x?new C(`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:_.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:_.DecryptError,error:e(r),durationMs:Date.now()-h,encryptedValues:g}),G(t,n.errorMessage,{isDelegated:n.delegator!==void 0})}}async#c(e,t,n,r,i){let a=(await Je(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 C)??a[0]}async#l(e,t,n,r,i,a){let o;try{o=await this.#o(t,n,r,a)}catch(t){throw G(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 D(`${e.errorMessage}: relayer returned no clear value for ${s.length} of ${r.length} handle(s) on ${n}`,{cause:AggregateError(s.map(e=>new D(`No clear value for handle ${e} on ${n}`)),`${s.length} handle(s) missing a clear value on ${n}`)})}#u(e,t){return new O(`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 D(`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:G(e,t,n)}#p(){throw new D(`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 Z={AlreadyDelegatedOrRevokedInSameBlock:e=>new nn(`Only one delegate/revoke per (delegator, delegate, contract) per block. Wait for the next block before retrying.`,{cause:e}),SenderCannotBeContractAddress:e=>new rn(`The contract address cannot be the caller address.`,{cause:e}),EnforcedPause:e=>new an(`The ACL contract is paused. Delegation operations are temporarily disabled.`,{cause:e}),SenderCannotBeDelegate:e=>new L(`Cannot delegate to yourself (delegate === msg.sender).`,{cause:e}),DelegateCannotBeContractAddress:e=>new V(`Delegate address cannot be the same as the contract address.`,{cause:e}),DelegateCannotBeWildcard:e=>new H(`Delegate address cannot be the wildcard address; it can only be used as the contract address.`,{cause:e}),ExpirationDateBeforeOneHour:e=>new U(`Expiration date must be at least 1 hour in the future.`,{cause:e}),ExpirationDateAlreadySetToSameValue:e=>new B(`The new expiration date is the same as the current one.`,{cause:e}),NotDelegatedYet:e=>new R(`Cannot revoke: no active delegation exists.`,{cause:e})};function wn(e){return Object.hasOwn(Z,e)}function Tn(e,t){let n=$e(e);if(n&&wn(n))return Z[n](t);let r=e instanceof Error?e.message:String(e);for(let[e,n]of Object.entries(Z))if(r.includes(e))return n(t);return null}var En=class{#e;#t;#n;#r;constructor({provider:e,router:t,emitEvent:n=()=>{},logger:r}){this.#t=e,this.#e=t,this.#r=r,this.#n=n}async delegateDecryption(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r,expirationDate:i}){if(i&&i.getTime()<Date.now()+36e5)throw new U(`Expiration date must be at least 1 hour in the future`);let a=P(t),o=P(n),s=P(r);if(o===s)throw new L(`Cannot delegate to yourself (delegate === msg.sender).`);if(o===P(`0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF`))throw new H(`Delegate address cannot be the wildcard address; it can only be used as the contract address.`);if(o===a)throw new V(`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)):Y,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 B(`The new expiration date (${l}) is the same as the current one. No on-chain change needed.`);return a!==P(`0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF`)&&await this.#i({contractAddress:a,delegatorAddress:s,delegateAddress:o}),this.#s({operation:`delegateDecryption`,signer:e,contractAddress:a,config:q(c,o,a,l)})}async revokeDelegation(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r}){let i=P(t),a=P(n),o=P(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 R(`No active delegation found for delegate ${a} on contract ${i}.`);return this.#s({operation:`revokeDelegation`,signer:e,contractAddress:i,config:J(s,a,i)})}async isDelegated(e){return(await this.getStatus(e)).isActive}async getStatus(e){let t=P(e.contractAddress)===X,[n,r]=await Promise.all([this.getDelegationExpiry(e),t?Promise.resolve(0n):this.getDelegationExpiry({...e,contractAddress:X})]),i=this.#a(n)||this.#a(r)?await this.#t.getBlockTimestamp():void 0,a=this.#o(n,i);if(a.isActive)return a;let o=this.#o(r,i);return o.isActive?o:n>=r?a:o}async#i(e){try{let{isActive:t}=await this.getStatus({...e,contractAddress:X});t&&this.#r.warn(`delegateDecryption: ${e.delegateAddress} already holds an active wildcard delegation from ${e.delegatorAddress}; this grant for ${e.contractAddress} is redundant.`)}catch(e){this.#r.warn(`delegateDecryption: wildcard redundancy check failed`,{error:e})}}#a(e){return e!==0n&&e!==Y}#o(e,t){return e===0n?{isActive:!1,expiryTimestamp:e}:e===Y?{isActive:!0,expiryTimestamp:e}:{isActive:t!==void 0&&e>t,expiryTimestamp:e}}async getDelegationExpiry({contractAddress:e,delegatorAddress:t,delegateAddress:n}){let r=this.#e.relayer.chain.aclContractAddress;return this.#t.readContract(cn(r,P(t),P(n),P(e)))}async#s({operation:e,signer:t,contractAddress:n,config:r}){try{return await Ge({operation:e,signer:t,provider:this.#t,config:r,emit:e=>this.#n(e,n),logger:this.#r})}catch(e){throw this.#c(e),e}}#c(e){if(!(e instanceof v))return;let t=Tn(e.cause??e,e);if(t)throw t}async findInactiveDelegations(e,t,n){let r=new Map;return await Promise.all(e.map(async e=>{try{await this.assertDelegationActive(e,t,n)}catch(t){if(t instanceof R||t instanceof z){let n=P(e);r.set(n,t);return}throw t}})),r}async assertDelegationActive(e,t,n){let r=P(e),i=P(t),a=P(n),{isActive:o,expiryTimestamp:s}=await this.getStatus({contractAddress:r,delegatorAddress:i,delegateAddress:a});if(!o)throw s===0n?new R(`No active delegation from ${i} to ${a} for ${r}`):new z(`Delegation from ${i} to ${a} for ${r} has expired`)}},Dn=class{#e;#t;constructor({router:e,emitEvent:t}){this.#e=e,this.#t=t}async encryptValues(t,n){let r=Date.now(),i=P(t.contractAddress);try{this.#t({type:_.EncryptStart},i);let e=await this.#e.relayer.encryptValues({...t,options:n});return this.#t({type:_.EncryptEnd,durationMs:Date.now()-r},i),e}catch(t){throw this.#t({type:_.EncryptError,error:e(t),durationMs:Date.now()-r},i),sn(t,`Encryption failed`)}}},On=class{#e;#t;#n;#r;#i;#a=new Set;#o;constructor(e){this.#e=e.signer,this.#t=e.router,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger,this.#e&&(this.#o=this.#e.walletAccount.subscribe(e=>{this.#s(e).catch(e=>{this.#i.warn(`wallet account handler failed`,{error:e})})}))}onWalletAccountChange(e){return this.#a.add(e),()=>{this.#a.delete(e)}}dispose(){this.#o?.(),this.#o=void 0,this.#a.clear()}async#s(e){let t=e.previous,n=e.next,r=n?.chainId;r!==void 0&&await 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 kn=F.object({kind:F.literal(`ConfidentialTransfer`),from:M,token:M,to:M,amount:F.bigint()}),An=F.object({kind:F.literal(`ConfidentialTransferFrom`),from:M,token:M,owner:M,to:M,amount:F.bigint()}),jn=F.object({kind:F.literal(`SetOperator`),from:M,token:M,operator:M,until:Pt}),Mn=F.object({kind:F.literal(`Unwrap`),from:M,token:M,to:M,amount:F.bigint()}),Nn=F.object({kind:F.literal(`UnwrapAll`),from:M,token:M,to:M}),Pn=F.object({kind:F.literal(`FinalizeUnwrap`),from:M,wrapper:M,unwrapRequestIdOrAmount:Nt}),Q=F.object({kind:F.literal(`ApproveUnderlying`),from:M,underlying:M,spender:M,amount:F.bigint()}),Fn=F.object({kind:F.literal(`Wrap`),from:M,wrapper:M,to:M,amount:F.bigint()}),In=Nt.check(F.refine(e=>e===`0x`||en(e)===20,`TransferAndCall.recipientData must be "0x" (self-shield to the sender) or a raw 20-byte address, not a 32-byte ABI-encoded value the wrapper would truncate to a garbage address`)),Ln=F.object({kind:F.literal(`TransferAndCall`),from:M,underlying:M,wrapper:M,amount:F.bigint(),recipientData:F.optional(In)}),Rn=F.object({kind:F.literal(`DelegateDecryption`),from:M,contractAddress:M,delegateAddress:M,expirationDate:F.optional(F.date())}),zn=F.object({kind:F.literal(`RevokeDelegation`),from:M,contractAddress:M,delegateAddress:M});F.discriminatedUnion(`kind`,[kn,An,jn,Mn,Nn,Pn,Q,Fn,Ln,Rn,zn]);const Bn=F.strictObject({maxFeePerGas:F.bigint(),maxPriorityFeePerGas:F.bigint()}),$=F.object({nonce:F.optional(F.int().check(F.nonnegative())),gasLimit:F.optional(F.bigint()),fees:F.optional(Bn)}),Vn=F.object({address:M,abi:F.array(F.unknown()),functionName:F.string(),args:F.array(F.unknown()),value:F.optional(F.bigint()),gas:F.optional(F.bigint())}),Hn=F.extend($,{from:M,calldata:Vn});var Un=class{#e;#t;#n;constructor(e){this.#e=e.provider,this.#t=e.router,this.#n=e.encryption}async prepare(e,t){t&&=N($,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=N(Hn,{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=N(kn,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from},{operation:`offline-confidential-transfer`}),r=t[0];if(!r)throw new E(`Encryption returned no handles for ConfidentialTransfer`);return Pe(e.token,e.to,r,n)}async#a(e){e=N(An,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from},{operation:`offline-confidential-transfer-from`}),r=t[0];if(!r)throw new E(`Encryption returned no handles for ConfidentialTransferFrom`);return ve(e.token,e.owner,e.to,r,n)}#o(e){return e=N(jn,e),pe(e.token,e.operator,e.until)}async#s(e){e=N(Mn,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from},{operation:`offline-unwrap`}),r=t[0];if(!r)throw new E(`Encryption returned no handles for Unwrap`);return ie(e.token,e.from,e.to,r,n)}async#c(e){e=N(Nn,e);let t=await this.#e.readContract(Se(e.token,e.from));return ce(e.token,e.from,e.to,t)}async#l(e){e=N(Pn,e);let t=await this.#t.relayer.decryptPublicValuesWithSignatures({encryptedValues:[e.unwrapRequestIdOrAmount],options:{operation:`offline-finalize-unwrap`}}).catch(e=>{throw G(e,`Public decryption failed during FinalizeUnwrap`)}),n=t.clearValues[0]?.value;return se(n,`FinalizeUnwrap: decryptPublicValuesWithSignatures(handle).clearValue`),T(e.wrapper,e.unwrapRequestIdOrAmount,n,t.checkSignaturesArgs.decryptionProof)}#u(e){return e=N(Q,e),Te(e.underlying,e.spender,e.amount)}#d(e){return e=N(Fn,e),te(e.wrapper,e.to,e.amount)}#f(e){return e=N(Ln,e),Qe(e.underlying,e.wrapper,e.amount,e.recipientData)}#p(e){if(e=N(Rn,e),e.expirationDate&&e.expirationDate.getTime()<Date.now()+36e5)throw new U(`Expiration date must be at least 1 hour in the future`);if(e.delegateAddress===e.from)throw new L(`Cannot delegate to yourself (delegate === msg.sender).`);if(e.delegateAddress===e.contractAddress)throw new V(`Delegate address cannot be the same as the contract address (${e.contractAddress}).`);let t=e.expirationDate?BigInt(Math.floor(e.expirationDate.getTime()/1e3)):Y;return q(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress,t)}#m(e){return e=N(zn,e),J(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress)}};function Wn(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 Gn(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 Kn(e){if(e===void 0)return;let t=N(St,e);return new Et(typeof t==`string`?t:new Uint8Array(t))}var qn=class{#e;provider;signer;storage;registry;permits;delegations;decryption;offline;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;constructor(e,t={}){Wn(t),Gn(t.transportKeyPairDerivationSecret);let n=Kn(t.transportKeyPairDerivationSecret);this.#e=e.router,this.provider=e.provider,this.signer=e.signer,this.storage=e.storage,this.#r=e.onEvent??function(){},this.#i=e.logger,this.#a=new yn(e.storage,this.#i),this.#u=new En({provider:this.provider,router:e.router,emitEvent:this.emitEvent.bind(this),logger:this.#i});let r={};for(let t of e.chains)t.registryAddress&&(r[t.id]=t.registryAddress);this.registry=new j({provider:this.provider,registryAddresses:r,registryTTL:e.registryTTL}),this.#n=r,this.#t=e.registryTTL,this.#l=new At({router:e.router,signer:e.signer,transportKeyPairTTL:e.transportKeyPairTTL,permitTTL:e.permitTTL,scope:e.transportKeyPairScope,derivationSecret:n,storage:this.storage,permitStorage:e.permitStorage,logger:this.#i,emitEvent:this.emitEvent.bind(this)}),e.signer&&(this.#c=new Cn({cache:this.#a,credentialService:this.#l,delegationService:this.#u,router:e.router,emitEvent:this.emitEvent.bind(this)})),this.#s=new Dn({router:e.router,emitEvent:this.emitEvent.bind(this)}),this.#o=new On({signer:e.signer,router:e.router,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.#d=new Un({provider:this.provider,router:e.router,encryption:this.#s,emitEvent:(e,t)=>this.emitEvent(e,t)}),this.permits=new dn({signer:this.signer,provider:this.provider,cachingService:this.#a,credentialService:this.#l,logger:this.#i,emitEvent:this.emitEvent.bind(this)}),this.delegations=new fn({signer:this.signer,provider:this.provider,delegationService:this.#u}),this.decryption=new pn({signer:this.signer,provider:this.provider,router:e.router,decryptionService:this.#c}),this.offline=new mn(this.#d,this.#l)}onWalletAccountChange(e){return this.#o.onWalletAccountChange(e)}get logger(){return this.#i}get relayer(){return this.#e.relayer}emitEvent(e,t){try{this.#r({...e,tokenAddress:t,timestamp:Date.now()})}catch(t){this.#i.warn(`${e.type} event listener silently failed`,{error:t})}}createWrappersRegistry(e){return new j({provider:this.provider,registryAddresses:{...this.#n,...e},registryTTL:this.#t})}async encrypt(e,t){return this.#s.encryptValues(e,A(t,`encrypt`))}createToken(e){return new Xe(this,e)}createWrappedToken(e){return new ht(this,e)}dispose(){this.#o.dispose(),this.#e.dispose()}terminate(){this.dispose(),this.signer?.dispose?.()}[Symbol.dispose](){this.terminate()}};export{ut as ACL_TOPICS,an as AclPausedError,pt as AclTopics,ze as BalanceCheckUnavailableError,jt as BaseSigner,Ve as ChainMismatchError,hn as ChromeSessionStorage,h as ConfigurationError,pn as Decryption,D as DecryptionFailedError,xt as DefaultRegistryAddresses,rn as DelegationContractIsSelfError,nn as DelegationCooldownError,H as DelegationDelegateCannotBeWildcardError,V as DelegationDelegateEqualsContractError,U as DelegationExpirationTooSoonError,z as DelegationExpiredError,B as DelegationExpiryUnchangedError,R as DelegationNotFoundError,W as DelegationNotPropagatedError,L as DelegationSelfNotAllowedError,fn as Delegations,Me as ERC1363_INTERFACE_ID,Be as ERC20ReadFailedError,De as ERC7984_INTERFACE_ID,Ae as ERC7984_WRAPPER_INTERFACE_ID,Le as EncryptOffloadUnavailableError,E as EncryptionFailedError,wt as IndexedDBStorage,qe as InsufficientAllowanceError,We as InsufficientConfidentialBalanceError,He as InsufficientERC20BalanceError,b as InvalidTransportKeyPairError,ke as KeyWrappingError,Y as MAX_UINT64,Mt as MemoryStorage,Dt as MutableWalletAccountStore,y as NoCiphertextError,I as NotEntitledError,mn as Offline,dn as Permits,ge as PreparedPermitChainMismatchError,he as PreparedPermitExpiredError,u as RelayerRequestFailedError,C as RevokedKmsContextError,O as RpcRateLimitError,oe as SignerNotConfiguredError,de as SignerRequiredError,x as SigningFailedError,me as SigningRejectedError,st as TOKEN_TOPICS,Xe as Token,tt as Topics,v as TransactionRevertedError,ue as TransportKeyPairChangedError,g as TransportKeyPairExpiredError,vt as UnshieldAlreadyFinalizedError,X as WILDCARD_CONTRACT,Ie as WalletAccountNotReadyError,ne as WalletNotConnectedError,ht as WrappedToken,j as WrappersRegistry,Ye as ZERO_ENCRYPTED_VALUE,p as ZamaError,c as ZamaErrorCode,qn as ZamaSDK,_ as ZamaSDKEvents,ye as allowanceContract,Qt as anvil,Te as approveContract,Ne as balanceOfContract,Jt as bscTestnet,Xt as chains,gn as chromeSessionStorage,bt as cleartext,Se as confidentialBalanceOfContract,xe as confidentialTotalSupplyContract,Pe as confidentialTransferContract,ve as confidentialTransferFromContract,un as createConfig,kt as createWalletAccountStore,be as decimalsContract,dt as decodeAclEvent,mt as decodeAclEvents,nt as decodeConfidentialTransfer,ct as decodeDelegatedForUserDecryption,gt as decodeOnChainEvent,rt as decodeOnChainEvents,it as decodeRevokedDelegationForUserDecryption,ft as decodeUnwrapFinalized,lt as decodeUnwrapRequested,ot as decodeWrap,q as delegateForUserDecryptionContract,T as finalizeUnwrapContract,at as findDelegatedForUserDecryption,et as findRevokedDelegationForUserDecryption,_t as findUnwrapRequested,yt as findWrap,Ht as getConfidentialTokenAddressContract,cn as getDelegationExpiryContract,Rt as getTokenAddressContract,Bt as getTokenPairContract,Lt as getTokenPairsContract,It as getTokenPairsLengthContract,zt as getTokenPairsSliceContract,Kt as hardhat,Ut as hoodi,Ot as indexedDBStorage,fe as inferredTotalSupplyContract,Yt as ingenTestnet,Ce as isConfidentialTokenContract,Vt as isConfidentialTokenValidContract,_e as isConfidentialWrapperContract,Ue as isEncryptedValueZero,ln as isHandleDelegatedContract,re as isOperatorContract,n as isRetryable,Zt as mainnet,tn as matchZamaError,Ct as memoryStorage,Oe as nameContract,Wt as polygon,qt as polygonAmoy,Fe as rateContract,d as retryAfterSeconds,J as revokeDelegationContract,$t as sepolia,pe as setOperatorContract,je as supportsInterfaceContract,Ee as symbolContract,Qe as transferAndCallContract,ae as underlyingContract,ie as unwrapContract,ce as unwrapFromBalanceContract,we as unwrapRequesterContract,te as wrapContract,Gt as zenithTrexTestnet};
1
+ import{S as e,_ as t,a as n,b as r,c as i,d as a,g as o,h as s,i as c,m as l,n as u,o as d,p as f,r as p,s as m,t as h,v as ee}from"./relayer-C3jVhqSK.js";import{a as g,c as te,d as ne,i as _,l as v,n as re,o as y,s as ie,t as b,u as ae}from"./signing-C6nbPCyd.js";import{n as oe,r as x,t as S}from"./encryption-6AVd-82z.js";import{A as se,B as ce,C as le,D as ue,E as de,F as C,H as fe,L as pe,M as me,O as he,P as ge,R as _e,S as ve,T as ye,V as w,a as be,b as xe,c as Se,d as Ce,g as we,h as Te,i as Ee,j as T,k as De,l as E,m as Oe,n as ke,p as Ae,r as je,s as Me,t as Ne,u as Pe,v as D,w as Fe,x as O,z as Ie}from"./erc165-B8gx2luK.js";import{n as Le,r as k}from"./fatal-batch-BiiS7KdS.js";import{a as A,c as Re,d as ze,f as Be,h as Ve,l as He,m as Ue,n as We,o as Ge,p as Ke,r as qe,s as Je,t as Ye,u as Xe}from"./token-g6sinwTx.js";import{C as Ze,T as Qe,_ as $e,a as et,c as tt,d as nt,f as rt,g as it,h as at,i as ot,l as st,m as ct,n as lt,o as ut,p as dt,r as ft,s as pt,t as mt,u as ht,v as gt,w as _t,y as vt}from"./wrapped-token-3usJd0oi.js";import{r as j}from"./telemetry-BDnhC-vh.js";import{t as yt}from"./cleartext-CvCakQal.js";import{a as bt,c as xt,d as St,f as Ct,i as wt,l as Tt,m as Et,n as Dt,o as M,p as Ot,r as kt,s as At,t as jt,u as Mt}from"./base-signer-BoBsvn5Q.js";import{n as N,r as Nt,s as Pt,t as Ft}from"./primitives-Cym-3HKa.js";import{t as P}from"./validation-ClSvPh6P.js";import{a as It,i as Lt,n as Rt,o as zt,r as Bt,s as Vt,t as Ht}from"./wrappers-registry-Cm3JJeqx.js";import{a as Ut,c as Wt,i as Gt,l as Kt,n as qt,o as Jt,r as Yt,s as Xt,t as Zt,u as Qt}from"./chains-BwlDI944.js";import{getAddress as F,size as $t}from"viem";import{z as I}from"zod/mini";function en(e,t){if(e instanceof p){let n=t[e.code];if(n)return n(e)}return t._?.(e)}var L=class extends p{encryptedValue;contractAddress;account;constructor(e,t){super(c.NotEntitled,`Account ${e.account} is not entitled to decrypt encrypted value ${e.encryptedValue} on contract ${e.contractAddress}. This is not a transient failure — the account needs an on-chain ACL grant before it can decrypt this encrypted value.`,t),this.name=`NotEntitledError`,this.encryptedValue=e.encryptedValue,this.contractAddress=e.contractAddress,this.account=e.account}},R=class extends p{constructor(e,t){super(c.DelegationSelfNotAllowed,e,t),this.name=`DelegationSelfNotAllowedError`}},tn=class extends p{constructor(e,t){super(c.DelegationCooldown,e,t),this.name=`DelegationCooldownError`}},z=class extends p{constructor(e,t){super(c.DelegationNotFound,e,t),this.name=`DelegationNotFoundError`}},B=class extends p{constructor(e,t){super(c.DelegationExpired,e,t),this.name=`DelegationExpiredError`}},V=class extends p{constructor(e,t){super(c.DelegationExpiryUnchanged,e,t),this.name=`DelegationExpiryUnchangedError`}},H=class extends p{constructor(e,t){super(c.DelegationDelegateEqualsContract,e,t),this.name=`DelegationDelegateEqualsContractError`}},U=class extends p{constructor(e,t){super(c.DelegationDelegateCannotBeWildcard,e,t),this.name=`DelegationDelegateCannotBeWildcardError`}},nn=class extends p{constructor(e,t){super(c.DelegationContractIsSelf,e,t),this.name=`DelegationContractIsSelfError`}},rn=class extends p{constructor(e,t){super(c.AclPaused,e,t),this.name=`AclPausedError`}},W=class extends p{constructor(e,t){super(c.DelegationExpirationTooSoon,e,t),this.name=`DelegationExpirationTooSoonError`}},G=class extends p{constructor(e,t){super(c.DelegationNotPropagated,e,t),this.name=`DelegationNotPropagatedError`}};const an=[S,y,u,G,re,b,L,k,_,v];function K(e,n,c={}){if(an.some(t=>e instanceof t))return e;let d=e instanceof Error?e.message:n;if(e instanceof Error&&f(e.message))return new _(e.message,{cause:e});if(t(e))return new v(`The permit's KMS context has been revoked on-chain, so the permit is no longer usable. The SDK evicts the permit and re-grants automatically; if this error surfaced, the retry failed the same way. The on-chain validity check is cached for up to 15 minutes, so a just-revoked context can keep failing across that window. Retry after the window; the SDK re-runs the recovery on the next decrypt, no manual cleanup is needed.`,{cause:e});if(e instanceof Error&&l(e.message))return c.isDelegated?new G(`Delegated decryption was denied by the on-chain ACL check. This is most commonly caused by the delegation not having propagated yet, or by the RPC node serving a stale block. Propagation usually completes within ~10 blocks (a few seconds) and the SDK retries across that window; seeing this means it did not sync in time. Retry shortly (and prefer a fresh, low-lag RPC endpoint). If it persists, the delegator may genuinely lack the on-chain ACL grant.`,{cause:e}):new L({encryptedValue:r(e.message)??``,contractAddress:c.contractAddress??``,account:c.account??``},{cause:e});if(a(e))return new k(d,{cause:e,retryAfter:i(e)});let p=m(e);return p===void 0&&ee(e)?new k(d,{cause:e,retryAfter:i(e)}):p===400?new y(e instanceof Error?e.message:`No ciphertext for this account`,{cause:e}):c.isDelegated&&p===500?new G(`Delegated decryption failed with a server error. This is most commonly caused by the delegation not having propagated to the gateway yet. Cross-chain sync usually completes within ~10 blocks (a few seconds) and the SDK retries across that window; seeing this means it did not sync in time — retry shortly. If the error persists, the gateway or relayer may be experiencing an unrelated issue.`,{cause:e}):s(e)||p!==void 0?new u(d,p,{cause:e,retryAfter:i(e),retryable:o(e)||void 0}):new S(n,{cause:e})}function on(e,t){if(e instanceof p)return e;let n=m(e),r=o(e);return n!==void 0||s(e)?new u(e instanceof Error?e.message:t,n,{cause:e,retryAfter:i(e),retryable:r||void 0}):new x(t,{cause:e})}const q=[{type:`function`,name:`allow`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`allowForDecryption`,inputs:[{name:`handlesList`,type:`bytes32[]`,internalType:`bytes32[]`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`allowTransient`,inputs:[{name:`ciphertext`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`cleanTransientStorage`,inputs:[],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`delegateForUserDecryption`,inputs:[{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`},{name:`expirationDate`,type:`uint64`,internalType:`uint64`}],outputs:[],stateMutability:`nonpayable`},{type:`function`,name:`getUserDecryptionDelegationExpirationDate`,inputs:[{name:`delegator`,type:`address`,internalType:`address`},{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint64`,internalType:`uint64`}],stateMutability:`view`},{type:`function`,name:`isAccountDenied`,inputs:[{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isAllowed`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isAllowedForDecryption`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`isHandleDelegatedForUserDecryption`,inputs:[{name:`delegator`,type:`address`,internalType:`address`},{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`},{name:`handle`,type:`bytes32`,internalType:`bytes32`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`multicall`,inputs:[{name:`data`,type:`bytes[]`,internalType:`bytes[]`}],outputs:[{name:`results`,type:`bytes[]`,internalType:`bytes[]`}],stateMutability:`payable`},{type:`function`,name:`persistAllowed`,inputs:[{name:`handle`,type:`bytes32`,internalType:`bytes32`},{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`revokeDelegationForUserDecryption`,inputs:[{name:`delegate`,type:`address`,internalType:`address`},{name:`contractAddress`,type:`address`,internalType:`address`}],outputs:[],stateMutability:`nonpayable`}];function J(e,t,n,r){return{address:e,abi:q,functionName:`delegateForUserDecryption`,args:[t,n,r]}}function Y(e,t,n){return{address:e,abi:q,functionName:`revokeDelegationForUserDecryption`,args:[t,n]}}function sn(e,t,n,r){return{address:e,abi:q,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function cn(e,t,n,r,i){return{address:e,abi:q,functionName:`isHandleDelegatedForUserDecryption`,args:[t,n,r,i]}}const X=2n**64n-1n,Z=`0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF`;function ln(e){return wt(e.signer,e.provider,e)}var un=class{#e;#t;#n;#r;#i;#a;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger,this.#a=e.emitEvent}#o(e){return w(this.#r,e)}#s(e,t){throw this.#a({type:C.PermitError,operation:e,error:t instanceof Error?t:Error(String(t))}),t}async grantPermit(e){if(e.length===0)return;let t;try{t=this.#o(`grantPermit`),await Ge(`grantPermit`,this.#e,this.#t)}catch(e){this.#s(`grantPermit`,e)}await t.grantPermit(e)}async grantDelegationPermit(e,t){if(t.length===0)return;let n;try{n=this.#o(`grantDelegationPermit`),await Ge(`grantDelegationPermit`,this.#e,this.#t)}catch(e){this.#s(`grantDelegationPermit`,e)}await n.grantPermit(t,e)}async hasPermit(e){return this.#r?this.#r.hasPermit(e):!1}async hasDelegationPermit(e,t){return this.#r?this.#r.hasPermit(t,e):!1}async warmTransportKeyPair(){let e=this.#r;if(!e)return;let t=this.#e?.walletAccount.getSnapshot();t&&await e.warmTransportKeyPair(t.address)}registerPermit(e,t){return this.batchRegisterPermits([{prepared:e,signature:t}])}async batchRegisterPermits(e){let t;try{t=this.#o(`registerPermit`)}catch(e){this.#s(`registerPermit`,e)}await t.batchRegisterPermits(e),await Promise.all([...new Set(e.map(e=>e.prepared.signerAddress))].map(e=>this.#c(e)))}async revokePermits(e){let t=this.#o(`revokePermits`),n=F((await A(`revokePermits`,this.#e,this.#t)).address);try{await t.revokePermits(e)}finally{await this.#c(n)}}async clear(){let e=this.#o(`clear`),t=F((await A(`clear`,this.#e,this.#t)).address);try{await e.clearCredentials()}finally{await this.#c(t)}}async#c(e){await T(`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)}},dn=class{#e;#t;#n;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.delegationService}#r(e){return w(this.#e,e)}async delegateDecryption({contractAddress:e,delegateAddress:t,expirationDate:n}){let r=this.#r(`delegateDecryption`),i=await A(`delegateDecryption`,this.#e,this.#t);return this.#n.delegateDecryption(r,{contractAddress:e,delegateAddress:t,delegatorAddress:i.address,expirationDate:n})}async revokeDelegation({contractAddress:e,delegateAddress:t}){let n=this.#r(`revokeDelegation`),r=await A(`revokeDelegation`,this.#e,this.#t);return this.#n.revokeDelegation(n,{contractAddress:e,delegateAddress:t,delegatorAddress:r.address})}async isActive(e){return this.#n.isDelegated(e)}async getExpiry(e){return this.#n.getDelegationExpiry(e)}async getStatus(e){return this.#n.getStatus(e)}},fn=class{#e;#t;#n;#r;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.router,this.#r=e.decryptionService}#i(e){return w(this.#r,e)}async decryptValues(e,t){let n=this.#i(`decryptValues`),r=await A(`decryptValues`,this.#e,this.#t);return n.decryptValues(e,r.address,j(t,`decrypt-values`))}async delegatedDecryptValues(e,t,n=t,r){let i=this.#i(`delegatedDecryptValues`),a=await A(`delegatedDecryptValues`,this.#e,this.#t);return i.delegatedDecryptValues(e,t,a.address,n,j(r,`delegated-decrypt-values`))}async decryptPublicValues(e,t){if(e.length===0)return{clearValues:{},decryptionProof:`0x`,abiEncodedClearValues:`0x`};let n=j(t,`decrypt-public-values`);try{let t=await this.#n.relayer.decryptPublicValuesWithSignatures({encryptedValues:e,options:n}),r={};return t.checkSignaturesArgs.handlesList.forEach((e,n)=>{ge(t.clearValues[n],`result.clearValues[${n}]`),r[e]=t.clearValues[n].value}),{clearValues:r,abiEncodedClearValues:t.checkSignaturesArgs.abiEncodedCleartexts,decryptionProof:t.checkSignaturesArgs.decryptionProof}}catch(e){throw K(e,`Public decryption failed`)}}async delegatedBatchDecryptValues({encryptedInputs:e,delegatorAddress:t,accountAddress:n=t,maxConcurrency:r,waitForPropagation:i,operation:a}){let o=this.#i(`delegatedBatchDecryptValues`),s=await A(`delegatedBatchDecryptValues`,this.#e,this.#t);return o.delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:s.address,accountAddress:n,maxConcurrency:r,waitForPropagation:i,operation:a??`delegated-batch-decrypt-values`})}},pn=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}prepare(e,t){return this.#e.prepare(e,t)}preparePermit(e){return this.#t.preparePermit(e)}batchPreparePermits(e){return this.#t.batchPreparePermits(e)}},mn=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 hn=new mn,gn=I.union([I.bigint(),I.boolean(),N]),_n=I.array(I.string());var vn=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=gn.safeParse(i);return a.success?a.data:(await this.delete(e,t,n),null)}catch(e){return this.#t.warn(`CachingService.get failed`,{error:e}),null}}async set(e,t,n,r){try{let i=this.#c(e,t,n);await this.#e.set(i,r),this.#i=this.#i.then(()=>this.#u(i).catch(e=>{this.#t.warn(`CachingService index write failed`,{error:e})})),await this.#i}catch(e){this.#t.warn(`CachingService.set failed`,{error:e})}}async delete(e,t,n){let r=this.#c(e,t,n);this.#i=this.#i.then(()=>this.#a(r).catch(e=>{this.#t.warn(`CachingService.delete failed`,{error:e})})),await this.#i}async clearForRequester(e){this.#i=this.#i.then(()=>this.#o(e).catch(e=>{this.#t.warn(`CachingService.clearForRequester failed`,{error:e})})),await this.#i}async clearAll(){this.#i=this.#i.then(()=>this.#s().catch(e=>{this.#t.warn(`CachingService.clearAll failed`,{error:e})})),await this.#i}async#a(e){await this.#e.delete(e).catch(()=>{});let t=await this.#l(),n=t.filter(t=>t!==e);n.length!==t.length&&await this.#e.set(this.#r,n)}async#o(e){let t=F(e),n=`${this.#n}:${t}:`,r=await this.#l(),i=[],a=[];for(let e of r)e.startsWith(n)?i.push(e):a.push(e);await Promise.all(i.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.set(this.#r,a)}async#s(){let e=await this.#l();await Promise.all(e.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.delete(this.#r)}#c(e,t,n){return`${this.#n}:${F(e)}:${F(t)}:${n.toLowerCase()}`}async#l(){let e=await this.#e.get(this.#r);if(e===null)return[];let t=_n.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 yn(e,t){let n=bn(e,t);if(!n)throw new S(`No permit covers contract ${t} after allow()`);return{privateKey:e.keypair.privateKey,publicKey:e.keypair.publicKey,serializedPermit:n.serializedPermit}}function bn(e,t){let n=Ft(t);return e.permissions.find(e=>e.contractAddresses.includes(n))}const xn=e=>new Promise(t=>setTimeout(t,e));var Sn=class{#e;#t;#n;#r;#i;constructor({cache:e,credentialService:t,delegationService:n,router:r,emitEvent:i}){this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#i=i}async decryptValues(e,t,n){let r=F(t);return this.#s(e,{requesterAddress:r,errorMessage:`Failed to decrypt encrypted values`},n)}async delegatedDecryptValues(e,t,n,r,i){let a=F(t),o=F(n),s={spent:!1};return this.#a(i?.waitForPropagation??!0,()=>this.#s(e,{requesterAddress:F(r),delegator:a,validate:e=>this.#m(e,{delegatorAddress:a,delegateAddress:o}),errorMessage:`Failed to decrypt delegated encrypted values`},{operation:i?.operation},s))}async#a(e,t){let n;for(let r=0;r<16;r++)try{return await t()}catch(t){if(n=t,!(r<15&&e&&t instanceof G))throw t;await xn(2e3)}throw n}async delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:n,accountAddress:r,maxConcurrency:i=5,waitForPropagation:a=!0,operation:o}){let s=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:F(e.contractAddress)}));if(s.length===0)return{items:s};let c=F(r);try{let e=await this.delegatedDecryptValues(s.map(({encryptedValue:e,contractAddress:t})=>({encryptedValue:e,contractAddress:t})),t,n,c,{waitForPropagation:a,operation:o});for(let t of s)this.#d(t,e);return{items:s}}catch(e){if(Le(e))throw e;if(s.length===1){let[n=this.#p()]=s;return n.error=this.#f(e,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:n.contractAddress,account:F(t)}),{items:s}}}let l=!1,u;if(await qe(s.map(e=>async()=>{if(!l)try{let r=await this.delegatedDecryptValues([{encryptedValue:e.encryptedValue,contractAddress:e.contractAddress}],t,n,c,{waitForPropagation:!1,operation:o});this.#d(e,r)}catch(n){if(Le(n)){l=!0,u??=n;return}e.error=this.#f(n,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:e.contractAddress,account:F(t)})}}),i),u!==void 0)throw u;return{items:s}}async#o(e,t,n,r){let i=yn(e,t),a;try{a=await this.#r.relayer.parseTransportKeyPair({publicKey:i.publicKey,privateKey:i.privateKey,tkmsVersion:e.keypair.tkmsVersion})}catch(e){throw e instanceof Error&&f(e.message)&&await this.#t.evictTransportKeyPair(),e}let o=await this.#r.relayer.parseSignedDecryptionPermit({transportKeyPair:a,serializedPermit:i.serializedPermit});return this.#r.relayer.decryptValues({transportKeyPair:a,signedPermit:o,encryptedValues:n,contractAddress:t,options:r})}async#s(t,n,r,i={spent:!1}){if(t.length===0)return{};let a=t.map(e=>({encryptedValue:e.encryptedValue,contractAddress:F(e.contractAddress)})),o={},s=[];for(let e of a)He(e.encryptedValue)?o[e.encryptedValue]=0n:s.push(e);if(s.length===0)return o;let c=Array.from(new Set(a.map(e=>e.contractAddress))),l=Array.from(new Set(s.map(e=>e.contractAddress)));if(n.validate)try{await n.validate(l)}catch(e){throw ee(e)?this.#u(e,`the delegation pre-check`):e}let u=[];for(let e of s){let t=await this.#e.get(n.requesterAddress,e.contractAddress,e.encryptedValue);t===null?u.push(e):o[e.encryptedValue]=t}if(u.length===0)return o;let d=await this.#t.grantPermit(c,n.delegator),f=new Map;for(let e of u){let t=f.get(e.contractAddress);t?t.push(e.encryptedValue):f.set(e.contractAddress,[e.encryptedValue])}let m=[];for(let[e,t]of f)for(let n of Re(t))m.push({contractAddress:e,encryptedValues:n});let h=Date.now(),g=u.map(e=>e.encryptedValue);try{this.#i({type:C.DecryptStart,encryptedValues:g});try{await this.#c(n,d,m,o,r)}catch(e){if(!(e instanceof v)||i.spent)throw e;let t=d.permissions.map(e=>e.serializedPermit.signature);i.spent=!0;try{d=await this.#t.recoverPermits(c,n.delegator,t)}catch(e){throw e instanceof b?new v(`The permit's KMS context has been revoked on-chain and the automatic re-grant failed, so the decrypt cannot proceed. Establish a new permit for this scope and retry.`,{cause:e}):e}await this.#c(n,d,m.filter(({encryptedValues:e})=>e.some(e=>o[e]===void 0)),o,r)}let e={};for(let t of g){let n=o[t];n!==void 0&&(e[t]=n)}return this.#i({type:C.DecryptEnd,durationMs:Date.now()-h,encryptedValues:g,result:e}),o}catch(t){let r=t instanceof p&&t.cause instanceof Error?t.cause:t;throw this.#i({type:C.DecryptError,error:e(r),durationMs:Date.now()-h,encryptedValues:g}),K(t,n.errorMessage,{isDelegated:n.delegator!==void 0})}}async#c(e,t,n,r,i){let a=(await qe(n.map(({contractAddress:n,encryptedValues:a})=>async()=>{try{await this.#l(e,t,n,a,r,i);return}catch(e){return e}}),5)).filter(e=>e!==void 0);if(a.length>0)throw a.find(e=>e instanceof v)??a[0]}async#l(e,t,n,r,i,a){let o;try{o=await this.#o(t,n,r,a)}catch(t){throw K(t,e.errorMessage,{isDelegated:e.delegator!==void 0,contractAddress:n,account:e.delegator??e.requesterAddress})}for(let t=0;t<r.length;t++){let a=r[t],s=o[t]?.value;a!==void 0&&s!==void 0&&(i[a]=s,await this.#e.set(e.requesterAddress,n,a,s))}let s=r.filter(e=>i[e]===void 0);if(s.length>0)throw new S(`${e.errorMessage}: relayer returned no clear value for ${s.length} of ${r.length} handle(s) on ${n}`,{cause:AggregateError(s.map(e=>new S(`No clear value for handle ${e} on ${n}`)),`${s.length} handle(s) missing a clear value on ${n}`)})}#u(e,t){return new k(`RPC provider rate-limited ${t}; retry with backoff.`,{cause:e,retryAfter:i(e)})}#d(e,t){let n=t[e.encryptedValue];if(n===void 0){e.error=new S(`Batch delegated decryption returned no value for encrypted value ${e.encryptedValue} on contract ${e.contractAddress}`);return}e.value=n}#f(e,t,n){return e instanceof p?e:K(e,t,n)}#p(){throw new S(`Batch delegated decryption invariant failed: missing item`)}async#m(e,{delegatorAddress:t,delegateAddress:n}){let r=await this.#n.findInactiveDelegations(e,t,n);if(r.size!==0)for(let e of r.values())throw e}};const Q={AlreadyDelegatedOrRevokedInSameBlock:e=>new tn(`Only one delegate/revoke per (delegator, delegate, contract) per block. Wait for the next block before retrying.`,{cause:e}),SenderCannotBeContractAddress:e=>new nn(`The contract address cannot be the caller address.`,{cause:e}),EnforcedPause:e=>new rn(`The ACL contract is paused. Delegation operations are temporarily disabled.`,{cause:e}),SenderCannotBeDelegate:e=>new R(`Cannot delegate to yourself (delegate === msg.sender).`,{cause:e}),DelegateCannotBeContractAddress:e=>new H(`Delegate address cannot be the same as the contract address.`,{cause:e}),DelegateCannotBeWildcard:e=>new U(`Delegate address cannot be the wildcard address; it can only be used as the contract address.`,{cause:e}),ExpirationDateBeforeOneHour:e=>new W(`Expiration date must be at least 1 hour in the future.`,{cause:e}),ExpirationDateAlreadySetToSameValue:e=>new V(`The new expiration date is the same as the current one.`,{cause:e}),NotDelegatedYet:e=>new z(`Cannot revoke: no active delegation exists.`,{cause:e})};function Cn(e){return Object.hasOwn(Q,e)}function wn(e,t){let n=Qe(e);if(n&&Cn(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 Tn=class{#e;#t;#n;#r;constructor({provider:e,router:t,emitEvent:n=()=>{},logger:r}){this.#t=e,this.#e=t,this.#r=r,this.#n=n}async delegateDecryption(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r,expirationDate:i}){if(i&&i.getTime()<Date.now()+36e5)throw new W(`Expiration date must be at least 1 hour in the future`);let a=F(t),o=F(n),s=F(r);if(o===s)throw new R(`Cannot delegate to yourself (delegate === msg.sender).`);if(o===F(`0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF`))throw new U(`Delegate address cannot be the wildcard address; it can only be used as the contract address.`);if(o===a)throw new H(`Delegate address cannot be the same as the contract address (${a}).`);let c=this.#e.relayer.chain.aclContractAddress,l=i?BigInt(Math.floor(i.getTime()/1e3)):X,u;try{u=await this.getDelegationExpiry({contractAddress:a,delegatorAddress:s,delegateAddress:o})}catch(e){this.#r.warn(`delegateDecryption: pre-flight expiry check failed`,{error:e}),u=-1n}if(u===l)throw new V(`The new expiration date (${l}) is the same as the current one. No on-chain change needed.`);return a!==F(`0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF`)&&await this.#i({contractAddress:a,delegatorAddress:s,delegateAddress:o}),this.#s({operation:`delegateDecryption`,signer:e,contractAddress:a,config:J(c,o,a,l)})}async revokeDelegation(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r}){let i=F(t),a=F(n),o=F(r),s=this.#e.relayer.chain.aclContractAddress,c;try{c=await this.getDelegationExpiry({contractAddress:i,delegatorAddress:o,delegateAddress:a})}catch(e){this.#r.warn(`revokeDelegation: pre-flight expiry check failed`,{error:e}),c=1n}if(c===0n)throw new z(`No active delegation found for delegate ${a} on contract ${i}.`);return this.#s({operation:`revokeDelegation`,signer:e,contractAddress:i,config:Y(s,a,i)})}async isDelegated(e){return(await this.getStatus(e)).isActive}async getStatus(e){let t=F(e.contractAddress)===Z,[n,r]=await Promise.all([this.getDelegationExpiry(e),t?Promise.resolve(0n):this.getDelegationExpiry({...e,contractAddress:Z})]),i=this.#a(n)||this.#a(r)?await this.#t.getBlockTimestamp():void 0,a=this.#o(n,i);if(a.isActive)return a;let o=this.#o(r,i);return o.isActive?o:n>=r?a:o}async#i(e){try{let{isActive:t}=await this.getStatus({...e,contractAddress:Z});t&&this.#r.warn(`delegateDecryption: ${e.delegateAddress} already holds an active wildcard delegation from ${e.delegatorAddress}; this grant for ${e.contractAddress} is redundant.`)}catch(e){this.#r.warn(`delegateDecryption: wildcard redundancy check failed`,{error:e})}}#a(e){return e!==0n&&e!==X}#o(e,t){return e===0n?{isActive:!1,expiryTimestamp:e}:e===X?{isActive:!0,expiryTimestamp:e}:{isActive:t!==void 0&&e>t,expiryTimestamp:e}}async getDelegationExpiry({contractAddress:e,delegatorAddress:t,delegateAddress:n}){let r=this.#e.relayer.chain.aclContractAddress;return this.#t.readContract(sn(r,F(t),F(n),F(e)))}async#s({operation:e,signer:t,contractAddress:n,config:r}){try{return await We({operation:e,signer:t,provider:this.#t,config:r,emit:e=>this.#n(e,n),logger:this.#r})}catch(e){throw this.#c(e),e}}#c(e){if(!(e instanceof fe))return;let t=wn(e.cause??e,e);if(t)throw t}async findInactiveDelegations(e,t,n){let r=new Map;return await Promise.all(e.map(async e=>{try{await this.assertDelegationActive(e,t,n)}catch(t){if(t instanceof z||t instanceof B){let n=F(e);r.set(n,t);return}throw t}})),r}async assertDelegationActive(e,t,n){let r=F(e),i=F(t),a=F(n),{isActive:o,expiryTimestamp:s}=await this.getStatus({contractAddress:r,delegatorAddress:i,delegateAddress:a});if(!o)throw s===0n?new z(`No active delegation from ${i} to ${a} for ${r}`):new B(`Delegation from ${i} to ${a} for ${r} has expired`)}},En=class{#e;#t;constructor({router:e,emitEvent:t}){this.#e=e,this.#t=t}async encryptValues(t,n){let r=Date.now(),i=F(t.contractAddress);try{this.#t({type:C.EncryptStart},i);let e=await this.#e.relayer.encryptValues({...t,options:n});return this.#t({type:C.EncryptEnd,durationMs:Date.now()-r},i),e}catch(t){throw this.#t({type:C.EncryptError,error:e(t),durationMs:Date.now()-r},i),on(t,`Encryption failed`)}}},Dn=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 T(`switch relayer chain`,()=>this.#t.switchChain(r),this.#i);let i=this.#r;i&&await T(`credential wallet account change`,()=>i.handleWalletAccountChange(t,n),this.#i),t&&await T(`clear decrypt cache`,()=>this.#n.clearForRequester(t.address),this.#i),await Promise.all(Array.from(this.#a,t=>T(`wallet account listener`,()=>t(e),this.#i)))}};const On=I.object({kind:I.literal(`ConfidentialTransfer`),from:N,token:N,to:N,amount:I.bigint()}),kn=I.object({kind:I.literal(`ConfidentialTransferFrom`),from:N,token:N,owner:N,to:N,amount:I.bigint()}),An=I.object({kind:I.literal(`SetOperator`),from:N,token:N,operator:N,until:Pt}),jn=I.object({kind:I.literal(`Unwrap`),from:N,token:N,to:N,amount:I.bigint()}),Mn=I.object({kind:I.literal(`UnwrapAll`),from:N,token:N,to:N}),Nn=I.object({kind:I.literal(`FinalizeUnwrap`),from:N,wrapper:N,unwrapRequestIdOrAmount:Nt}),$=I.object({kind:I.literal(`ApproveUnderlying`),from:N,underlying:N,spender:N,amount:I.bigint()}),Pn=I.object({kind:I.literal(`Wrap`),from:N,wrapper:N,to:N,amount:I.bigint()}),Fn=Nt.check(I.refine(e=>e===`0x`||$t(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`)),In=I.object({kind:I.literal(`TransferAndCall`),from:N,underlying:N,wrapper:N,amount:I.bigint(),recipientData:I.optional(Fn)}),Ln=I.object({kind:I.literal(`DelegateDecryption`),from:N,contractAddress:N,delegateAddress:N,expirationDate:I.optional(I.date())}),Rn=I.object({kind:I.literal(`RevokeDelegation`),from:N,contractAddress:N,delegateAddress:N});I.discriminatedUnion(`kind`,[On,kn,An,jn,Mn,Nn,$,Pn,In,Ln,Rn]);const zn=I.strictObject({maxFeePerGas:I.bigint(),maxPriorityFeePerGas:I.bigint()}),Bn=I.object({nonce:I.optional(I.int().check(I.nonnegative())),gasLimit:I.optional(I.bigint()),fees:I.optional(zn)}),Vn=I.object({address:N,abi:I.array(I.unknown()),functionName:I.string(),args:I.array(I.unknown()),value:I.optional(I.bigint()),gas:I.optional(I.bigint())}),Hn=I.extend(Bn,{from:N,calldata:Vn});var Un=class{#e;#t;#n;constructor(e){this.#e=e.provider,this.#t=e.router,this.#n=e.encryption}async prepare(e,t){t&&=P(Bn,t);let n=await this.#e.getChainId(),r=this.#t.chain.id;if(n!==r)throw new h(`Offline.prepare: provider is on chain ${n} but the SDK is configured for chain ${r}. The prepared transaction's contract addresses and encrypted inputs are bound to chain ${r} — point the provider at the same chain.`);let i=P(Hn,{calldata:await this.#r(e),from:e.from,nonce:t?.nonce,gasLimit:t?.gasLimit,fees:t?.fees}),a=await this.#e.prepareTransaction(i);return{kind:e.kind,unsignedTx:a,from:i.from}}async#r(e){switch(e.kind){case`ConfidentialTransfer`:return this.#i(e);case`ConfidentialTransferFrom`:return this.#a(e);case`SetOperator`:return this.#o(e);case`Unwrap`:return this.#s(e);case`UnwrapAll`:return this.#c(e);case`FinalizeUnwrap`:return this.#l(e);case`ApproveUnderlying`:return this.#u(e);case`Wrap`:return this.#d(e);case`TransferAndCall`:return this.#f(e);case`DelegateDecryption`:return this.#p(e);case`RevokeDelegation`:return this.#m(e);default:throw new h(`OfflineService.prepare: unsupported transaction kind '${e.kind}'.`)}}async#i(e){e=P(On,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from},{operation:`offline-confidential-transfer`}),r=t[0];if(!r)throw new x(`Encryption returned no handles for ConfidentialTransfer`);return D(e.token,e.to,r,n)}async#a(e){e=P(kn,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from},{operation:`offline-confidential-transfer-from`}),r=t[0];if(!r)throw new x(`Encryption returned no handles for ConfidentialTransferFrom`);return xe(e.token,e.owner,e.to,r,n)}#o(e){return e=P(An,e),ye(e.token,e.operator,e.until)}async#s(e){e=P(jn,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from},{operation:`offline-unwrap`}),r=t[0];if(!r)throw new x(`Encryption returned no handles for Unwrap`);return ue(e.token,e.from,e.to,r,n)}async#c(e){e=P(Mn,e);let t=await this.#e.readContract(Te(e.token,e.from));return he(e.token,e.from,e.to,t)}async#l(e){e=P(Nn,e);let t=await this.#t.relayer.decryptPublicValuesWithSignatures({encryptedValues:[e.unwrapRequestIdOrAmount],options:{operation:`offline-finalize-unwrap`}}).catch(e=>{throw K(e,`Public decryption failed during FinalizeUnwrap`)}),n=t.clearValues[0]?.value;return me(n,`FinalizeUnwrap: decryptPublicValuesWithSignatures(handle).clearValue`),O(e.wrapper,e.unwrapRequestIdOrAmount,n,t.checkSignaturesArgs.decryptionProof)}#u(e){return e=P($,e),E(e.underlying,e.spender,e.amount)}#d(e){return e=P(Pn,e),se(e.wrapper,e.to,e.amount)}#f(e){return e=P(In,e),Ze(e.underlying,e.wrapper,e.amount,e.recipientData)}#p(e){if(e=P(Ln,e),e.expirationDate&&e.expirationDate.getTime()<Date.now()+36e5)throw new W(`Expiration date must be at least 1 hour in the future`);if(e.delegateAddress===e.from)throw new R(`Cannot delegate to yourself (delegate === msg.sender).`);if(e.delegateAddress===e.contractAddress)throw new H(`Delegate address cannot be the same as the contract address (${e.contractAddress}).`);let t=e.expirationDate?BigInt(Math.floor(e.expirationDate.getTime()/1e3)):X;return J(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress,t)}#m(e){return e=P(Rn,e),Y(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress)}};function Wn(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 Gn(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 Kn(e){if(e===void 0)return;let t=P(Tt,e);return new Mt(typeof t==`string`?t:new Uint8Array(t))}var qn=class{#e;provider;signer;storage;registry;permits;delegations;decryption;offline;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;constructor(e,t={}){Wn(t),Gn(t.transportKeyPairDerivationSecret);let n=Kn(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 vn(e.storage,this.#i),this.#u=new Tn({provider:this.provider,router:e.router,emitEvent:this.emitEvent.bind(this),logger:this.#i});let r={};for(let t of e.chains)t.registryAddress&&(r[t.id]=t.registryAddress);this.registry=new M({provider:this.provider,registryAddresses:r,registryTTL:e.registryTTL}),this.#n=r,this.#t=e.registryTTL,this.#l=new At({router:e.router,signer:e.signer,transportKeyPairTTL:e.transportKeyPairTTL,permitTTL:e.permitTTL,scope:e.transportKeyPairScope,derivationSecret:n,storage:this.storage,permitStorage:e.permitStorage,logger:this.#i,emitEvent:this.emitEvent.bind(this)}),e.signer&&(this.#c=new Sn({cache:this.#a,credentialService:this.#l,delegationService:this.#u,router:e.router,emitEvent:this.emitEvent.bind(this)})),this.#s=new En({router:e.router,emitEvent:this.emitEvent.bind(this)}),this.#o=new Dn({signer:e.signer,router:e.router,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.#d=new Un({provider:this.provider,router:e.router,encryption:this.#s,emitEvent:(e,t)=>this.emitEvent(e,t)}),this.permits=new un({signer:this.signer,provider:this.provider,cachingService:this.#a,credentialService:this.#l,logger:this.#i,emitEvent:this.emitEvent.bind(this)}),this.delegations=new dn({signer:this.signer,provider:this.provider,delegationService:this.#u}),this.decryption=new fn({signer:this.signer,provider:this.provider,router:e.router,decryptionService:this.#c}),this.offline=new pn(this.#d,this.#l)}onWalletAccountChange(e){return this.#o.onWalletAccountChange(e)}get logger(){return this.#i}get relayer(){return this.#e.relayer}emitEvent(e,t){try{this.#r({...e,tokenAddress:t,timestamp:Date.now()})}catch(t){this.#i.warn(`${e.type} event listener silently failed`,{error:t})}}createWrappersRegistry(e){return new M({provider:this.provider,registryAddresses:{...this.#n,...e},registryTTL:this.#t})}async encrypt(e,t){return this.#s.encryptValues(e,j(t,`encrypt`))}createToken(e){return new Ye(this,e)}createWrappedToken(e){return new mt(this,e)}dispose(){this.#o.dispose(),this.#e.dispose()}terminate(){this.dispose(),this.signer?.dispose?.()}[Symbol.dispose](){this.terminate()}};export{lt as ACL_TOPICS,rn as AclPausedError,ft as AclTopics,Xe as BalanceCheckUnavailableError,jt as BaseSigner,Ve as ChainMismatchError,mn as ChromeSessionStorage,h as ConfigurationError,fn as Decryption,S as DecryptionFailedError,bt as DefaultRegistryAddresses,nn as DelegationContractIsSelfError,tn as DelegationCooldownError,U as DelegationDelegateCannotBeWildcardError,H as DelegationDelegateEqualsContractError,W as DelegationExpirationTooSoonError,B as DelegationExpiredError,V as DelegationExpiryUnchangedError,z as DelegationNotFoundError,G as DelegationNotPropagatedError,R as DelegationSelfNotAllowedError,dn as Delegations,Ne as ERC1363_INTERFACE_ID,ze as ERC20ReadFailedError,ke as ERC7984_INTERFACE_ID,je as ERC7984_WRAPPER_INTERFACE_ID,oe as EncryptOffloadUnavailableError,x as EncryptionFailedError,Ot as IndexedDBStorage,Be as InsufficientAllowanceError,Ke as InsufficientConfidentialBalanceError,Ue as InsufficientERC20BalanceError,_ as InvalidTransportKeyPairError,g as KeyWrappingError,X as MAX_UINT64,St as MemoryStorage,Dt as MutableWalletAccountStore,y as NoCiphertextError,L as NotEntitledError,pn as Offline,un as Permits,ie as PreparedPermitChainMismatchError,te as PreparedPermitExpiredError,u as RelayerRequestFailedError,v as RevokedKmsContextError,k as RpcRateLimitError,pe as SignerNotConfiguredError,_e as SignerRequiredError,b as SigningFailedError,re as SigningRejectedError,ot as TOKEN_TOPICS,Ye as Token,et as Topics,fe as TransactionRevertedError,ae as TransportKeyPairChangedError,ne as TransportKeyPairExpiredError,_t as UnshieldAlreadyFinalizedError,Z as WILDCARD_CONTRACT,Ie as WalletAccountNotReadyError,ce as WalletNotConnectedError,mt as WrappedToken,M as WrappersRegistry,Je as ZERO_ENCRYPTED_VALUE,p as ZamaError,c as ZamaErrorCode,qn as ZamaSDK,C as ZamaSDKEvents,Se as allowanceContract,Zt as anvil,E as approveContract,Pe as balanceOfContract,qt as bscTestnet,Yt as chains,hn as chromeSessionStorage,yt as cleartext,Te as confidentialBalanceOfContract,we as confidentialTotalSupplyContract,D as confidentialTransferContract,xe as confidentialTransferFromContract,ln as createConfig,kt as createWalletAccountStore,Ce as decimalsContract,ut as decodeAclEvent,pt as decodeAclEvents,tt as decodeConfidentialTransfer,st as decodeDelegatedForUserDecryption,ht as decodeOnChainEvent,nt as decodeOnChainEvents,rt as decodeRevokedDelegationForUserDecryption,dt as decodeUnwrapFinalized,ct as decodeUnwrapRequested,at as decodeWrap,J as delegateForUserDecryptionContract,O as finalizeUnwrapContract,it as findDelegatedForUserDecryption,$e as findRevokedDelegationForUserDecryption,gt as findUnwrapRequested,vt as findWrap,Ht as getConfidentialTokenAddressContract,sn as getDelegationExpiryContract,Rt as getTokenAddressContract,Bt as getTokenPairContract,Lt as getTokenPairsContract,It as getTokenPairsLengthContract,zt as getTokenPairsSliceContract,Gt as hardhat,Ut as hoodi,Et as indexedDBStorage,ve as inferredTotalSupplyContract,Ee as isConfidentialTokenContract,Vt as isConfidentialTokenValidContract,be as isConfidentialWrapperContract,He as isEncryptedValueZero,cn as isHandleDelegatedContract,le as isOperatorContract,n as isRetryable,Jt as mainnet,en as matchZamaError,Ct as memoryStorage,Ae as nameContract,xt as parsePreparedPermit,Xt as polygon,Wt as polygonAmoy,Fe as rateContract,d as retryAfterSeconds,Y as revokeDelegationContract,Kt as sepolia,ye as setOperatorContract,Me as supportsInterfaceContract,Oe as symbolContract,Ze as transferAndCallContract,de as underlyingContract,ue as unwrapContract,he as unwrapFromBalanceContract,De as unwrapRequesterContract,se as wrapContract,Qt as zenithTrexTestnet};
2
2
  //# sourceMappingURL=index.js.map