@zama-fhe/sdk 2.3.0-alpha.3 → 2.3.0
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/activity.cjs +1 -1
- package/dist/cjs/activity.cjs.map +1 -1
- package/dist/cjs/cleartext.cjs +1 -1
- package/dist/cjs/cleartext.cjs.map +1 -1
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/query/index.cjs +1 -1
- package/dist/cjs/query/index.cjs.map +1 -1
- package/dist/cjs/relayer.cjs +1 -1
- package/dist/cjs/relayer.cjs.map +1 -1
- package/dist/esm/{activity-D8okM6NP.d.ts → activity-DTBvolDB.d.ts} +210 -15
- package/dist/esm/{activity-DVF6Mxsn.js → activity-b2RsqKHW.js} +2 -2
- package/dist/esm/{activity-DVF6Mxsn.js.map → activity-b2RsqKHW.js.map} +1 -1
- package/dist/esm/cleartext/index.d.ts +5 -3
- package/dist/esm/cleartext/index.js +1 -1
- package/dist/esm/{cleartext-BU7SYjBM.js → cleartext-Bzxet3H7.js} +2 -2
- package/dist/esm/cleartext-Bzxet3H7.js.map +1 -0
- package/dist/esm/{encryption-UaXE1L_W.js → encryption-CmIPBcfP.js} +2 -2
- package/dist/esm/{encryption-UaXE1L_W.js.map → encryption-CmIPBcfP.js.map} +1 -1
- package/dist/esm/ethers/index.d.ts +2 -2
- package/dist/esm/{fhe-artifact-cache-DMw74maw.js → fhe-artifact-cache-CyXna-Br.js} +2 -2
- package/dist/esm/{fhe-artifact-cache-DMw74maw.js.map → fhe-artifact-cache-CyXna-Br.js.map} +1 -1
- package/dist/esm/{index-C3ELlhM8.d.ts → index-BXdXzzx4.d.ts} +2 -2
- package/dist/esm/index.d.ts +8 -129
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/memory-storage-B4_heQa5.js +2 -0
- package/dist/esm/memory-storage-B4_heQa5.js.map +1 -0
- package/dist/esm/node/index.d.ts +5 -3
- package/dist/esm/node/index.js +1 -1
- package/dist/esm/node/index.js.map +1 -1
- package/dist/esm/query/index.d.ts +10 -18
- package/dist/esm/query/index.js +1 -1
- package/dist/esm/query/index.js.map +1 -1
- package/dist/esm/relayer-C6u3eOlN.js +2 -0
- package/dist/esm/relayer-C6u3eOlN.js.map +1 -0
- package/dist/esm/{relayer-sdk-Cqx3HnZh.d.ts → relayer-sdk-C_4bkxxH.d.ts} +2 -2
- package/dist/esm/{relayer-sdk.types-BhV3n5qO.d.ts → relayer-sdk.types-C9GAgQ7q.d.ts} +23 -2
- package/dist/esm/viem/index.d.ts +2 -2
- package/package.json +1 -1
- package/dist/esm/cleartext-BU7SYjBM.js.map +0 -1
- package/dist/esm/memory-storage-BkqO2DFz.js +0 -2
- package/dist/esm/memory-storage-BkqO2DFz.js.map +0 -1
- package/dist/esm/relayer-DfjPWTBf.js +0 -2
- package/dist/esm/relayer-DfjPWTBf.js.map +0 -1
package/dist/cjs/relayer.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relayer.cjs","names":[],"sources":["../../src/errors/base.ts","../../src/errors/encryption.ts","../../src/errors/relayer.ts"],"sourcesContent":["/**\n * Typed error codes thrown by the SDK.\n * Use `error.code` or `instanceof` to programmatically handle specific failure modes.\n *\n * @example\n * ```ts\n * try {\n * await token.confidentialTransfer(\"0xTo\", 100n);\n * } catch (e) {\n * if (e instanceof SigningRejectedError) {\n * // User rejected the wallet signature\n * }\n * }\n * ```\n */\nexport const ZamaErrorCode = {\n /** User rejected the wallet signature prompt. */\n SigningRejected: \"SIGNING_REJECTED\",\n /** Wallet signature failed for a reason other than rejection. */\n SigningFailed: \"SIGNING_FAILED\",\n /** FHE encryption failed. */\n EncryptionFailed: \"ENCRYPTION_FAILED\",\n /** FHE decryption failed. */\n DecryptionFailed: \"DECRYPTION_FAILED\",\n /** ERC-20 approval transaction failed. */\n ApprovalFailed: \"APPROVAL_FAILED\",\n /** On-chain transaction reverted. */\n TransactionReverted: \"TRANSACTION_REVERTED\",\n /** FHE keypair has expired and needs regeneration. */\n KeypairExpired: \"KEYPAIR_EXPIRED\",\n /** Relayer rejected FHE keypair (stale, expired, or malformed). */\n InvalidKeypair: \"INVALID_KEYPAIR\",\n /** No FHE ciphertext exists for this account (never shielded). */\n NoCiphertext: \"NO_CIPHERTEXT\",\n /** Relayer HTTP request failed. */\n RelayerRequestFailed: \"RELAYER_REQUEST_FAILED\",\n /** SDK configuration is invalid (e.g. forbidden chain ID, unsupported type). */\n Configuration: \"CONFIGURATION\",\n /** Delegation cannot target self (delegate === msg.sender). */\n DelegationSelfNotAllowed: \"DELEGATION_SELF_NOT_ALLOWED\",\n /** Only one delegate/revoke per (delegator, delegate, contract) per block. */\n DelegationCooldown: \"DELEGATION_COOLDOWN\",\n /** No active delegation found for this (delegator, delegate, contract) tuple. */\n DelegationNotFound: \"DELEGATION_NOT_FOUND\",\n /** The delegation has expired. */\n DelegationExpired: \"DELEGATION_EXPIRED\",\n /** The new expiration date equals the current one — no on-chain change needed. */\n DelegationExpiryUnchanged: \"DELEGATION_EXPIRY_UNCHANGED\",\n /** Delegate address cannot be the contract address. */\n DelegationDelegateEqualsContract: \"DELEGATION_DELEGATE_EQUALS_CONTRACT\",\n /** Contract address cannot be the sender address. */\n DelegationContractIsSelf: \"DELEGATION_CONTRACT_IS_SELF\",\n /** The ACL contract is paused. */\n AclPaused: \"ACL_PAUSED\",\n /** Expiration date is too soon (must be at least 1 hour in the future). */\n DelegationExpirationTooSoon: \"DELEGATION_EXPIRATION_TOO_SOON\",\n /** Delegation exists on-chain but hasn't propagated to the gateway yet. */\n DelegationNotPropagated: \"DELEGATION_NOT_PROPAGATED\",\n} as const;\n\n/** Union of all {@link ZamaErrorCode} string values. */\nexport type ZamaErrorCode = (typeof ZamaErrorCode)[keyof typeof ZamaErrorCode];\n\n/**\n * Base error thrown by all SDK operations.\n * Carries a {@link ZamaErrorCode} for programmatic error handling.\n * Prefer catching specific subclasses (e.g. {@link EncryptionFailedError}).\n */\nexport class ZamaError extends Error {\n /** Machine-readable error code. */\n readonly code: ZamaErrorCode;\n\n constructor(code: ZamaErrorCode, message: string, options?: ErrorOptions) {\n super(message, options);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"ZamaError\";\n this.code = code;\n }\n}\n\n/**\n * Pattern-match on a {@link ZamaError} by its error code.\n * Falls through to the `_` wildcard handler if no specific handler matches.\n * Returns `undefined` if the error is not a `ZamaError` and no `_` handler is provided.\n *\n * @example\n * ```ts\n * matchZamaError(error, {\n * SIGNING_REJECTED: () => toast(\"Please approve in wallet\"),\n * TRANSACTION_REVERTED: (e) => toast(`Tx failed: ${e.message}`),\n * _: () => toast(\"Unknown error\"),\n * });\n * ```\n */\nexport function matchZamaError<R>(\n error: unknown,\n handlers: Partial<Record<ZamaErrorCode, (error: ZamaError) => R>> & {\n _?: (error: unknown) => R;\n },\n): R | undefined {\n if (error instanceof ZamaError) {\n const handler = handlers[error.code];\n if (handler) {\n return handler(error);\n }\n }\n return handlers._?.(error);\n}\n","import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/** FHE encryption failed. */\nexport class EncryptionFailedError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.EncryptionFailed, message, options);\n this.name = \"EncryptionFailedError\";\n }\n}\n\n/** FHE decryption failed. */\nexport class DecryptionFailedError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.DecryptionFailed, message, options);\n this.name = \"DecryptionFailedError\";\n }\n}\n","import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/** Relayer HTTP request failed. */\nexport class RelayerRequestFailedError extends ZamaError {\n /** HTTP status code from the relayer, if available. */\n readonly statusCode: number | undefined;\n\n constructor(message: string, statusCode?: number, options?: ErrorOptions) {\n super(ZamaErrorCode.RelayerRequestFailed, message, options);\n this.name = \"RelayerRequestFailedError\";\n this.statusCode = statusCode;\n }\n}\n\n/** SDK configuration is invalid (e.g. forbidden chain ID, unsupported type). */\nexport class ConfigurationError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.Configuration, message, options);\n this.name = \"ConfigurationError\";\n }\n}\n"],"mappings":"AAeA,MAAa,EAAgB,CAE3B,gBAAiB,mBAEjB,cAAe,iBAEf,iBAAkB,oBAElB,iBAAkB,oBAElB,eAAgB,kBAEhB,oBAAqB,uBAErB,eAAgB,kBAEhB,eAAgB,kBAEhB,aAAc,gBAEd,qBAAsB,yBAEtB,cAAe,gBAEf,yBAA0B,8BAE1B,mBAAoB,sBAEpB,mBAAoB,uBAEpB,kBAAmB,qBAEnB,0BAA2B,8BAE3B,iCAAkC,sCAElC,yBAA0B,8BAE1B,UAAW,aAEX,4BAA6B,iCAE7B,wBAAyB,4BAC1B,CAUD,IAAa,EAAb,cAA+B,KAAM,CAEnC,KAEA,YAAY,EAAqB,EAAiB,EAAwB,CACxE,MAAM,EAAS,EAAQ,CACvB,OAAO,eAAe,KAAM,IAAI,OAAO,UAAU,CACjD,KAAK,KAAO,YACZ,KAAK,KAAO,IAkBhB,SAAgB,EACd,EACA,EAGe,CACf,GAAI,aAAiB,EAAW,CAC9B,IAAM,EAAU,EAAS,EAAM,MAC/B,GAAI,EACF,OAAO,EAAQ,EAAM,CAGzB,OAAO,EAAS,IAAI,EAAM,
|
|
1
|
+
{"version":3,"file":"relayer.cjs","names":[],"sources":["../../src/errors/base.ts","../../src/errors/encryption.ts","../../src/errors/relayer.ts"],"sourcesContent":["/**\n * Typed error codes thrown by the SDK.\n * Use `error.code` or `instanceof` to programmatically handle specific failure modes.\n *\n * @example\n * ```ts\n * try {\n * await token.confidentialTransfer(\"0xTo\", 100n);\n * } catch (e) {\n * if (e instanceof SigningRejectedError) {\n * // User rejected the wallet signature\n * }\n * }\n * ```\n */\nexport const ZamaErrorCode = {\n /** User rejected the wallet signature prompt. */\n SigningRejected: \"SIGNING_REJECTED\",\n /** Wallet signature failed for a reason other than rejection. */\n SigningFailed: \"SIGNING_FAILED\",\n /** FHE encryption failed. */\n EncryptionFailed: \"ENCRYPTION_FAILED\",\n /** FHE decryption failed. */\n DecryptionFailed: \"DECRYPTION_FAILED\",\n /** ERC-20 approval transaction failed. */\n ApprovalFailed: \"APPROVAL_FAILED\",\n /** On-chain transaction reverted. */\n TransactionReverted: \"TRANSACTION_REVERTED\",\n /** FHE keypair has expired and needs regeneration. */\n KeypairExpired: \"KEYPAIR_EXPIRED\",\n /** Relayer rejected FHE keypair (stale, expired, or malformed). */\n InvalidKeypair: \"INVALID_KEYPAIR\",\n /** No FHE ciphertext exists for this account (never shielded). */\n NoCiphertext: \"NO_CIPHERTEXT\",\n /** Relayer HTTP request failed. */\n RelayerRequestFailed: \"RELAYER_REQUEST_FAILED\",\n /** SDK configuration is invalid (e.g. forbidden chain ID, unsupported type). */\n Configuration: \"CONFIGURATION\",\n /** Delegation cannot target self (delegate === msg.sender). */\n DelegationSelfNotAllowed: \"DELEGATION_SELF_NOT_ALLOWED\",\n /** Only one delegate/revoke per (delegator, delegate, contract) per block. */\n DelegationCooldown: \"DELEGATION_COOLDOWN\",\n /** No active delegation found for this (delegator, delegate, contract) tuple. */\n DelegationNotFound: \"DELEGATION_NOT_FOUND\",\n /** The delegation has expired. */\n DelegationExpired: \"DELEGATION_EXPIRED\",\n /** Confidential (cToken) balance is insufficient for the requested operation. */\n InsufficientConfidentialBalance: \"INSUFFICIENT_CONFIDENTIAL_BALANCE\",\n /** ERC-20 balance is insufficient for the requested shield amount. */\n InsufficientERC20Balance: \"INSUFFICIENT_ERC20_BALANCE\",\n /** Balance validation could not be performed (no cached credentials and decryption not possible). */\n BalanceCheckUnavailable: \"BALANCE_CHECK_UNAVAILABLE\",\n /** Public ERC-20 read (e.g. balanceOf) failed due to a network or contract error. */\n ERC20ReadFailed: \"ERC20_READ_FAILED\",\n /** The new expiration date equals the current one — no on-chain change needed. */\n DelegationExpiryUnchanged: \"DELEGATION_EXPIRY_UNCHANGED\",\n /** Delegate address cannot be the contract address. */\n DelegationDelegateEqualsContract: \"DELEGATION_DELEGATE_EQUALS_CONTRACT\",\n /** Contract address cannot be the sender address. */\n DelegationContractIsSelf: \"DELEGATION_CONTRACT_IS_SELF\",\n /** The ACL contract is paused. */\n AclPaused: \"ACL_PAUSED\",\n /** Expiration date is too soon (must be at least 1 hour in the future). */\n DelegationExpirationTooSoon: \"DELEGATION_EXPIRATION_TOO_SOON\",\n /** Delegation exists on-chain but hasn't propagated to the gateway yet. */\n DelegationNotPropagated: \"DELEGATION_NOT_PROPAGATED\",\n} as const;\n\n/** Union of all {@link ZamaErrorCode} string values. */\nexport type ZamaErrorCode = (typeof ZamaErrorCode)[keyof typeof ZamaErrorCode];\n\n/**\n * Base error thrown by all SDK operations.\n * Carries a {@link ZamaErrorCode} for programmatic error handling.\n * Prefer catching specific subclasses (e.g. {@link EncryptionFailedError}).\n */\nexport class ZamaError extends Error {\n /** Machine-readable error code. */\n readonly code: ZamaErrorCode;\n\n constructor(code: ZamaErrorCode, message: string, options?: ErrorOptions) {\n super(message, options);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = \"ZamaError\";\n this.code = code;\n }\n}\n\n/**\n * Pattern-match on a {@link ZamaError} by its error code.\n * Falls through to the `_` wildcard handler if no specific handler matches.\n * Returns `undefined` if the error is not a `ZamaError` and no `_` handler is provided.\n *\n * @example\n * ```ts\n * matchZamaError(error, {\n * SIGNING_REJECTED: () => toast(\"Please approve in wallet\"),\n * TRANSACTION_REVERTED: (e) => toast(`Tx failed: ${e.message}`),\n * _: () => toast(\"Unknown error\"),\n * });\n * ```\n */\nexport function matchZamaError<R>(\n error: unknown,\n handlers: Partial<Record<ZamaErrorCode, (error: ZamaError) => R>> & {\n _?: (error: unknown) => R;\n },\n): R | undefined {\n if (error instanceof ZamaError) {\n const handler = handlers[error.code];\n if (handler) {\n return handler(error);\n }\n }\n return handlers._?.(error);\n}\n","import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/** FHE encryption failed. */\nexport class EncryptionFailedError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.EncryptionFailed, message, options);\n this.name = \"EncryptionFailedError\";\n }\n}\n\n/** FHE decryption failed. */\nexport class DecryptionFailedError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.DecryptionFailed, message, options);\n this.name = \"DecryptionFailedError\";\n }\n}\n","import { ZamaError, ZamaErrorCode } from \"./base\";\n\n/** Relayer HTTP request failed. */\nexport class RelayerRequestFailedError extends ZamaError {\n /** HTTP status code from the relayer, if available. */\n readonly statusCode: number | undefined;\n\n constructor(message: string, statusCode?: number, options?: ErrorOptions) {\n super(ZamaErrorCode.RelayerRequestFailed, message, options);\n this.name = \"RelayerRequestFailedError\";\n this.statusCode = statusCode;\n }\n}\n\n/** SDK configuration is invalid (e.g. forbidden chain ID, unsupported type). */\nexport class ConfigurationError extends ZamaError {\n constructor(message: string, options?: ErrorOptions) {\n super(ZamaErrorCode.Configuration, message, options);\n this.name = \"ConfigurationError\";\n }\n}\n"],"mappings":"AAeA,MAAa,EAAgB,CAE3B,gBAAiB,mBAEjB,cAAe,iBAEf,iBAAkB,oBAElB,iBAAkB,oBAElB,eAAgB,kBAEhB,oBAAqB,uBAErB,eAAgB,kBAEhB,eAAgB,kBAEhB,aAAc,gBAEd,qBAAsB,yBAEtB,cAAe,gBAEf,yBAA0B,8BAE1B,mBAAoB,sBAEpB,mBAAoB,uBAEpB,kBAAmB,qBAEnB,gCAAiC,oCAEjC,yBAA0B,6BAE1B,wBAAyB,4BAEzB,gBAAiB,oBAEjB,0BAA2B,8BAE3B,iCAAkC,sCAElC,yBAA0B,8BAE1B,UAAW,aAEX,4BAA6B,iCAE7B,wBAAyB,4BAC1B,CAUD,IAAa,EAAb,cAA+B,KAAM,CAEnC,KAEA,YAAY,EAAqB,EAAiB,EAAwB,CACxE,MAAM,EAAS,EAAQ,CACvB,OAAO,eAAe,KAAM,IAAI,OAAO,UAAU,CACjD,KAAK,KAAO,YACZ,KAAK,KAAO,IAkBhB,SAAgB,EACd,EACA,EAGe,CACf,GAAI,aAAiB,EAAW,CAC9B,IAAM,EAAU,EAAS,EAAM,MAC/B,GAAI,EACF,OAAO,EAAQ,EAAM,CAGzB,OAAO,EAAS,IAAI,EAAM,CC/G5B,IAAa,EAAb,cAA2C,CAAU,CACnD,YAAY,EAAiB,EAAwB,CACnD,MAAM,EAAc,iBAAkB,EAAS,EAAQ,CACvD,KAAK,KAAO,0BAKH,EAAb,cAA2C,CAAU,CACnD,YAAY,EAAiB,EAAwB,CACnD,MAAM,EAAc,iBAAkB,EAAS,EAAQ,CACvD,KAAK,KAAO,0BCXH,EAAb,cAA+C,CAAU,CAEvD,WAEA,YAAY,EAAiB,EAAqB,EAAwB,CACxE,MAAM,EAAc,qBAAsB,EAAS,EAAQ,CAC3D,KAAK,KAAO,4BACZ,KAAK,WAAa,IAKT,EAAb,cAAwC,CAAU,CAChD,YAAY,EAAiB,EAAwB,CACnD,MAAM,EAAc,cAAe,EAAS,EAAQ,CACpD,KAAK,KAAO"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as
|
|
2
|
-
import { n as TokenWrapperPair, r as TokenWrapperPairWithMetadata, t as PaginatedResult } from "./index-
|
|
3
|
-
import { t as RelayerSDK } from "./relayer-sdk-
|
|
1
|
+
import { C as GenericSigner, D as TransactionResult, S as GenericStorage, T as RawLog, b as DelegatedStoredCredentials, g as UnshieldOptions, h as TransferOptions, m as ShieldOptions, s as Handle, v as TransferCallbacks, w as SignerLifecycleCallbacks, x as StoredCredentials, y as UnshieldCallbacks } from "./relayer-sdk.types-C9GAgQ7q.js";
|
|
2
|
+
import { n as TokenWrapperPair, r as TokenWrapperPairWithMetadata, t as PaginatedResult } from "./index-BXdXzzx4.js";
|
|
3
|
+
import { t as RelayerSDK } from "./relayer-sdk-C_4bkxxH.js";
|
|
4
4
|
import { Address, Hex } from "viem";
|
|
5
5
|
|
|
6
6
|
//#region src/events/sdk-events.d.ts
|
|
@@ -885,7 +885,11 @@ declare const ZamaErrorCode: {
|
|
|
885
885
|
readonly DelegationSelfNotAllowed: "DELEGATION_SELF_NOT_ALLOWED"; /** Only one delegate/revoke per (delegator, delegate, contract) per block. */
|
|
886
886
|
readonly DelegationCooldown: "DELEGATION_COOLDOWN"; /** No active delegation found for this (delegator, delegate, contract) tuple. */
|
|
887
887
|
readonly DelegationNotFound: "DELEGATION_NOT_FOUND"; /** The delegation has expired. */
|
|
888
|
-
readonly DelegationExpired: "DELEGATION_EXPIRED"; /**
|
|
888
|
+
readonly DelegationExpired: "DELEGATION_EXPIRED"; /** Confidential (cToken) balance is insufficient for the requested operation. */
|
|
889
|
+
readonly InsufficientConfidentialBalance: "INSUFFICIENT_CONFIDENTIAL_BALANCE"; /** ERC-20 balance is insufficient for the requested shield amount. */
|
|
890
|
+
readonly InsufficientERC20Balance: "INSUFFICIENT_ERC20_BALANCE"; /** Balance validation could not be performed (no cached credentials and decryption not possible). */
|
|
891
|
+
readonly BalanceCheckUnavailable: "BALANCE_CHECK_UNAVAILABLE"; /** Public ERC-20 read (e.g. balanceOf) failed due to a network or contract error. */
|
|
892
|
+
readonly ERC20ReadFailed: "ERC20_READ_FAILED"; /** The new expiration date equals the current one — no on-chain change needed. */
|
|
889
893
|
readonly DelegationExpiryUnchanged: "DELEGATION_EXPIRY_UNCHANGED"; /** Delegate address cannot be the contract address. */
|
|
890
894
|
readonly DelegationDelegateEqualsContract: "DELEGATION_DELEGATE_EQUALS_CONTRACT"; /** Contract address cannot be the sender address. */
|
|
891
895
|
readonly DelegationContractIsSelf: "DELEGATION_CONTRACT_IS_SELF"; /** The ACL contract is paused. */
|
|
@@ -923,6 +927,165 @@ declare function matchZamaError<R>(error: unknown, handlers: Partial<Record<Zama
|
|
|
923
927
|
_?: (error: unknown) => R;
|
|
924
928
|
}): R | undefined;
|
|
925
929
|
//#endregion
|
|
930
|
+
//#region src/errors/signing.d.ts
|
|
931
|
+
/** User rejected the wallet signature prompt. */
|
|
932
|
+
declare class SigningRejectedError extends ZamaError {
|
|
933
|
+
constructor(message: string, options?: ErrorOptions);
|
|
934
|
+
}
|
|
935
|
+
/** Wallet signature failed for a reason other than rejection. */
|
|
936
|
+
declare class SigningFailedError extends ZamaError {
|
|
937
|
+
constructor(message: string, options?: ErrorOptions);
|
|
938
|
+
}
|
|
939
|
+
//#endregion
|
|
940
|
+
//#region src/errors/encryption.d.ts
|
|
941
|
+
/** FHE encryption failed. */
|
|
942
|
+
declare class EncryptionFailedError extends ZamaError {
|
|
943
|
+
constructor(message: string, options?: ErrorOptions);
|
|
944
|
+
}
|
|
945
|
+
/** FHE decryption failed. */
|
|
946
|
+
declare class DecryptionFailedError extends ZamaError {
|
|
947
|
+
constructor(message: string, options?: ErrorOptions);
|
|
948
|
+
}
|
|
949
|
+
//#endregion
|
|
950
|
+
//#region src/errors/transaction.d.ts
|
|
951
|
+
/** ERC-20 approval transaction failed. */
|
|
952
|
+
declare class ApprovalFailedError extends ZamaError {
|
|
953
|
+
constructor(message: string, options?: ErrorOptions);
|
|
954
|
+
}
|
|
955
|
+
/** On-chain transaction reverted. */
|
|
956
|
+
declare class TransactionRevertedError extends ZamaError {
|
|
957
|
+
constructor(message: string, options?: ErrorOptions);
|
|
958
|
+
}
|
|
959
|
+
//#endregion
|
|
960
|
+
//#region src/errors/credential.d.ts
|
|
961
|
+
/** FHE keypair has expired and needs regeneration. */
|
|
962
|
+
declare class KeypairExpiredError extends ZamaError {
|
|
963
|
+
constructor(message: string, options?: ErrorOptions);
|
|
964
|
+
}
|
|
965
|
+
/** Relayer rejected FHE keypair (stale, expired, or malformed). */
|
|
966
|
+
declare class InvalidKeypairError extends ZamaError {
|
|
967
|
+
constructor(message: string, options?: ErrorOptions);
|
|
968
|
+
}
|
|
969
|
+
/** No FHE ciphertext exists for this account (never shielded). */
|
|
970
|
+
declare class NoCiphertextError extends ZamaError {
|
|
971
|
+
constructor(message: string, options?: ErrorOptions);
|
|
972
|
+
}
|
|
973
|
+
//#endregion
|
|
974
|
+
//#region src/errors/relayer.d.ts
|
|
975
|
+
/** Relayer HTTP request failed. */
|
|
976
|
+
declare class RelayerRequestFailedError extends ZamaError {
|
|
977
|
+
/** HTTP status code from the relayer, if available. */
|
|
978
|
+
readonly statusCode: number | undefined;
|
|
979
|
+
constructor(message: string, statusCode?: number, options?: ErrorOptions);
|
|
980
|
+
}
|
|
981
|
+
/** SDK configuration is invalid (e.g. forbidden chain ID, unsupported type). */
|
|
982
|
+
declare class ConfigurationError extends ZamaError {
|
|
983
|
+
constructor(message: string, options?: ErrorOptions);
|
|
984
|
+
}
|
|
985
|
+
//#endregion
|
|
986
|
+
//#region src/errors/delegation.d.ts
|
|
987
|
+
/** Delegation cannot target self (delegate === msg.sender). */
|
|
988
|
+
declare class DelegationSelfNotAllowedError extends ZamaError {
|
|
989
|
+
constructor(message: string, options?: ErrorOptions);
|
|
990
|
+
}
|
|
991
|
+
/** Only one delegate/revoke per (delegator, delegate, contract) per block. */
|
|
992
|
+
declare class DelegationCooldownError extends ZamaError {
|
|
993
|
+
constructor(message: string, options?: ErrorOptions);
|
|
994
|
+
}
|
|
995
|
+
/** No active delegation found for this (delegator, delegate, contract) tuple. */
|
|
996
|
+
declare class DelegationNotFoundError extends ZamaError {
|
|
997
|
+
constructor(message: string, options?: ErrorOptions);
|
|
998
|
+
}
|
|
999
|
+
/** The delegation has expired. */
|
|
1000
|
+
declare class DelegationExpiredError extends ZamaError {
|
|
1001
|
+
constructor(message: string, options?: ErrorOptions);
|
|
1002
|
+
}
|
|
1003
|
+
/** The new expiration date equals the current one. */
|
|
1004
|
+
declare class DelegationExpiryUnchangedError extends ZamaError {
|
|
1005
|
+
constructor(message: string, options?: ErrorOptions);
|
|
1006
|
+
}
|
|
1007
|
+
/** Delegate address cannot be the contract address. */
|
|
1008
|
+
declare class DelegationDelegateEqualsContractError extends ZamaError {
|
|
1009
|
+
constructor(message: string, options?: ErrorOptions);
|
|
1010
|
+
}
|
|
1011
|
+
/** Contract address cannot be the sender address. */
|
|
1012
|
+
declare class DelegationContractIsSelfError extends ZamaError {
|
|
1013
|
+
constructor(message: string, options?: ErrorOptions);
|
|
1014
|
+
}
|
|
1015
|
+
/** The ACL contract is paused. */
|
|
1016
|
+
declare class AclPausedError extends ZamaError {
|
|
1017
|
+
constructor(message: string, options?: ErrorOptions);
|
|
1018
|
+
}
|
|
1019
|
+
/** Expiration date is too soon (must be at least 1 hour in the future). */
|
|
1020
|
+
declare class DelegationExpirationTooSoonError extends ZamaError {
|
|
1021
|
+
constructor(message: string, options?: ErrorOptions);
|
|
1022
|
+
}
|
|
1023
|
+
/**
|
|
1024
|
+
* Delegation exists on L1 but hasn't propagated to the gateway yet.
|
|
1025
|
+
*
|
|
1026
|
+
* After calling `delegateForUserDecryption()`, the delegation is recorded on-chain
|
|
1027
|
+
* immediately. However, the gateway (deployed on Arbitrum) must sync this state
|
|
1028
|
+
* via cross-chain event propagation, which typically takes 1–2 minutes.
|
|
1029
|
+
*
|
|
1030
|
+
* Calling `decryptBalanceAs` during this window will fail because the gateway's
|
|
1031
|
+
* `isHandleDelegatedForUserDecryption()` check reads from its own synced copy
|
|
1032
|
+
* of the ACL state, which hasn't been updated yet.
|
|
1033
|
+
*
|
|
1034
|
+
* **Note:** This error is raised as a best-effort heuristic — when a delegated
|
|
1035
|
+
* decryption receives an HTTP 500 from the relayer, the most likely cause is a
|
|
1036
|
+
* propagation delay. However, the same status code can occur if the gateway or
|
|
1037
|
+
* relayer experiences an unrelated internal error.
|
|
1038
|
+
*/
|
|
1039
|
+
declare class DelegationNotPropagatedError extends ZamaError {
|
|
1040
|
+
constructor(message: string, options?: ErrorOptions);
|
|
1041
|
+
}
|
|
1042
|
+
//#endregion
|
|
1043
|
+
//#region src/errors/balance.d.ts
|
|
1044
|
+
/** Structured details shared by balance-related errors. */
|
|
1045
|
+
interface BalanceErrorDetails {
|
|
1046
|
+
readonly requested: bigint;
|
|
1047
|
+
readonly available: bigint;
|
|
1048
|
+
readonly token: Address;
|
|
1049
|
+
}
|
|
1050
|
+
/** Confidential (cToken) balance is insufficient for the requested operation. */
|
|
1051
|
+
declare class InsufficientConfidentialBalanceError extends ZamaError {
|
|
1052
|
+
/** The amount the caller requested. */
|
|
1053
|
+
readonly requested: bigint;
|
|
1054
|
+
/** The available balance at the time of the check. */
|
|
1055
|
+
readonly available: bigint;
|
|
1056
|
+
/** The token contract address. */
|
|
1057
|
+
readonly token: Address;
|
|
1058
|
+
constructor(message: string, details: BalanceErrorDetails, options?: ErrorOptions);
|
|
1059
|
+
}
|
|
1060
|
+
/** ERC-20 balance is insufficient for the requested shield amount. */
|
|
1061
|
+
declare class InsufficientERC20BalanceError extends ZamaError {
|
|
1062
|
+
/** The amount the caller requested. */
|
|
1063
|
+
readonly requested: bigint;
|
|
1064
|
+
/** The available balance at the time of the check. */
|
|
1065
|
+
readonly available: bigint;
|
|
1066
|
+
/** The ERC-20 token contract address. */
|
|
1067
|
+
readonly token: Address;
|
|
1068
|
+
constructor(message: string, details: BalanceErrorDetails, options?: ErrorOptions);
|
|
1069
|
+
}
|
|
1070
|
+
/** Balance validation could not be performed (no cached credentials and decryption not possible). */
|
|
1071
|
+
declare class BalanceCheckUnavailableError extends ZamaError {
|
|
1072
|
+
constructor(message: string, options?: ErrorOptions);
|
|
1073
|
+
}
|
|
1074
|
+
/** A public ERC-20 read (e.g. balanceOf) failed due to a network or contract error. */
|
|
1075
|
+
declare class ERC20ReadFailedError extends ZamaError {
|
|
1076
|
+
constructor(message: string, options?: ErrorOptions);
|
|
1077
|
+
}
|
|
1078
|
+
//#endregion
|
|
1079
|
+
//#region src/errors/acl-revert.d.ts
|
|
1080
|
+
/**
|
|
1081
|
+
* Map known ACL Solidity revert error names to typed ZamaError subclasses.
|
|
1082
|
+
* Prefers viem's structured `error.cause.data.errorName` when available,
|
|
1083
|
+
* falling back to string-includes matching on the error message.
|
|
1084
|
+
* Returns `null` if the revert reason is not recognized.
|
|
1085
|
+
* @public
|
|
1086
|
+
*/
|
|
1087
|
+
declare function matchAclRevert(error: unknown): ZamaError | null;
|
|
1088
|
+
//#endregion
|
|
926
1089
|
//#region src/token/token.d.ts
|
|
927
1090
|
/**
|
|
928
1091
|
* ERC-20-like interface for a single confidential token.
|
|
@@ -945,18 +1108,28 @@ declare class Token extends ReadonlyToken {
|
|
|
945
1108
|
* Confidential transfer. Encrypts the amount via FHE, then calls the contract.
|
|
946
1109
|
* Returns the transaction hash.
|
|
947
1110
|
*
|
|
1111
|
+
* By default, the SDK validates the confidential balance before submitting.
|
|
1112
|
+
* If a cached plaintext balance exists it is used; otherwise, if credentials
|
|
1113
|
+
* are cached, it decrypts on the fly. Set `skipBalanceCheck: true` to bypass
|
|
1114
|
+
* this validation (e.g. for smart wallets).
|
|
1115
|
+
*
|
|
948
1116
|
* @param to - Recipient address.
|
|
949
1117
|
* @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
|
|
1118
|
+
* @param options - Optional: `skipBalanceCheck` (default `false`).
|
|
950
1119
|
* @returns The transaction hash and mined receipt.
|
|
1120
|
+
* @throws {@link InsufficientConfidentialBalanceError} if the confidential balance is less than `amount`.
|
|
1121
|
+
* @throws {@link BalanceCheckUnavailableError} if balance validation is required but decryption is not possible (no cached credentials).
|
|
951
1122
|
* @throws {@link EncryptionFailedError} if FHE encryption fails.
|
|
952
1123
|
* @throws {@link TransactionRevertedError} if the on-chain transfer reverts.
|
|
953
1124
|
*
|
|
954
1125
|
* @example
|
|
955
1126
|
* ```ts
|
|
956
1127
|
* const txHash = await token.confidentialTransfer("0xRecipient", 1000n);
|
|
1128
|
+
* // Smart wallet (skip balance check):
|
|
1129
|
+
* const txHash = await token.confidentialTransfer("0xRecipient", 1000n, { skipBalanceCheck: true });
|
|
957
1130
|
* ```
|
|
958
1131
|
*/
|
|
959
|
-
confidentialTransfer(to: Address, amount: bigint,
|
|
1132
|
+
confidentialTransfer(to: Address, amount: bigint, options?: TransferOptions): Promise<TransactionResult>;
|
|
960
1133
|
/**
|
|
961
1134
|
* Operator encrypted transfer on behalf of another address.
|
|
962
1135
|
* The caller must be an approved operator for `from`.
|
|
@@ -1011,9 +1184,14 @@ declare class Token extends ReadonlyToken {
|
|
|
1011
1184
|
* Handles ERC-20 approval automatically based on `approvalStrategy`
|
|
1012
1185
|
* (`"exact"` by default, `"max"` for unlimited approval, `"skip"` to opt out).
|
|
1013
1186
|
*
|
|
1187
|
+
* The ERC-20 balance is validated before submitting (public read, no signing
|
|
1188
|
+
* required). For native ETH shields (`underlying === address(0)`), the ERC-20
|
|
1189
|
+
* check is skipped — the chain validates ETH balance natively.
|
|
1190
|
+
*
|
|
1014
1191
|
* @param amount - The plaintext amount to shield.
|
|
1015
1192
|
* @param options - Optional configuration: `approvalStrategy` (`"exact"` | `"max"` | `"skip"`, default `"exact"`), `fees` (extra ETH for native wrappers).
|
|
1016
1193
|
* @returns The transaction hash and mined receipt.
|
|
1194
|
+
* @throws {@link InsufficientERC20BalanceError} if the ERC-20 balance is less than `amount`.
|
|
1017
1195
|
* @throws {@link ApprovalFailedError} if the ERC-20 approval step fails.
|
|
1018
1196
|
* @throws {@link TransactionRevertedError} if the shield transaction reverts.
|
|
1019
1197
|
*
|
|
@@ -1024,12 +1202,7 @@ declare class Token extends ReadonlyToken {
|
|
|
1024
1202
|
* const txHash = await token.shield(1000n, { approvalStrategy: "exact" });
|
|
1025
1203
|
* ```
|
|
1026
1204
|
*/
|
|
1027
|
-
shield(amount: bigint, options?:
|
|
1028
|
-
approvalStrategy?: "max" | "exact" | "skip";
|
|
1029
|
-
fees?: bigint; /** Recipient address for the shielded tokens. Defaults to the connected wallet. */
|
|
1030
|
-
to?: Address; /** Progress callbacks for the multi-step shield flow. */
|
|
1031
|
-
callbacks?: ShieldCallbacks;
|
|
1032
|
-
}): Promise<TransactionResult>;
|
|
1205
|
+
shield(amount: bigint, options?: ShieldOptions): Promise<TransactionResult>;
|
|
1033
1206
|
/**
|
|
1034
1207
|
* Shield native ETH into confidential tokens. `value` defaults to `amount`.
|
|
1035
1208
|
*
|
|
@@ -1078,18 +1251,25 @@ declare class Token extends ReadonlyToken {
|
|
|
1078
1251
|
* Unshield a specific amount and finalize in one call.
|
|
1079
1252
|
* Orchestrates: unshield → wait for receipt → parse event → finalize.
|
|
1080
1253
|
*
|
|
1254
|
+
* By default, the SDK validates the confidential balance before submitting.
|
|
1255
|
+
* Set `skipBalanceCheck: true` to bypass this validation (e.g. for smart wallets).
|
|
1256
|
+
*
|
|
1081
1257
|
* @param amount - The plaintext amount to unshield.
|
|
1082
|
-
* @param
|
|
1258
|
+
* @param options - Optional: `skipBalanceCheck` (default `false`), `callbacks`.
|
|
1083
1259
|
* @returns The finalize transaction hash and mined receipt.
|
|
1260
|
+
* @throws {@link InsufficientConfidentialBalanceError} if the confidential balance is less than `amount`.
|
|
1261
|
+
* @throws {@link BalanceCheckUnavailableError} if balance validation is required but decryption is not possible.
|
|
1084
1262
|
* @throws {@link EncryptionFailedError} if FHE encryption fails.
|
|
1085
1263
|
* @throws {@link TransactionRevertedError} if any transaction in the flow reverts.
|
|
1086
1264
|
*
|
|
1087
1265
|
* @example
|
|
1088
1266
|
* ```ts
|
|
1089
1267
|
* const txHash = await token.unshield(500n);
|
|
1268
|
+
* // Smart wallet (skip balance check):
|
|
1269
|
+
* const txHash = await token.unshield(500n, { skipBalanceCheck: true });
|
|
1090
1270
|
* ```
|
|
1091
1271
|
*/
|
|
1092
|
-
unshield(amount: bigint,
|
|
1272
|
+
unshield(amount: bigint, options?: UnshieldOptions): Promise<TransactionResult>;
|
|
1093
1273
|
/**
|
|
1094
1274
|
* Unshield the entire balance and finalize in one call.
|
|
1095
1275
|
* Orchestrates: unshieldAll → wait for receipt → parse event → finalize.
|
|
@@ -1586,6 +1766,21 @@ declare class ZamaSDK {
|
|
|
1586
1766
|
* Call this when the SDK is no longer needed (e.g. on unmount or shutdown).
|
|
1587
1767
|
*/
|
|
1588
1768
|
terminate(): void;
|
|
1769
|
+
/**
|
|
1770
|
+
* Implements the TC39 Explicit Resource Management protocol.
|
|
1771
|
+
* Calls {@link terminate} when the `using` binding goes out of scope,
|
|
1772
|
+
* unsubscribing signer events and shutting down the relayer.
|
|
1773
|
+
*
|
|
1774
|
+
* @example
|
|
1775
|
+
* ```ts
|
|
1776
|
+
* {
|
|
1777
|
+
* using sdk = new ZamaSDK({ relayer, signer, storage });
|
|
1778
|
+
* await sdk.allow(cUSDT);
|
|
1779
|
+
* const balance = await sdk.createReadonlyToken(cUSDT).balanceOf();
|
|
1780
|
+
* } // sdk.terminate() called automatically here
|
|
1781
|
+
* ```
|
|
1782
|
+
*/
|
|
1783
|
+
[Symbol.dispose](): void;
|
|
1589
1784
|
}
|
|
1590
1785
|
//#endregion
|
|
1591
1786
|
//#region src/events/onchain-events.d.ts
|
|
@@ -1892,5 +2087,5 @@ declare function applyDecryptedValues(items: readonly ActivityItem[], decryptedM
|
|
|
1892
2087
|
*/
|
|
1893
2088
|
declare function sortByBlockNumber(items: readonly ActivityItem[]): ActivityItem[];
|
|
1894
2089
|
//#endregion
|
|
1895
|
-
export {
|
|
1896
|
-
//# sourceMappingURL=activity-
|
|
2090
|
+
export { DelegationContractIsSelfError as $, ShieldSubmittedEvent as $t, decodeUnwrapRequested as A, CredentialsManagerConfig as At, DefaultRegistryAddresses as B, CredentialsLoadingEvent as Bt, decodeAclEvent as C, BatchDecryptOptions as Ct, decodeOnChainEvent as D, DelegatedCredentialsManager as Dt, decodeDelegatedForUserDecryption as E, ZERO_HANDLE as Et, findRevokedDelegationForUserDecryption as F, CredentialsCachedEvent as Ft, TokenConfig as G, DecryptStartEvent as Gt, WrappersRegistry as H, CredentialsRevokedEvent as Ht, findUnwrapRequested as I, CredentialsCorruptedEvent as It, BalanceErrorDetails as J, EncryptErrorEvent as Jt, matchAclRevert as K, DelegationSubmittedEvent as Kt, findWrapped as L, CredentialsCreatedEvent as Lt, decodeUnwrappedStarted as M, ApproveUnderlyingSubmittedEvent as Mt, decodeWrapped as N, BaseEvent as Nt, decodeOnChainEvents as O, DelegatedCredentialsManagerConfig as Ot, findDelegatedForUserDecryption as P, CredentialsAllowedEvent as Pt, AclPausedError as Q, SessionExpiredEvent as Qt, ZamaSDK as R, CredentialsCreatingEvent as Rt, WrappedEvent as S, BatchDecryptAsOptions as St, decodeConfidentialTransfer as T, ReadonlyTokenConfig as Tt, WrappersRegistryConfig as U, DecryptEndEvent as Ut, ListPairsOptions as V, CredentialsPersistFailedEvent as Vt, Token as W, DecryptErrorEvent as Wt, InsufficientConfidentialBalanceError as X, FinalizeUnwrapSubmittedEvent as Xt, ERC20ReadFailedError as Y, EncryptStartEvent as Yt, InsufficientERC20BalanceError as Z, RevokeDelegationSubmittedEvent as Zt, TOKEN_TOPICS as _, SigningFailedError as _t, ActivityType as a, UnshieldPhase2SubmittedEvent as an, DelegationNotFoundError as at, UnwrappedFinalizedEvent as b, ZamaErrorCode as bt, parseActivityFeed as c, ZamaSDKEventInput as cn, ConfigurationError as ct, AclEvent as d, ZamaSDKEvents as dn, KeypairExpiredError as dt, TransactionErrorEvent as en, DelegationCooldownError as et, AclTopics as f, NoCiphertextError as ft, RevokedDelegationForUserDecryptionEvent as g, EncryptionFailedError as gt, OnChainEvent as h, DecryptionFailedError as ht, ActivityLogMetadata as i, UnshieldPhase2StartedEvent as in, DelegationExpiryUnchangedError as it, decodeUnwrappedFinalized as j, ApproveSubmittedEvent as jt, decodeRevokedDelegationForUserDecryption as k, CredentialsManager as kt, sortByBlockNumber as l, ZamaSDKEventListener as ln, RelayerRequestFailedError as lt, DelegatedForUserDecryptionEvent as m, TransactionRevertedError as mt, ActivityDirection as n, TransferSubmittedEvent as nn, DelegationExpirationTooSoonError as nt, applyDecryptedValues as o, UnwrapSubmittedEvent as on, DelegationNotPropagatedError as ot, ConfidentialTransferEvent as p, ApprovalFailedError as pt, BalanceCheckUnavailableError as q, EncryptEndEvent as qt, ActivityItem as r, UnshieldPhase1SubmittedEvent as rn, DelegationExpiredError as rt, extractEncryptedHandles as s, ZamaSDKEvent as sn, DelegationSelfNotAllowedError as st, ActivityAmount as t, TransferFromSubmittedEvent as tn, DelegationDelegateEqualsContractError as tt, ACL_TOPICS as u, ZamaSDKEventType as un, InvalidKeypairError as ut, Topics as v, SigningRejectedError as vt, decodeAclEvents as w, ReadonlyToken as wt, UnwrappedStartedEvent as x, matchZamaError as xt, UnwrapRequestedEvent as y, ZamaError as yt, ZamaSDKConfig as z, CredentialsExpiredEvent as zt };
|
|
2091
|
+
//# sourceMappingURL=activity-DTBvolDB.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e,n as t,r as n,t as r}from"./relayer-DfjPWTBf.js";import{t as i}from"./encryption-UaXE1L_W.js";import{a,n as o,o as s,t as c}from"./assertions-Dty7Quc0.js";import{r as l,t as u}from"./memory-storage-BkqO2DFz.js";import{t as d}from"./hex-CgAj4TLu.js";import{_ as f,c as p,f as m,l as h,m as g}from"./wrappers-registry-DqPr_JG2.js";import{erc20Abi as _,getAddress as v,isAddress as y}from"viem";var b=class extends n{constructor(t,n){super(e.SigningRejected,t,n),this.name=`SigningRejectedError`}},x=class extends n{constructor(t,n){super(e.SigningFailed,t,n),this.name=`SigningFailedError`}};function ee(e,t){let n=typeof e==`object`&&!!e&&`code`in e&&e.code===4001,r=e instanceof Error?e.message:String(e),i=r.toLowerCase(),a=i.includes(`user rejected`)||i.includes(`user denied`),o=`${t}: ${r}`;throw n||a?new b(o,{cause:e}):new x(o,{cause:e})}var te=class extends n{constructor(t,n){super(e.KeypairExpired,t,n),this.name=`KeypairExpiredError`}},ne=class extends n{constructor(t,n){super(e.InvalidKeypair,t,n),this.name=`InvalidKeypairError`}},S=class extends n{constructor(t,n){super(e.NoCiphertext,t,n),this.name=`NoCiphertextError`}},re=class extends n{constructor(t,n){super(e.DelegationSelfNotAllowed,t,n),this.name=`DelegationSelfNotAllowedError`}},ie=class extends n{constructor(t,n){super(e.DelegationCooldown,t,n),this.name=`DelegationCooldownError`}},C=class extends n{constructor(t,n){super(e.DelegationNotFound,t,n),this.name=`DelegationNotFoundError`}},w=class extends n{constructor(t,n){super(e.DelegationExpired,t,n),this.name=`DelegationExpiredError`}},ae=class extends n{constructor(t,n){super(e.DelegationExpiryUnchanged,t,n),this.name=`DelegationExpiryUnchangedError`}},oe=class extends n{constructor(t,n){super(e.DelegationDelegateEqualsContract,t,n),this.name=`DelegationDelegateEqualsContractError`}},se=class extends n{constructor(t,n){super(e.DelegationContractIsSelf,t,n),this.name=`DelegationContractIsSelfError`}},ce=class extends n{constructor(t,n){super(e.AclPaused,t,n),this.name=`AclPausedError`}},le=class extends n{constructor(t,n){super(e.DelegationExpirationTooSoon,t,n),this.name=`DelegationExpirationTooSoonError`}},T=class extends n{constructor(t,n){super(e.DelegationNotPropagated,t,n),this.name=`DelegationNotPropagatedError`}};function ue(e){return{address:e,abi:_,functionName:`name`,args:[]}}function de(e){return{address:e,abi:_,functionName:`symbol`,args:[]}}function fe(e){return{address:e,abi:_,functionName:`decimals`,args:[]}}function pe(e){return{address:e,abi:_,functionName:`totalSupply`,args:[]}}function me(e,t){return{address:e,abi:_,functionName:`balanceOf`,args:[t]}}function he(e,t,n){return{address:e,abi:_,functionName:`allowance`,args:[t,n]}}function ge(e,t,n){return{address:e,abi:_,functionName:`approve`,args:[t,n]}}const E=[{inputs:[{internalType:`uint64`,name:`wrapFeeBasisPoints_`,type:`uint64`},{internalType:`uint64`,name:`unwrapFeeBasisPoints_`,type:`uint64`},{internalType:`uint64`,name:`deployFee_`,type:`uint64`},{internalType:`uint64`,name:`batchTransferFee_`,type:`uint64`},{internalType:`address`,name:`feeRecipient_`,type:`address`}],stateMutability:`nonpayable`,type:`constructor`},{inputs:[],name:`AccessControlBadConfirmation`,type:`error`},{inputs:[{internalType:`address`,name:`account`,type:`address`},{internalType:`bytes32`,name:`neededRole`,type:`bytes32`}],name:`AccessControlUnauthorizedAccount`,type:`error`},{inputs:[],name:`FeeExceedsMaximum`,type:`error`},{inputs:[],name:`ZeroAddressFeeRecipient`,type:`error`},{anonymous:!1,inputs:[{indexed:!1,internalType:`uint64`,name:`oldBatchTransferFee`,type:`uint64`},{indexed:!1,internalType:`uint64`,name:`newBatchTransferFee`,type:`uint64`}],name:`BatchTransferFeeUpdated`,type:`event`},{anonymous:!1,inputs:[{indexed:!1,internalType:`uint64`,name:`oldDeployFee`,type:`uint64`},{indexed:!1,internalType:`uint64`,name:`newDeployFee`,type:`uint64`}],name:`DeployFeeUpdated`,type:`event`},{anonymous:!1,inputs:[{indexed:!0,internalType:`address`,name:`oldRecipient`,type:`address`},{indexed:!0,internalType:`address`,name:`newRecipient`,type:`address`}],name:`FeeRecipientUpdated`,type:`event`},{anonymous:!1,inputs:[{indexed:!0,internalType:`bytes32`,name:`role`,type:`bytes32`},{indexed:!0,internalType:`bytes32`,name:`previousAdminRole`,type:`bytes32`},{indexed:!0,internalType:`bytes32`,name:`newAdminRole`,type:`bytes32`}],name:`RoleAdminChanged`,type:`event`},{anonymous:!1,inputs:[{indexed:!0,internalType:`bytes32`,name:`role`,type:`bytes32`},{indexed:!0,internalType:`address`,name:`account`,type:`address`},{indexed:!0,internalType:`address`,name:`sender`,type:`address`}],name:`RoleGranted`,type:`event`},{anonymous:!1,inputs:[{indexed:!0,internalType:`bytes32`,name:`role`,type:`bytes32`},{indexed:!0,internalType:`address`,name:`account`,type:`address`},{indexed:!0,internalType:`address`,name:`sender`,type:`address`}],name:`RoleRevoked`,type:`event`},{anonymous:!1,inputs:[{indexed:!1,internalType:`bool`,name:`active`,type:`bool`}],name:`SwapperFeeWaiverUpdated`,type:`event`},{anonymous:!1,inputs:[{indexed:!1,internalType:`uint64`,name:`oldFeeBasisPoints`,type:`uint64`},{indexed:!1,internalType:`uint64`,name:`newFeeBasisPoints`,type:`uint64`}],name:`UnwrapFeeBasisPointsUpdated`,type:`event`},{anonymous:!1,inputs:[{indexed:!1,internalType:`uint64`,name:`oldFeeBasisPoints`,type:`uint64`},{indexed:!1,internalType:`uint64`,name:`newFeeBasisPoints`,type:`uint64`}],name:`WrapFeeBasisPointsUpdated`,type:`event`},{inputs:[],name:`DEFAULT_ADMIN_ROLE`,outputs:[{internalType:`bytes32`,name:``,type:`bytes32`}],stateMutability:`view`,type:`function`},{inputs:[],name:`FEE_MANAGER_ROLE`,outputs:[{internalType:`bytes32`,name:``,type:`bytes32`}],stateMutability:`view`,type:`function`},{inputs:[],name:`MAX_BASIS_POINTS`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`},{inputs:[],name:`SWAPPER_ROLE`,outputs:[{internalType:`bytes32`,name:``,type:`bytes32`}],stateMutability:`view`,type:`function`},{inputs:[],name:`batchTransferFee`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`},{inputs:[],name:`deployFee`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`},{inputs:[],name:`feeRecipient`,outputs:[{internalType:`address`,name:``,type:`address`}],stateMutability:`view`,type:`function`},{inputs:[],name:`getBatchTransferFee`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`address`,name:`deployer`,type:`address`}],name:`getDeployFee`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`},{inputs:[],name:`getFeeRecipient`,outputs:[{internalType:`address`,name:``,type:`address`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`bytes32`,name:`role`,type:`bytes32`}],name:`getRoleAdmin`,outputs:[{internalType:`bytes32`,name:``,type:`bytes32`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`uint64`,name:`amount`,type:`uint64`},{internalType:`address`,name:`unwrapFrom`,type:`address`},{internalType:`address`,name:`unwrapTo`,type:`address`}],name:`getUnwrapFee`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`uint256`,name:`amount`,type:`uint256`},{internalType:`address`,name:`wrapFrom`,type:`address`},{internalType:`address`,name:`wrapTo`,type:`address`}],name:`getWrapFee`,outputs:[{internalType:`uint256`,name:``,type:`uint256`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`bytes32`,name:`role`,type:`bytes32`},{internalType:`address`,name:`account`,type:`address`}],name:`grantRole`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`bytes32`,name:`role`,type:`bytes32`},{internalType:`address`,name:`account`,type:`address`}],name:`hasRole`,outputs:[{internalType:`bool`,name:``,type:`bool`}],stateMutability:`view`,type:`function`},{inputs:[],name:`protocolId`,outputs:[{internalType:`uint256`,name:``,type:`uint256`}],stateMutability:`pure`,type:`function`},{inputs:[{internalType:`bytes32`,name:`role`,type:`bytes32`},{internalType:`address`,name:`callerConfirmation`,type:`address`}],name:`renounceRole`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`bytes32`,name:`role`,type:`bytes32`},{internalType:`address`,name:`account`,type:`address`}],name:`revokeRole`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`uint64`,name:`newBatchTransferFee`,type:`uint64`}],name:`setBatchTransferFee`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`uint64`,name:`newDeployFee`,type:`uint64`}],name:`setDeployFee`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`address`,name:`recipient`,type:`address`}],name:`setFeeRecipient`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`bool`,name:`active`,type:`bool`}],name:`setSwapperFeeWaiverActive`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`uint64`,name:`feeBasisPoints`,type:`uint64`}],name:`setUnwrapFeeBasisPoints`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`uint64`,name:`feeBasisPoints`,type:`uint64`}],name:`setWrapFeeBasisPoints`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`bytes4`,name:`interfaceId`,type:`bytes4`}],name:`supportsInterface`,outputs:[{internalType:`bool`,name:``,type:`bool`}],stateMutability:`view`,type:`function`},{inputs:[],name:`swapperFeeWaiverActive`,outputs:[{internalType:`bool`,name:``,type:`bool`}],stateMutability:`view`,type:`function`},{inputs:[],name:`unwrapFeeBasisPoints`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`},{inputs:[],name:`wrapFeeBasisPoints`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`}];function _e(e,t,n,r){return{address:e,abi:E,functionName:`getWrapFee`,args:[t,n,r]}}function ve(e,t,n,r){return{address:e,abi:E,functionName:`getUnwrapFee`,args:[t,n,r]}}function ye(e){return{address:e,abi:E,functionName:`getBatchTransferFee`,args:[]}}function be(e){return{address:e,abi:E,functionName:`getFeeRecipient`,args:[]}}const D=[{inputs:[{internalType:`address`,name:`delegate`,type:`address`},{internalType:`address`,name:`contractAddress`,type:`address`},{internalType:`uint64`,name:`expirationDate`,type:`uint64`}],name:`delegateForUserDecryption`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`address`,name:`delegate`,type:`address`},{internalType:`address`,name:`contractAddress`,type:`address`}],name:`revokeDelegationForUserDecryption`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`address`,name:`delegator`,type:`address`},{internalType:`address`,name:`delegate`,type:`address`},{internalType:`address`,name:`contractAddress`,type:`address`}],name:`getUserDecryptionDelegationExpirationDate`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`address`,name:`delegator`,type:`address`},{internalType:`address`,name:`delegate`,type:`address`},{internalType:`address`,name:`contractAddress`,type:`address`},{internalType:`bytes32`,name:`handle`,type:`bytes32`}],name:`isHandleDelegatedForUserDecryption`,outputs:[{internalType:`bool`,name:``,type:`bool`}],stateMutability:`view`,type:`function`}];function xe(e,t,n,r){return{address:e,abi:D,functionName:`delegateForUserDecryption`,args:[t,n,r]}}function Se(e,t,n){return{address:e,abi:D,functionName:`revokeDelegationForUserDecryption`,args:[t,n]}}function O(e,t,n,r){return{address:e,abi:D,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function Ce(e,t,n,r,i){return{address:e,abi:D,functionName:`isHandleDelegatedForUserDecryption`,args:[t,n,r,i]}}const k=2n**64n-1n,A={CredentialsLoading:`credentials:loading`,CredentialsCached:`credentials:cached`,CredentialsExpired:`credentials:expired`,CredentialsCreating:`credentials:creating`,CredentialsCreated:`credentials:created`,CredentialsRevoked:`credentials:revoked`,CredentialsPersistFailed:`credentials:persist_failed`,CredentialsAllowed:`credentials:allowed`,CredentialsCorrupted:`credentials:corrupted`,SessionExpired:`session:expired`,EncryptStart:`encrypt:start`,EncryptEnd:`encrypt:end`,EncryptError:`encrypt:error`,DecryptStart:`decrypt:start`,DecryptEnd:`decrypt:end`,DecryptError:`decrypt:error`,TransactionError:`transaction:error`,ShieldSubmitted:`shield:submitted`,TransferSubmitted:`transfer:submitted`,TransferFromSubmitted:`transferFrom:submitted`,ApproveSubmitted:`approve:submitted`,ApproveUnderlyingSubmitted:`approveUnderlying:submitted`,UnwrapSubmitted:`unwrap:submitted`,FinalizeUnwrapSubmitted:`finalizeUnwrap:submitted`,DelegationSubmitted:`delegation:submitted`,RevokeDelegationSubmitted:`revokeDelegation:submitted`,UnshieldPhase1Submitted:`unshield:phase1_submitted`,UnshieldPhase2Started:`unshield:phase2_started`,UnshieldPhase2Submitted:`unshield:phase2_submitted`};var we=class{#e=null;#t=null;clearCache(){this.#e=null,this.#t=null}async encrypt(e,t,n){let r=await this.#n(t,n),i=crypto.getRandomValues(new Uint8Array(12)),a=new TextEncoder,o=await crypto.subtle.encrypt({name:`AES-GCM`,iv:i},r,a.encode(e));return{iv:btoa(String.fromCharCode(...i)),ciphertext:btoa(String.fromCharCode(...new Uint8Array(o)))}}async decrypt(e,t,n){let r=await this.#n(t,n),i=Uint8Array.from(atob(e.iv),e=>e.charCodeAt(0)),a=Uint8Array.from(atob(e.ciphertext),e=>e.charCodeAt(0)),o=await crypto.subtle.decrypt({name:`AES-GCM`,iv:i},r,a);return d(new TextDecoder().decode(o))}async#n(e,t){let n=`${e}:${t}`;if(this.#e&&this.#t===n)return this.#e;let r=new TextEncoder,i=await crypto.subtle.importKey(`raw`,r.encode(e),`PBKDF2`,!1,[`deriveKey`]),a=await crypto.subtle.deriveKey({name:`PBKDF2`,salt:r.encode(t),iterations:6e5,hash:`SHA-256`},i,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`]);return this.#t=n,this.#e=a,a}};function j(e){a(e,`Stored credentials`),s(e.publicKey,`credentials.publicKey`),c(e.contractAddresses,`credentials.contractAddresses`);for(let t of e.contractAddresses)o(typeof t==`string`&&y(t,{strict:!1}),`Expected each contractAddress to be a valid hex address`);a(e.encryptedPrivateKey,`credentials.encryptedPrivateKey`),s(e.encryptedPrivateKey.iv,`encryptedPrivateKey.iv`),s(e.encryptedPrivateKey.ciphertext,`encryptedPrivateKey.ciphertext`),o(typeof e.startTimestamp==`number`,`Expected credentials.startTimestamp to be a number`),o(typeof e.durationDays==`number`,`Expected credentials.durationDays to be a number`)}function Te(e){j(e);let t=e;o(typeof t.delegatorAddress==`string`&&y(t.delegatorAddress,{strict:!1}),`Expected credentials.delegatorAddress to be a valid address`),o(typeof t.delegateAddress==`string`&&y(t.delegateAddress,{strict:!1}),`Expected credentials.delegateAddress to be a valid address`),o(typeof t.startTimestamp==`number`,`Expected startTimestamp to be a number`),o(typeof t.durationDays==`number`,`Expected durationDays to be a number`)}function M(e){return Math.floor(Date.now()/1e3)<e.startTimestamp+e.durationDays*86400}function N(e,t){let n=new Set(t.map(e=>v(e))),r=new Set(e.map(e=>v(e)));return n.isSubsetOf(r)}function Ee(e,t){return M(e)?N(e.contractAddresses,t):!1}function P(e){return[...new Set(e.map(e=>v(e)))].toSorted()}async function De(...e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e.map(String).join(`:`)));return Array.from(new Uint8Array(t)).map(e=>e.toString(16).padStart(2,`0`)).join(``).slice(0,32)}var Oe=class{#e;constructor(e){this.#e=e}#t(e){a(e,`Session entry`),s(e.signature,`session.signature`),o(typeof e.createdAt==`number`,`Expected session.createdAt to be a number`),o(typeof e.ttl==`number`||e.ttl===`infinite`,`Expected session.ttl to be a number or "infinite"`)}async get(e){let t=await this.#e.get(e);return t===null?null:(this.#t(t),t)}async set(e){let t={signature:e.signature,createdAt:Math.floor(Date.now()/1e3),ttl:e.ttl};await this.#e.set(e.key,t)}async delete(e){await this.#e.delete(e)}isExpired(e){return e.ttl===`infinite`?!1:e.ttl===0?!0:Math.floor(Date.now()/1e3)-e.createdAt>=e.ttl}},ke=class{signer;storage;sessionSignatures;crypto;keypairTTL;sessionTTL;#e;#t=null;#n=null;#r=null;constructor(e){if(this.signer=e.signer,this.storage=e.storage,this.sessionSignatures=new Oe(e.sessionStorage),this.crypto=new we,this.keypairTTL=e.keypairTTL??2592e3,this.sessionTTL=e.sessionTTL??2592e3,this.#e=e.onEvent??(()=>{}),typeof this.keypairTTL==`number`&&this.keypairTTL<0)throw Error(`keypairTTL must be >= 0`);if(typeof this.sessionTTL==`number`&&this.sessionTTL<0)throw Error(`sessionTTL must be >= 0`);typeof this.sessionTTL==`number`&&this.sessionTTL>this.keypairTTL&&(this.sessionTTL=this.keypairTTL,console.warn(`[zama-sdk] sessionTTL was clamped to keypairTTL (${this.keypairTTL}s). A session that outlives the keypair causes isAllowed() to return true after the keypair expires, leading to unexpected wallet prompts.`))}emit(e){this.#e({...e,timestamp:Date.now()})}async resolveCredentials({key:e,contracts:t,createKey:r,createFn:i}){this.emit({type:A.CredentialsLoading,contractAddresses:t});try{let n=await this.storage.get(e);if(n){this.assertEncrypted(n);let r=await this.sessionSignatures.get(e);if(r)if(this.sessionSignatures.isExpired(r))await this.sessionSignatures.delete(e),this.emit({type:A.SessionExpired,reason:`ttl`});else{let i=await this.decryptCredentials(n,r.signature);if(Ee(i,t))return this.emit({type:A.CredentialsCached,contractAddresses:t}),this.emit({type:A.CredentialsAllowed,contractAddresses:t}),i;if(M(i))return this.#i({key:e,credentials:i,requiredContracts:t});this.emit({type:A.CredentialsExpired,contractAddresses:t})}if(M(n)){if(N(n.contractAddresses,t)){let r=await this.signForContracts(n,n.contractAddresses);await this.sessionSignatures.set({key:e,signature:r,ttl:this.sessionTTL});let i=await this.decryptCredentials(n,r);return this.emit({type:A.CredentialsCached,contractAddresses:t}),this.emit({type:A.CredentialsAllowed,contractAddresses:t}),i}let r=await this.signForContracts(n,n.contractAddresses),i=await this.decryptCredentials(n,r);return this.#i({key:e,credentials:i,requiredContracts:t})}this.emit({type:A.CredentialsExpired,contractAddresses:t})}}catch(t){if(t instanceof n)throw t;console.warn(`[zama-sdk] Credential resolution failed, recreating:`,t),this.emit({type:A.CredentialsCorrupted,error:l(t)}),await this.#o(e)}return(!this.#t||this.#n!==r)&&(this.#n=r,this.#t=i().then(e=>(this.emit({type:A.CredentialsAllowed,contractAddresses:t}),e)).finally(()=>{this.#t=null,this.#n=null})),this.#t}async checkExpired(e,t){try{let n=await this.storage.get(e);return n?(this.assertEncrypted(n),!Ee(n,t?[t]:[])):!1}catch(e){return console.warn(`[zama-sdk] isExpired check failed, treating as expired:`,e),!0}}async revokeSession(e,t){await this.sessionSignatures.delete(e),this.clearCaches(),this.emit({type:A.CredentialsRevoked,...t?{contractAddresses:t}:{}})}async checkAllowed(e){let t=await this.sessionSignatures.get(e);return t===null?!1:!this.sessionSignatures.isExpired(t)}async clearAll(e){await this.sessionSignatures.delete(e),this.clearCaches(),await this.#o(e)}clearCaches(){this.crypto.clearCache()}async createCredentials({key:e,contractAddresses:t,createFn:r,errorContext:i}){this.emit({type:A.CredentialsCreating,contractAddresses:t});try{let n=await r();return await this.persistCredentials(e,n),await this.sessionSignatures.set({key:e,signature:n.signature,ttl:this.sessionTTL}),this.emit({type:A.CredentialsCreated,contractAddresses:t}),n}catch(e){if(e instanceof n)throw e;ee(e,i)}}async#i({key:e,credentials:t,requiredContracts:n}){if(this.#r){let e=await this.#r;if(N(e.contractAddresses,n))return this.emit({type:A.CredentialsAllowed,contractAddresses:n}),e;t=e}let r=this.#a({key:e,credentials:t,requiredContracts:n});this.#r=r;try{return await r}finally{this.#r===r&&(this.#r=null)}}async#a({key:e,credentials:t,requiredContracts:n}){let r=P([...t.contractAddresses,...n]),i=await this.signForContracts(t,r),a={...t,contractAddresses:r,signature:i};return await this.persistCredentials(e,a),await this.sessionSignatures.set({key:e,signature:i,ttl:this.sessionTTL}),this.emit({type:A.CredentialsAllowed,contractAddresses:n}),a}async persistCredentials(e,t){try{let n=await this.encryptCredentials(t);await this.storage.set(e,n)}catch(e){console.warn(`[zama-sdk] Failed to encrypt credentials for persistence:`,e),this.emit({type:A.CredentialsPersistFailed,error:l(e)})}}async#o(e){try{await this.storage.delete(e)}catch(e){console.warn(`[zama-sdk] Failed to delete credentials:`,e),this.emit({type:A.CredentialsPersistFailed,error:l(e)})}}};function Ae(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`runtime`);return typeof t!=`object`||!t?!1:typeof Reflect.get(t,`id`)==`string`}var je=class e extends ke{#e;#t=null;#n=null;static async computeStoreKey(e,t){return De(v(e),t)}constructor(e){super(e),this.#e=e.relayer,Ae(typeof globalThis<`u`?Reflect.get(globalThis,`chrome`):void 0)&&e.sessionStorage instanceof u&&console.warn(`[zama-sdk] Detected Chrome extension context with in-memory session storage. Session signatures will be lost on service worker restart and won't be shared across contexts. Consider using chromeSessionStorage instead. `)}async allow(...e){let t=P(e),n=await this.#r();return this.resolveCredentials({key:n,contracts:t,createKey:t.join(`,`),createFn:()=>this.create(t)})}async isExpired(e){return this.checkExpired(await this.#r(),e)}async revoke(...e){await this.revokeSession(await this.#r(),e.length>0?e:void 0)}async revokeByKey(e){await this.revokeSession(e)}async isAllowed(){return this.checkAllowed(await this.#r())}async clear(){await this.clearAll(await this.#r())}async create(e){let t=P(e),n=await this.#r();return this.createCredentials({key:n,contractAddresses:t,createFn:async()=>{let e=await this.#e.generateKeypair(),n=Math.floor(Date.now()/1e3),r=Math.ceil(this.keypairTTL/86400),i=await this.#e.createEIP712(e.publicKey,t,n,r),a=await this.signer.signTypedData(i);return{publicKey:e.publicKey,privateKey:e.privateKey,signature:a,contractAddresses:t,startTimestamp:n,durationDays:r}},errorContext:`Failed to create decrypt credentials`})}assertEncrypted(e){j(e)}async signForContracts(e,t){let n=await this.#e.createEIP712(e.publicKey,t,e.startTimestamp,e.durationDays);return this.signer.signTypedData(n)}async encryptCredentials(e){let t=await this.signer.getAddress(),n=await this.crypto.encrypt(e.privateKey,e.signature,t),{privateKey:r,signature:i,...a}=e;return{...a,encryptedPrivateKey:n}}async decryptCredentials(e,t){let n=await this.signer.getAddress(),r=await this.crypto.decrypt(e.encryptedPrivateKey,t,n),{encryptedPrivateKey:i,...a}=e;return{...a,privateKey:r,signature:t}}clearCaches(){this.#t=null,this.#n=null,super.clearCaches()}async#r(){let t=await this.signer.getAddress(),n=await this.signer.getChainId(),r=`${v(t)}:${n}`;if(this.#t&&this.#n===r)return this.#t;let i=await e.computeStoreKey(t,n);return this.#n=r,this.#t=i,i}},Me=class e extends ke{#e;#t=null;#n=null;static async computeStoreKey(e,t,n){return De(v(e),v(t),n)}constructor(e){super(e),this.#e=e.relayer}async allow(e,...t){let n=v(e),r=P(t),i=await this.#i(n);return this.resolveCredentials({key:i,contracts:r,createKey:`${n}:${r.join(`,`)}`,createFn:()=>this.#r(n,r)})}async isExpired(e,t){return this.checkExpired(await this.#i(v(e)),t)}async revoke(e){await this.revokeSession(await this.#i(v(e)))}async isAllowed(e){return this.checkAllowed(await this.#i(v(e)))}async clear(e){await this.clearAll(await this.#i(v(e)))}async#r(e,t){let n=await this.#i(e);return this.createCredentials({key:n,contractAddresses:t,createFn:async()=>{let n=await this.#e.generateKeypair(),r=await this.signer.getAddress(),i=Math.floor(Date.now()/1e3),a=Math.ceil(this.keypairTTL/86400),o={publicKey:n.publicKey,startTimestamp:i,durationDays:a,delegatorAddress:e},s=await this.#a(o,t);return{publicKey:n.publicKey,privateKey:n.privateKey,signature:s,contractAddresses:t,startTimestamp:i,durationDays:a,delegatorAddress:e,delegateAddress:r}},errorContext:`Failed to create delegated decrypt credentials`})}assertEncrypted(e){Te(e)}async signForContracts(e,t){return this.#a(e,t)}async encryptCredentials(e){let t=await this.signer.getAddress(),n=await this.crypto.encrypt(e.privateKey,e.signature,t),{privateKey:r,signature:i,...a}=e;return{...a,encryptedPrivateKey:n}}async decryptCredentials(e,t){let n=await this.signer.getAddress(),r=await this.crypto.decrypt(e.encryptedPrivateKey,t,n),{encryptedPrivateKey:i,...a}=e;return{...a,privateKey:r,signature:t}}clearCaches(){this.#t=null,this.#n=null,super.clearCaches()}async#i(t){let n=await this.signer.getAddress(),r=await this.signer.getChainId(),i=`${v(n)}:${v(t)}:${r}`;if(this.#t&&this.#n===i)return this.#t;let a=await e.computeStoreKey(n,t,r);return this.#n=i,this.#t=a,a}async#a(e,t){let n=await this.#e.createDelegatedUserDecryptEIP712(e.publicKey,t,e.delegatorAddress,e.startTimestamp,e.durationDays);return this.signer.signTypedData({domain:{...n.domain,chainId:Number(n.domain.chainId)},types:n.types,message:{...n.message,startTimestamp:BigInt(n.message.startTimestamp),durationDays:BigInt(n.message.durationDays)}})}};const Ne=`zama:balances`;function Pe(e,t,n){return`zama:balance:${v(e)}:${v(t)}:${n.toLowerCase()}`}async function F({storage:e,tokenAddress:t,owner:n,handle:r}){try{let i=await e.get(Pe(t,n,r));return i===null?null:BigInt(i)}catch(e){return console.warn(`[zama-sdk] Balance cache read failed:`,e),null}}async function I(e){let{storage:t,tokenAddress:n,owner:r,handle:i,value:a}=e,o=Pe(n,r,i);try{await t.set(o,a.toString()),await Ie(t,o)}catch{}}const Fe=new WeakMap;async function Ie(e,t){let n=(Fe.get(e)??Promise.resolve()).then(async()=>{let n=await e.get(Ne),r=n?JSON.parse(n):[];r.includes(t)||(r.push(t),await e.set(Ne,JSON.stringify(r)))});return Fe.set(e,n.catch(()=>{})),n}async function Le(e,t=1/0){if(Number.isFinite(t)&&t<=0)throw Error(`maxConcurrency must be a positive number`);if(!Number.isFinite(t)||t>=e.length)return Promise.all(e.map(e=>e()));let n=Array.from({length:e.length}),r=0;async function i(){for(;r<e.length;){let t=r++;e[t]&&(n[t]=await e[t]())}}return await Promise.all(Array.from({length:t},i)),n}const Re=`0x0000000000000000000000000000000000000000000000000000000000000000`;var ze=class e{credentials;delegatedCredentials;relayer;signer;address;storage;#e;constructor(e){let t={relayer:e.relayer,signer:e.signer,storage:e.storage,sessionStorage:e.sessionStorage,keypairTTL:e.keypairTTL??2592e3,sessionTTL:e.sessionTTL??2592e3,onEvent:e.onEvent};this.credentials=e.credentials??new je(t),this.delegatedCredentials=e.delegatedCredentials??new Me(t),this.relayer=e.relayer,this.signer=e.signer,this.address=v(e.address),this.storage=e.storage,this.#e=e.onEvent}emit(e){this.#e?.({...e,tokenAddress:this.address,timestamp:Date.now()})}async balanceOf(e){let t=e?v(e):await this.signer.getAddress(),n=await this.readConfidentialBalanceOf(t);return this.decryptBalance(n,t)}async confidentialBalanceOf(e){let t=e?v(e):await this.signer.getAddress();return this.readConfidentialBalanceOf(t)}async isConfidential(){return await this.signer.readContract(m(this.address,p))}async isWrapper(){return await this.signer.readContract(m(this.address,h))}static async batchDecryptBalances(t,n){if(t.length===0)return new Map;let{handles:r,owner:i,onError:a,maxConcurrency:o}=n??{},s=t[0],c=e.assertSameRelayer(t),l=i??await s.signer.getAddress();return e.#t({tokens:t,handles:r,ownerAddress:l,onError:a,maxConcurrency:o,obtainCreds:e=>s.credentials.allow(...e),decrypt:(e,t,n)=>c.userDecrypt({handles:[t],contractAddress:n,signedContractAddresses:e.contractAddresses,privateKey:e.privateKey,publicKey:e.publicKey,signature:e.signature,signerAddress:l,startTimestamp:e.startTimestamp,durationDays:e.durationDays}),errorPrefix:`Batch decryption`})}static async batchDecryptBalancesAs(t,n){if(t.length===0)return new Map;let{delegatorAddress:r,handles:i,owner:a,onError:o,maxConcurrency:s}=n,c=a??r,l=t[0];return e.assertSameRelayer(t),e.#t({tokens:t,handles:i,ownerAddress:c,onError:o,maxConcurrency:s,preFlightCheck:()=>l.#n(r),obtainCreds:e=>l.delegatedCredentials.allow(r,...e),decrypt:(e,t,n)=>l.relayer.delegatedUserDecrypt({handles:[t],contractAddress:n,signedContractAddresses:e.contractAddresses,privateKey:e.privateKey,publicKey:e.publicKey,signature:e.signature,delegatorAddress:e.delegatorAddress,delegateAddress:e.delegateAddress,startTimestamp:e.startTimestamp,durationDays:e.durationDays}),errorPrefix:`Batch delegated decryption`})}static async#t(e){let{tokens:t,handles:n,ownerAddress:r,onError:a,maxConcurrency:o,obtainCreds:s,decrypt:c,errorPrefix:u}=e,d=t[0],f=n??await Promise.all(t.map(e=>e.readConfidentialBalanceOf(r)));if(t.length!==f.length)throw new i(`tokens.length (${t.length}) must equal handles.length (${f.length})`);let p=d.storage,m=new Map,h=[],g=await Promise.all(t.map((e,t)=>{let n=f[t];return e.isZeroHandle(n)?0n:F({storage:p,tokenAddress:e.address,owner:r,handle:n})}));for(let e=0;e<t.length;e++){let n=t[e],r=f[e],i=g[e];if(i!=null){m.set(n.address,i);continue}h.push({token:n,handle:r})}if(h.length===0)return m;e.preFlightCheck&&await e.preFlightCheck();let _=await s(h.map(e=>e.token.address)),v=[],y=[];for(let{token:e,handle:t}of h)y.push(()=>c(_,t,e.address).then(async n=>{let a=n[t];if(a===void 0)throw new i(`${u} returned no value for handle ${t} on token ${e.address}`);m.set(e.address,a);try{await I({storage:p,tokenAddress:e.address,owner:r,handle:t,value:a})}catch(e){console.warn(`[zama-sdk] Cache write failed (non-blocking):`,e)}}).catch(t=>{let n=l(t);if(a)try{m.set(e.address,a(n,e.address))}catch(t){v.push({address:e.address,error:l(t)})}else v.push({address:e.address,error:n})}));if(await Le(y,o),v.length>0){let e=v.map(e=>`${e.address}: ${e.error.message}`).join(`; `);throw new i(`${u} failed for ${v.length} token(s): ${e}`)}return m}async underlyingToken(){return this.signer.readContract(g(this.address))}async allowance(e,t){let n=v(e),r=await this.signer.readContract(g(n)),i=t?v(t):await this.signer.getAddress();return this.signer.readContract(he(r,i,n))}async name(){return this.signer.readContract(ue(this.address))}async symbol(){return this.signer.readContract(de(this.address))}async decimals(){return this.signer.readContract(fe(this.address))}async allow(){await this.credentials.allow(this.address)}async isAllowed(){return this.credentials.isAllowed()}async revoke(...e){await this.credentials.revoke(...e)}static async allow(...e){if(e.length===0)return;let t=e.map(e=>e.address);await e[0].credentials.allow(...t)}async getAclAddress(){return this.relayer.getAclAddress()}async isDelegated(e){let t=await this.getDelegationExpiry(e);return t===0n?!1:t===k?!0:t>await this.signer.getBlockTimestamp()}async getDelegationExpiry({delegatorAddress:e,delegateAddress:t}){let n=await this.getAclAddress();return this.signer.readContract(O(n,v(e),v(t),this.address))}async#n(e){let t=await this.signer.getAddress(),n=await this.getDelegationExpiry({delegatorAddress:e,delegateAddress:t});if(n===0n)throw new C(`No active delegation from ${e} to ${t} for ${this.address}`);if(n!==k&&n<=await this.signer.getBlockTimestamp())throw new w(`Delegation from ${e} to ${t} for ${this.address} has expired`)}async readConfidentialBalanceOf(e){return await this.signer.readContract(f(this.address,e))}isZeroHandle(e){return e===`0x0000000000000000000000000000000000000000000000000000000000000000`||e===`0x`}async decryptBalanceAs({delegatorAddress:e,owner:t}){let n=v(e),r=t?v(t):n,a=await this.readConfidentialBalanceOf(r);if(this.isZeroHandle(a))return 0n;let o=await F({storage:this.storage,tokenAddress:this.address,owner:r,handle:a});if(o!==null)return o;await this.#n(n);let s=Date.now();try{this.emit({type:A.DecryptStart});let e=await this.delegatedCredentials.allow(n,this.address),t=await this.relayer.delegatedUserDecrypt({handles:[a],contractAddress:this.address,signedContractAddresses:e.contractAddresses,privateKey:e.privateKey,publicKey:e.publicKey,signature:e.signature,delegatorAddress:e.delegatorAddress,delegateAddress:e.delegateAddress,startTimestamp:e.startTimestamp,durationDays:e.durationDays});this.emit({type:A.DecryptEnd,durationMs:Date.now()-s});let o=t[a];if(o===void 0)throw new i(`Delegated decryption returned no value for handle ${a}`);try{await I({storage:this.storage,tokenAddress:this.address,owner:r,handle:a,value:o})}catch(e){console.warn(`[zama-sdk] Cache write failed (non-blocking):`,e)}return o}catch(e){throw this.emit({type:A.DecryptError,error:l(e),durationMs:Date.now()-s}),L(e,`Failed to decrypt delegated balance`,!0)}}async decryptBalance(e,t){if(this.isZeroHandle(e))return 0n;let n=t??await this.signer.getAddress(),r=await F({storage:this.storage,tokenAddress:this.address,owner:n,handle:e});if(r!==null)return r;let a=await this.credentials.allow(this.address),o=Date.now();try{this.emit({type:A.DecryptStart});let t=await this.relayer.userDecrypt({handles:[e],contractAddress:this.address,signedContractAddresses:a.contractAddresses,privateKey:a.privateKey,publicKey:a.publicKey,signature:a.signature,signerAddress:n,startTimestamp:a.startTimestamp,durationDays:a.durationDays});this.emit({type:A.DecryptEnd,durationMs:Date.now()-o});let r=t[e];if(r===void 0)throw new i(`Decryption returned no value for handle ${e}`);try{await I({storage:this.storage,tokenAddress:this.address,owner:n,handle:e,value:r})}catch(e){console.warn(`[zama-sdk] Cache write failed (non-blocking):`,e)}return r}catch(e){throw this.emit({type:A.DecryptError,error:l(e),durationMs:Date.now()-o}),L(e,`Failed to decrypt balance`)}}async decryptHandles(e,t){let n=new Map,r=[];for(let t of e)this.isZeroHandle(t)?n.set(t,0n):r.push(t);if(r.length===0)return n;let a=await this.credentials.allow(this.address),o=Date.now();try{this.emit({type:A.DecryptStart});let e=await this.relayer.userDecrypt({handles:r,contractAddress:this.address,signedContractAddresses:a.contractAddresses,privateKey:a.privateKey,publicKey:a.publicKey,signature:a.signature,signerAddress:t??await this.signer.getAddress(),startTimestamp:a.startTimestamp,durationDays:a.durationDays});this.emit({type:A.DecryptEnd,durationMs:Date.now()-o});for(let t of r){let r=e[t];if(r===void 0)throw new i(`Decryption returned no value for handle ${t}`);n.set(t,r)}}catch(e){throw this.emit({type:A.DecryptError,error:l(e),durationMs:Date.now()-o}),L(e,`Failed to decrypt handles`)}return n}static assertSameRelayer(e){let t=e[0].relayer;for(let n=1;n<e.length;n++)if(e[n].relayer!==t)throw new r(`All tokens in a batch operation must share the same relayer instance`);return t}};function L(e,n,r=!1){if(e instanceof i||e instanceof S||e instanceof t||e instanceof T||e instanceof b||e instanceof x)return e;let a=typeof e==`object`&&e&&`statusCode`in e&&typeof e.statusCode==`number`?e.statusCode:void 0;return a===400?new S(e instanceof Error?e.message:`No ciphertext for this account`,{cause:e}):r&&a===500?new T(`Delegated decryption failed with a server error. This is most commonly caused by the delegation not having propagated to the gateway yet — after granting delegation, allow 1–2 minutes for cross-chain synchronization before retrying. If the error persists, the gateway or relayer may be experiencing an unrelated issue.`,{cause:e}):a===void 0?new i(n,{cause:e}):new t(e instanceof Error?e.message:n,a,{cause:e})}const R={ConfidentialTransfer:`0x67500e8d0ed826d2194f514dd0d8124f35648ab6e3fb5e6ed867134cffe661e9`,Wrapped:`0x1f7907f4d84043abe0fb7c74e8865ee5fe93fe4f691c54a7b8fa9d6fb17c7cba`,UnwrapRequested:`0x77d02d353c5629272875d11f1b34ec4c65d7430b075575b78cd2502034c469ee`,UnwrappedFinalized:`0xc64e7c81b18b674fc5b037d8a0041bfe3332d86c780a4688f404ee01fbabb152`,UnwrappedStarted:`0x3838891d4843c6d7f9f494570b6fd8843f4e3c3ddb817c1411760bd31b819806`};function z(e){return v(d(e.slice(-40)))}function B(e){return BigInt(e)}function Be(e){return e}function V(e,t){let n=2+t*64,r=e.slice(n,n+64);return r.length===64?r:r.padEnd(64,`0`)}function H(e,t){return v(d(V(e,t).slice(-40)))}function U(e,t){return BigInt(`0x`+V(e,t))}function W(e,t){return BigInt(`0x`+V(e,t))!==0n}function G(e,t){return d(V(e,t))}function Ve(e){return e.topics[0]!==R.ConfidentialTransfer||e.topics.length<4?null:{eventName:`ConfidentialTransfer`,from:z(e.topics[1]),to:z(e.topics[2]),encryptedAmountHandle:Be(e.topics[3])}}function K(e){return e.topics[0]!==R.Wrapped||e.topics.length<3?null:{eventName:`Wrapped`,to:z(e.topics[1]),mintTxId:B(e.topics[2]),mintAmount:U(e.data,0),amountIn:U(e.data,1),feeAmount:U(e.data,2)}}function q(e){return e.topics[0]!==R.UnwrapRequested||e.topics.length<2?null:{eventName:`UnwrapRequested`,receiver:z(e.topics[1]),encryptedAmount:G(e.data,0)}}function He(e){return e.topics[0]!==R.UnwrappedFinalized||e.topics.length<3?null:{eventName:`UnwrappedFinalized`,burntAmountHandle:Be(e.topics[1]),nextTxId:B(e.topics[2]),finalizeSuccess:W(e.data,0),feeTransferSuccess:W(e.data,1),burnAmount:U(e.data,2),unwrapAmount:U(e.data,3),feeAmount:U(e.data,4)}}function Ue(e){return e.topics[0]!==R.UnwrappedStarted||e.topics.length<4?null:{eventName:`UnwrappedStarted`,requestId:B(e.topics[1]),txId:B(e.topics[2]),to:z(e.topics[3]),returnVal:W(e.data,0),refund:H(e.data,1),requestedAmount:G(e.data,2),burnAmount:G(e.data,3)}}function J(e){return Ve(e)??K(e)??q(e)??He(e)??Ue(e)}function We(e){let t=[];for(let n of e){let e=J(n);e&&t.push(e)}return t}function Ge(e){for(let t of e){let e=q(t);if(e)return e}return null}function Ke(e){for(let t of e){let e=K(t);if(e)return e}return null}const qe=[R.ConfidentialTransfer,R.Wrapped,R.UnwrapRequested,R.UnwrappedFinalized,R.UnwrappedStarted],Y={DelegatedForUserDecryption:`0x527b025d7ff06689c1ab9d32dfd7881c964cce72ce8ac5b2fe1d3be8cfda5bfc`,RevokedDelegationForUserDecryption:`0x7aca80b6b7928b9038f186e3d9922a0fc5d52c398fbf144725c142c52a5277e4`};function X(e){return e.topics[0]!==Y.DelegatedForUserDecryption||e.topics.length<3?null:{eventName:`DelegatedForUserDecryption`,delegator:z(e.topics[1]),delegate:z(e.topics[2]),contractAddress:H(e.data,0),delegationCounter:U(e.data,1),oldExpirationDate:U(e.data,2),newExpirationDate:U(e.data,3)}}function Z(e){return e.topics[0]!==Y.RevokedDelegationForUserDecryption||e.topics.length<3?null:{eventName:`RevokedDelegationForUserDecryption`,delegator:z(e.topics[1]),delegate:z(e.topics[2]),contractAddress:H(e.data,0),delegationCounter:U(e.data,1),oldExpirationDate:U(e.data,2)}}function Je(e){return X(e)??Z(e)}function Ye(e){let t=[];for(let n of e){let e=Je(n);e&&t.push(e)}return t}function Xe(e){for(let t of e){let e=X(t);if(e)return e}return null}function Ze(e){for(let t of e){let e=Z(t);if(e)return e}return null}const Qe=[Y.DelegatedForUserDecryption,Y.RevokedDelegationForUserDecryption];function Q(e,t){return e.toLowerCase()===t.toLowerCase()}function $(e,t,n){let r=t!==void 0&&Q(e,t),i=n!==void 0&&Q(e,n);return r&&i?`self`:r?`outgoing`:`incoming`}function $e(e,t,n){switch(e.eventName){case`ConfidentialTransfer`:return et(e,t,n);case`Wrapped`:return tt(e,t,n);case`UnwrapRequested`:return nt(e,t,n);case`UnwrappedStarted`:return rt(e,t,n);case`UnwrappedFinalized`:return it(e,n)}}function et(e,t,n){return{type:`transfer`,direction:$(t,e.from,e.to),amount:{type:`encrypted`,handle:e.encryptedAmountHandle},from:e.from,to:e.to,metadata:n,rawEvent:e}}function tt(e,t,n){return{type:`shield`,direction:$(t,void 0,e.to),amount:{type:`clear`,value:e.amountIn},to:e.to,fee:e.feeAmount,metadata:n,rawEvent:e}}function nt(e,t,n){return{type:`unshield_requested`,direction:$(t,void 0,e.receiver),amount:{type:`encrypted`,handle:e.encryptedAmount},to:e.receiver,metadata:n,rawEvent:e}}function rt(e,t,n){return{type:`unshield_started`,direction:$(t,void 0,e.to),amount:{type:`encrypted`,handle:e.requestedAmount},to:e.to,success:e.returnVal,metadata:n,rawEvent:e}}function it(e,t){return{type:`unshield_finalized`,direction:`incoming`,amount:{type:`clear`,value:e.unwrapAmount},fee:e.feeAmount,success:e.finalizeSuccess,metadata:t,rawEvent:e}}function at(e,t){let n=[];for(let r of e){let e=J(r);if(!e)continue;let i={transactionHash:r.transactionHash,blockNumber:r.blockNumber,logIndex:r.logIndex};n.push($e(e,t,i))}return n}function ot(e){let t=new Set;for(let n of e)if(n.amount.type===`encrypted`&&n.amount.decryptedValue===void 0){let e=n.amount.handle;e!==`0x`&&e!==`0x0000000000000000000000000000000000000000000000000000000000000000`&&t.add(e)}return[...t]}function st(e,t){return e.map(e=>{if(e.amount.type!==`encrypted`)return e;let n=t.get(e.amount.handle);return n===void 0?e:{...e,amount:{type:`encrypted`,handle:e.amount.handle,decryptedValue:n}}})}function ct(e){return[...e].toSorted((e,t)=>{let n=e.metadata.blockNumber,r=t.metadata.blockNumber;if(n===void 0&&r===void 0)return 0;if(n===void 0)return-1;if(r===void 0)return 1;let i=typeof n==`bigint`?n:BigInt(n),a=typeof r==`bigint`?r:BigInt(r);if(a>i)return 1;if(a<i)return-1;let o=e.metadata.logIndex??0;return(t.metadata.logIndex??0)-o})}export{T as $,xe as A,me as B,Ke as C,je as D,Me as E,be as F,ce as G,pe as H,ve as I,oe as J,se as K,_e as L,Ce as M,Se as N,A as O,ye as P,C as Q,he as R,Ge as S,Re as T,ue as U,fe as V,de as W,w as X,le as Y,ae as Z,He as _,Qe as a,b as at,Xe as b,R as c,Ve as d,re as et,X as f,q as g,Z as h,ct as i,x as it,O as j,k,Je as l,We as m,ot as n,te as nt,Y as o,J as p,ie as q,at as r,S as rt,qe as s,st as t,ne as tt,Ye as u,Ue as v,ze as w,Ze as x,K as y,ge as z};
|
|
2
|
-
//# sourceMappingURL=activity-
|
|
1
|
+
import{i as e,n as t,r as n,t as r}from"./relayer-C6u3eOlN.js";import{t as i}from"./encryption-CmIPBcfP.js";import{a,n as o,o as s,t as c}from"./assertions-Dty7Quc0.js";import{i as l,t as u}from"./memory-storage-B4_heQa5.js";import{t as d}from"./hex-CgAj4TLu.js";import{_ as f,c as p,f as m,l as h,m as g}from"./wrappers-registry-DqPr_JG2.js";import{erc20Abi as _,getAddress as v,isAddress as y}from"viem";var b=class extends n{constructor(t,n){super(e.SigningRejected,t,n),this.name=`SigningRejectedError`}},x=class extends n{constructor(t,n){super(e.SigningFailed,t,n),this.name=`SigningFailedError`}};function ee(e,t){let n=typeof e==`object`&&!!e&&`code`in e&&e.code===4001,r=e instanceof Error?e.message:String(e),i=r.toLowerCase(),a=i.includes(`user rejected`)||i.includes(`user denied`),o=`${t}: ${r}`;throw n||a?new b(o,{cause:e}):new x(o,{cause:e})}var te=class extends n{constructor(t,n){super(e.KeypairExpired,t,n),this.name=`KeypairExpiredError`}},ne=class extends n{constructor(t,n){super(e.InvalidKeypair,t,n),this.name=`InvalidKeypairError`}},S=class extends n{constructor(t,n){super(e.NoCiphertext,t,n),this.name=`NoCiphertextError`}},re=class extends n{constructor(t,n){super(e.DelegationSelfNotAllowed,t,n),this.name=`DelegationSelfNotAllowedError`}},ie=class extends n{constructor(t,n){super(e.DelegationCooldown,t,n),this.name=`DelegationCooldownError`}},C=class extends n{constructor(t,n){super(e.DelegationNotFound,t,n),this.name=`DelegationNotFoundError`}},w=class extends n{constructor(t,n){super(e.DelegationExpired,t,n),this.name=`DelegationExpiredError`}},ae=class extends n{constructor(t,n){super(e.DelegationExpiryUnchanged,t,n),this.name=`DelegationExpiryUnchangedError`}},oe=class extends n{constructor(t,n){super(e.DelegationDelegateEqualsContract,t,n),this.name=`DelegationDelegateEqualsContractError`}},se=class extends n{constructor(t,n){super(e.DelegationContractIsSelf,t,n),this.name=`DelegationContractIsSelfError`}},ce=class extends n{constructor(t,n){super(e.AclPaused,t,n),this.name=`AclPausedError`}},le=class extends n{constructor(t,n){super(e.DelegationExpirationTooSoon,t,n),this.name=`DelegationExpirationTooSoonError`}},T=class extends n{constructor(t,n){super(e.DelegationNotPropagated,t,n),this.name=`DelegationNotPropagatedError`}};function ue(e){return{address:e,abi:_,functionName:`name`,args:[]}}function de(e){return{address:e,abi:_,functionName:`symbol`,args:[]}}function fe(e){return{address:e,abi:_,functionName:`decimals`,args:[]}}function pe(e){return{address:e,abi:_,functionName:`totalSupply`,args:[]}}function me(e,t){return{address:e,abi:_,functionName:`balanceOf`,args:[t]}}function he(e,t,n){return{address:e,abi:_,functionName:`allowance`,args:[t,n]}}function ge(e,t,n){return{address:e,abi:_,functionName:`approve`,args:[t,n]}}const E=[{inputs:[{internalType:`uint64`,name:`wrapFeeBasisPoints_`,type:`uint64`},{internalType:`uint64`,name:`unwrapFeeBasisPoints_`,type:`uint64`},{internalType:`uint64`,name:`deployFee_`,type:`uint64`},{internalType:`uint64`,name:`batchTransferFee_`,type:`uint64`},{internalType:`address`,name:`feeRecipient_`,type:`address`}],stateMutability:`nonpayable`,type:`constructor`},{inputs:[],name:`AccessControlBadConfirmation`,type:`error`},{inputs:[{internalType:`address`,name:`account`,type:`address`},{internalType:`bytes32`,name:`neededRole`,type:`bytes32`}],name:`AccessControlUnauthorizedAccount`,type:`error`},{inputs:[],name:`FeeExceedsMaximum`,type:`error`},{inputs:[],name:`ZeroAddressFeeRecipient`,type:`error`},{anonymous:!1,inputs:[{indexed:!1,internalType:`uint64`,name:`oldBatchTransferFee`,type:`uint64`},{indexed:!1,internalType:`uint64`,name:`newBatchTransferFee`,type:`uint64`}],name:`BatchTransferFeeUpdated`,type:`event`},{anonymous:!1,inputs:[{indexed:!1,internalType:`uint64`,name:`oldDeployFee`,type:`uint64`},{indexed:!1,internalType:`uint64`,name:`newDeployFee`,type:`uint64`}],name:`DeployFeeUpdated`,type:`event`},{anonymous:!1,inputs:[{indexed:!0,internalType:`address`,name:`oldRecipient`,type:`address`},{indexed:!0,internalType:`address`,name:`newRecipient`,type:`address`}],name:`FeeRecipientUpdated`,type:`event`},{anonymous:!1,inputs:[{indexed:!0,internalType:`bytes32`,name:`role`,type:`bytes32`},{indexed:!0,internalType:`bytes32`,name:`previousAdminRole`,type:`bytes32`},{indexed:!0,internalType:`bytes32`,name:`newAdminRole`,type:`bytes32`}],name:`RoleAdminChanged`,type:`event`},{anonymous:!1,inputs:[{indexed:!0,internalType:`bytes32`,name:`role`,type:`bytes32`},{indexed:!0,internalType:`address`,name:`account`,type:`address`},{indexed:!0,internalType:`address`,name:`sender`,type:`address`}],name:`RoleGranted`,type:`event`},{anonymous:!1,inputs:[{indexed:!0,internalType:`bytes32`,name:`role`,type:`bytes32`},{indexed:!0,internalType:`address`,name:`account`,type:`address`},{indexed:!0,internalType:`address`,name:`sender`,type:`address`}],name:`RoleRevoked`,type:`event`},{anonymous:!1,inputs:[{indexed:!1,internalType:`bool`,name:`active`,type:`bool`}],name:`SwapperFeeWaiverUpdated`,type:`event`},{anonymous:!1,inputs:[{indexed:!1,internalType:`uint64`,name:`oldFeeBasisPoints`,type:`uint64`},{indexed:!1,internalType:`uint64`,name:`newFeeBasisPoints`,type:`uint64`}],name:`UnwrapFeeBasisPointsUpdated`,type:`event`},{anonymous:!1,inputs:[{indexed:!1,internalType:`uint64`,name:`oldFeeBasisPoints`,type:`uint64`},{indexed:!1,internalType:`uint64`,name:`newFeeBasisPoints`,type:`uint64`}],name:`WrapFeeBasisPointsUpdated`,type:`event`},{inputs:[],name:`DEFAULT_ADMIN_ROLE`,outputs:[{internalType:`bytes32`,name:``,type:`bytes32`}],stateMutability:`view`,type:`function`},{inputs:[],name:`FEE_MANAGER_ROLE`,outputs:[{internalType:`bytes32`,name:``,type:`bytes32`}],stateMutability:`view`,type:`function`},{inputs:[],name:`MAX_BASIS_POINTS`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`},{inputs:[],name:`SWAPPER_ROLE`,outputs:[{internalType:`bytes32`,name:``,type:`bytes32`}],stateMutability:`view`,type:`function`},{inputs:[],name:`batchTransferFee`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`},{inputs:[],name:`deployFee`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`},{inputs:[],name:`feeRecipient`,outputs:[{internalType:`address`,name:``,type:`address`}],stateMutability:`view`,type:`function`},{inputs:[],name:`getBatchTransferFee`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`address`,name:`deployer`,type:`address`}],name:`getDeployFee`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`},{inputs:[],name:`getFeeRecipient`,outputs:[{internalType:`address`,name:``,type:`address`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`bytes32`,name:`role`,type:`bytes32`}],name:`getRoleAdmin`,outputs:[{internalType:`bytes32`,name:``,type:`bytes32`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`uint64`,name:`amount`,type:`uint64`},{internalType:`address`,name:`unwrapFrom`,type:`address`},{internalType:`address`,name:`unwrapTo`,type:`address`}],name:`getUnwrapFee`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`uint256`,name:`amount`,type:`uint256`},{internalType:`address`,name:`wrapFrom`,type:`address`},{internalType:`address`,name:`wrapTo`,type:`address`}],name:`getWrapFee`,outputs:[{internalType:`uint256`,name:``,type:`uint256`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`bytes32`,name:`role`,type:`bytes32`},{internalType:`address`,name:`account`,type:`address`}],name:`grantRole`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`bytes32`,name:`role`,type:`bytes32`},{internalType:`address`,name:`account`,type:`address`}],name:`hasRole`,outputs:[{internalType:`bool`,name:``,type:`bool`}],stateMutability:`view`,type:`function`},{inputs:[],name:`protocolId`,outputs:[{internalType:`uint256`,name:``,type:`uint256`}],stateMutability:`pure`,type:`function`},{inputs:[{internalType:`bytes32`,name:`role`,type:`bytes32`},{internalType:`address`,name:`callerConfirmation`,type:`address`}],name:`renounceRole`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`bytes32`,name:`role`,type:`bytes32`},{internalType:`address`,name:`account`,type:`address`}],name:`revokeRole`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`uint64`,name:`newBatchTransferFee`,type:`uint64`}],name:`setBatchTransferFee`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`uint64`,name:`newDeployFee`,type:`uint64`}],name:`setDeployFee`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`address`,name:`recipient`,type:`address`}],name:`setFeeRecipient`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`bool`,name:`active`,type:`bool`}],name:`setSwapperFeeWaiverActive`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`uint64`,name:`feeBasisPoints`,type:`uint64`}],name:`setUnwrapFeeBasisPoints`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`uint64`,name:`feeBasisPoints`,type:`uint64`}],name:`setWrapFeeBasisPoints`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`bytes4`,name:`interfaceId`,type:`bytes4`}],name:`supportsInterface`,outputs:[{internalType:`bool`,name:``,type:`bool`}],stateMutability:`view`,type:`function`},{inputs:[],name:`swapperFeeWaiverActive`,outputs:[{internalType:`bool`,name:``,type:`bool`}],stateMutability:`view`,type:`function`},{inputs:[],name:`unwrapFeeBasisPoints`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`},{inputs:[],name:`wrapFeeBasisPoints`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`}];function _e(e,t,n,r){return{address:e,abi:E,functionName:`getWrapFee`,args:[t,n,r]}}function ve(e,t,n,r){return{address:e,abi:E,functionName:`getUnwrapFee`,args:[t,n,r]}}function ye(e){return{address:e,abi:E,functionName:`getBatchTransferFee`,args:[]}}function be(e){return{address:e,abi:E,functionName:`getFeeRecipient`,args:[]}}const D=[{inputs:[{internalType:`address`,name:`delegate`,type:`address`},{internalType:`address`,name:`contractAddress`,type:`address`},{internalType:`uint64`,name:`expirationDate`,type:`uint64`}],name:`delegateForUserDecryption`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`address`,name:`delegate`,type:`address`},{internalType:`address`,name:`contractAddress`,type:`address`}],name:`revokeDelegationForUserDecryption`,outputs:[],stateMutability:`nonpayable`,type:`function`},{inputs:[{internalType:`address`,name:`delegator`,type:`address`},{internalType:`address`,name:`delegate`,type:`address`},{internalType:`address`,name:`contractAddress`,type:`address`}],name:`getUserDecryptionDelegationExpirationDate`,outputs:[{internalType:`uint64`,name:``,type:`uint64`}],stateMutability:`view`,type:`function`},{inputs:[{internalType:`address`,name:`delegator`,type:`address`},{internalType:`address`,name:`delegate`,type:`address`},{internalType:`address`,name:`contractAddress`,type:`address`},{internalType:`bytes32`,name:`handle`,type:`bytes32`}],name:`isHandleDelegatedForUserDecryption`,outputs:[{internalType:`bool`,name:``,type:`bool`}],stateMutability:`view`,type:`function`}];function xe(e,t,n,r){return{address:e,abi:D,functionName:`delegateForUserDecryption`,args:[t,n,r]}}function Se(e,t,n){return{address:e,abi:D,functionName:`revokeDelegationForUserDecryption`,args:[t,n]}}function O(e,t,n,r){return{address:e,abi:D,functionName:`getUserDecryptionDelegationExpirationDate`,args:[t,n,r]}}function Ce(e,t,n,r,i){return{address:e,abi:D,functionName:`isHandleDelegatedForUserDecryption`,args:[t,n,r,i]}}const k=2n**64n-1n,A={CredentialsLoading:`credentials:loading`,CredentialsCached:`credentials:cached`,CredentialsExpired:`credentials:expired`,CredentialsCreating:`credentials:creating`,CredentialsCreated:`credentials:created`,CredentialsRevoked:`credentials:revoked`,CredentialsPersistFailed:`credentials:persist_failed`,CredentialsAllowed:`credentials:allowed`,CredentialsCorrupted:`credentials:corrupted`,SessionExpired:`session:expired`,EncryptStart:`encrypt:start`,EncryptEnd:`encrypt:end`,EncryptError:`encrypt:error`,DecryptStart:`decrypt:start`,DecryptEnd:`decrypt:end`,DecryptError:`decrypt:error`,TransactionError:`transaction:error`,ShieldSubmitted:`shield:submitted`,TransferSubmitted:`transfer:submitted`,TransferFromSubmitted:`transferFrom:submitted`,ApproveSubmitted:`approve:submitted`,ApproveUnderlyingSubmitted:`approveUnderlying:submitted`,UnwrapSubmitted:`unwrap:submitted`,FinalizeUnwrapSubmitted:`finalizeUnwrap:submitted`,DelegationSubmitted:`delegation:submitted`,RevokeDelegationSubmitted:`revokeDelegation:submitted`,UnshieldPhase1Submitted:`unshield:phase1_submitted`,UnshieldPhase2Started:`unshield:phase2_started`,UnshieldPhase2Submitted:`unshield:phase2_submitted`};var we=class{#e=null;#t=null;clearCache(){this.#e=null,this.#t=null}async encrypt(e,t,n){let r=await this.#n(t,n),i=crypto.getRandomValues(new Uint8Array(12)),a=new TextEncoder,o=await crypto.subtle.encrypt({name:`AES-GCM`,iv:i},r,a.encode(e));return{iv:btoa(String.fromCharCode(...i)),ciphertext:btoa(String.fromCharCode(...new Uint8Array(o)))}}async decrypt(e,t,n){let r=await this.#n(t,n),i=Uint8Array.from(atob(e.iv),e=>e.charCodeAt(0)),a=Uint8Array.from(atob(e.ciphertext),e=>e.charCodeAt(0)),o=await crypto.subtle.decrypt({name:`AES-GCM`,iv:i},r,a);return d(new TextDecoder().decode(o))}async#n(e,t){let n=`${e}:${t}`;if(this.#e&&this.#t===n)return this.#e;let r=new TextEncoder,i=await crypto.subtle.importKey(`raw`,r.encode(e),`PBKDF2`,!1,[`deriveKey`]),a=await crypto.subtle.deriveKey({name:`PBKDF2`,salt:r.encode(t),iterations:6e5,hash:`SHA-256`},i,{name:`AES-GCM`,length:256},!1,[`encrypt`,`decrypt`]);return this.#t=n,this.#e=a,a}};function j(e){a(e,`Stored credentials`),s(e.publicKey,`credentials.publicKey`),c(e.contractAddresses,`credentials.contractAddresses`);for(let t of e.contractAddresses)o(typeof t==`string`&&y(t,{strict:!1}),`Expected each contractAddress to be a valid hex address`);a(e.encryptedPrivateKey,`credentials.encryptedPrivateKey`),s(e.encryptedPrivateKey.iv,`encryptedPrivateKey.iv`),s(e.encryptedPrivateKey.ciphertext,`encryptedPrivateKey.ciphertext`),o(typeof e.startTimestamp==`number`,`Expected credentials.startTimestamp to be a number`),o(typeof e.durationDays==`number`,`Expected credentials.durationDays to be a number`)}function Te(e){j(e);let t=e;o(typeof t.delegatorAddress==`string`&&y(t.delegatorAddress,{strict:!1}),`Expected credentials.delegatorAddress to be a valid address`),o(typeof t.delegateAddress==`string`&&y(t.delegateAddress,{strict:!1}),`Expected credentials.delegateAddress to be a valid address`),o(typeof t.startTimestamp==`number`,`Expected startTimestamp to be a number`),o(typeof t.durationDays==`number`,`Expected durationDays to be a number`)}function M(e){return Math.floor(Date.now()/1e3)<e.startTimestamp+e.durationDays*86400}function N(e,t){let n=new Set(t.map(e=>v(e))),r=new Set(e.map(e=>v(e)));return n.isSubsetOf(r)}function Ee(e,t){return M(e)?N(e.contractAddresses,t):!1}function P(e){return[...new Set(e.map(e=>v(e)))].toSorted()}async function De(...e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e.map(String).join(`:`)));return Array.from(new Uint8Array(t)).map(e=>e.toString(16).padStart(2,`0`)).join(``).slice(0,32)}var Oe=class{#e;constructor(e){this.#e=e}#t(e){a(e,`Session entry`),s(e.signature,`session.signature`),o(typeof e.createdAt==`number`,`Expected session.createdAt to be a number`),o(typeof e.ttl==`number`||e.ttl===`infinite`,`Expected session.ttl to be a number or "infinite"`)}async get(e){let t=await this.#e.get(e);return t===null?null:(this.#t(t),t)}async set(e){let t={signature:e.signature,createdAt:Math.floor(Date.now()/1e3),ttl:e.ttl};await this.#e.set(e.key,t)}async delete(e){await this.#e.delete(e)}isExpired(e){return e.ttl===`infinite`?!1:e.ttl===0?!0:Math.floor(Date.now()/1e3)-e.createdAt>=e.ttl}},ke=class{signer;storage;sessionSignatures;crypto;keypairTTL;sessionTTL;#e;#t=null;#n=null;#r=null;constructor(e){if(this.signer=e.signer,this.storage=e.storage,this.sessionSignatures=new Oe(e.sessionStorage),this.crypto=new we,this.keypairTTL=e.keypairTTL??2592e3,this.sessionTTL=e.sessionTTL??2592e3,this.#e=e.onEvent??(()=>{}),typeof this.keypairTTL==`number`&&this.keypairTTL<0)throw Error(`keypairTTL must be >= 0`);if(typeof this.sessionTTL==`number`&&this.sessionTTL<0)throw Error(`sessionTTL must be >= 0`);typeof this.sessionTTL==`number`&&this.sessionTTL>this.keypairTTL&&(this.sessionTTL=this.keypairTTL,console.warn(`[zama-sdk] sessionTTL was clamped to keypairTTL (${this.keypairTTL}s). A session that outlives the keypair causes isAllowed() to return true after the keypair expires, leading to unexpected wallet prompts.`))}emit(e){this.#e({...e,timestamp:Date.now()})}async resolveCredentials({key:e,contracts:t,createKey:r,createFn:i}){this.emit({type:A.CredentialsLoading,contractAddresses:t});try{let n=await this.storage.get(e);if(n){this.assertEncrypted(n);let r=await this.sessionSignatures.get(e);if(r)if(this.sessionSignatures.isExpired(r))await this.sessionSignatures.delete(e),this.emit({type:A.SessionExpired,reason:`ttl`});else{let i=await this.decryptCredentials(n,r.signature);if(Ee(i,t))return this.emit({type:A.CredentialsCached,contractAddresses:t}),this.emit({type:A.CredentialsAllowed,contractAddresses:t}),i;if(M(i))return this.#i({key:e,credentials:i,requiredContracts:t});this.emit({type:A.CredentialsExpired,contractAddresses:t})}if(M(n)){if(N(n.contractAddresses,t)){let r=await this.signForContracts(n,n.contractAddresses);await this.sessionSignatures.set({key:e,signature:r,ttl:this.sessionTTL});let i=await this.decryptCredentials(n,r);return this.emit({type:A.CredentialsCached,contractAddresses:t}),this.emit({type:A.CredentialsAllowed,contractAddresses:t}),i}let r=await this.signForContracts(n,n.contractAddresses),i=await this.decryptCredentials(n,r);return this.#i({key:e,credentials:i,requiredContracts:t})}this.emit({type:A.CredentialsExpired,contractAddresses:t})}}catch(t){if(t instanceof n)throw t;console.warn(`[zama-sdk] Credential resolution failed, recreating:`,t),this.emit({type:A.CredentialsCorrupted,error:l(t)}),await this.#o(e)}return(!this.#t||this.#n!==r)&&(this.#n=r,this.#t=i().then(e=>(this.emit({type:A.CredentialsAllowed,contractAddresses:t}),e)).finally(()=>{this.#t=null,this.#n=null})),this.#t}async checkExpired(e,t){try{let n=await this.storage.get(e);return n?(this.assertEncrypted(n),!Ee(n,t?[t]:[])):!1}catch(e){return console.warn(`[zama-sdk] isExpired check failed, treating as expired:`,e),!0}}async revokeSession(e,t){await this.sessionSignatures.delete(e),this.clearCaches(),this.emit({type:A.CredentialsRevoked,...t?{contractAddresses:t}:{}})}async checkAllowed(e){let t=await this.sessionSignatures.get(e);return t===null?!1:!this.sessionSignatures.isExpired(t)}async clearAll(e){await this.sessionSignatures.delete(e),this.clearCaches(),await this.#o(e)}clearCaches(){this.crypto.clearCache()}async createCredentials({key:e,contractAddresses:t,createFn:r,errorContext:i}){this.emit({type:A.CredentialsCreating,contractAddresses:t});try{let n=await r();return await this.persistCredentials(e,n),await this.sessionSignatures.set({key:e,signature:n.signature,ttl:this.sessionTTL}),this.emit({type:A.CredentialsCreated,contractAddresses:t}),n}catch(e){if(e instanceof n)throw e;ee(e,i)}}async#i({key:e,credentials:t,requiredContracts:n}){if(this.#r){let e=await this.#r;if(N(e.contractAddresses,n))return this.emit({type:A.CredentialsAllowed,contractAddresses:n}),e;t=e}let r=this.#a({key:e,credentials:t,requiredContracts:n});this.#r=r;try{return await r}finally{this.#r===r&&(this.#r=null)}}async#a({key:e,credentials:t,requiredContracts:n}){let r=P([...t.contractAddresses,...n]),i=await this.signForContracts(t,r),a={...t,contractAddresses:r,signature:i};return await this.persistCredentials(e,a),await this.sessionSignatures.set({key:e,signature:i,ttl:this.sessionTTL}),this.emit({type:A.CredentialsAllowed,contractAddresses:n}),a}async persistCredentials(e,t){try{let n=await this.encryptCredentials(t);await this.storage.set(e,n)}catch(e){console.warn(`[zama-sdk] Failed to encrypt credentials for persistence:`,e),this.emit({type:A.CredentialsPersistFailed,error:l(e)})}}async#o(e){try{await this.storage.delete(e)}catch(e){console.warn(`[zama-sdk] Failed to delete credentials:`,e),this.emit({type:A.CredentialsPersistFailed,error:l(e)})}}};function Ae(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`runtime`);return typeof t!=`object`||!t?!1:typeof Reflect.get(t,`id`)==`string`}var je=class e extends ke{#e;#t=null;#n=null;static async computeStoreKey(e,t){return De(v(e),t)}constructor(e){super(e),this.#e=e.relayer,Ae(typeof globalThis<`u`?Reflect.get(globalThis,`chrome`):void 0)&&e.sessionStorage instanceof u&&console.warn(`[zama-sdk] Detected Chrome extension context with in-memory session storage. Session signatures will be lost on service worker restart and won't be shared across contexts. Consider using chromeSessionStorage instead. `)}async allow(...e){let t=P(e),n=await this.#r();return this.resolveCredentials({key:n,contracts:t,createKey:t.join(`,`),createFn:()=>this.create(t)})}async isExpired(e){return this.checkExpired(await this.#r(),e)}async revoke(...e){await this.revokeSession(await this.#r(),e.length>0?e:void 0)}async revokeByKey(e){await this.revokeSession(e)}async isAllowed(){return this.checkAllowed(await this.#r())}async clear(){await this.clearAll(await this.#r())}async create(e){let t=P(e),n=await this.#r();return this.createCredentials({key:n,contractAddresses:t,createFn:async()=>{let e=await this.#e.generateKeypair(),n=Math.floor(Date.now()/1e3),r=Math.ceil(this.keypairTTL/86400),i=await this.#e.createEIP712(e.publicKey,t,n,r),a=await this.signer.signTypedData(i);return{publicKey:e.publicKey,privateKey:e.privateKey,signature:a,contractAddresses:t,startTimestamp:n,durationDays:r}},errorContext:`Failed to create decrypt credentials`})}assertEncrypted(e){j(e)}async signForContracts(e,t){let n=await this.#e.createEIP712(e.publicKey,t,e.startTimestamp,e.durationDays);return this.signer.signTypedData(n)}async encryptCredentials(e){let t=await this.signer.getAddress(),n=await this.crypto.encrypt(e.privateKey,e.signature,t),{privateKey:r,signature:i,...a}=e;return{...a,encryptedPrivateKey:n}}async decryptCredentials(e,t){let n=await this.signer.getAddress(),r=await this.crypto.decrypt(e.encryptedPrivateKey,t,n),{encryptedPrivateKey:i,...a}=e;return{...a,privateKey:r,signature:t}}clearCaches(){this.#t=null,this.#n=null,super.clearCaches()}async#r(){let t=await this.signer.getAddress(),n=await this.signer.getChainId(),r=`${v(t)}:${n}`;if(this.#t&&this.#n===r)return this.#t;let i=await e.computeStoreKey(t,n);return this.#n=r,this.#t=i,i}},Me=class e extends ke{#e;#t=null;#n=null;static async computeStoreKey(e,t,n){return De(v(e),v(t),n)}constructor(e){super(e),this.#e=e.relayer}async allow(e,...t){let n=v(e),r=P(t),i=await this.#i(n);return this.resolveCredentials({key:i,contracts:r,createKey:`${n}:${r.join(`,`)}`,createFn:()=>this.#r(n,r)})}async isExpired(e,t){return this.checkExpired(await this.#i(v(e)),t)}async revoke(e){await this.revokeSession(await this.#i(v(e)))}async isAllowed(e){return this.checkAllowed(await this.#i(v(e)))}async clear(e){await this.clearAll(await this.#i(v(e)))}async#r(e,t){let n=await this.#i(e);return this.createCredentials({key:n,contractAddresses:t,createFn:async()=>{let n=await this.#e.generateKeypair(),r=await this.signer.getAddress(),i=Math.floor(Date.now()/1e3),a=Math.ceil(this.keypairTTL/86400),o={publicKey:n.publicKey,startTimestamp:i,durationDays:a,delegatorAddress:e},s=await this.#a(o,t);return{publicKey:n.publicKey,privateKey:n.privateKey,signature:s,contractAddresses:t,startTimestamp:i,durationDays:a,delegatorAddress:e,delegateAddress:r}},errorContext:`Failed to create delegated decrypt credentials`})}assertEncrypted(e){Te(e)}async signForContracts(e,t){return this.#a(e,t)}async encryptCredentials(e){let t=await this.signer.getAddress(),n=await this.crypto.encrypt(e.privateKey,e.signature,t),{privateKey:r,signature:i,...a}=e;return{...a,encryptedPrivateKey:n}}async decryptCredentials(e,t){let n=await this.signer.getAddress(),r=await this.crypto.decrypt(e.encryptedPrivateKey,t,n),{encryptedPrivateKey:i,...a}=e;return{...a,privateKey:r,signature:t}}clearCaches(){this.#t=null,this.#n=null,super.clearCaches()}async#i(t){let n=await this.signer.getAddress(),r=await this.signer.getChainId(),i=`${v(n)}:${v(t)}:${r}`;if(this.#t&&this.#n===i)return this.#t;let a=await e.computeStoreKey(n,t,r);return this.#n=i,this.#t=a,a}async#a(e,t){let n=await this.#e.createDelegatedUserDecryptEIP712(e.publicKey,t,e.delegatorAddress,e.startTimestamp,e.durationDays);return this.signer.signTypedData({domain:{...n.domain,chainId:Number(n.domain.chainId)},types:n.types,message:{...n.message,startTimestamp:BigInt(n.message.startTimestamp),durationDays:BigInt(n.message.durationDays)}})}};const Ne=`zama:balances`;function Pe(e,t,n){return`zama:balance:${v(e)}:${v(t)}:${n.toLowerCase()}`}async function F({storage:e,tokenAddress:t,owner:n,handle:r}){try{let i=await e.get(Pe(t,n,r));return i===null?null:BigInt(i)}catch(e){return console.warn(`[zama-sdk] Balance cache read failed:`,e),null}}async function I(e){let{storage:t,tokenAddress:n,owner:r,handle:i,value:a}=e,o=Pe(n,r,i);try{await t.set(o,a.toString()),await Ie(t,o)}catch{}}const Fe=new WeakMap;async function Ie(e,t){let n=(Fe.get(e)??Promise.resolve()).then(async()=>{let n=await e.get(Ne),r=n?JSON.parse(n):[];r.includes(t)||(r.push(t),await e.set(Ne,JSON.stringify(r)))});return Fe.set(e,n.catch(()=>{})),n}async function Le(e,t=1/0){if(Number.isFinite(t)&&t<=0)throw Error(`maxConcurrency must be a positive number`);if(!Number.isFinite(t)||t>=e.length)return Promise.all(e.map(e=>e()));let n=Array.from({length:e.length}),r=0;async function i(){for(;r<e.length;){let t=r++;e[t]&&(n[t]=await e[t]())}}return await Promise.all(Array.from({length:t},i)),n}const Re=`0x0000000000000000000000000000000000000000000000000000000000000000`;var ze=class e{credentials;delegatedCredentials;relayer;signer;address;storage;#e;constructor(e){let t={relayer:e.relayer,signer:e.signer,storage:e.storage,sessionStorage:e.sessionStorage,keypairTTL:e.keypairTTL??2592e3,sessionTTL:e.sessionTTL??2592e3,onEvent:e.onEvent};this.credentials=e.credentials??new je(t),this.delegatedCredentials=e.delegatedCredentials??new Me(t),this.relayer=e.relayer,this.signer=e.signer,this.address=v(e.address),this.storage=e.storage,this.#e=e.onEvent}emit(e){this.#e?.({...e,tokenAddress:this.address,timestamp:Date.now()})}async balanceOf(e){let t=e?v(e):await this.signer.getAddress(),n=await this.readConfidentialBalanceOf(t);return this.decryptBalance(n,t)}async confidentialBalanceOf(e){let t=e?v(e):await this.signer.getAddress();return this.readConfidentialBalanceOf(t)}async isConfidential(){return await this.signer.readContract(m(this.address,p))}async isWrapper(){return await this.signer.readContract(m(this.address,h))}static async batchDecryptBalances(t,n){if(t.length===0)return new Map;let{handles:r,owner:i,onError:a,maxConcurrency:o}=n??{},s=t[0],c=e.assertSameRelayer(t),l=i??await s.signer.getAddress();return e.#t({tokens:t,handles:r,ownerAddress:l,onError:a,maxConcurrency:o,obtainCreds:e=>s.credentials.allow(...e),decrypt:(e,t,n)=>c.userDecrypt({handles:[t],contractAddress:n,signedContractAddresses:e.contractAddresses,privateKey:e.privateKey,publicKey:e.publicKey,signature:e.signature,signerAddress:l,startTimestamp:e.startTimestamp,durationDays:e.durationDays}),errorPrefix:`Batch decryption`})}static async batchDecryptBalancesAs(t,n){if(t.length===0)return new Map;let{delegatorAddress:r,handles:i,owner:a,onError:o,maxConcurrency:s}=n,c=a??r,l=t[0];return e.assertSameRelayer(t),e.#t({tokens:t,handles:i,ownerAddress:c,onError:o,maxConcurrency:s,preFlightCheck:()=>l.#n(r),obtainCreds:e=>l.delegatedCredentials.allow(r,...e),decrypt:(e,t,n)=>l.relayer.delegatedUserDecrypt({handles:[t],contractAddress:n,signedContractAddresses:e.contractAddresses,privateKey:e.privateKey,publicKey:e.publicKey,signature:e.signature,delegatorAddress:e.delegatorAddress,delegateAddress:e.delegateAddress,startTimestamp:e.startTimestamp,durationDays:e.durationDays}),errorPrefix:`Batch delegated decryption`})}static async#t(e){let{tokens:t,handles:n,ownerAddress:r,onError:a,maxConcurrency:o,obtainCreds:s,decrypt:c,errorPrefix:u}=e,d=t[0],f=n??await Promise.all(t.map(e=>e.readConfidentialBalanceOf(r)));if(t.length!==f.length)throw new i(`tokens.length (${t.length}) must equal handles.length (${f.length})`);let p=d.storage,m=new Map,h=[],g=await Promise.all(t.map((e,t)=>{let n=f[t];return e.isZeroHandle(n)?0n:F({storage:p,tokenAddress:e.address,owner:r,handle:n})}));for(let e=0;e<t.length;e++){let n=t[e],r=f[e],i=g[e];if(i!=null){m.set(n.address,i);continue}h.push({token:n,handle:r})}if(h.length===0)return m;e.preFlightCheck&&await e.preFlightCheck();let _=await s(h.map(e=>e.token.address)),v=[],y=[];for(let{token:e,handle:t}of h)y.push(()=>c(_,t,e.address).then(async n=>{let a=n[t];if(a===void 0)throw new i(`${u} returned no value for handle ${t} on token ${e.address}`);m.set(e.address,a);try{await I({storage:p,tokenAddress:e.address,owner:r,handle:t,value:a})}catch(e){console.warn(`[zama-sdk] Cache write failed (non-blocking):`,e)}}).catch(t=>{let n=l(t);if(a)try{m.set(e.address,a(n,e.address))}catch(t){v.push({address:e.address,error:l(t)})}else v.push({address:e.address,error:n})}));if(await Le(y,o),v.length>0){let e=v.map(e=>`${e.address}: ${e.error.message}`).join(`; `);throw new i(`${u} failed for ${v.length} token(s): ${e}`)}return m}async underlyingToken(){return this.signer.readContract(g(this.address))}async allowance(e,t){let n=v(e),r=await this.signer.readContract(g(n)),i=t?v(t):await this.signer.getAddress();return this.signer.readContract(he(r,i,n))}async name(){return this.signer.readContract(ue(this.address))}async symbol(){return this.signer.readContract(de(this.address))}async decimals(){return this.signer.readContract(fe(this.address))}async allow(){await this.credentials.allow(this.address)}async isAllowed(){return this.credentials.isAllowed()}async revoke(...e){await this.credentials.revoke(...e)}static async allow(...e){if(e.length===0)return;let t=e.map(e=>e.address);await e[0].credentials.allow(...t)}async getAclAddress(){return this.relayer.getAclAddress()}async isDelegated(e){let t=await this.getDelegationExpiry(e);return t===0n?!1:t===k?!0:t>await this.signer.getBlockTimestamp()}async getDelegationExpiry({delegatorAddress:e,delegateAddress:t}){let n=await this.getAclAddress();return this.signer.readContract(O(n,v(e),v(t),this.address))}async#n(e){let t=await this.signer.getAddress(),n=await this.getDelegationExpiry({delegatorAddress:e,delegateAddress:t});if(n===0n)throw new C(`No active delegation from ${e} to ${t} for ${this.address}`);if(n!==k&&n<=await this.signer.getBlockTimestamp())throw new w(`Delegation from ${e} to ${t} for ${this.address} has expired`)}async readConfidentialBalanceOf(e){return await this.signer.readContract(f(this.address,e))}isZeroHandle(e){return e===`0x0000000000000000000000000000000000000000000000000000000000000000`||e===`0x`}async decryptBalanceAs({delegatorAddress:e,owner:t}){let n=v(e),r=t?v(t):n,a=await this.readConfidentialBalanceOf(r);if(this.isZeroHandle(a))return 0n;let o=await F({storage:this.storage,tokenAddress:this.address,owner:r,handle:a});if(o!==null)return o;await this.#n(n);let s=Date.now();try{this.emit({type:A.DecryptStart});let e=await this.delegatedCredentials.allow(n,this.address),t=await this.relayer.delegatedUserDecrypt({handles:[a],contractAddress:this.address,signedContractAddresses:e.contractAddresses,privateKey:e.privateKey,publicKey:e.publicKey,signature:e.signature,delegatorAddress:e.delegatorAddress,delegateAddress:e.delegateAddress,startTimestamp:e.startTimestamp,durationDays:e.durationDays});this.emit({type:A.DecryptEnd,durationMs:Date.now()-s});let o=t[a];if(o===void 0)throw new i(`Delegated decryption returned no value for handle ${a}`);try{await I({storage:this.storage,tokenAddress:this.address,owner:r,handle:a,value:o})}catch(e){console.warn(`[zama-sdk] Cache write failed (non-blocking):`,e)}return o}catch(e){throw this.emit({type:A.DecryptError,error:l(e),durationMs:Date.now()-s}),L(e,`Failed to decrypt delegated balance`,!0)}}async decryptBalance(e,t){if(this.isZeroHandle(e))return 0n;let n=t??await this.signer.getAddress(),r=await F({storage:this.storage,tokenAddress:this.address,owner:n,handle:e});if(r!==null)return r;let a=await this.credentials.allow(this.address),o=Date.now();try{this.emit({type:A.DecryptStart});let t=await this.relayer.userDecrypt({handles:[e],contractAddress:this.address,signedContractAddresses:a.contractAddresses,privateKey:a.privateKey,publicKey:a.publicKey,signature:a.signature,signerAddress:n,startTimestamp:a.startTimestamp,durationDays:a.durationDays});this.emit({type:A.DecryptEnd,durationMs:Date.now()-o});let r=t[e];if(r===void 0)throw new i(`Decryption returned no value for handle ${e}`);try{await I({storage:this.storage,tokenAddress:this.address,owner:n,handle:e,value:r})}catch(e){console.warn(`[zama-sdk] Cache write failed (non-blocking):`,e)}return r}catch(e){throw this.emit({type:A.DecryptError,error:l(e),durationMs:Date.now()-o}),L(e,`Failed to decrypt balance`)}}async decryptHandles(e,t){let n=new Map,r=[];for(let t of e)this.isZeroHandle(t)?n.set(t,0n):r.push(t);if(r.length===0)return n;let a=await this.credentials.allow(this.address),o=Date.now();try{this.emit({type:A.DecryptStart});let e=await this.relayer.userDecrypt({handles:r,contractAddress:this.address,signedContractAddresses:a.contractAddresses,privateKey:a.privateKey,publicKey:a.publicKey,signature:a.signature,signerAddress:t??await this.signer.getAddress(),startTimestamp:a.startTimestamp,durationDays:a.durationDays});this.emit({type:A.DecryptEnd,durationMs:Date.now()-o});for(let t of r){let r=e[t];if(r===void 0)throw new i(`Decryption returned no value for handle ${t}`);n.set(t,r)}}catch(e){throw this.emit({type:A.DecryptError,error:l(e),durationMs:Date.now()-o}),L(e,`Failed to decrypt handles`)}return n}static assertSameRelayer(e){let t=e[0].relayer;for(let n=1;n<e.length;n++)if(e[n].relayer!==t)throw new r(`All tokens in a batch operation must share the same relayer instance`);return t}};function L(e,n,r=!1){if(e instanceof i||e instanceof S||e instanceof t||e instanceof T||e instanceof b||e instanceof x)return e;let a=typeof e==`object`&&e&&`statusCode`in e&&typeof e.statusCode==`number`?e.statusCode:void 0;return a===400?new S(e instanceof Error?e.message:`No ciphertext for this account`,{cause:e}):r&&a===500?new T(`Delegated decryption failed with a server error. This is most commonly caused by the delegation not having propagated to the gateway yet — after granting delegation, allow 1–2 minutes for cross-chain synchronization before retrying. If the error persists, the gateway or relayer may be experiencing an unrelated issue.`,{cause:e}):a===void 0?new i(n,{cause:e}):new t(e instanceof Error?e.message:n,a,{cause:e})}const R={ConfidentialTransfer:`0x67500e8d0ed826d2194f514dd0d8124f35648ab6e3fb5e6ed867134cffe661e9`,Wrapped:`0x1f7907f4d84043abe0fb7c74e8865ee5fe93fe4f691c54a7b8fa9d6fb17c7cba`,UnwrapRequested:`0x77d02d353c5629272875d11f1b34ec4c65d7430b075575b78cd2502034c469ee`,UnwrappedFinalized:`0xc64e7c81b18b674fc5b037d8a0041bfe3332d86c780a4688f404ee01fbabb152`,UnwrappedStarted:`0x3838891d4843c6d7f9f494570b6fd8843f4e3c3ddb817c1411760bd31b819806`};function z(e){return v(d(e.slice(-40)))}function B(e){return BigInt(e)}function Be(e){return e}function V(e,t){let n=2+t*64,r=e.slice(n,n+64);return r.length===64?r:r.padEnd(64,`0`)}function H(e,t){return v(d(V(e,t).slice(-40)))}function U(e,t){return BigInt(`0x`+V(e,t))}function W(e,t){return BigInt(`0x`+V(e,t))!==0n}function G(e,t){return d(V(e,t))}function Ve(e){return e.topics[0]!==R.ConfidentialTransfer||e.topics.length<4?null:{eventName:`ConfidentialTransfer`,from:z(e.topics[1]),to:z(e.topics[2]),encryptedAmountHandle:Be(e.topics[3])}}function K(e){return e.topics[0]!==R.Wrapped||e.topics.length<3?null:{eventName:`Wrapped`,to:z(e.topics[1]),mintTxId:B(e.topics[2]),mintAmount:U(e.data,0),amountIn:U(e.data,1),feeAmount:U(e.data,2)}}function q(e){return e.topics[0]!==R.UnwrapRequested||e.topics.length<2?null:{eventName:`UnwrapRequested`,receiver:z(e.topics[1]),encryptedAmount:G(e.data,0)}}function He(e){return e.topics[0]!==R.UnwrappedFinalized||e.topics.length<3?null:{eventName:`UnwrappedFinalized`,burntAmountHandle:Be(e.topics[1]),nextTxId:B(e.topics[2]),finalizeSuccess:W(e.data,0),feeTransferSuccess:W(e.data,1),burnAmount:U(e.data,2),unwrapAmount:U(e.data,3),feeAmount:U(e.data,4)}}function Ue(e){return e.topics[0]!==R.UnwrappedStarted||e.topics.length<4?null:{eventName:`UnwrappedStarted`,requestId:B(e.topics[1]),txId:B(e.topics[2]),to:z(e.topics[3]),returnVal:W(e.data,0),refund:H(e.data,1),requestedAmount:G(e.data,2),burnAmount:G(e.data,3)}}function J(e){return Ve(e)??K(e)??q(e)??He(e)??Ue(e)}function We(e){let t=[];for(let n of e){let e=J(n);e&&t.push(e)}return t}function Ge(e){for(let t of e){let e=q(t);if(e)return e}return null}function Ke(e){for(let t of e){let e=K(t);if(e)return e}return null}const qe=[R.ConfidentialTransfer,R.Wrapped,R.UnwrapRequested,R.UnwrappedFinalized,R.UnwrappedStarted],Y={DelegatedForUserDecryption:`0x527b025d7ff06689c1ab9d32dfd7881c964cce72ce8ac5b2fe1d3be8cfda5bfc`,RevokedDelegationForUserDecryption:`0x7aca80b6b7928b9038f186e3d9922a0fc5d52c398fbf144725c142c52a5277e4`};function X(e){return e.topics[0]!==Y.DelegatedForUserDecryption||e.topics.length<3?null:{eventName:`DelegatedForUserDecryption`,delegator:z(e.topics[1]),delegate:z(e.topics[2]),contractAddress:H(e.data,0),delegationCounter:U(e.data,1),oldExpirationDate:U(e.data,2),newExpirationDate:U(e.data,3)}}function Z(e){return e.topics[0]!==Y.RevokedDelegationForUserDecryption||e.topics.length<3?null:{eventName:`RevokedDelegationForUserDecryption`,delegator:z(e.topics[1]),delegate:z(e.topics[2]),contractAddress:H(e.data,0),delegationCounter:U(e.data,1),oldExpirationDate:U(e.data,2)}}function Je(e){return X(e)??Z(e)}function Ye(e){let t=[];for(let n of e){let e=Je(n);e&&t.push(e)}return t}function Xe(e){for(let t of e){let e=X(t);if(e)return e}return null}function Ze(e){for(let t of e){let e=Z(t);if(e)return e}return null}const Qe=[Y.DelegatedForUserDecryption,Y.RevokedDelegationForUserDecryption];function Q(e,t){return e.toLowerCase()===t.toLowerCase()}function $(e,t,n){let r=t!==void 0&&Q(e,t),i=n!==void 0&&Q(e,n);return r&&i?`self`:r?`outgoing`:`incoming`}function $e(e,t,n){switch(e.eventName){case`ConfidentialTransfer`:return et(e,t,n);case`Wrapped`:return tt(e,t,n);case`UnwrapRequested`:return nt(e,t,n);case`UnwrappedStarted`:return rt(e,t,n);case`UnwrappedFinalized`:return it(e,n)}}function et(e,t,n){return{type:`transfer`,direction:$(t,e.from,e.to),amount:{type:`encrypted`,handle:e.encryptedAmountHandle},from:e.from,to:e.to,metadata:n,rawEvent:e}}function tt(e,t,n){return{type:`shield`,direction:$(t,void 0,e.to),amount:{type:`clear`,value:e.amountIn},to:e.to,fee:e.feeAmount,metadata:n,rawEvent:e}}function nt(e,t,n){return{type:`unshield_requested`,direction:$(t,void 0,e.receiver),amount:{type:`encrypted`,handle:e.encryptedAmount},to:e.receiver,metadata:n,rawEvent:e}}function rt(e,t,n){return{type:`unshield_started`,direction:$(t,void 0,e.to),amount:{type:`encrypted`,handle:e.requestedAmount},to:e.to,success:e.returnVal,metadata:n,rawEvent:e}}function it(e,t){return{type:`unshield_finalized`,direction:`incoming`,amount:{type:`clear`,value:e.unwrapAmount},fee:e.feeAmount,success:e.finalizeSuccess,metadata:t,rawEvent:e}}function at(e,t){let n=[];for(let r of e){let e=J(r);if(!e)continue;let i={transactionHash:r.transactionHash,blockNumber:r.blockNumber,logIndex:r.logIndex};n.push($e(e,t,i))}return n}function ot(e){let t=new Set;for(let n of e)if(n.amount.type===`encrypted`&&n.amount.decryptedValue===void 0){let e=n.amount.handle;e!==`0x`&&e!==`0x0000000000000000000000000000000000000000000000000000000000000000`&&t.add(e)}return[...t]}function st(e,t){return e.map(e=>{if(e.amount.type!==`encrypted`)return e;let n=t.get(e.amount.handle);return n===void 0?e:{...e,amount:{type:`encrypted`,handle:e.amount.handle,decryptedValue:n}}})}function ct(e){return[...e].toSorted((e,t)=>{let n=e.metadata.blockNumber,r=t.metadata.blockNumber;if(n===void 0&&r===void 0)return 0;if(n===void 0)return-1;if(r===void 0)return 1;let i=typeof n==`bigint`?n:BigInt(n),a=typeof r==`bigint`?r:BigInt(r);if(a>i)return 1;if(a<i)return-1;let o=e.metadata.logIndex??0;return(t.metadata.logIndex??0)-o})}export{C as $,k as A,ge as B,Ke as C,Me as D,F as E,ye as F,de as G,fe as H,be as I,ie as J,ce as K,ve as L,O as M,Ce as N,je as O,Se as P,ae as Q,_e as R,Ge as S,Re as T,pe as U,me as V,ue as W,le as X,oe as Y,w as Z,He as _,Qe as a,x as at,Xe as b,R as c,Ve as d,T as et,X as f,q as g,Z as h,ct as i,S as it,xe as j,A as k,Je as l,We as m,ot as n,ne as nt,Y as o,b as ot,J as p,se as q,at as r,te as rt,qe as s,st as t,re as tt,Ye as u,Ue as v,ze as w,Ze as x,K as y,he as z};
|
|
2
|
+
//# sourceMappingURL=activity-b2RsqKHW.js.map
|