@zama-fhe/sdk 3.5.1 → 3.5.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/base-signer.cjs +1 -1
- package/dist/cjs/base-signer.cjs.map +1 -1
- package/dist/cjs/ethers/index.cjs +1 -1
- package/dist/cjs/ethers/index.cjs.map +1 -1
- package/dist/cjs/fhevm-relayer.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/relayer.cjs +1 -1
- package/dist/cjs/relayer.cjs.map +1 -1
- package/dist/cjs/sdk-events.cjs +1 -1
- package/dist/cjs/sdk-events.cjs.map +1 -1
- package/dist/cjs/token.cjs +1 -1
- package/dist/cjs/viem/index.cjs +1 -1
- package/dist/esm/base-signer-BK-hbCF0.js +2 -0
- package/dist/esm/{base-signer-GatxEuGN.js.map → base-signer-BK-hbCF0.js.map} +1 -1
- package/dist/esm/{base-signer-DttMQOKx.d.ts → base-signer-Ds1OunIh.d.ts} +2 -2
- package/dist/esm/cleartext/index.d.ts +2 -2
- package/dist/esm/cleartext/index.js +1 -1
- package/dist/esm/{cleartext-BwzD7uJa.js → cleartext-B4_UCmwb.js} +2 -2
- package/dist/esm/{cleartext-BwzD7uJa.js.map → cleartext-B4_UCmwb.js.map} +1 -1
- package/dist/esm/{cleartext-Di1DDxqa.d.ts → cleartext-uK68IeOj.d.ts} +2 -2
- package/dist/esm/ethers/index.d.ts +3 -3
- package/dist/esm/ethers/index.js +1 -1
- package/dist/esm/ethers/index.js.map +1 -1
- package/dist/esm/{fhevm-relayer-CTwFyl0v.js → fhevm-relayer-b4VMx_9M.js} +2 -2
- package/dist/esm/{fhevm-relayer-CTwFyl0v.js.map → fhevm-relayer-b4VMx_9M.js.map} +1 -1
- package/dist/esm/{index-C4xKY5Fw.d.ts → index-BLbMNvb7.d.ts} +3 -3
- package/dist/esm/{index-COrLsVKC.d.ts → index-Cjzgb5qJ.d.ts} +5828 -4207
- package/dist/esm/index.d.ts +98 -7
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node/index.d.ts +3 -3
- package/dist/esm/node/index.js +1 -1
- package/dist/esm/query/index.d.ts +3 -536
- package/dist/esm/query/index.js +1 -1
- package/dist/esm/{relayer-DC1OKWzW.js → relayer-_oKZItq7.js} +2 -2
- package/dist/esm/{relayer-DC1OKWzW.js.map → relayer-_oKZItq7.js.map} +1 -1
- package/dist/esm/sdk-events-Bxw_ZfyZ.js +2 -0
- package/dist/esm/sdk-events-Bxw_ZfyZ.js.map +1 -0
- package/dist/esm/{token-DOYtYc7P.js → token-DTHiLih_.js} +2 -2
- package/dist/esm/{token-DOYtYc7P.js.map → token-DTHiLih_.js.map} +1 -1
- package/dist/esm/{types-CuDiV0Wy.d.ts → types-D2Wc2kuN.d.ts} +4 -2
- package/dist/esm/{types-BxJzdNur.d.ts → types-DSLyoJuI.d.ts} +2 -2
- package/dist/esm/{types-BSRyQBTx.d.ts → types-kAGT-Vls.d.ts} +2 -2
- package/dist/esm/viem/index.d.ts +3 -3
- package/dist/esm/viem/index.js +1 -1
- package/dist/esm/web/index.d.ts +1 -1
- package/dist/esm/web/index.js +1 -1
- package/package.json +2 -2
- package/dist/esm/base-signer-GatxEuGN.js +0 -2
- package/dist/esm/sdk-events-B1sUunjZ.js +0 -2
- package/dist/esm/sdk-events-B1sUunjZ.js.map +0 -1
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,8 +1,99 @@
|
|
|
1
1
|
import { a as hoodi, c as polygon, d as AtLeastOneChain, f as FheChain, i as hardhat, l as polygonAmoy, n as bscTestnet, o as ingenTestnet, p as FheChainAuth, r as chains, s as mainnet, t as anvil, u as sepolia } from "./index-ijgDL4IC.js";
|
|
2
|
-
import { $ as TransactionErrorEvent, $t as DecryptValuesParameters, A as WalletAccountListener, At as Topics, B as ApproveUnderlyingSubmittedEvent, Bt as decodeRevokedDelegationForUserDecryption, C as TransferAndCallRequest, Ct as AclEvent, D as GenericSigner, Dt as OnChainEvent, E as WrapRequest, Et as DelegatedForUserDecryptionEvent, F as ReadContractReturnType, Ft as decodeAclEvents, G as DelegationSubmittedEvent, Gt as findRevokedDelegationForUserDecryption, H as DecryptEndEvent, Ht as decodeUnwrapRequested, I as ReadFunctionName, It as decodeConfidentialTransfer, J as EncryptStartEvent, Jt as RawLog, K as EncryptEndEvent, Kt as findUnwrapRequested, L as WriteContractArgs, Lt as decodeDelegatedForUserDecryption, M as ContractAbi, Mt as UnwrapRequestedEvent, N as ReadContractArgs, Nt as WrapEvent, O as WalletAccount, Ot as RevokedDelegationForUserDecryptionEvent, P as ReadContractConfig, Pt as decodeAclEvent, Q as ShieldSubmittedEvent, Qt as DecryptPublicValuesResult, R as WriteContractConfig, Rt as decodeOnChainEvent, S as TransactionKind, St as ACL_TOPICS, T as UnwrapRequest, Tt as ConfidentialTransferEvent, U as DecryptErrorEvent, Ut as decodeWrap, V as BaseEvent, Vt as decodeUnwrapFinalized, W as DecryptStartEvent, Wt as findDelegatedForUserDecryption, X as RevokeDelegationSubmittedEvent, Xt as TransactionResult, Y as FinalizeUnwrapSubmittedEvent, Yt as TransactionReceipt, Z as SetOperatorSubmittedEvent, Zt as ClearValue, _ as PrepareTransactionRequest, _t as UnwrapResult, a as ZamaConfigBase, an as FhevmClient, at as UnshieldPhase2SubmittedEvent, b as RevokeDelegationRequest, bt as TransferCallbacks, c as GenericStorage, cn as FhevmRuntimeConfig, ct as ZamaSDKEvent, d as ConfidentialTransferFromRequest, dn as TypedValue, dt as ZamaSDKEvents, en as EIP712TypedData, et as TransactionOperation, f as ConfidentialTransferRequest, ft as ApprovalStrategy, g as PrepareOptions, gt as UnshieldOptions, h as PrepareFees, ht as TransferOptions, i as ZamaConfig, in as EncryptedValue, it as UnshieldPhase2StartedEvent, j as WalletAccountStore, jt as UnwrapFinalizedEvent, k as WalletAccountChange, kt as TOKEN_TOPICS, l as GenericProvider, ln as RelayerOptions, lt as ZamaSDKEventListener, m as FinalizeUnwrapRequest, mt as ShieldPath, n as RelayerConfig, nn as EncryptParams, nt as TransferSubmittedEvent, o as ZamaConfigGeneric, on as FhevmClientOptions, ot as UnwrapSubmittedEvent, p as DelegateDecryptionRequest, pt as ShieldOptions, q as EncryptErrorEvent, qt as findWrap, rn as EncryptResult, rt as UnshieldPhase1SubmittedEvent, s as GenericLogger, sn as FhevmRelayerOptions, st as WrapSubmittedEvent, t as CleartextRelayerConfig, tn as EncryptInput, tt as TransferFromSubmittedEvent, u as ApproveUnderlyingRequest, un as RelayerSDK, ut as ZamaSDKEventType, v as PreparedFor, vt as WrapOptions, w as UnwrapAllRequest, wt as AclTopics, x as SetOperatorRequest, xt as UnshieldCallbacks, y as PreparedTransaction, yt as ShieldCallbacks, z as WriteFunctionName, zt as decodeOnChainEvents } from "./types-
|
|
3
|
-
import { t as cleartext } from "./cleartext-
|
|
4
|
-
import { t as ZamaConfigEthers } from "./types-
|
|
5
|
-
import { n as MutableWalletAccountStore, r as createWalletAccountStore, t as BaseSigner } from "./base-signer-
|
|
6
|
-
import { $ as
|
|
7
|
-
import { t as ZamaConfigViem } from "./types-
|
|
8
|
-
|
|
2
|
+
import { $ as TransactionErrorEvent, $t as DecryptValuesParameters, A as WalletAccountListener, At as Topics, B as ApproveUnderlyingSubmittedEvent, Bt as decodeRevokedDelegationForUserDecryption, C as TransferAndCallRequest, Ct as AclEvent, D as GenericSigner, Dt as OnChainEvent, E as WrapRequest, Et as DelegatedForUserDecryptionEvent, F as ReadContractReturnType, Ft as decodeAclEvents, G as DelegationSubmittedEvent, Gt as findRevokedDelegationForUserDecryption, H as DecryptEndEvent, Ht as decodeUnwrapRequested, I as ReadFunctionName, It as decodeConfidentialTransfer, J as EncryptStartEvent, Jt as RawLog, K as EncryptEndEvent, Kt as findUnwrapRequested, L as WriteContractArgs, Lt as decodeDelegatedForUserDecryption, M as ContractAbi, Mt as UnwrapRequestedEvent, N as ReadContractArgs, Nt as WrapEvent, O as WalletAccount, Ot as RevokedDelegationForUserDecryptionEvent, P as ReadContractConfig, Pt as decodeAclEvent, Q as ShieldSubmittedEvent, Qt as DecryptPublicValuesResult, R as WriteContractConfig, Rt as decodeOnChainEvent, S as TransactionKind, St as ACL_TOPICS, T as UnwrapRequest, Tt as ConfidentialTransferEvent, U as DecryptErrorEvent, Ut as decodeWrap, V as BaseEvent, Vt as decodeUnwrapFinalized, W as DecryptStartEvent, Wt as findDelegatedForUserDecryption, X as RevokeDelegationSubmittedEvent, Xt as TransactionResult, Y as FinalizeUnwrapSubmittedEvent, Yt as TransactionReceipt, Z as SetOperatorSubmittedEvent, Zt as ClearValue, _ as PrepareTransactionRequest, _t as UnwrapResult, a as ZamaConfigBase, an as FhevmClient, at as UnshieldPhase2SubmittedEvent, b as RevokeDelegationRequest, bt as TransferCallbacks, c as GenericStorage, cn as FhevmRuntimeConfig, ct as ZamaSDKEvent, d as ConfidentialTransferFromRequest, dn as TypedValue, dt as ZamaSDKEvents, en as EIP712TypedData, et as TransactionOperation, f as ConfidentialTransferRequest, ft as ApprovalStrategy, g as PrepareOptions, gt as UnshieldOptions, h as PrepareFees, ht as TransferOptions, i as ZamaConfig, in as EncryptedValue, it as UnshieldPhase2StartedEvent, j as WalletAccountStore, jt as UnwrapFinalizedEvent, k as WalletAccountChange, kt as TOKEN_TOPICS, l as GenericProvider, ln as RelayerOptions, lt as ZamaSDKEventListener, m as FinalizeUnwrapRequest, mt as ShieldPath, n as RelayerConfig, nn as EncryptParams, nt as TransferSubmittedEvent, o as ZamaConfigGeneric, on as FhevmClientOptions, ot as UnwrapSubmittedEvent, p as DelegateDecryptionRequest, pt as ShieldOptions, q as EncryptErrorEvent, qt as findWrap, rn as EncryptResult, rt as UnshieldPhase1SubmittedEvent, s as GenericLogger, sn as FhevmRelayerOptions, st as WrapSubmittedEvent, t as CleartextRelayerConfig, tn as EncryptInput, tt as TransferFromSubmittedEvent, u as ApproveUnderlyingRequest, un as RelayerSDK, ut as ZamaSDKEventType, v as PreparedFor, vt as WrapOptions, w as UnwrapAllRequest, wt as AclTopics, x as SetOperatorRequest, xt as UnshieldCallbacks, y as PreparedTransaction, yt as ShieldCallbacks, z as WriteFunctionName, zt as decodeOnChainEvents } from "./types-D2Wc2kuN.js";
|
|
3
|
+
import { t as cleartext } from "./cleartext-uK68IeOj.js";
|
|
4
|
+
import { t as ZamaConfigEthers } from "./types-DSLyoJuI.js";
|
|
5
|
+
import { n as MutableWalletAccountStore, r as createWalletAccountStore, t as BaseSigner } from "./base-signer-Ds1OunIh.js";
|
|
6
|
+
import { $n as KeyWrappingError, $r as setOperatorContract, An as RpcRateLimitError, Ar as isHandleDelegatedContract, Bn as DecryptionFailedError, Br as approveContract, Bt as WrappersRegistryConfig, Cn as TransactionRevertedError, Cr as getTokenPairContract, Dn as SignerRequiredError, Dr as isConfidentialTokenValidContract, Dt as BatchDecryptAsOptions, En as SignerNotConfiguredError, Er as getTokenPairsSliceContract, Et as BatchBalancesResult, Fn as BalanceErrorDetails, Fr as ERC7984_WRAPPER_INTERFACE_ID, Gn as DelegationDelegateEqualsContractError, Gr as confidentialBalanceOfContract, Hn as AclPausedError, Hr as decimalsContract, In as ERC20ReadFailedError, Ir as isConfidentialTokenContract, Jn as DelegationExpiryUnchangedError, Jr as confidentialTransferFromContract, Kn as DelegationExpirationTooSoonError, Kr as confidentialTotalSupplyContract, Ln as InsufficientAllowanceError, Lr as isConfidentialWrapperContract, Lt as DefaultRegistryAddresses, Mn as ConfigurationError, Mr as transferAndCallContract, Nn as RelayerRequestFailedError, Nr as ERC1363_INTERFACE_ID, On as WalletAccountNotReadyError, Or as delegateForUserDecryptionContract, Ot as Token, Pn as BalanceCheckUnavailableError, Pr as ERC7984_INTERFACE_ID, Qn as InvalidTransportKeyPairError, Qr as rateContract, Rn as InsufficientConfidentialBalanceError, Rr as supportsInterfaceContract, Rt as ListPairsOptions, Sn as UnshieldAlreadyFinalizedError, Sr as getTokenAddressContract, Tn as SigningRejectedError, Tr as getTokenPairsLengthContract, Tt as WrappedToken, Un as DelegationContractIsSelfError, Ur as nameContract, Vn as EncryptionFailedError, Vr as balanceOfContract, Wn as DelegationCooldownError, Wr as symbolContract, Xn as DelegationNotPropagatedError, Xr as inferredTotalSupplyContract, Yn as DelegationNotFoundError, Yr as finalizeUnwrapContract, Zn as DelegationSelfNotAllowedError, Zr as isOperatorContract, _n as DelegationStatus, _r as ChecksummedAddress, a as ZamaSDK, ai as createConfig, ar as TransportKeyPairExpiredError, bn as matchZamaError, br as TokenWrapperPairWithMetadata, c as BatchDecryptItem, cr as ZamaErrorCode, dr as Permission, ei as underlyingContract, er as NoCiphertextError, fr as PreparePermitRequest, gn as Delegations, gr as SerializedTransportKeyPair, hr as SerializedPermitEip712, ii as wrapContract, ir as TransportKeyPairChangedError, jn as NotEntitledError, jr as revokeDelegationContract, kn as WalletNotConnectedError, kr as getDelegationExpiryContract, l as BatchDecryptResult, lr as isRetryable, mr as SerializedPermit, n as DecryptResult, ni as unwrapFromBalanceContract, nr as PreparedPermitExpiredError, o as ZamaSDKOptions, or as ChainMismatchError, pr as PreparedPermit, qn as DelegationExpiredError, qr as confidentialTransferContract, r as EncryptedInput, ri as unwrapRequesterContract, rr as RevokedKmsContextError, s as Offline, sr as ZamaError, t as Decryption, ti as unwrapContract, tr as PreparedPermitChainMismatchError, u as DelegatedDecryptOptions, ur as retryAfterSeconds, vn as Permits, vr as PaginatedResult, wn as SigningFailedError, wr as getTokenPairsContract, xn as UnshieldAlreadyFinalizedDetails, xr as getConfidentialTokenAddressContract, yn as ErrorForCode, yr as TokenWrapperPair, zn as InsufficientERC20BalanceError, zr as allowanceContract, zt as WrappersRegistry } from "./index-Cjzgb5qJ.js";
|
|
7
|
+
import { t as ZamaConfigViem } from "./types-kAGT-Vls.js";
|
|
8
|
+
import { Address, Hex } from "viem";
|
|
9
|
+
//#region src/storage/memory-storage.d.ts
|
|
10
|
+
/** In-memory credential store. Credentials are lost on page reload. */
|
|
11
|
+
declare class MemoryStorage implements GenericStorage {
|
|
12
|
+
#private;
|
|
13
|
+
/**
|
|
14
|
+
* Retrieve a value by key.
|
|
15
|
+
* @returns The stored value, or `null` if the key does not exist.
|
|
16
|
+
*/
|
|
17
|
+
get<T = unknown>(key: string): Promise<T | null>;
|
|
18
|
+
/** Store a value under the given key, overwriting any existing entry. */
|
|
19
|
+
set<T = unknown>(key: string, value: T): Promise<void>;
|
|
20
|
+
/** Remove the entry for the given key (no-op if absent). */
|
|
21
|
+
delete(key: string): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
/** Default singleton for application-wide use. */
|
|
24
|
+
declare const memoryStorage: MemoryStorage;
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/storage/indexeddb-storage.d.ts
|
|
27
|
+
/**
|
|
28
|
+
* IndexedDB-backed {@link GenericStorage}.
|
|
29
|
+
*
|
|
30
|
+
* Stores keypair and permit objects keyed by a hashed wallet address. The
|
|
31
|
+
* SDK delegates security to the storage backend — values are persisted
|
|
32
|
+
* verbatim with no SDK-layer encryption.
|
|
33
|
+
*/
|
|
34
|
+
declare class IndexedDBStorage implements GenericStorage {
|
|
35
|
+
#private;
|
|
36
|
+
constructor(dbName?: string, dbVersion?: number, storeName?: string);
|
|
37
|
+
/**
|
|
38
|
+
* Retrieve a value by key.
|
|
39
|
+
* @returns The stored value, or `null` if the key does not exist.
|
|
40
|
+
*/
|
|
41
|
+
get<T = unknown>(key: string): Promise<T | null>;
|
|
42
|
+
/** Store a value under the given key, overwriting any existing entry. */
|
|
43
|
+
set<T = unknown>(key: string, value: T): Promise<void>;
|
|
44
|
+
/** Remove the entry for the given key (no-op if absent). */
|
|
45
|
+
delete(key: string): Promise<void>;
|
|
46
|
+
/** Remove all stored entries. */
|
|
47
|
+
clear(): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
/** Default singleton for application-wide use. */
|
|
50
|
+
declare const indexedDBStorage: IndexedDBStorage;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/storage/chrome-session-storage.d.ts
|
|
53
|
+
/**
|
|
54
|
+
* {@link GenericStorage} backed by `chrome.storage.session`.
|
|
55
|
+
*
|
|
56
|
+
* Use this in MV3 web extensions so the wallet signature survives
|
|
57
|
+
* service worker restarts and is shared across popup, background,
|
|
58
|
+
* and content script contexts.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { ZamaSDK, indexedDBStorage, chromeSessionStorage } from "@zama-fhe/sdk";
|
|
63
|
+
* import { createConfig } from "@zama-fhe/sdk/viem";
|
|
64
|
+
*
|
|
65
|
+
* const config = createConfig({
|
|
66
|
+
* chains: [mySepolia],
|
|
67
|
+
* publicClient,
|
|
68
|
+
* walletClient,
|
|
69
|
+
* relayers: { [mySepolia.id]: web() },
|
|
70
|
+
* storage: indexedDBStorage, // encrypted transport key pair — persistent
|
|
71
|
+
* permitStorage: chromeSessionStorage, // signed permits — ephemeral
|
|
72
|
+
* });
|
|
73
|
+
* const sdk = new ZamaSDK(config);
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
declare class ChromeSessionStorage implements GenericStorage {
|
|
77
|
+
/**
|
|
78
|
+
* Retrieve a value by key.
|
|
79
|
+
* @returns The stored value, or `null` if the key does not exist.
|
|
80
|
+
*/
|
|
81
|
+
get<T = unknown>(key: string): Promise<T | null>;
|
|
82
|
+
/** Store a value under the given key, overwriting any existing entry. */
|
|
83
|
+
set(key: string, value: unknown): Promise<void>;
|
|
84
|
+
/** Remove the entry for the given key (no-op if absent). */
|
|
85
|
+
delete(key: string): Promise<void>;
|
|
86
|
+
}
|
|
87
|
+
/** Default singleton for application-wide use. */
|
|
88
|
+
declare const chromeSessionStorage: ChromeSessionStorage;
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/utils/handles.d.ts
|
|
91
|
+
/** All-zero encrypted-value sentinel — a 32-byte zero handle representing the cleartext value `0`. */
|
|
92
|
+
declare const ZERO_ENCRYPTED_VALUE: "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
93
|
+
/**
|
|
94
|
+
* Check whether an encrypted value represents the zero value.
|
|
95
|
+
*/
|
|
96
|
+
declare function isEncryptedValueZero(encryptedValue: string): boolean;
|
|
97
|
+
//#endregion
|
|
98
|
+
export { ACL_TOPICS, type AclEvent, AclPausedError, AclTopics, type Address, type ApprovalStrategy, type ApproveUnderlyingRequest, type ApproveUnderlyingSubmittedEvent, type AtLeastOneChain, BalanceCheckUnavailableError, type BalanceErrorDetails, type BaseEvent, BaseSigner, type BatchBalancesResult, type BatchDecryptAsOptions, type BatchDecryptItem, type BatchDecryptResult, ChainMismatchError, type ChecksummedAddress, ChromeSessionStorage, type ClearValue, type CleartextRelayerConfig, type ConfidentialTransferEvent, type ConfidentialTransferFromRequest, type ConfidentialTransferRequest, ConfigurationError, type ContractAbi, type DecryptEndEvent, type DecryptErrorEvent, type EncryptedInput as DecryptInput, type DecryptPublicValuesResult, type DecryptResult, type DecryptStartEvent, type DecryptValuesParameters, Decryption, DecryptionFailedError, DefaultRegistryAddresses, type DelegateDecryptionRequest, type DelegatedDecryptOptions, type DelegatedForUserDecryptionEvent, DelegationContractIsSelfError, DelegationCooldownError, DelegationDelegateEqualsContractError, DelegationExpirationTooSoonError, DelegationExpiredError, DelegationExpiryUnchangedError, DelegationNotFoundError, DelegationNotPropagatedError, DelegationSelfNotAllowedError, type DelegationStatus, type DelegationSubmittedEvent, Delegations, type EIP712TypedData, ERC1363_INTERFACE_ID, ERC20ReadFailedError, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, type EncryptEndEvent, type EncryptErrorEvent, type EncryptInput, type EncryptParams, type EncryptResult, type EncryptStartEvent, type EncryptedValue, EncryptionFailedError, type ErrorForCode, type FheChain, type FheChainAuth, type FhevmClient, type FhevmClientOptions, type FhevmRelayerOptions, type FhevmRuntimeConfig, type FinalizeUnwrapRequest, type FinalizeUnwrapSubmittedEvent, type GenericLogger, type GenericProvider, type GenericSigner, type GenericStorage, type Hex, IndexedDBStorage, InsufficientAllowanceError, InsufficientConfidentialBalanceError, InsufficientERC20BalanceError, InvalidTransportKeyPairError, KeyWrappingError, type ListPairsOptions, MemoryStorage, MutableWalletAccountStore, NoCiphertextError, NotEntitledError, Offline, type OnChainEvent, type PaginatedResult, type Permission, Permits, type PrepareFees, type PrepareOptions, type PreparePermitRequest, type PrepareTransactionRequest, type PreparedFor, type PreparedPermit, PreparedPermitChainMismatchError, PreparedPermitExpiredError, type PreparedTransaction, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, type RelayerConfig, type RelayerOptions, RelayerRequestFailedError, type RelayerSDK, type RevokeDelegationRequest, type RevokeDelegationSubmittedEvent, type RevokedDelegationForUserDecryptionEvent, RevokedKmsContextError, RpcRateLimitError, type SerializedPermit, type SerializedPermitEip712, type SerializedTransportKeyPair, type SetOperatorRequest, type SetOperatorSubmittedEvent, type ShieldCallbacks, type ShieldOptions, type ShieldPath, type ShieldSubmittedEvent, SignerNotConfiguredError, SignerRequiredError, 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 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 };
|
|
99
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l 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 g}from"./relayer-DC1OKWzW.js";import{$ as _,A as v,B as ee,C as te,D as ne,F as re,G as y,H as ie,I as ae,K as oe,L as se,M as ce,N as le,P as ue,Q as de,R as b,S as fe,T as pe,U as me,V as he,W as x,X as ge,Y as _e,Z as ve,_ as S,a as ye,b as be,c as xe,d as Se,et as C,f as Ce,g as we,h as Te,i as Ee,j as De,k as Oe,l as ke,m as Ae,nt as je,o as Me,p as Ne,q as Pe,r as Fe,s as Ie,t as w,tt as Le,u as Re,v as T,w as ze,y as E,z as D}from"./sdk-events-B1sUunjZ.js";import{_ as O,a as Be,c as Ve,d as k,f as He,g as A,h as Ue,i as j,l as We,m as Ge,n as Ke,o as qe,p as Je,r as Ye,s as Xe,t as M,u as Ze,v as N}from"./token-DOYtYc7P.js";import{t as Qe}from"./cleartext-BwzD7uJa.js";import{_ as $e,a as et,c as tt,d as nt,f as P,g as rt,h as it,i as at,l as ot,m as st,n as ct,o as lt,p as F,r as ut,s as dt,t as ft,u as I,v as pt}from"./base-signer-GatxEuGN.js";import{a as mt,c as ht,i as gt,l as _t,n as vt,o as yt,r as bt,s as xt,t as St,u as Ct}from"./chains-ByyCdrrd.js";import{r as wt,t as Tt}from"./assertions-Ca1ePdRJ.js";import{getAddress as L,keccak256 as Et,size as Dt,toBytes as Ot}from"viem";import{z as R}from"zod/mini";function kt(e,t){if(e instanceof p){let n=t[e.code];if(n)return n(e)}return t._?.(e)}var At=class extends p{encryptedValue;contractAddress;account;constructor(e,t){super(s.NotEntitled,`Account ${e.account} is not entitled to decrypt encrypted value ${e.encryptedValue} on contract ${e.contractAddress}. This is not a transient failure — the account needs an on-chain ACL grant before it can decrypt this encrypted value.`,t),this.name=`NotEntitledError`,this.encryptedValue=e.encryptedValue,this.contractAddress=e.contractAddress,this.account=e.account}},z=class extends p{constructor(e,t){super(s.DelegationSelfNotAllowed,e,t),this.name=`DelegationSelfNotAllowedError`}},jt=class extends p{constructor(e,t){super(s.DelegationCooldown,e,t),this.name=`DelegationCooldownError`}},B=class extends p{constructor(e,t){super(s.DelegationNotFound,e,t),this.name=`DelegationNotFoundError`}},V=class extends p{constructor(e,t){super(s.DelegationExpired,e,t),this.name=`DelegationExpiredError`}},H=class extends p{constructor(e,t){super(s.DelegationExpiryUnchanged,e,t),this.name=`DelegationExpiryUnchangedError`}},U=class extends p{constructor(e,t){super(s.DelegationDelegateEqualsContract,e,t),this.name=`DelegationDelegateEqualsContractError`}},Mt=class extends p{constructor(e,t){super(s.DelegationContractIsSelf,e,t),this.name=`DelegationContractIsSelfError`}},Nt=class extends p{constructor(e,t){super(s.AclPaused,e,t),this.name=`AclPausedError`}},W=class extends p{constructor(e,t){super(s.DelegationExpirationTooSoon,e,t),this.name=`DelegationExpirationTooSoonError`}},G=class extends p{constructor(e,t){super(s.DelegationNotPropagated,e,t),this.name=`DelegationNotPropagatedError`}};const Pt=[O,ve,u,G,Pe,oe,At,A,_e,C];function K(t,s,d={}){if(Pt.some(e=>t instanceof e))return t;let p=t instanceof Error?t.message:s;if(t instanceof Error&&r(t.message))return new _e(t.message,{cause:t});if(o(t))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:t});if(t instanceof Error&&i(t.message))return d.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:t}):new At({encryptedValue:e(t.message)??``,contractAddress:d.contractAddress??``,account:d.account??``},{cause:t});if(c(t))return new A(p,{cause:t,retryAfter:n(t)});let h=m(t);return h===void 0&&a(t)?new A(p,{cause:t,retryAfter:n(t)}):h===400?new ve(t instanceof Error?t.message:`No ciphertext for this account`,{cause:t}):d.isDelegated&&h===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:t}):f(t)||h!==void 0?new u(p,h,{cause:t,retryAfter:n(t),retryable:l(t)||void 0}):new O(s,{cause:t})}function Ft(e,t){if(e instanceof p)return e;let r=m(e),i=l(e);return r!==void 0||f(e)?new u(e instanceof Error?e.message:t,r,{cause:e,retryAfter:n(e),retryable:i||void 0}):new N(t,{cause:e})}const It=[{type:`function`,name:`allowance`,inputs:[{name:`owner`,type:`address`,internalType:`address`},{name:`spender`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`approve`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`balanceOf`,inputs:[{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`supportsInterface`,inputs:[{name:`interfaceId`,type:`bytes4`,internalType:`bytes4`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`totalSupply`,inputs:[],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`transfer`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFrom`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`event`,name:`Approval`,inputs:[{name:`owner`,type:`address`,indexed:!0,internalType:`address`},{name:`spender`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1},{type:`event`,name:`Transfer`,inputs:[{name:`from`,type:`address`,indexed:!0,internalType:`address`},{name:`to`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1}];function Lt(e,t,n,r=`0x`){return{address:e,abi:It,functionName:`transferAndCall`,args:[t,n,r]}}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 Rt(e,t,n,r){return{address:e,abi:q,functionName:`delegateForUserDecryption`,args:[t,n,r]}}function zt(e,t,n){return{address:e,abi:q,functionName:`revokeDelegationForUserDecryption`,args:[t,n]}}function Bt(e,t,n,r){return{address:e,abi:q,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function Vt(e,t,n,r,i){return{address:e,abi:q,functionName:`isHandleDelegatedForUserDecryption`,args:[t,n,r,i]}}const Ht=2n**64n-1n;function Ut(e){return at(e.signer,e.provider,e)}function Wt(e){return e.startsWith(`0x`)?e:`0x${e}`}function J(e){return Et(Ot(e))}const Y={ConfidentialTransfer:J(`ConfidentialTransfer(address,address,bytes32)`),Wrap:J(`Wrap(address,uint256,bytes32)`),UnwrapRequested:J(`UnwrapRequested(address,bytes32,bytes32)`),UnwrapFinalized:J(`UnwrapFinalized(address,bytes32,bytes32,uint64)`)};function X(e){return L(Wt(e.slice(-40)))}function Gt(e){return e}function Kt(e,t){let n=2+t*64,r=e.slice(n,n+64);return r.length===64?r:r.padEnd(64,`0`)}function qt(e,t){return L(Wt(Kt(e,t).slice(-40)))}function Z(e,t){return BigInt(`0x`+Kt(e,t))}function Jt(e,t){return Wt(Kt(e,t))}function Yt(e){return e.topics[0]!==Y.ConfidentialTransfer||e.topics.length<4?null:{eventName:`ConfidentialTransfer`,from:X(e.topics[1]),to:X(e.topics[2]),encryptedAmount:Gt(e.topics[3])}}function Xt(e){return e.topics[0]!==Y.Wrap||e.topics.length<2?null:{eventName:`Wrap`,to:X(e.topics[1]),roundedAmount:Z(e.data,0),encryptedWrappedAmount:Jt(e.data,1)}}function Zt(e){return e.topics[0]!==Y.UnwrapRequested||e.topics.length<3?null:{eventName:`UnwrapRequested`,receiver:X(e.topics[1]),unwrapRequestId:Gt(e.topics[2]),encryptedAmount:Jt(e.data,0)}}function Qt(e){return e.topics[0]!==Y.UnwrapFinalized||e.topics.length<3?null:{eventName:`UnwrapFinalized`,receiver:X(e.topics[1]),unwrapRequestId:Gt(e.topics[2]),encryptedAmount:Jt(e.data,0),cleartextAmount:Z(e.data,1)}}function $t(e){return Yt(e)??Xt(e)??Zt(e)??Qt(e)}function en(e){let t=[];for(let n of e){let e=$t(n);e&&t.push(e)}return t}function tn(e){for(let t of e){let e=Zt(t);if(e)return e}return null}function nn(e){for(let t of e){let e=Xt(t);if(e)return e}return null}const rn=[Y.ConfidentialTransfer,Y.Wrap,Y.UnwrapRequested,Y.UnwrapFinalized],Q={DelegatedForUserDecryption:J(`DelegatedForUserDecryption(address,address,address,uint64,uint64,uint64)`),RevokedDelegationForUserDecryption:J(`RevokedDelegationForUserDecryption(address,address,address,uint64,uint64)`)};function an(e){return e.topics[0]!==Q.DelegatedForUserDecryption||e.topics.length<3?null:{eventName:`DelegatedForUserDecryption`,delegator:X(e.topics[1]),delegate:X(e.topics[2]),contractAddress:qt(e.data,0),delegationCounter:Z(e.data,1),oldExpirationDate:Z(e.data,2),newExpirationDate:Z(e.data,3)}}function on(e){return e.topics[0]!==Q.RevokedDelegationForUserDecryption||e.topics.length<3?null:{eventName:`RevokedDelegationForUserDecryption`,delegator:X(e.topics[1]),delegate:X(e.topics[2]),contractAddress:qt(e.data,0),delegationCounter:Z(e.data,1),oldExpirationDate:Z(e.data,2)}}function sn(e){return an(e)??on(e)}function cn(e){let t=[];for(let n of e){let e=sn(n);e&&t.push(e)}return t}function ln(e){for(let t of e){let e=an(t);if(e)return e}return null}function un(e){for(let t of e){let e=on(t);if(e)return e}return null}const dn=[Q.DelegatedForUserDecryption,Q.RevokedDelegationForUserDecryption];var fn=class{#e;#t;#n;#r;#i;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger}#a(e){return x(this.#r,e)}async grantPermit(e){if(e.length===0)return;let t=this.#a(`grantPermit`);await Be(`grantPermit`,this.#e,this.#t),await t.grantPermit(e)}async grantDelegationPermit(e,t){if(t.length===0)return;let n=this.#a(`grantDelegationPermit`);await Be(`grantDelegationPermit`,this.#e,this.#t),await n.grantPermit(t,e)}async hasPermit(e){return this.#r?this.#r.hasPermit(e):!1}async hasDelegationPermit(e,t){return this.#r?this.#r.hasPermit(t,e):!1}async warmTransportKeyPair(){let e=this.#r;if(!e)return;let t=this.#e?.walletAccount.getSnapshot();t&&await e.warmTransportKeyPair(t.address)}async registerPermit(e,t){await this.#a(`registerPermit`).registerPermit(e,t),await this.#o(e.signerAddress)}async revokePermits(e){let t=this.#a(`revokePermits`),n=L((await j(`revokePermits`,this.#e,this.#t)).address);try{await t.revokePermits(e)}finally{await this.#o(n)}}async clear(){let e=this.#a(`clear`),t=L((await j(`clear`,this.#e,this.#t)).address);try{await e.clearCredentials()}finally{await this.#o(t)}}async#o(e){await D(`clear decrypt cache`,()=>this.#n.clearForRequester(e),this.#i)}async revokeTransportKeyPair(e){await this.#a(`revokeTransportKeyPair`).revokeTransportKeyPair(e)}async warmTransportKeyPairScope(e){await this.#a(`warmTransportKeyPairScope`).warmTransportKeyPairScope(e)}},pn=class{#e;#t;#n;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.delegationService}#r(e){return x(this.#e,e)}async delegateDecryption({contractAddress:e,delegateAddress:t,expirationDate:n}){let r=this.#r(`delegateDecryption`),i=await j(`delegateDecryption`,this.#e,this.#t);return this.#n.delegateDecryption(r,{contractAddress:e,delegateAddress:t,delegatorAddress:i.address,expirationDate:n})}async revokeDelegation({contractAddress:e,delegateAddress:t}){let n=this.#r(`revokeDelegation`),r=await j(`revokeDelegation`,this.#e,this.#t);return this.#n.revokeDelegation(n,{contractAddress:e,delegateAddress:t,delegatorAddress:r.address})}async isActive(e){return this.#n.isDelegated(e)}async getExpiry(e){return this.#n.getDelegationExpiry(e)}async getStatus(e){return this.#n.getStatus(e)}},mn=class{#e;#t;#n;#r;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.router,this.#r=e.decryptionService}#i(e){return x(this.#r,e)}async decryptValues(e,t){let n=this.#i(`decryptValues`),r=await j(`decryptValues`,this.#e,this.#t);return n.decryptValues(e,r.address,t)}async delegatedDecryptValues(e,t,n=t,r){let i=this.#i(`delegatedDecryptValues`),a=await j(`delegatedDecryptValues`,this.#e,this.#t);return i.delegatedDecryptValues(e,t,a.address,n,r)}async decryptPublicValues(e,t){if(e.length===0)return{clearValues:{},decryptionProof:`0x`,abiEncodedClearValues:`0x`};try{let n=await this.#n.relayer.decryptPublicValuesWithSignatures({encryptedValues:e,options:t}),r={};return n.checkSignaturesArgs.handlesList.forEach((e,t)=>{wt(n.clearValues[t],`result.clearValues[${t}]`),r[e]=n.clearValues[t].value}),{clearValues:r,abiEncodedClearValues:n.checkSignaturesArgs.abiEncodedCleartexts,decryptionProof:n.checkSignaturesArgs.decryptionProof}}catch(e){throw K(e,`Public decryption failed`)}}async delegatedBatchDecryptValues({encryptedInputs:e,delegatorAddress:t,accountAddress:n=t,maxConcurrency:r,waitForPropagation:i}){let a=this.#i(`delegatedBatchDecryptValues`),o=await j(`delegatedBatchDecryptValues`,this.#e,this.#t);return a.delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:o.address,accountAddress:n,maxConcurrency:r,waitForPropagation:i})}},hn=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}prepare(e,t){return this.#e.prepare(e,t)}preparePermit(e){return this.#t.preparePermit(e)}},gn=class{async get(e){return(await chrome.storage.session.get(e))[e]??null}async set(e,t){await chrome.storage.session.set({[e]:t})}async delete(e){await chrome.storage.session.remove(e)}};const _n=new gn;function $(e){return`zama:pending-unshield:${nt(e)}`}const vn=R.union([R.pipe(F,R.transform(e=>({unwrapTxHash:e}))),R.pipe(R.object({version:R.literal(1),unwrapTxHash:F,unwrapRequestId:R.optional(F)}),R.transform(({unwrapTxHash:e,unwrapRequestId:t})=>({unwrapTxHash:e,unwrapRequestId:t})))]);async function yn(e,t,n,r){if(r===void 0){await e.set($(t),n);return}await e.set($(t),{version:1,unwrapTxHash:n,unwrapRequestId:r})}async function bn(e,t){return(await xn(e,t))?.unwrapTxHash??null}async function xn(e,t){let n=$(t),r=await e.get(n);if(r==null)return null;let i=vn.safeParse(r);return i.success?i.data:(await e.delete(n),null)}async function Sn(e,t){await e.delete($(t))}var Cn=class extends M{#e;#t=null;#n=null;#r(e){try{return wt(this.sdk.signer,`WrappedToken.sdk.signer`),this.sdk.signer}catch(t){throw new ee(e,{cause:t})}}async underlying(){return this.#s()}async isPayable(){if(this.#n!==null)return this.#n;try{let e=await this.#s();this.#n=await this.sdk.provider.readContract(Te(e))}catch{this.#n=!1}return this.#n}async allowance(e){let t=await this.#s();return this.sdk.provider.readContract(S(t,L(e),this.address))}async shield(e,t){let n=await j(`shield`,this.sdk.signer,this.sdk.provider),r=await this.isPayable(),i=await this.#s(),a=L(n.address),o;try{o=await this.sdk.provider.readContract(E(i,a))}catch(e){throw e instanceof p?e:new k(`Could not read ERC-20 balance for shield validation (token: ${i})`,{cause:g(e)})}if(o<e)throw new Ge(`Insufficient ERC-20 balance: requested ${e}, available ${o} (token: ${i})`,{requested:e,available:o,token:i});return r?this.#i(e,i,a,t):this.#a(e,a,t)}async#i(e,t,n,r){this.#r(`shield`);let i=r?.to?L(r.to):n,a=i===n?`0x`:i;return this.submitTransaction({operation:`shield:transferAndCall`,config:Lt(t,this.address,e,a),onSubmitted:r?.onShieldSubmitted})}async wrap(e,t){this.#r(`wrap`);let n=await j(`wrap`,this.sdk.signer,this.sdk.provider),r=await this.#s(),i=L(n.address),a;try{a=await this.sdk.provider.readContract(E(r,i))}catch(e){throw e instanceof p?e:new k(`Could not read ERC-20 balance for wrap validation (token: ${r})`,{cause:g(e)})}if(a<e)throw new Ge(`Insufficient ERC-20 balance: requested ${e}, available ${a} (token: ${r})`,{requested:e,available:a,token:r});let o;try{o=await this.sdk.provider.readContract(S(r,i,this.address))}catch(e){throw e instanceof p?e:new k(`Could not read ERC-20 allowance for wrap validation (token: ${r})`,{cause:g(e)})}if(o<e)throw new He(`Insufficient allowance for wrap: requested ${e}, approved ${o}. Call approveUnderlying() first (token: ${r}).`,{requested:e,available:o,token:r});let s=t?.to?L(t.to):i;return this.submitTransaction({operation:`wrap`,config:b(this.address,s,e),onSubmitted:t?.onWrapSubmitted})}async#a(e,t,n){this.#r(`shield`);let r=n?.approvalStrategy??`exact`;r!==`skip`&&await this.#l(e,r===`max`,n);let i=n?.to?L(n.to):t;return this.submitTransaction({operation:`shield:approveAndWrap`,config:b(this.address,i,e),onSubmitted:n?.onShieldSubmitted})}async approveUnderlying(e){this.#r(`approveUnderlying`);let t=await j(`approveUnderlying`,this.sdk.signer,this.sdk.provider),n=await this.#s(),r=L(t.address),i=e??2n**256n-1n;return i>0n&&await this.sdk.provider.readContract(S(n,r,this.address))>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:T(n,this.address,0n)}),this.submitTransaction({operation:`approveUnderlying`,config:T(n,this.address,i)})}async unshield(e,t){let{skipBalanceCheck:n=!1,onUnwrapSubmitted:r,onFinalizing:i,onFinalizeSubmitted:a}=t??{};n||await this.assertConfidentialBalance(e);let o={onFinalizing:i,onFinalizeSubmitted:a},s=crypto.randomUUID(),c=await this.unwrap(e);return D(`unshield: onUnwrapSubmitted`,()=>r?.(c.txHash),this.sdk.logger),this.#c(c.unwrapRequestId,c.txHash,s,o)}async unshieldAll(e){let t=crypto.randomUUID(),n=await this.unwrapAll();return D(`unshieldAll: onUnwrapSubmitted`,()=>e?.onUnwrapSubmitted?.(n.txHash),this.sdk.logger),this.#c(n.unwrapRequestId,n.txHash,t,e)}async resumeUnshield(e,t){let n;try{n=await this.sdk.provider.waitForTransactionReceipt(e)}catch(e){throw e instanceof p?e:new y(`Failed to get unwrap receipt`,{cause:e})}let r=this.#o(n.logs);return this.#c(r,e,crypto.randomUUID(),t)}async getPendingUnshield(){return bn(this.sdk.storage,this.address)}async unwrap(e){this.#r(`unwrap`);let t=L((await j(`unwrap`,this.sdk.signer,this.sdk.provider)).address),{encryptedValues:n,inputProof:r}=await this.sdk.encrypt({values:[{value:e,type:`euint64`}],contractAddress:this.address,userAddress:t}),[i]=n;if(!i)throw new N(`Encryption returned no encrypted values`);let a=await this.submitTransaction({operation:`unwrap`,config:ae(this.address,t,t,i,r)});return{...a,unwrapRequestId:this.#o(a.receipt.logs)}}async unwrapAll(){this.#r(`unwrapAll`);let e=L((await j(`unwrapAll`,this.sdk.signer,this.sdk.provider)).address),t=await this.readConfidentialBalanceOf(e);if(Ve(t))throw new O(`Cannot unshield: balance is zero`);let n=await this.submitTransaction({operation:`unwrapAll`,config:se(this.address,e,e,t)});return{...n,unwrapRequestId:this.#o(n.receipt.logs)}}async finalizeUnwrap(e){this.#r(`finalizeUnwrap`),await Be(`finalizeUnwrap`,this.sdk.signer,this.sdk.provider);let t=await this.sdk.decryption.decryptPublicValues([e]),n=t.clearValues[e];return Tt(n,`finalizeUnwrap: clearValue`),this.submitTransaction({operation:`finalizeUnwrap`,config:v(this.address,e,n,t.decryptionProof)})}#o(e){let t=tn(e);if(!t)throw new y(`No UnwrapRequested event found in unwrap receipt`);return t.unwrapRequestId}async#s(){return this.#e===void 0?(this.#t||=this.sdk.provider.readContract(re(this.address)).then(e=>(this.#e=e,this.#t=null,e)).catch(e=>{throw this.#t=null,e}),this.#t):this.#e}async#c(e,t,n,r){this.emit({type:w.UnshieldPhase1Submitted,txHash:t,operationId:n}),await D(`unshield: savePendingUnshield`,()=>yn(this.sdk.storage,this.address,t),this.sdk.logger),this.emit({type:w.UnshieldPhase2Started,operationId:n}),D(`unshield: onFinalizing`,()=>r?.onFinalizing?.(),this.sdk.logger);let i=await this.finalizeUnwrap(e);return this.emit({type:w.UnshieldPhase2Submitted,txHash:i.txHash,operationId:n}),D(`unshield: onFinalizeSubmitted`,()=>r?.onFinalizeSubmitted?.(i.txHash),this.sdk.logger),await D(`unshield: clearPendingUnshield`,()=>Sn(this.sdk.storage,this.address),this.sdk.logger),i}async#l(e,t,n){this.#r(`approveUnderlying`);let r=await this.#s(),i=L((await j(`approveUnderlying`,this.sdk.signer,this.sdk.provider)).address),a=await this.sdk.provider.readContract(S(r,i,this.address));if(a>=e)return;a>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:T(r,this.address,0n)});let o=t?2n**256n-1n:e;await this.submitTransaction({operation:`approveUnderlying`,config:T(r,this.address,o),onSubmitted:n?.onApprovalSubmitted})}};const wn=R.union([R.bigint(),R.boolean(),P]),Tn=R.array(R.string());var En=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=wn.safeParse(i);return a.success?a.data:(await this.delete(e,t,n),null)}catch(e){return this.#t.warn(`CachingService.get failed`,{error:e}),null}}async set(e,t,n,r){try{let i=this.#c(e,t,n);await this.#e.set(i,r),this.#i=this.#i.then(()=>this.#u(i).catch(e=>{this.#t.warn(`CachingService index write failed`,{error:e})})),await this.#i}catch(e){this.#t.warn(`CachingService.set failed`,{error:e})}}async delete(e,t,n){let r=this.#c(e,t,n);this.#i=this.#i.then(()=>this.#a(r).catch(e=>{this.#t.warn(`CachingService.delete failed`,{error:e})})),await this.#i}async clearForRequester(e){this.#i=this.#i.then(()=>this.#o(e).catch(e=>{this.#t.warn(`CachingService.clearForRequester failed`,{error:e})})),await this.#i}async clearAll(){this.#i=this.#i.then(()=>this.#s().catch(e=>{this.#t.warn(`CachingService.clearAll failed`,{error:e})})),await this.#i}async#a(e){await this.#e.delete(e).catch(()=>{});let t=await this.#l(),n=t.filter(t=>t!==e);n.length!==t.length&&await this.#e.set(this.#r,n)}async#o(e){let t=L(e),n=`${this.#n}:${t}:`,r=await this.#l(),i=[],a=[];for(let e of r)e.startsWith(n)?i.push(e):a.push(e);await Promise.all(i.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.set(this.#r,a)}async#s(){let e=await this.#l();await Promise.all(e.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.delete(this.#r)}#c(e,t,n){return`${this.#n}:${L(e)}:${L(t)}:${n.toLowerCase()}`}async#l(){let e=await this.#e.get(this.#r);if(e===null)return[];let t=Tn.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 Dn(e,t){let n=On(e,t);if(!n)throw new O(`No permit covers contract ${t} after allow()`);return{privateKey:e.keypair.privateKey,publicKey:e.keypair.publicKey,serializedPermit:n.serializedPermit}}function On(e,t){let n=nt(t);return e.permissions.find(e=>e.contractAddresses.includes(n))}const kn=e=>new Promise(t=>setTimeout(t,e));var An=class{#e;#t;#n;#r;#i;constructor({cache:e,credentialService:t,delegationService:n,router:r,emitEvent:i}){this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#i=i}async decryptValues(e,t,n){let r=L(t);return this.#s(e,{requesterAddress:r,errorMessage:`Failed to decrypt encrypted values`},n)}async delegatedDecryptValues(e,t,n,r,i){let a=L(t),o=L(n),s={spent:!1};return this.#a(i?.waitForPropagation??!0,()=>this.#s(e,{requesterAddress:L(r),delegator:a,validate:e=>this.#m(e,{delegatorAddress:a,delegateAddress:o}),errorMessage:`Failed to decrypt delegated encrypted values`},void 0,s))}async#a(e,t){let n;for(let r=0;r<16;r++)try{return await t()}catch(t){if(n=t,!(r<15&&e&&t instanceof G))throw t;await kn(2e3)}throw n}async delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:n,accountAddress:r,maxConcurrency:i=5,waitForPropagation:a=!0}){let o=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:L(e.contractAddress)}));if(o.length===0)return{items:o};let s=L(r);try{let e=await this.delegatedDecryptValues(o.map(({encryptedValue:e,contractAddress:t})=>({encryptedValue:e,contractAddress:t})),t,n,s,{waitForPropagation:a});for(let t of o)this.#d(t,e);return{items:o}}catch(e){if(We(e))throw e;if(o.length===1){let[n=this.#p()]=o;return n.error=this.#f(e,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:n.contractAddress,account:L(t)}),{items:o}}}let c=!1,l;if(await Ye(o.map(e=>async()=>{if(!c)try{let r=await this.delegatedDecryptValues([{encryptedValue:e.encryptedValue,contractAddress:e.contractAddress}],t,n,s,{waitForPropagation:!1});this.#d(e,r)}catch(n){if(We(n)){c=!0,l??=n;return}e.error=this.#f(n,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:e.contractAddress,account:L(t)})}}),i),l!==void 0)throw l;return{items:o}}async#o(e,t,n,i){let a=Dn(e,t),o;try{o=await this.#r.relayer.parseTransportKeyPair({publicKey:a.publicKey,privateKey:a.privateKey,tkmsVersion:e.keypair.tkmsVersion})}catch(e){throw e instanceof Error&&r(e.message)&&await this.#t.evictTransportKeyPair(),e}let s=await this.#r.relayer.parseSignedDecryptionPermit({transportKeyPair:o,serializedPermit:a.serializedPermit});return this.#r.relayer.decryptValues({transportKeyPair:o,signedPermit:s,encryptedValues:n,contractAddress:t,options:i})}async#s(e,t,n,r={spent:!1}){if(e.length===0)return{};let i=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:L(e.contractAddress)})),o={},s=[];for(let e of i)Ve(e.encryptedValue)?o[e.encryptedValue]=0n:s.push(e);if(s.length===0)return o;let c=Array.from(new Set(i.map(e=>e.contractAddress))),l=Array.from(new Set(s.map(e=>e.contractAddress)));if(t.validate)try{await t.validate(l)}catch(e){throw a(e)?this.#u(e,`the delegation pre-check`):e}let u=[];for(let e of s){let n=await this.#e.get(t.requesterAddress,e.contractAddress,e.encryptedValue);n===null?u.push(e):o[e.encryptedValue]=n}if(u.length===0)return o;let d=await this.#t.grantPermit(c,t.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 Xe(t))m.push({contractAddress:e,encryptedValues:n});let h=Date.now(),_=u.map(e=>e.encryptedValue);try{this.#i({type:w.DecryptStart,encryptedValues:_});try{await this.#c(t,d,m,o,n)}catch(e){if(!(e instanceof C)||r.spent)throw e;let i=d.permissions.map(e=>e.serializedPermit.signature);r.spent=!0;try{d=await this.#t.recoverPermits(c,t.delegator,i)}catch(e){throw e instanceof oe?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(t,d,m.filter(({encryptedValues:e})=>e.some(e=>o[e]===void 0)),o,n)}let e={};for(let t of _){let n=o[t];n!==void 0&&(e[t]=n)}return this.#i({type:w.DecryptEnd,durationMs:Date.now()-h,encryptedValues:_,result:e}),o}catch(e){let n=e instanceof p&&e.cause instanceof Error?e.cause:e;throw this.#i({type:w.DecryptError,error:g(n),durationMs:Date.now()-h,encryptedValues:_}),K(e,t.errorMessage,{isDelegated:t.delegator!==void 0})}}async#c(e,t,n,r,i){let a=(await Ye(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 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 O(`${e.errorMessage}: relayer returned no clear value for ${s.length} of ${r.length} handle(s) on ${n}`,{cause:AggregateError(s.map(e=>new O(`No clear value for handle ${e} on ${n}`)),`${s.length} handle(s) missing a clear value on ${n}`)})}#u(e,t){return new A(`RPC provider rate-limited ${t}; retry with backoff.`,{cause:e,retryAfter:n(e)})}#d(e,t){let n=t[e.encryptedValue];if(n===void 0){e.error=new O(`Batch delegated decryption returned no value for encrypted value ${e.encryptedValue} on contract ${e.contractAddress}`);return}e.value=n}#f(e,t,n){return e instanceof p?e:K(e,t,n)}#p(){throw new O(`Batch delegated decryption invariant failed: missing item`)}async#m(e,{delegatorAddress:t,delegateAddress:n}){let r=await this.#n.findInactiveDelegations(e,t,n);if(r.size!==0)for(let e of r.values())throw e}};function jn(e){if(!(e instanceof Error))return null;let t=e.cause;if(typeof t!=`object`||!t||!(`data`in t))return null;let{data:n}=t;return typeof n!=`object`||!n||!(`errorName`in n)?null:typeof n.errorName==`string`?n.errorName:null}const Mn={AlreadyDelegatedOrRevokedInSameBlock:e=>new jt(`Only one delegate/revoke per (delegator, delegate, contract) per block. Wait for the next block before retrying.`,{cause:e}),SenderCannotBeContractAddress:e=>new Mt(`The contract address cannot be the caller address.`,{cause:e}),EnforcedPause:e=>new Nt(`The ACL contract is paused. Delegation operations are temporarily disabled.`,{cause:e}),SenderCannotBeDelegate:e=>new z(`Cannot delegate to yourself (delegate === msg.sender).`,{cause:e}),DelegateCannotBeContractAddress:e=>new U(`Delegate address cannot be the same as the contract address.`,{cause:e}),ExpirationDateBeforeOneHour:e=>new W(`Expiration date must be at least 1 hour in the future.`,{cause:e}),ExpirationDateAlreadySetToSameValue:e=>new H(`The new expiration date is the same as the current one.`,{cause:e}),NotDelegatedYet:e=>new B(`Cannot revoke: no active delegation exists.`,{cause:e})};function Nn(e){return Object.hasOwn(Mn,e)}function Pn(e,t){let n=jn(e);if(n&&Nn(n))return Mn[n](t);let r=e instanceof Error?e.message:String(e);for(let[e,n]of Object.entries(Mn))if(r.includes(e))return n(t);return null}var Fn=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=L(t),o=L(n),s=L(r);if(o===s)throw new z(`Cannot delegate to yourself (delegate === msg.sender).`);if(o===a)throw new U(`Delegate address cannot be the same as the contract address (${a}).`);let c=this.#e.relayer.chain.aclContractAddress,l=i?BigInt(Math.floor(i.getTime()/1e3)):Ht,u;try{u=await this.getDelegationExpiry({contractAddress:a,delegatorAddress:s,delegateAddress:o})}catch(e){this.#r.warn(`delegateDecryption: pre-flight expiry check failed`,{error:e}),u=-1n}if(u===l)throw new H(`The new expiration date (${l}) is the same as the current one. No on-chain change needed.`);return this.#i({operation:`delegateDecryption`,signer:e,contractAddress:a,config:Rt(c,o,a,l)})}async revokeDelegation(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r}){let i=L(t),a=L(n),o=L(r),s=this.#e.relayer.chain.aclContractAddress,c;try{c=await this.getDelegationExpiry({contractAddress:i,delegatorAddress:o,delegateAddress:a})}catch(e){this.#r.warn(`revokeDelegation: pre-flight expiry check failed`,{error:e}),c=1n}if(c===0n)throw new B(`No active delegation found for delegate ${a} on contract ${i}.`);return this.#i({operation:`revokeDelegation`,signer:e,contractAddress:i,config:zt(s,a,i)})}async isDelegated(e){return(await this.getStatus(e)).isActive}async getStatus(e){let t=await this.getDelegationExpiry(e);return t===0n?{isActive:!1,expiryTimestamp:t}:t===Ht?{isActive:!0,expiryTimestamp:t}:{isActive:t>await this.#t.getBlockTimestamp(),expiryTimestamp:t}}async getDelegationExpiry({contractAddress:e,delegatorAddress:t,delegateAddress:n}){let r=this.#e.relayer.chain.aclContractAddress;return this.#t.readContract(Bt(r,L(t),L(n),L(e)))}async#i({operation:e,signer:t,contractAddress:n,config:r}){try{return await Ke({operation:e,signer:t,provider:this.#t,config:r,emit:e=>this.#n(e,n),logger:this.#r})}catch(e){throw this.#a(e),e}}#a(e){if(!(e instanceof y))return;let t=Pn(e.cause??e,e);if(t)throw t}async findInactiveDelegations(e,t,n){let r=new Map;return await Promise.all(e.map(async e=>{try{await this.assertDelegationActive(e,t,n)}catch(t){if(t instanceof B||t instanceof V){let n=L(e);r.set(n,t);return}throw t}})),r}async assertDelegationActive(e,t,n){let r=L(e),i=L(t),a=L(n),{isActive:o,expiryTimestamp:s}=await this.getStatus({contractAddress:r,delegatorAddress:i,delegateAddress:a});if(!o)throw s===0n?new B(`No active delegation from ${i} to ${a} for ${r}`):new V(`Delegation from ${i} to ${a} for ${r} has expired`)}},In=class{#e;#t;constructor({router:e,emitEvent:t}){this.#e=e,this.#t=t}async encryptValues(e,t){let n=Date.now(),r=L(e.contractAddress);try{this.#t({type:w.EncryptStart},r);let i=await this.#e.relayer.encryptValues({...e,options:t});return this.#t({type:w.EncryptEnd,durationMs:Date.now()-n},r),i}catch(e){throw this.#t({type:w.EncryptError,error:g(e),durationMs:Date.now()-n},r),Ft(e,`Encryption failed`)}}},Ln=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 D(`switch relayer chain`,()=>this.#t.switchChain(r),this.#i);let i=this.#r;i&&await D(`credential wallet account change`,()=>i.handleWalletAccountChange(t,n),this.#i),t&&await D(`clear decrypt cache`,()=>this.#n.clearForRequester(t.address),this.#i),await Promise.all(Array.from(this.#a,t=>D(`wallet account listener`,()=>t(e),this.#i)))}};const Rn=R.object({kind:R.literal(`ConfidentialTransfer`),from:P,token:P,to:P,amount:R.bigint()}),zn=R.object({kind:R.literal(`ConfidentialTransferFrom`),from:P,token:P,owner:P,to:P,amount:R.bigint()}),Bn=R.object({kind:R.literal(`SetOperator`),from:P,token:P,operator:P,until:st}),Vn=R.object({kind:R.literal(`Unwrap`),from:P,token:P,to:P,amount:R.bigint()}),Hn=R.object({kind:R.literal(`UnwrapAll`),from:P,token:P,to:P}),Un=R.object({kind:R.literal(`FinalizeUnwrap`),from:P,wrapper:P,unwrapRequestIdOrAmount:F}),Wn=R.object({kind:R.literal(`ApproveUnderlying`),from:P,underlying:P,spender:P,amount:R.bigint()}),Gn=R.object({kind:R.literal(`Wrap`),from:P,wrapper:P,to:P,amount:R.bigint()}),Kn=F.check(R.refine(e=>e===`0x`||Dt(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`)),qn=R.object({kind:R.literal(`TransferAndCall`),from:P,underlying:P,wrapper:P,amount:R.bigint(),recipientData:R.optional(Kn)}),Jn=R.object({kind:R.literal(`DelegateDecryption`),from:P,contractAddress:P,delegateAddress:P,expirationDate:R.optional(R.date())}),Yn=R.object({kind:R.literal(`RevokeDelegation`),from:P,contractAddress:P,delegateAddress:P});R.discriminatedUnion(`kind`,[Rn,zn,Bn,Vn,Hn,Un,Wn,Gn,qn,Jn,Yn]);const Xn=R.strictObject({maxFeePerGas:R.bigint(),maxPriorityFeePerGas:R.bigint()}),Zn=R.object({nonce:R.optional(R.int().check(R.nonnegative())),gasLimit:R.optional(R.bigint()),fees:R.optional(Xn)}),Qn=R.object({address:P,abi:R.array(R.unknown()),functionName:R.string(),args:R.array(R.unknown()),value:R.optional(R.bigint()),gas:R.optional(R.bigint())}),$n=R.extend(Zn,{from:P,calldata:Qn});var er=class{#e;#t;#n;constructor(e){this.#e=e.provider,this.#t=e.router,this.#n=e.encryption}async prepare(e,t){t&&=I(Zn,t);let n=await this.#e.getChainId(),r=this.#t.chain.id;if(n!==r)throw new h(`Offline.prepare: provider is on chain ${n} but the SDK is configured for chain ${r}. The prepared transaction's contract addresses and encrypted inputs are bound to chain ${r} — point the provider at the same chain.`);let i=I($n,{calldata:await this.#r(e),from:e.from,nonce:t?.nonce,gasLimit:t?.gasLimit,fees:t?.fees}),a=await this.#e.prepareTransaction(i);return{kind:e.kind,unsignedTx:a,from:i.from}}async#r(e){switch(e.kind){case`ConfidentialTransfer`:return this.#i(e);case`ConfidentialTransferFrom`:return this.#a(e);case`SetOperator`:return this.#o(e);case`Unwrap`:return this.#s(e);case`UnwrapAll`:return this.#c(e);case`FinalizeUnwrap`:return this.#l(e);case`ApproveUnderlying`:return this.#u(e);case`Wrap`:return this.#d(e);case`TransferAndCall`:return this.#f(e);case`DelegateDecryption`:return this.#p(e);case`RevokeDelegation`:return this.#m(e);default:throw new h(`OfflineService.prepare: unsupported transaction kind '${e.kind}'.`)}}async#i(e){e=I(Rn,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from}),r=t[0];if(!r)throw new N(`Encryption returned no handles for ConfidentialTransfer`);return ne(e.token,e.to,r,n)}async#a(e){e=I(zn,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from}),r=t[0];if(!r)throw new N(`Encryption returned no handles for ConfidentialTransferFrom`);return Oe(e.token,e.owner,e.to,r,n)}#o(e){return e=I(Bn,e),ue(e.token,e.operator,e.until)}async#s(e){e=I(Vn,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from}),r=t[0];if(!r)throw new N(`Encryption returned no handles for Unwrap`);return ae(e.token,e.from,e.to,r,n)}async#c(e){e=I(Hn,e);let t=await this.#e.readContract(ze(e.token,e.from));return se(e.token,e.from,e.to,t)}async#l(e){e=I(Un,e);let t=await this.#t.relayer.decryptPublicValuesWithSignatures({encryptedValues:[e.unwrapRequestIdOrAmount]}).catch(e=>{throw K(e,`Public decryption failed during FinalizeUnwrap`)}),n=t.clearValues[0]?.value;return Tt(n,`FinalizeUnwrap: decryptPublicValuesWithSignatures(handle).clearValue`),v(e.wrapper,e.unwrapRequestIdOrAmount,n,t.checkSignaturesArgs.decryptionProof)}#u(e){return e=I(Wn,e),T(e.underlying,e.spender,e.amount)}#d(e){return e=I(Gn,e),b(e.wrapper,e.to,e.amount)}#f(e){return e=I(qn,e),Lt(e.underlying,e.wrapper,e.amount,e.recipientData)}#p(e){if(e=I(Jn,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 z(`Cannot delegate to yourself (delegate === msg.sender).`);if(e.delegateAddress===e.contractAddress)throw new U(`Delegate address cannot be the same as the contract address (${e.contractAddress}).`);let t=e.expirationDate?BigInt(Math.floor(e.expirationDate.getTime()/1e3)):Ht;return Rt(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress,t)}#m(e){return e=I(Yn,e),zt(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress)}};function tr(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 nr(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 rr(e){if(e===void 0)return;let t=I(tt,e);return new ot(typeof t==`string`?t:new Uint8Array(t))}var ir=class{#e;provider;signer;storage;registry;permits;delegations;decryption;offline;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;constructor(e,t={}){tr(t),nr(t.transportKeyPairDerivationSecret);let n=rr(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 En(e.storage,this.#i),this.#u=new Fn({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 lt({provider:this.provider,registryAddresses:r,registryTTL:e.registryTTL}),this.#n=r,this.#t=e.registryTTL,this.#l=new dt({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}),e.signer&&(this.#c=new An({cache:this.#a,credentialService:this.#l,delegationService:this.#u,router:e.router,emitEvent:this.emitEvent.bind(this)})),this.#s=new In({router:e.router,emitEvent:this.emitEvent.bind(this)}),this.#o=new Ln({signer:e.signer,router:e.router,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.#d=new er({provider:this.provider,router:e.router,encryption:this.#s,emitEvent:(e,t)=>this.emitEvent(e,t)}),this.permits=new fn({signer:this.signer,provider:this.provider,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.delegations=new pn({signer:this.signer,provider:this.provider,delegationService:this.#u}),this.decryption=new mn({signer:this.signer,provider:this.provider,router:e.router,decryptionService:this.#c}),this.offline=new hn(this.#d,this.#l)}onWalletAccountChange(e){return this.#o.onWalletAccountChange(e)}get logger(){return this.#i}get relayer(){return this.#e.relayer}emitEvent(e,t){try{this.#r({...e,tokenAddress:t,timestamp:Date.now()})}catch(t){this.#i.warn(`${e.type} event listener silently failed`,{error:t})}}createWrappersRegistry(e){return new lt({provider:this.provider,registryAddresses:{...this.#n,...e},registryTTL:this.#t})}async encrypt(e,t){return this.#s.encryptValues(e,t)}createToken(e){return new M(this,e)}createWrappedToken(e){return new Cn(this,e)}dispose(){this.#o.dispose()}terminate(){this.dispose(),this.signer?.dispose?.()}[Symbol.dispose](){this.terminate()}};export{dn as ACL_TOPICS,Nt as AclPausedError,Q as AclTopics,Ze as BalanceCheckUnavailableError,ft as BaseSigner,Ue as ChainMismatchError,gn as ChromeSessionStorage,h as ConfigurationError,mn as Decryption,O as DecryptionFailedError,et as DefaultRegistryAddresses,Mt as DelegationContractIsSelfError,jt as DelegationCooldownError,U as DelegationDelegateEqualsContractError,W as DelegationExpirationTooSoonError,V as DelegationExpiredError,H as DelegationExpiryUnchangedError,B as DelegationNotFoundError,G as DelegationNotPropagatedError,z as DelegationSelfNotAllowedError,pn as Delegations,Re as ERC1363_INTERFACE_ID,k as ERC20ReadFailedError,Se as ERC7984_INTERFACE_ID,Ce as ERC7984_WRAPPER_INTERFACE_ID,N as EncryptionFailedError,$e as IndexedDBStorage,He as InsufficientAllowanceError,Je as InsufficientConfidentialBalanceError,Ge as InsufficientERC20BalanceError,_e as InvalidTransportKeyPairError,ge as KeyWrappingError,it as MemoryStorage,ct as MutableWalletAccountStore,ve as NoCiphertextError,At as NotEntitledError,hn as Offline,fn as Permits,de as PreparedPermitChainMismatchError,_ as PreparedPermitExpiredError,u as RelayerRequestFailedError,C as RevokedKmsContextError,A as RpcRateLimitError,ee as SignerNotConfiguredError,he as SignerRequiredError,oe as SigningFailedError,Pe as SigningRejectedError,rn as TOKEN_TOPICS,M as Token,Y as Topics,y as TransactionRevertedError,Le as TransportKeyPairChangedError,je as TransportKeyPairExpiredError,ie as WalletAccountNotReadyError,me as WalletNotConnectedError,Cn as WrappedToken,lt as WrappersRegistry,qe as ZERO_ENCRYPTED_VALUE,p as ZamaError,s as ZamaErrorCode,ir as ZamaSDK,w as ZamaSDKEvents,S as allowanceContract,St as anvil,T as approveContract,E as balanceOfContract,vt as bscTestnet,bt as chains,_n as chromeSessionStorage,Qe as cleartext,ze as confidentialBalanceOfContract,pe as confidentialTotalSupplyContract,ne as confidentialTransferContract,Oe as confidentialTransferFromContract,Ut as createConfig,ut as createWalletAccountStore,be as decimalsContract,sn as decodeAclEvent,cn as decodeAclEvents,Yt as decodeConfidentialTransfer,an as decodeDelegatedForUserDecryption,$t as decodeOnChainEvent,en as decodeOnChainEvents,on as decodeRevokedDelegationForUserDecryption,Qt as decodeUnwrapFinalized,Zt as decodeUnwrapRequested,Xt as decodeWrap,Rt as delegateForUserDecryptionContract,v as finalizeUnwrapContract,ln as findDelegatedForUserDecryption,un as findRevokedDelegationForUserDecryption,tn as findUnwrapRequested,nn as findWrap,Fe as getConfidentialTokenAddressContract,Bt as getDelegationExpiryContract,Ee as getTokenAddressContract,ye as getTokenPairContract,Me as getTokenPairsContract,Ie as getTokenPairsLengthContract,xe as getTokenPairsSliceContract,gt as hardhat,mt as hoodi,pt as indexedDBStorage,De as inferredTotalSupplyContract,yt as ingenTestnet,Ne as isConfidentialTokenContract,ke as isConfidentialTokenValidContract,Ae as isConfidentialWrapperContract,Ve as isEncryptedValueZero,Vt as isHandleDelegatedContract,ce as isOperatorContract,t as isRetryable,xt as mainnet,kt as matchZamaError,rt as memoryStorage,fe as nameContract,ht as polygon,_t as polygonAmoy,le as rateContract,d as retryAfterSeconds,zt as revokeDelegationContract,Ct as sepolia,ue as setOperatorContract,we as supportsInterfaceContract,te as symbolContract,Lt as transferAndCallContract,re as underlyingContract,ae as unwrapContract,se as unwrapFromBalanceContract,b as wrapContract};
|
|
1
|
+
import{_ as e,a as t,c as n,d as r,f as i,g as a,h as o,i as s,l 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 g}from"./relayer-_oKZItq7.js";import{$ as _,A as ee,B as v,C as te,D as ne,F as re,G as ie,H as ae,I as oe,J as se,K as y,L as ce,M as le,N as ue,P as de,Q as fe,R as pe,S as me,T as he,U as ge,V as _e,W as ve,X as ye,Z as be,_ as b,a as xe,b as Se,c as Ce,d as we,et as Te,f as Ee,g as De,h as Oe,i as ke,j as Ae,k as je,l as Me,m as Ne,nt as Pe,o as Fe,p as Ie,q as Le,r as Re,rt as ze,s as Be,t as x,tt as S,u as Ve,v as C,w as He,y as Ue,z as w}from"./sdk-events-Bxw_ZfyZ.js";import{_ as T,a as We,c as E,d as D,f as Ge,g as O,h as Ke,i as k,l as qe,m as A,n as Je,o as Ye,p as Xe,r as Ze,s as Qe,t as j,u as $e,v as M}from"./token-DTHiLih_.js";import{t as et}from"./cleartext-B4_UCmwb.js";import{_ as tt,a as nt,c as rt,d as it,f as N,g as at,h as ot,i as st,l as ct,m as lt,n as ut,o as dt,p as P,r as ft,s as pt,t as mt,u as F,v as ht}from"./base-signer-BK-hbCF0.js";import{a as gt,c as _t,i as vt,l as yt,n as bt,o as xt,r as St,s as Ct,t as wt,u as Tt}from"./chains-ByyCdrrd.js";import{r as Et,t as Dt}from"./assertions-Ca1ePdRJ.js";import{getAddress as I,keccak256 as Ot,size as kt,toBytes as At,zeroAddress as jt}from"viem";import{z as L}from"zod/mini";function Mt(e,t){if(e instanceof p){let n=t[e.code];if(n)return n(e)}return t._?.(e)}var Nt=class extends p{encryptedValue;contractAddress;account;constructor(e,t){super(s.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(s.DelegationSelfNotAllowed,e,t),this.name=`DelegationSelfNotAllowedError`}},Pt=class extends p{constructor(e,t){super(s.DelegationCooldown,e,t),this.name=`DelegationCooldownError`}},z=class extends p{constructor(e,t){super(s.DelegationNotFound,e,t),this.name=`DelegationNotFoundError`}},B=class extends p{constructor(e,t){super(s.DelegationExpired,e,t),this.name=`DelegationExpiredError`}},V=class extends p{constructor(e,t){super(s.DelegationExpiryUnchanged,e,t),this.name=`DelegationExpiryUnchangedError`}},H=class extends p{constructor(e,t){super(s.DelegationDelegateEqualsContract,e,t),this.name=`DelegationDelegateEqualsContractError`}},Ft=class extends p{constructor(e,t){super(s.DelegationContractIsSelf,e,t),this.name=`DelegationContractIsSelfError`}},It=class extends p{constructor(e,t){super(s.AclPaused,e,t),this.name=`AclPausedError`}},U=class extends p{constructor(e,t){super(s.DelegationExpirationTooSoon,e,t),this.name=`DelegationExpirationTooSoonError`}},W=class extends p{constructor(e,t){super(s.DelegationNotPropagated,e,t),this.name=`DelegationNotPropagatedError`}};function Lt(e){if(!(e instanceof Error))return null;let t=e.cause;if(typeof t!=`object`||!t||!(`data`in t))return null;let{data:n}=t;return typeof n!=`object`||!n||!(`errorName`in n)?null:typeof n.errorName==`string`?n.errorName:null}var Rt=class extends p{unwrapTxHash;unwrapRequestId;constructor(e,t,n){super(s.UnshieldAlreadyFinalized,e,n),this.name=`UnshieldAlreadyFinalizedError`,this.unwrapTxHash=t.unwrapTxHash,this.unwrapRequestId=t.unwrapRequestId}};const zt=`InvalidUnwrapRequest`,Bt=Ot(At(`${zt}(bytes32)`)).slice(0,10);function Vt(e){for(let t=e;t instanceof Error;t=t.cause)if(Lt(t)===zt||t.message.includes(zt)||t.message.includes(Bt))return!0;return!1}const Ht=[T,fe,u,W,se,Le,Nt,O,ye,S];function G(t,s,d={}){if(Ht.some(e=>t instanceof e))return t;let p=t instanceof Error?t.message:s;if(t instanceof Error&&r(t.message))return new ye(t.message,{cause:t});if(o(t))return new S(`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:t});if(t instanceof Error&&i(t.message))return d.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:t}):new Nt({encryptedValue:e(t.message)??``,contractAddress:d.contractAddress??``,account:d.account??``},{cause:t});if(c(t))return new O(p,{cause:t,retryAfter:n(t)});let h=m(t);return h===void 0&&a(t)?new O(p,{cause:t,retryAfter:n(t)}):h===400?new fe(t instanceof Error?t.message:`No ciphertext for this account`,{cause:t}):d.isDelegated&&h===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:t}):f(t)||h!==void 0?new u(p,h,{cause:t,retryAfter:n(t),retryable:l(t)||void 0}):new T(s,{cause:t})}function Ut(e,t){if(e instanceof p)return e;let r=m(e),i=l(e);return r!==void 0||f(e)?new u(e instanceof Error?e.message:t,r,{cause:e,retryAfter:n(e),retryable:i||void 0}):new M(t,{cause:e})}const Wt=[{type:`function`,name:`allowance`,inputs:[{name:`owner`,type:`address`,internalType:`address`},{name:`spender`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`approve`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`balanceOf`,inputs:[{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`supportsInterface`,inputs:[{name:`interfaceId`,type:`bytes4`,internalType:`bytes4`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`totalSupply`,inputs:[],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`transfer`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFrom`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`event`,name:`Approval`,inputs:[{name:`owner`,type:`address`,indexed:!0,internalType:`address`},{name:`spender`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1},{type:`event`,name:`Transfer`,inputs:[{name:`from`,type:`address`,indexed:!0,internalType:`address`},{name:`to`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1}];function Gt(e,t,n,r=`0x`){return{address:e,abi:Wt,functionName:`transferAndCall`,args:[t,n,r]}}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 Kt(e,t,n,r){return{address:e,abi:K,functionName:`delegateForUserDecryption`,args:[t,n,r]}}function qt(e,t,n){return{address:e,abi:K,functionName:`revokeDelegationForUserDecryption`,args:[t,n]}}function Jt(e,t,n,r){return{address:e,abi:K,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function Yt(e,t,n,r,i){return{address:e,abi:K,functionName:`isHandleDelegatedForUserDecryption`,args:[t,n,r,i]}}const Xt=2n**64n-1n;function Zt(e){return st(e.signer,e.provider,e)}function Qt(e){return e.startsWith(`0x`)?e:`0x${e}`}function q(e){return Ot(At(e))}const J={ConfidentialTransfer:q(`ConfidentialTransfer(address,address,bytes32)`),Wrap:q(`Wrap(address,uint256,bytes32)`),UnwrapRequested:q(`UnwrapRequested(address,bytes32,bytes32)`),UnwrapFinalized:q(`UnwrapFinalized(address,bytes32,bytes32,uint64)`)};function Y(e){return I(Qt(e.slice(-40)))}function $t(e){return e}function en(e,t){let n=2+t*64,r=e.slice(n,n+64);return r.length===64?r:r.padEnd(64,`0`)}function tn(e,t){return I(Qt(en(e,t).slice(-40)))}function X(e,t){return BigInt(`0x`+en(e,t))}function nn(e,t){return Qt(en(e,t))}function rn(e){return e.topics[0]!==J.ConfidentialTransfer||e.topics.length<4?null:{eventName:`ConfidentialTransfer`,from:Y(e.topics[1]),to:Y(e.topics[2]),encryptedAmount:$t(e.topics[3])}}function an(e){return e.topics[0]!==J.Wrap||e.topics.length<2?null:{eventName:`Wrap`,to:Y(e.topics[1]),roundedAmount:X(e.data,0),encryptedWrappedAmount:nn(e.data,1)}}function Z(e){return e.topics[0]!==J.UnwrapRequested||e.topics.length<3?null:{eventName:`UnwrapRequested`,receiver:Y(e.topics[1]),unwrapRequestId:$t(e.topics[2]),encryptedAmount:nn(e.data,0)}}function on(e){return e.topics[0]!==J.UnwrapFinalized||e.topics.length<3?null:{eventName:`UnwrapFinalized`,receiver:Y(e.topics[1]),unwrapRequestId:$t(e.topics[2]),encryptedAmount:nn(e.data,0),cleartextAmount:X(e.data,1)}}function sn(e){return rn(e)??an(e)??Z(e)??on(e)}function cn(e){let t=[];for(let n of e){let e=sn(n);e&&t.push(e)}return t}function ln(e){for(let t of e){let e=Z(t);if(e)return e}return null}function un(e){for(let t of e){let e=an(t);if(e)return e}return null}const dn=[J.ConfidentialTransfer,J.Wrap,J.UnwrapRequested,J.UnwrapFinalized],Q={DelegatedForUserDecryption:q(`DelegatedForUserDecryption(address,address,address,uint64,uint64,uint64)`),RevokedDelegationForUserDecryption:q(`RevokedDelegationForUserDecryption(address,address,address,uint64,uint64)`)};function fn(e){return e.topics[0]!==Q.DelegatedForUserDecryption||e.topics.length<3?null:{eventName:`DelegatedForUserDecryption`,delegator:Y(e.topics[1]),delegate:Y(e.topics[2]),contractAddress:tn(e.data,0),delegationCounter:X(e.data,1),oldExpirationDate:X(e.data,2),newExpirationDate:X(e.data,3)}}function pn(e){return e.topics[0]!==Q.RevokedDelegationForUserDecryption||e.topics.length<3?null:{eventName:`RevokedDelegationForUserDecryption`,delegator:Y(e.topics[1]),delegate:Y(e.topics[2]),contractAddress:tn(e.data,0),delegationCounter:X(e.data,1),oldExpirationDate:X(e.data,2)}}function mn(e){return fn(e)??pn(e)}function hn(e){let t=[];for(let n of e){let e=mn(n);e&&t.push(e)}return t}function gn(e){for(let t of e){let e=fn(t);if(e)return e}return null}function _n(e){for(let t of e){let e=pn(t);if(e)return e}return null}const vn=[Q.DelegatedForUserDecryption,Q.RevokedDelegationForUserDecryption];var yn=class{#e;#t;#n;#r;#i;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger}#a(e){return ie(this.#r,e)}async grantPermit(e){if(e.length===0)return;let t=this.#a(`grantPermit`);await We(`grantPermit`,this.#e,this.#t),await t.grantPermit(e)}async grantDelegationPermit(e,t){if(t.length===0)return;let n=this.#a(`grantDelegationPermit`);await We(`grantDelegationPermit`,this.#e,this.#t),await n.grantPermit(t,e)}async hasPermit(e){return this.#r?this.#r.hasPermit(e):!1}async hasDelegationPermit(e,t){return this.#r?this.#r.hasPermit(t,e):!1}async warmTransportKeyPair(){let e=this.#r;if(!e)return;let t=this.#e?.walletAccount.getSnapshot();t&&await e.warmTransportKeyPair(t.address)}async registerPermit(e,t){await this.#a(`registerPermit`).registerPermit(e,t),await this.#o(e.signerAddress)}async revokePermits(e){let t=this.#a(`revokePermits`),n=I((await k(`revokePermits`,this.#e,this.#t)).address);try{await t.revokePermits(e)}finally{await this.#o(n)}}async clear(){let e=this.#a(`clear`),t=I((await k(`clear`,this.#e,this.#t)).address);try{await e.clearCredentials()}finally{await this.#o(t)}}async#o(e){await v(`clear decrypt cache`,()=>this.#n.clearForRequester(e),this.#i)}async revokeTransportKeyPair(e){await this.#a(`revokeTransportKeyPair`).revokeTransportKeyPair(e)}async warmTransportKeyPairScope(e){await this.#a(`warmTransportKeyPairScope`).warmTransportKeyPairScope(e)}},bn=class{#e;#t;#n;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.delegationService}#r(e){return ie(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)}},xn=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 ie(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,t)}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,r)}async decryptPublicValues(e,t){if(e.length===0)return{clearValues:{},decryptionProof:`0x`,abiEncodedClearValues:`0x`};try{let n=await this.#n.relayer.decryptPublicValuesWithSignatures({encryptedValues:e,options:t}),r={};return n.checkSignaturesArgs.handlesList.forEach((e,t)=>{Et(n.clearValues[t],`result.clearValues[${t}]`),r[e]=n.clearValues[t].value}),{clearValues:r,abiEncodedClearValues:n.checkSignaturesArgs.abiEncodedCleartexts,decryptionProof:n.checkSignaturesArgs.decryptionProof}}catch(e){throw G(e,`Public decryption failed`)}}async delegatedBatchDecryptValues({encryptedInputs:e,delegatorAddress:t,accountAddress:n=t,maxConcurrency:r,waitForPropagation:i}){let a=this.#i(`delegatedBatchDecryptValues`),o=await k(`delegatedBatchDecryptValues`,this.#e,this.#t);return a.delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:o.address,accountAddress:n,maxConcurrency:r,waitForPropagation:i})}},Sn=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)}},Cn=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 wn=new Cn;function $(e){return`zama:pending-unshield:${it(e)}`}const Tn=L.union([L.pipe(P,L.transform(e=>({unwrapTxHash:e}))),L.pipe(L.object({version:L.literal(1),unwrapTxHash:P,unwrapRequestId:L.optional(P)}),L.transform(({unwrapTxHash:e,unwrapRequestId:t})=>({unwrapTxHash:e,unwrapRequestId:t})))]);async function En(e,t,n,r){if(r===void 0){await e.set($(t),n);return}await e.set($(t),{version:1,unwrapTxHash:n,unwrapRequestId:r})}async function Dn(e,t){let n=$(t),r=await e.get(n);if(r==null)return null;let i=Tn.safeParse(r);return i.success?i.data:(await e.delete(n),null)}async function On(e,t){await e.delete($(t))}var kn=class extends j{#e;#t=null;#n=null;#r(e){try{return Et(this.sdk.signer,`WrappedToken.sdk.signer`),this.sdk.signer}catch(t){throw new _e(e,{cause:t})}}async underlying(){return this.#u()}async isPayable(){if(this.#n!==null)return this.#n;try{let e=await this.#u();this.#n=await this.sdk.provider.readContract(Oe(e))}catch{this.#n=!1}return this.#n}async allowance(e){let t=await this.#u();return this.sdk.provider.readContract(b(t,I(e),this.address))}async shield(e,t){let n=await k(`shield`,this.sdk.signer,this.sdk.provider),r=await this.isPayable(),i=await this.#u(),a=I(n.address),o;try{o=await this.sdk.provider.readContract(Ue(i,a))}catch(e){throw e instanceof p?e:new D(`Could not read ERC-20 balance for shield validation (token: ${i})`,{cause:g(e)})}if(o<e)throw new A(`Insufficient ERC-20 balance: requested ${e}, available ${o} (token: ${i})`,{requested:e,available:o,token:i});return r?this.#i(e,i,a,t):this.#a(e,a,t)}async#i(e,t,n,r){this.#r(`shield`);let i=r?.to?I(r.to):n,a=i===n?`0x`:i;return this.submitTransaction({operation:`shield:transferAndCall`,config:Gt(t,this.address,e,a),onSubmitted:r?.onShieldSubmitted})}async wrap(e,t){this.#r(`wrap`);let n=await k(`wrap`,this.sdk.signer,this.sdk.provider),r=await this.#u(),i=I(n.address),a;try{a=await this.sdk.provider.readContract(Ue(r,i))}catch(e){throw e instanceof p?e:new D(`Could not read ERC-20 balance for wrap validation (token: ${r})`,{cause:g(e)})}if(a<e)throw new A(`Insufficient ERC-20 balance: requested ${e}, available ${a} (token: ${r})`,{requested:e,available:a,token:r});let o;try{o=await this.sdk.provider.readContract(b(r,i,this.address))}catch(e){throw e instanceof p?e:new D(`Could not read ERC-20 allowance for wrap validation (token: ${r})`,{cause:g(e)})}if(o<e)throw new Ge(`Insufficient allowance for wrap: requested ${e}, approved ${o}. Call approveUnderlying() first (token: ${r}).`,{requested:e,available:o,token:r});let s=t?.to?I(t.to):i;return this.submitTransaction({operation:`wrap`,config:w(this.address,s,e),onSubmitted:t?.onWrapSubmitted})}async#a(e,t,n){this.#r(`shield`);let r=n?.approvalStrategy??`exact`;r!==`skip`&&await this.#f(e,r===`max`,n);let i=n?.to?I(n.to):t;return this.submitTransaction({operation:`shield:approveAndWrap`,config:w(this.address,i,e),onSubmitted:n?.onShieldSubmitted})}async approveUnderlying(e){this.#r(`approveUnderlying`);let t=await k(`approveUnderlying`,this.sdk.signer,this.sdk.provider),n=await this.#u(),r=I(t.address),i=e??2n**256n-1n;return i>0n&&await this.sdk.provider.readContract(b(n,r,this.address))>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:C(n,this.address,0n)}),this.submitTransaction({operation:`approveUnderlying`,config:C(n,this.address,i)})}async unshield(e,t){let{skipBalanceCheck:n=!1,onUnwrapSubmitted:r,onFinalizing:i,onFinalizeSubmitted:a}=t??{};n||await this.assertConfidentialBalance(e);let o={onFinalizing:i,onFinalizeSubmitted:a},s=crypto.randomUUID(),c=await this.unwrap(e);return v(`unshield: onUnwrapSubmitted`,()=>r?.(c.txHash),this.sdk.logger),this.#d(c.unwrapRequestId,c.txHash,s,o)}async unshieldAll(e){let t=crypto.randomUUID(),n=await this.unwrapAll();return v(`unshieldAll: onUnwrapSubmitted`,()=>e?.onUnwrapSubmitted?.(n.txHash),this.sdk.logger),this.#d(n.unwrapRequestId,n.txHash,t,e)}async resumeUnshield(e,t){let n;try{n=await this.sdk.provider.waitForTransactionReceipt(e)}catch(e){throw e instanceof p?e:new y(`Failed to get unwrap receipt`,{cause:e})}let r=this.#o(n.logs);if(await this.#s(r))throw await this.#l(`resumeUnshield`),new Rt(`Nothing to resume: the unwrap request was already finalized on-chain and the funds were delivered.`,{unwrapTxHash:e,unwrapRequestId:r});return this.#d(r,e,crypto.randomUUID(),t)}async getPendingUnshield(){let e=await Dn(this.sdk.storage,this.address);return e?await this.#c(e)?(await this.#l(`getPendingUnshield`),null):e.unwrapTxHash:null}async unwrap(e){this.#r(`unwrap`);let t=I((await k(`unwrap`,this.sdk.signer,this.sdk.provider)).address),{encryptedValues:n,inputProof:r}=await this.sdk.encrypt({values:[{value:e,type:`euint64`}],contractAddress:this.address,userAddress:t}),[i]=n;if(!i)throw new M(`Encryption returned no encrypted values`);let a=await this.submitTransaction({operation:`unwrap`,config:oe(this.address,t,t,i,r)});return{...a,unwrapRequestId:this.#o(a.receipt.logs)}}async unwrapAll(){this.#r(`unwrapAll`);let e=I((await k(`unwrapAll`,this.sdk.signer,this.sdk.provider)).address),t=await this.readConfidentialBalanceOf(e);if(E(t))throw new T(`Cannot unshield: balance is zero`);let n=await this.submitTransaction({operation:`unwrapAll`,config:ce(this.address,e,e,t)});return{...n,unwrapRequestId:this.#o(n.receipt.logs)}}async finalizeUnwrap(e){this.#r(`finalizeUnwrap`),await We(`finalizeUnwrap`,this.sdk.signer,this.sdk.provider);let t=await this.sdk.decryption.decryptPublicValues([e]),n=t.clearValues[e];return Dt(n,`finalizeUnwrap: clearValue`),this.submitTransaction({operation:`finalizeUnwrap`,config:ee(this.address,e,n,t.decryptionProof)})}#o(e){let t=ln(e.filter(e=>e.address===void 0||I(e.address)===this.address));if(!t)throw new y(`No UnwrapRequested event from this wrapper found in the unwrap receipt`);return t.unwrapRequestId}async#s(e){try{return await this.sdk.provider.readContract(pe(this.address,e))===jt}catch{return!1}}async#c(e){let t=e.unwrapRequestId;if(t===void 0)try{let n=await this.sdk.provider.waitForTransactionReceipt(e.unwrapTxHash);t=this.#o(n.logs)}catch{return!1}return this.#s(t)}async#l(e){await v(`${e}: clearPendingUnshield`,()=>On(this.sdk.storage,this.address),this.sdk.logger)}async#u(){return this.#e===void 0?(this.#t||=this.sdk.provider.readContract(re(this.address)).then(e=>(this.#e=e,this.#t=null,e)).catch(e=>{throw this.#t=null,e}),this.#t):this.#e}async#d(e,t,n,r){this.emit({type:x.UnshieldPhase1Submitted,txHash:t,operationId:n}),await v(`unshield: savePendingUnshield`,()=>En(this.sdk.storage,this.address,t,e),this.sdk.logger),this.emit({type:x.UnshieldPhase2Started,operationId:n}),v(`unshield: onFinalizing`,()=>r?.onFinalizing?.(),this.sdk.logger);let i;try{i=await this.finalizeUnwrap(e)}catch(n){throw Vt(n)?(await this.#l(`unshield`),new Rt(`The unwrap request was finalized concurrently — the funds were already delivered.`,{unwrapTxHash:t,unwrapRequestId:e},{cause:n})):n}return this.emit({type:x.UnshieldPhase2Submitted,txHash:i.txHash,operationId:n}),v(`unshield: onFinalizeSubmitted`,()=>r?.onFinalizeSubmitted?.(i.txHash),this.sdk.logger),await this.#l(`unshield`),i}async#f(e,t,n){this.#r(`approveUnderlying`);let r=await this.#u(),i=I((await k(`approveUnderlying`,this.sdk.signer,this.sdk.provider)).address),a=await this.sdk.provider.readContract(b(r,i,this.address));if(a>=e)return;a>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:C(r,this.address,0n)});let o=t?2n**256n-1n:e;await this.submitTransaction({operation:`approveUnderlying`,config:C(r,this.address,o),onSubmitted:n?.onApprovalSubmitted})}};const An=L.union([L.bigint(),L.boolean(),N]),jn=L.array(L.string());var Mn=class{#e;#t;#n=`zama:decrypt`;#r=`${this.#n}:keys`;#i=Promise.resolve();constructor(e,t){this.#e=e,this.#t=t}async get(e,t,n){try{let r=this.#c(e,t,n),i=await this.#e.get(r);if(i===null)return null;let a=An.safeParse(i);return a.success?a.data:(await this.delete(e,t,n),null)}catch(e){return this.#t.warn(`CachingService.get failed`,{error:e}),null}}async set(e,t,n,r){try{let i=this.#c(e,t,n);await this.#e.set(i,r),this.#i=this.#i.then(()=>this.#u(i).catch(e=>{this.#t.warn(`CachingService index write failed`,{error:e})})),await this.#i}catch(e){this.#t.warn(`CachingService.set failed`,{error:e})}}async delete(e,t,n){let r=this.#c(e,t,n);this.#i=this.#i.then(()=>this.#a(r).catch(e=>{this.#t.warn(`CachingService.delete failed`,{error:e})})),await this.#i}async clearForRequester(e){this.#i=this.#i.then(()=>this.#o(e).catch(e=>{this.#t.warn(`CachingService.clearForRequester failed`,{error:e})})),await this.#i}async clearAll(){this.#i=this.#i.then(()=>this.#s().catch(e=>{this.#t.warn(`CachingService.clearAll failed`,{error:e})})),await this.#i}async#a(e){await this.#e.delete(e).catch(()=>{});let t=await this.#l(),n=t.filter(t=>t!==e);n.length!==t.length&&await this.#e.set(this.#r,n)}async#o(e){let t=I(e),n=`${this.#n}:${t}:`,r=await this.#l(),i=[],a=[];for(let e of r)e.startsWith(n)?i.push(e):a.push(e);await Promise.all(i.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.set(this.#r,a)}async#s(){let e=await this.#l();await Promise.all(e.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.delete(this.#r)}#c(e,t,n){return`${this.#n}:${I(e)}:${I(t)}:${n.toLowerCase()}`}async#l(){let e=await this.#e.get(this.#r);if(e===null)return[];let t=jn.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 Nn(e,t){let n=Pn(e,t);if(!n)throw new T(`No permit covers contract ${t} after allow()`);return{privateKey:e.keypair.privateKey,publicKey:e.keypair.publicKey,serializedPermit:n.serializedPermit}}function Pn(e,t){let n=it(t);return e.permissions.find(e=>e.contractAddresses.includes(n))}const Fn=e=>new Promise(t=>setTimeout(t,e));var In=class{#e;#t;#n;#r;#i;constructor({cache:e,credentialService:t,delegationService:n,router:r,emitEvent:i}){this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#i=i}async decryptValues(e,t,n){let r=I(t);return this.#s(e,{requesterAddress:r,errorMessage:`Failed to decrypt encrypted values`},n)}async delegatedDecryptValues(e,t,n,r,i){let a=I(t),o=I(n),s={spent:!1};return this.#a(i?.waitForPropagation??!0,()=>this.#s(e,{requesterAddress:I(r),delegator:a,validate:e=>this.#m(e,{delegatorAddress:a,delegateAddress:o}),errorMessage:`Failed to decrypt delegated encrypted values`},void 0,s))}async#a(e,t){let n;for(let r=0;r<16;r++)try{return await t()}catch(t){if(n=t,!(r<15&&e&&t instanceof W))throw t;await Fn(2e3)}throw n}async delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:n,accountAddress:r,maxConcurrency:i=5,waitForPropagation:a=!0}){let o=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:I(e.contractAddress)}));if(o.length===0)return{items:o};let s=I(r);try{let e=await this.delegatedDecryptValues(o.map(({encryptedValue:e,contractAddress:t})=>({encryptedValue:e,contractAddress:t})),t,n,s,{waitForPropagation:a});for(let t of o)this.#d(t,e);return{items:o}}catch(e){if(qe(e))throw e;if(o.length===1){let[n=this.#p()]=o;return n.error=this.#f(e,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:n.contractAddress,account:I(t)}),{items:o}}}let c=!1,l;if(await Ze(o.map(e=>async()=>{if(!c)try{let r=await this.delegatedDecryptValues([{encryptedValue:e.encryptedValue,contractAddress:e.contractAddress}],t,n,s,{waitForPropagation:!1});this.#d(e,r)}catch(n){if(qe(n)){c=!0,l??=n;return}e.error=this.#f(n,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:e.contractAddress,account:I(t)})}}),i),l!==void 0)throw l;return{items:o}}async#o(e,t,n,i){let a=Nn(e,t),o;try{o=await this.#r.relayer.parseTransportKeyPair({publicKey:a.publicKey,privateKey:a.privateKey,tkmsVersion:e.keypair.tkmsVersion})}catch(e){throw e instanceof Error&&r(e.message)&&await this.#t.evictTransportKeyPair(),e}let s=await this.#r.relayer.parseSignedDecryptionPermit({transportKeyPair:o,serializedPermit:a.serializedPermit});return this.#r.relayer.decryptValues({transportKeyPair:o,signedPermit:s,encryptedValues:n,contractAddress:t,options:i})}async#s(e,t,n,r={spent:!1}){if(e.length===0)return{};let i=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:I(e.contractAddress)})),o={},s=[];for(let e of i)E(e.encryptedValue)?o[e.encryptedValue]=0n:s.push(e);if(s.length===0)return o;let c=Array.from(new Set(i.map(e=>e.contractAddress))),l=Array.from(new Set(s.map(e=>e.contractAddress)));if(t.validate)try{await t.validate(l)}catch(e){throw a(e)?this.#u(e,`the delegation pre-check`):e}let u=[];for(let e of s){let n=await this.#e.get(t.requesterAddress,e.contractAddress,e.encryptedValue);n===null?u.push(e):o[e.encryptedValue]=n}if(u.length===0)return o;let d=await this.#t.grantPermit(c,t.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 Qe(t))m.push({contractAddress:e,encryptedValues:n});let h=Date.now(),_=u.map(e=>e.encryptedValue);try{this.#i({type:x.DecryptStart,encryptedValues:_});try{await this.#c(t,d,m,o,n)}catch(e){if(!(e instanceof S)||r.spent)throw e;let i=d.permissions.map(e=>e.serializedPermit.signature);r.spent=!0;try{d=await this.#t.recoverPermits(c,t.delegator,i)}catch(e){throw e instanceof Le?new S(`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(t,d,m.filter(({encryptedValues:e})=>e.some(e=>o[e]===void 0)),o,n)}let e={};for(let t of _){let n=o[t];n!==void 0&&(e[t]=n)}return this.#i({type:x.DecryptEnd,durationMs:Date.now()-h,encryptedValues:_,result:e}),o}catch(e){let n=e instanceof p&&e.cause instanceof Error?e.cause:e;throw this.#i({type:x.DecryptError,error:g(n),durationMs:Date.now()-h,encryptedValues:_}),G(e,t.errorMessage,{isDelegated:t.delegator!==void 0})}}async#c(e,t,n,r,i){let a=(await Ze(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 S)??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 T(`${e.errorMessage}: relayer returned no clear value for ${s.length} of ${r.length} handle(s) on ${n}`,{cause:AggregateError(s.map(e=>new T(`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:n(e)})}#d(e,t){let n=t[e.encryptedValue];if(n===void 0){e.error=new T(`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 T(`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 Ln={AlreadyDelegatedOrRevokedInSameBlock:e=>new Pt(`Only one delegate/revoke per (delegator, delegate, contract) per block. Wait for the next block before retrying.`,{cause:e}),SenderCannotBeContractAddress:e=>new Ft(`The contract address cannot be the caller address.`,{cause:e}),EnforcedPause:e=>new It(`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}),ExpirationDateBeforeOneHour:e=>new U(`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 Rn(e){return Object.hasOwn(Ln,e)}function zn(e,t){let n=Lt(e);if(n&&Rn(n))return Ln[n](t);let r=e instanceof Error?e.message:String(e);for(let[e,n]of Object.entries(Ln))if(r.includes(e))return n(t);return null}var Bn=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=I(t),o=I(n),s=I(r);if(o===s)throw new R(`Cannot delegate to yourself (delegate === msg.sender).`);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)):Xt,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 this.#i({operation:`delegateDecryption`,signer:e,contractAddress:a,config:Kt(c,o,a,l)})}async revokeDelegation(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r}){let i=I(t),a=I(n),o=I(r),s=this.#e.relayer.chain.aclContractAddress,c;try{c=await this.getDelegationExpiry({contractAddress:i,delegatorAddress:o,delegateAddress:a})}catch(e){this.#r.warn(`revokeDelegation: pre-flight expiry check failed`,{error:e}),c=1n}if(c===0n)throw new z(`No active delegation found for delegate ${a} on contract ${i}.`);return this.#i({operation:`revokeDelegation`,signer:e,contractAddress:i,config:qt(s,a,i)})}async isDelegated(e){return(await this.getStatus(e)).isActive}async getStatus(e){let t=await this.getDelegationExpiry(e);return t===0n?{isActive:!1,expiryTimestamp:t}:t===Xt?{isActive:!0,expiryTimestamp:t}:{isActive:t>await this.#t.getBlockTimestamp(),expiryTimestamp:t}}async getDelegationExpiry({contractAddress:e,delegatorAddress:t,delegateAddress:n}){let r=this.#e.relayer.chain.aclContractAddress;return this.#t.readContract(Jt(r,I(t),I(n),I(e)))}async#i({operation:e,signer:t,contractAddress:n,config:r}){try{return await Je({operation:e,signer:t,provider:this.#t,config:r,emit:e=>this.#n(e,n),logger:this.#r})}catch(e){throw this.#a(e),e}}#a(e){if(!(e instanceof y))return;let t=zn(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=I(e);r.set(n,t);return}throw t}})),r}async assertDelegationActive(e,t,n){let r=I(e),i=I(t),a=I(n),{isActive:o,expiryTimestamp:s}=await this.getStatus({contractAddress:r,delegatorAddress:i,delegateAddress:a});if(!o)throw s===0n?new z(`No active delegation from ${i} to ${a} for ${r}`):new B(`Delegation from ${i} to ${a} for ${r} has expired`)}},Vn=class{#e;#t;constructor({router:e,emitEvent:t}){this.#e=e,this.#t=t}async encryptValues(e,t){let n=Date.now(),r=I(e.contractAddress);try{this.#t({type:x.EncryptStart},r);let i=await this.#e.relayer.encryptValues({...e,options:t});return this.#t({type:x.EncryptEnd,durationMs:Date.now()-n},r),i}catch(e){throw this.#t({type:x.EncryptError,error:g(e),durationMs:Date.now()-n},r),Ut(e,`Encryption failed`)}}},Hn=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 v(`switch relayer chain`,()=>this.#t.switchChain(r),this.#i);let i=this.#r;i&&await v(`credential wallet account change`,()=>i.handleWalletAccountChange(t,n),this.#i),t&&await v(`clear decrypt cache`,()=>this.#n.clearForRequester(t.address),this.#i),await Promise.all(Array.from(this.#a,t=>v(`wallet account listener`,()=>t(e),this.#i)))}};const Un=L.object({kind:L.literal(`ConfidentialTransfer`),from:N,token:N,to:N,amount:L.bigint()}),Wn=L.object({kind:L.literal(`ConfidentialTransferFrom`),from:N,token:N,owner:N,to:N,amount:L.bigint()}),Gn=L.object({kind:L.literal(`SetOperator`),from:N,token:N,operator:N,until:lt}),Kn=L.object({kind:L.literal(`Unwrap`),from:N,token:N,to:N,amount:L.bigint()}),qn=L.object({kind:L.literal(`UnwrapAll`),from:N,token:N,to:N}),Jn=L.object({kind:L.literal(`FinalizeUnwrap`),from:N,wrapper:N,unwrapRequestIdOrAmount:P}),Yn=L.object({kind:L.literal(`ApproveUnderlying`),from:N,underlying:N,spender:N,amount:L.bigint()}),Xn=L.object({kind:L.literal(`Wrap`),from:N,wrapper:N,to:N,amount:L.bigint()}),Zn=P.check(L.refine(e=>e===`0x`||kt(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`)),Qn=L.object({kind:L.literal(`TransferAndCall`),from:N,underlying:N,wrapper:N,amount:L.bigint(),recipientData:L.optional(Zn)}),$n=L.object({kind:L.literal(`DelegateDecryption`),from:N,contractAddress:N,delegateAddress:N,expirationDate:L.optional(L.date())}),er=L.object({kind:L.literal(`RevokeDelegation`),from:N,contractAddress:N,delegateAddress:N});L.discriminatedUnion(`kind`,[Un,Wn,Gn,Kn,qn,Jn,Yn,Xn,Qn,$n,er]);const tr=L.strictObject({maxFeePerGas:L.bigint(),maxPriorityFeePerGas:L.bigint()}),nr=L.object({nonce:L.optional(L.int().check(L.nonnegative())),gasLimit:L.optional(L.bigint()),fees:L.optional(tr)}),rr=L.object({address:N,abi:L.array(L.unknown()),functionName:L.string(),args:L.array(L.unknown()),value:L.optional(L.bigint()),gas:L.optional(L.bigint())}),ir=L.extend(nr,{from:N,calldata:rr});var ar=class{#e;#t;#n;constructor(e){this.#e=e.provider,this.#t=e.router,this.#n=e.encryption}async prepare(e,t){t&&=F(nr,t);let n=await this.#e.getChainId(),r=this.#t.chain.id;if(n!==r)throw new h(`Offline.prepare: provider is on chain ${n} but the SDK is configured for chain ${r}. The prepared transaction's contract addresses and encrypted inputs are bound to chain ${r} — point the provider at the same chain.`);let i=F(ir,{calldata:await this.#r(e),from:e.from,nonce:t?.nonce,gasLimit:t?.gasLimit,fees:t?.fees}),a=await this.#e.prepareTransaction(i);return{kind:e.kind,unsignedTx:a,from:i.from}}async#r(e){switch(e.kind){case`ConfidentialTransfer`:return this.#i(e);case`ConfidentialTransferFrom`:return this.#a(e);case`SetOperator`:return this.#o(e);case`Unwrap`:return this.#s(e);case`UnwrapAll`:return this.#c(e);case`FinalizeUnwrap`:return this.#l(e);case`ApproveUnderlying`:return this.#u(e);case`Wrap`:return this.#d(e);case`TransferAndCall`:return this.#f(e);case`DelegateDecryption`:return this.#p(e);case`RevokeDelegation`:return this.#m(e);default:throw new h(`OfflineService.prepare: unsupported transaction kind '${e.kind}'.`)}}async#i(e){e=F(Un,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from}),r=t[0];if(!r)throw new M(`Encryption returned no handles for ConfidentialTransfer`);return ne(e.token,e.to,r,n)}async#a(e){e=F(Wn,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from}),r=t[0];if(!r)throw new M(`Encryption returned no handles for ConfidentialTransferFrom`);return je(e.token,e.owner,e.to,r,n)}#o(e){return e=F(Gn,e),de(e.token,e.operator,e.until)}async#s(e){e=F(Kn,e);let{encryptedValues:t,inputProof:n}=await this.#n.encryptValues({values:[{value:e.amount,type:`euint64`}],contractAddress:e.token,userAddress:e.from}),r=t[0];if(!r)throw new M(`Encryption returned no handles for Unwrap`);return oe(e.token,e.from,e.to,r,n)}async#c(e){e=F(qn,e);let t=await this.#e.readContract(He(e.token,e.from));return ce(e.token,e.from,e.to,t)}async#l(e){e=F(Jn,e);let t=await this.#t.relayer.decryptPublicValuesWithSignatures({encryptedValues:[e.unwrapRequestIdOrAmount]}).catch(e=>{throw G(e,`Public decryption failed during FinalizeUnwrap`)}),n=t.clearValues[0]?.value;return Dt(n,`FinalizeUnwrap: decryptPublicValuesWithSignatures(handle).clearValue`),ee(e.wrapper,e.unwrapRequestIdOrAmount,n,t.checkSignaturesArgs.decryptionProof)}#u(e){return e=F(Yn,e),C(e.underlying,e.spender,e.amount)}#d(e){return e=F(Xn,e),w(e.wrapper,e.to,e.amount)}#f(e){return e=F(Qn,e),Gt(e.underlying,e.wrapper,e.amount,e.recipientData)}#p(e){if(e=F($n,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 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)):Xt;return Kt(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress,t)}#m(e){return e=F(er,e),qt(this.#t.chain.aclContractAddress,e.delegateAddress,e.contractAddress)}};function or(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 sr(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 cr(e){if(e===void 0)return;let t=F(rt,e);return new ct(typeof t==`string`?t:new Uint8Array(t))}var lr=class{#e;provider;signer;storage;registry;permits;delegations;decryption;offline;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;#d;constructor(e,t={}){or(t),sr(t.transportKeyPairDerivationSecret);let n=cr(t.transportKeyPairDerivationSecret);this.#e=e.router,this.provider=e.provider,this.signer=e.signer,this.storage=e.storage,this.#r=e.onEvent??function(){},this.#i=e.logger,this.#a=new Mn(e.storage,this.#i),this.#u=new Bn({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 dt({provider:this.provider,registryAddresses:r,registryTTL:e.registryTTL}),this.#n=r,this.#t=e.registryTTL,this.#l=new pt({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}),e.signer&&(this.#c=new In({cache:this.#a,credentialService:this.#l,delegationService:this.#u,router:e.router,emitEvent:this.emitEvent.bind(this)})),this.#s=new Vn({router:e.router,emitEvent:this.emitEvent.bind(this)}),this.#o=new Hn({signer:e.signer,router:e.router,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.#d=new ar({provider:this.provider,router:e.router,encryption:this.#s,emitEvent:(e,t)=>this.emitEvent(e,t)}),this.permits=new yn({signer:this.signer,provider:this.provider,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.delegations=new bn({signer:this.signer,provider:this.provider,delegationService:this.#u}),this.decryption=new xn({signer:this.signer,provider:this.provider,router:e.router,decryptionService:this.#c}),this.offline=new Sn(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 dt({provider:this.provider,registryAddresses:{...this.#n,...e},registryTTL:this.#t})}async encrypt(e,t){return this.#s.encryptValues(e,t)}createToken(e){return new j(this,e)}createWrappedToken(e){return new kn(this,e)}dispose(){this.#o.dispose()}terminate(){this.dispose(),this.signer?.dispose?.()}[Symbol.dispose](){this.terminate()}};export{vn as ACL_TOPICS,It as AclPausedError,Q as AclTopics,$e as BalanceCheckUnavailableError,mt as BaseSigner,Ke as ChainMismatchError,Cn as ChromeSessionStorage,h as ConfigurationError,xn as Decryption,T as DecryptionFailedError,nt as DefaultRegistryAddresses,Ft as DelegationContractIsSelfError,Pt as DelegationCooldownError,H as DelegationDelegateEqualsContractError,U as DelegationExpirationTooSoonError,B as DelegationExpiredError,V as DelegationExpiryUnchangedError,z as DelegationNotFoundError,W as DelegationNotPropagatedError,R as DelegationSelfNotAllowedError,bn as Delegations,Ve as ERC1363_INTERFACE_ID,D as ERC20ReadFailedError,we as ERC7984_INTERFACE_ID,Ee as ERC7984_WRAPPER_INTERFACE_ID,M as EncryptionFailedError,tt as IndexedDBStorage,Ge as InsufficientAllowanceError,Xe as InsufficientConfidentialBalanceError,A as InsufficientERC20BalanceError,ye as InvalidTransportKeyPairError,be as KeyWrappingError,ot as MemoryStorage,ut as MutableWalletAccountStore,fe as NoCiphertextError,Nt as NotEntitledError,Sn as Offline,yn as Permits,_ as PreparedPermitChainMismatchError,Te as PreparedPermitExpiredError,u as RelayerRequestFailedError,S as RevokedKmsContextError,O as RpcRateLimitError,_e as SignerNotConfiguredError,ae as SignerRequiredError,Le as SigningFailedError,se as SigningRejectedError,dn as TOKEN_TOPICS,j as Token,J as Topics,y as TransactionRevertedError,Pe as TransportKeyPairChangedError,ze as TransportKeyPairExpiredError,Rt as UnshieldAlreadyFinalizedError,ge as WalletAccountNotReadyError,ve as WalletNotConnectedError,kn as WrappedToken,dt as WrappersRegistry,Ye as ZERO_ENCRYPTED_VALUE,p as ZamaError,s as ZamaErrorCode,lr as ZamaSDK,x as ZamaSDKEvents,b as allowanceContract,wt as anvil,C as approveContract,Ue as balanceOfContract,bt as bscTestnet,St as chains,wn as chromeSessionStorage,et as cleartext,He as confidentialBalanceOfContract,he as confidentialTotalSupplyContract,ne as confidentialTransferContract,je as confidentialTransferFromContract,Zt as createConfig,ft as createWalletAccountStore,Se as decimalsContract,mn as decodeAclEvent,hn as decodeAclEvents,rn as decodeConfidentialTransfer,fn as decodeDelegatedForUserDecryption,sn as decodeOnChainEvent,cn as decodeOnChainEvents,pn as decodeRevokedDelegationForUserDecryption,on as decodeUnwrapFinalized,Z as decodeUnwrapRequested,an as decodeWrap,Kt as delegateForUserDecryptionContract,ee as finalizeUnwrapContract,gn as findDelegatedForUserDecryption,_n as findRevokedDelegationForUserDecryption,ln as findUnwrapRequested,un as findWrap,Re as getConfidentialTokenAddressContract,Jt as getDelegationExpiryContract,ke as getTokenAddressContract,xe as getTokenPairContract,Fe as getTokenPairsContract,Be as getTokenPairsLengthContract,Ce as getTokenPairsSliceContract,vt as hardhat,gt as hoodi,ht as indexedDBStorage,Ae as inferredTotalSupplyContract,xt as ingenTestnet,Ie as isConfidentialTokenContract,Me as isConfidentialTokenValidContract,Ne as isConfidentialWrapperContract,E as isEncryptedValueZero,Yt as isHandleDelegatedContract,le as isOperatorContract,t as isRetryable,Ct as mainnet,Mt as matchZamaError,at as memoryStorage,me as nameContract,_t as polygon,yt as polygonAmoy,ue as rateContract,d as retryAfterSeconds,qt as revokeDelegationContract,Tt as sepolia,de as setOperatorContract,De as supportsInterfaceContract,te as symbolContract,Gt as transferAndCallContract,re as underlyingContract,oe as unwrapContract,ce as unwrapFromBalanceContract,pe as unwrapRequesterContract,w as wrapContract};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|