@zama-fhe/sdk 3.3.1-alpha.2 → 3.4.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/cjs/index.cjs +1 -1
  2. package/dist/cjs/index.cjs.map +1 -1
  3. package/dist/cjs/query/index.cjs +1 -1
  4. package/dist/cjs/query/index.cjs.map +1 -1
  5. package/dist/cjs/relayer.cjs +1 -1
  6. package/dist/cjs/relayer.cjs.map +1 -1
  7. package/dist/cjs/token.cjs +1 -1
  8. package/dist/cjs/token.cjs.map +1 -1
  9. package/dist/esm/{base-signer-CI-FYai2.js → base-signer-Co79VFwf.js} +2 -2
  10. package/dist/esm/{base-signer-CI-FYai2.js.map → base-signer-Co79VFwf.js.map} +1 -1
  11. package/dist/esm/{base-signer-Q2EJECrc.d.ts → base-signer-D5HdiBp1.d.ts} +2 -3
  12. package/dist/esm/chains/index.d.ts +1 -1
  13. package/dist/esm/cleartext/index.d.ts +2 -2
  14. package/dist/esm/cleartext/index.js +1 -1
  15. package/dist/esm/{cleartext-U6sPs_Kd.d.ts → cleartext-Bvx-0y6k.d.ts} +2 -3
  16. package/dist/esm/{cleartext-BfXTVQu-.js → cleartext-DHEMC21x.js} +2 -2
  17. package/dist/esm/{cleartext-BfXTVQu-.js.map → cleartext-DHEMC21x.js.map} +1 -1
  18. package/dist/esm/ethers/index.d.ts +4 -5
  19. package/dist/esm/ethers/index.js +1 -1
  20. package/dist/esm/{fhevm-relayer-B-lEKfPQ.js → fhevm-relayer-CyfdS4_t.js} +2 -2
  21. package/dist/esm/{fhevm-relayer-B-lEKfPQ.js.map → fhevm-relayer-CyfdS4_t.js.map} +1 -1
  22. package/dist/esm/{index-BnIp_-Ak.d.ts → index-CDJk5ZAg.d.ts} +4 -3
  23. package/dist/esm/{index-D66eC3G7.d.ts → index-doNE2KoX.d.ts} +1 -2
  24. package/dist/esm/index.d.ts +8 -9
  25. package/dist/esm/index.js +1 -1
  26. package/dist/esm/index.js.map +1 -1
  27. package/dist/esm/node/index.d.ts +4 -4
  28. package/dist/esm/node/index.js +1 -1
  29. package/dist/esm/query/index.d.ts +2 -2
  30. package/dist/esm/query/index.js +1 -1
  31. package/dist/esm/query/index.js.map +1 -1
  32. package/dist/esm/relayer-BUxKmetl.js +2 -0
  33. package/dist/esm/relayer-BUxKmetl.js.map +1 -0
  34. package/dist/esm/token-CK6XGnWp.js +2 -0
  35. package/dist/esm/token-CK6XGnWp.js.map +1 -0
  36. package/dist/esm/{types-Bov8XY36.d.ts → types-CObfaH4A.d.ts} +3 -4
  37. package/dist/esm/{types-BpvL50qX.d.ts → types-D8g0H49N.d.ts} +3 -4
  38. package/dist/esm/{types-C-WTLcHZ.d.ts → types-nwhfaUCK.d.ts} +14 -9
  39. package/dist/esm/viem/index.d.ts +4 -5
  40. package/dist/esm/viem/index.js +1 -1
  41. package/dist/esm/web/index.d.ts +1 -2
  42. package/dist/esm/web/index.js +1 -1
  43. package/dist/esm/{wrappers-registry-xZWzyAi4.js → wrappers-registry-vjouAqDk.js} +2 -2
  44. package/dist/esm/{wrappers-registry-xZWzyAi4.js.map → wrappers-registry-vjouAqDk.js.map} +1 -1
  45. package/dist/esm/{zama-sdk-q4_qt64Q.d.ts → zama-sdk-aaLl2ZlA.d.ts} +131 -107
  46. package/package.json +2 -2
  47. package/dist/esm/relayer-BYq9bLh8.js +0 -2
  48. package/dist/esm/relayer-BYq9bLh8.js.map +0 -1
  49. package/dist/esm/token-CmHTAAWW.js +0 -2
  50. package/dist/esm/token-CmHTAAWW.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"fhevm-relayer-B-lEKfPQ.js","names":["#chain","#base","#decrypt","#encrypt","#defaultOptions","#encryptInitPromise","#initEncrypt"],"sources":["../../src/chains/to-fhevm-chain.ts","../../src/relayer/fhevm-relayer.ts"],"sourcesContent":["import type { FhevmChain } from \"@fhevm/sdk/chains\";\nimport type { FheChain } from \"./types\";\n\n/**\n * Derive an `@fhevm/sdk` {@link FhevmChain} from zama-sdk's richer\n * {@link FheChain}.\n *\n * `FheChain` carries fields `@fhevm/sdk` does not model (RPC `network`,\n * `registryAddress`, `executorAddress`, cleartext signer keys); those stay on\n * `FheChain` for the token layer. This adapter projects only the subset the\n * FHE runtime needs: contract addresses, relayer URL, and gateway.\n */\nexport function toFhevmChain(chain: FheChain): FhevmChain {\n return {\n id: chain.id,\n fhevm: {\n contracts: {\n acl: { address: chain.aclContractAddress },\n inputVerifier: { address: chain.inputVerifierContractAddress },\n kmsVerifier: { address: chain.kmsContractAddress },\n protocolConfig: undefined,\n },\n relayerUrl: chain.relayerUrl,\n gateway: {\n id: chain.gatewayChainId,\n contracts: {\n decryption: { address: chain.verifyingContractAddressDecryption },\n inputVerification: { address: chain.verifyingContractAddressInputVerification },\n },\n },\n },\n } satisfies FhevmChain;\n}\n","import {\n createFhevmBaseClient,\n createFhevmDecryptClient,\n createFhevmEncryptClient,\n} from \"@fhevm/sdk/viem\";\nimport {\n createFhevmCleartextBaseClient,\n createFhevmCleartextDecryptClient,\n createFhevmCleartextEncryptClient,\n} from \"@fhevm/sdk/viem/cleartext\";\nimport { createPublicClient, custom, http } from \"viem\";\nimport { toFhevmChain } from \"../chains/to-fhevm-chain\";\nimport type { FheChain } from \"../chains/types\";\nimport type {\n FhevmBaseClient,\n FhevmClient,\n FhevmDecryptClient,\n FhevmEncryptClient,\n FhevmRelayerOptions,\n FhevmRelayerSDK,\n RelayerOptions,\n} from \"./types\";\nimport { ConfigurationError } from \"../errors\";\n\n/** Construction config for {@link FhevmRelayer}. */\nexport interface FhevmRelayerConfig {\n /** FHE chain configuration. */\n chain: FheChain;\n /**\n * Cleartext mode for local dev/test chains without FHE infrastructure — reads\n * mock cleartexts from the on-chain executor (discovered automatically)\n * instead of calling the relayer.\n */\n cleartext?: boolean;\n /**\n * Per-transport {@link RelayerOptions}: `@fhevm/sdk` client options plus a\n * default request `timeout` applied to every relayer round-trip on the chain.\n */\n options?: RelayerOptions;\n}\n\n/**\n * Single-chain FHE backend that drives `@fhevm/sdk` on the calling thread with\n * capability-scoped lazy initialization.\n * EIP-712 signing is done by the signer layer; this backend builds the typed\n * data and, on decrypt, reassembles the new SDK's signed permit from the\n * interface's params + the previously returned signature.\n *\n * @remarks\n * Each method delegates to the narrowest base, decrypt, or encrypt client,\n * adding two cross-cutting behaviors that the delegated signatures don't\n * express:\n *\n * - **Lazy init.** Each operation initializes only the capability it requires.\n * Public decrypt avoids WASM, private decrypt loads TKMS only, and encryption\n * alone loads TFHE and the FHE encryption key.\n * - **Option merging.** The chain's default options (`auth`, `timeout`, `debug`)\n * are spread in first, then the per-call `options`, so a per-call value always\n * wins over the chain default. Serialization helpers make no relayer\n * round-trip, so they inject no options.\n */\nexport class FhevmRelayer implements FhevmRelayerSDK {\n readonly #chain: FheChain;\n readonly #base: FhevmBaseClient;\n readonly #decrypt: FhevmDecryptClient;\n readonly #encrypt: FhevmEncryptClient;\n readonly #defaultOptions: Partial<FhevmRelayerOptions>;\n #encryptInitPromise: Promise<void> | undefined;\n\n /**\n * Builds capability-scoped `@fhevm/sdk` clients for the chain and captures\n * the chain's `auth`/`timeout`/`debug` as request defaults. Construction is\n * cheap; each client's one-time init is deferred to its first operation.\n */\n constructor(config: FhevmRelayerConfig) {\n this.#chain = config.chain;\n const { timeout, debug, batchRpcCalls, moduleVersions, fheEncryptionKey } =\n config.options ?? {};\n const params = {\n publicClient: createPublicClient({\n transport:\n typeof this.#chain.network === \"string\"\n ? http(this.#chain.network)\n : custom(this.#chain.network),\n }),\n chain: toFhevmChain(this.#chain),\n options: { batchRpcCalls, moduleVersions, fheEncryptionKey },\n };\n if (config.cleartext) {\n this.#base = createFhevmCleartextBaseClient(params);\n this.#decrypt = createFhevmCleartextDecryptClient(params);\n this.#encrypt = createFhevmCleartextEncryptClient(params);\n } else {\n this.#base = createFhevmBaseClient(params);\n this.#decrypt = createFhevmDecryptClient(params);\n this.#encrypt = createFhevmEncryptClient(params);\n }\n this.#defaultOptions = {\n ...(this.#chain.auth !== undefined && { auth: toFhevmAuth(this.#chain.auth) }),\n ...(timeout !== undefined && { timeout }),\n ...(debug !== undefined && { debug }),\n };\n }\n\n /** The FHE chain this backend is bound to. */\n get chain() {\n return this.#chain;\n }\n\n #initEncrypt = (): Promise<void> => {\n this.#encryptInitPromise ??= this.#encrypt\n .fetchFheEncryptionKeyBytes({ options: this.#defaultOptions })\n .then(() => this.#encrypt.init());\n return this.#encryptInitPromise;\n };\n\n /**\n * Decrypts a single publicly-decryptable value — one whose contract granted\n * public access, so no permit or key pair is needed — into its typed clear\n * value.\n *\n * @example\n * ```ts\n * const { type, value } = await relayer.decryptPublicValue({\n * encryptedValue: handle, // a bytes32 ciphertext reference\n * });\n * ```\n */\n decryptPublicValue: FhevmClient[\"decryptPublicValue\"] = async (parameters) => {\n await this.#base.init();\n return this.#base.decryptPublicValue({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters.options },\n });\n };\n\n /**\n * Batch form of {@link decryptPublicValue}: decrypts many publicly-decryptable\n * values in one relayer round-trip, returning their typed clear values in\n * order.\n *\n * @example\n * ```ts\n * const values = await relayer.decryptPublicValues({\n * encryptedValues: [handleA, handleB],\n * });\n * ```\n */\n decryptPublicValues: FhevmClient[\"decryptPublicValues\"] = async (parameters) => {\n await this.#base.init();\n return this.#base.decryptPublicValues({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters.options },\n });\n };\n\n /**\n * Like {@link decryptPublicValues}, but also returns the KMS signature bundle —\n * the handles list, ABI-encoded cleartexts, and decryption proof — needed to\n * verify or replay the result on-chain.\n *\n * @example\n * ```ts\n * const { clearValues, checkSignaturesArgs } =\n * await relayer.decryptPublicValuesWithSignatures({ encryptedValues: [handle] });\n * // checkSignaturesArgs: { handlesList, abiEncodedCleartexts, decryptionProof }\n * ```\n */\n decryptPublicValuesWithSignatures: FhevmClient[\"decryptPublicValuesWithSignatures\"] = async (\n parameters,\n ) => {\n await this.#base.init();\n return this.#base.decryptPublicValuesWithSignatures({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters.options },\n });\n };\n\n /**\n * Encrypts one typed input under the chain's FHE key, bound to the contract it\n * targets and the user submitting it, and returns the ciphertext handle plus\n * the input proof the contract verifies on-chain. `type` is the FHE type\n * with the `e` prefix (`\"euint64\"`, `\"ebool\"`, `\"eaddress\"`).\n *\n * @example\n * ```ts\n * const { encryptedValue, inputProof } = await relayer.encryptValue({\n * value: { type: \"euint64\", value: 1000n },\n * contractAddress: \"0xToken…\",\n * userAddress: \"0xUser…\",\n * });\n * ```\n */\n encryptValue: FhevmClient[\"encryptValue\"] = async (parameters) => {\n await this.#initEncrypt();\n return this.#encrypt.encryptValue({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters.options },\n });\n };\n\n /**\n * Batch form of {@link encryptValue}: encrypts several inputs for the same\n * contract and user in one call, returning all ciphertext handles under a\n * single shared input proof.\n *\n * @example\n * ```ts\n * const { encryptedValues, inputProof } = await relayer.encryptValues({\n * values: [\n * { type: \"euint64\", value: 1000n },\n * { type: \"ebool\", value: true },\n * ],\n * contractAddress: \"0xToken…\",\n * userAddress: \"0xUser…\",\n * });\n * ```\n */\n encryptValues: FhevmClient[\"encryptValues\"] = async (parameters) => {\n await this.#initEncrypt();\n return this.#encrypt.encryptValues({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters.options },\n });\n };\n\n /**\n * User-decrypts a single access-controlled value: the relayer re-encrypts it\n * to the ephemeral transport key pair, gated by the signed permit, and this\n * returns the typed clear value. Build the key pair with\n * {@link generateTransportKeyPair} and the permit with\n * {@link signDecryptionPermit}.\n *\n * @example\n * ```ts\n * const { type, value } = await relayer.decryptValue({\n * encryptedValue: handle,\n * contractAddress: \"0xToken…\",\n * transportKeyPair,\n * signedPermit,\n * });\n * ```\n */\n decryptValue: FhevmClient[\"decryptValue\"] = async (parameters) => {\n await this.#decrypt.init();\n return this.#decrypt.decryptValue({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters.options },\n });\n };\n\n /**\n * Batch form of {@link decryptValue} for values that all belong to the same\n * contract; returns the typed clear values positionally. For values spanning\n * multiple contracts, use {@link decryptValuesFromPairs}.\n *\n * @example\n * ```ts\n * const values = await relayer.decryptValues({\n * encryptedValues: [handleA, handleB],\n * contractAddress: \"0xToken…\",\n * transportKeyPair,\n * signedPermit,\n * });\n * ```\n */\n decryptValues: FhevmClient[\"decryptValues\"] = async (parameters) => {\n await this.#decrypt.init();\n return this.#decrypt.decryptValues({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters.options },\n });\n };\n\n /**\n * User-decrypts values that span multiple contracts: each pair carries its own\n * `contractAddress`, so one permit covering those contracts decrypts them all\n * in a single round-trip. Returns the typed clear values positionally.\n *\n * @example\n * ```ts\n * const values = await relayer.decryptValuesFromPairs({\n * pairs: [\n * { encryptedValue: handleA, contractAddress: \"0xTokenA…\" },\n * { encryptedValue: handleB, contractAddress: \"0xTokenB…\" },\n * ],\n * transportKeyPair,\n * signedPermit,\n * });\n * ```\n */\n decryptValuesFromPairs: FhevmClient[\"decryptValuesFromPairs\"] = async (parameters) => {\n await this.#decrypt.init();\n return this.#decrypt.decryptValuesFromPairs({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters.options },\n });\n };\n\n /**\n * Fetches the chain's raw FHE public-key bytes — the key encryption uses —\n * served from cache unless `ignoreCache` forces a refetch. Rarely called\n * directly: {@link encryptValue}/{@link encryptValues} fetch the key for you.\n *\n * @example\n * ```ts\n * const keyBytes = await relayer.fetchFheEncryptionKeyBytes();\n * const fresh = await relayer.fetchFheEncryptionKeyBytes({ ignoreCache: true });\n * ```\n */\n fetchFheEncryptionKeyBytes: FhevmClient[\"fetchFheEncryptionKeyBytes\"] = async (parameters) => {\n await this.#initEncrypt();\n return this.#encrypt.fetchFheEncryptionKeyBytes({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters?.options },\n });\n };\n\n /**\n * Builds the EIP-712 user-decrypt permit and signs it with the given signer,\n * authorizing the transport key pair to decrypt the listed contracts' values\n * for `durationSeconds` starting at `startTimestamp`. Pass `delegatorAddress`\n * to sign a delegated permit — decrypting values owned by that account instead\n * of the signer's own. Persist the result via\n * {@link serializeSignedDecryptionPermit}.\n *\n * @example\n * ```ts\n * const signedPermit = await relayer.signDecryptionPermit({\n * transportKeyPair,\n * contractAddresses: [\"0xToken…\"],\n * startTimestamp: Math.floor(Date.now() / 1000),\n * durationSeconds: 60 * 60 * 24,\n * signerAddress: \"0xUser…\",\n * signer,\n * // delegatorAddress: \"0xOwner…\", // omit for a self permit\n * });\n * ```\n */\n signDecryptionPermit: FhevmClient[\"signDecryptionPermit\"] = async (parameters) => {\n await this.#base.init();\n return this.#base.signDecryptionPermit(parameters);\n };\n\n // Permit/key-pair helpers carry no request options. Parsing initializes the\n // capability needed to validate the restored value; serialization stays local.\n\n /**\n * Serializes a transport key pair to a hex `{ publicKey, privateKey }` pair for\n * storage or transport, so a decryption session can resume without regenerating\n * keys. Reverse of {@link parseTransportKeyPair}. Purely local — no round-trip.\n *\n * @example\n * ```ts\n * const stored = relayer.serializeTransportKeyPair({ transportKeyPair });\n * // { publicKey: \"0x…\", privateKey: \"0x…\" }\n * ```\n */\n serializeTransportKeyPair: FhevmClient[\"serializeTransportKeyPair\"] = (parameters) =>\n this.#decrypt.serializeTransportKeyPair(parameters);\n\n /**\n * Serializes a signed permit to a plain, JSON-stringifiable object (version,\n * EIP-712 payload, signature, signer) for caching or transport. Reverse of\n * {@link parseSignedDecryptionPermit}. Purely local — no round-trip.\n *\n * @example\n * ```ts\n * const serialized = relayer.serializeSignedDecryptionPermit({ signedPermit });\n * localStorage.setItem(\"permit\", JSON.stringify(serialized));\n * ```\n */\n serializeSignedDecryptionPermit: FhevmClient[\"serializeSignedDecryptionPermit\"] = (parameters) =>\n this.#base.serializeSignedDecryptionPermit(parameters);\n\n /**\n * Rebuilds a transport key pair from its serialized hex\n * `{ publicKey, privateKey }` form. Reverse of {@link serializeTransportKeyPair}.\n *\n * @example\n * ```ts\n * const transportKeyPair = await relayer.parseTransportKeyPair({\n * publicKey: stored.publicKey,\n * privateKey: stored.privateKey,\n * });\n * ```\n */\n parseTransportKeyPair: FhevmClient[\"parseTransportKeyPair\"] = async (parameters) => {\n await this.#decrypt.init();\n return this.#decrypt.parseTransportKeyPair(parameters);\n };\n\n /**\n * Rebuilds a signed permit from its serialized form and validates it: checks\n * the EIP-712 structure, verifies the signature against the on-chain verifier,\n * and confirms the permit's public key matches `transportKeyPair`. Reverse of\n * {@link serializeSignedDecryptionPermit}.\n *\n * @throws if the permit is malformed, expired, or its signature is invalid.\n *\n * @example\n * ```ts\n * const signedPermit = await relayer.parseSignedDecryptionPermit({\n * serializedPermit,\n * transportKeyPair,\n * });\n * ```\n */\n parseSignedDecryptionPermit: FhevmClient[\"parseSignedDecryptionPermit\"] = async (parameters) => {\n await this.#base.init();\n return this.#base.parseSignedDecryptionPermit(parameters);\n };\n\n /**\n * Generates a fresh ephemeral transport key pair for a user-decrypt session.\n * The relayer re-encrypts decrypted values to this pair's public key, so only\n * the holder of the private key can read them; bind it to a permit via\n * {@link signDecryptionPermit}.\n *\n * @example\n * ```ts\n * const transportKeyPair = await relayer.generateTransportKeyPair();\n * ```\n */\n generateTransportKeyPair: FhevmClient[\"generateTransportKeyPair\"] = async () => {\n await this.#decrypt.init();\n return this.#decrypt.generateTransportKeyPair();\n };\n}\n\nfunction toFhevmAuth(\n auth: NonNullable<FheChain[\"auth\"]>,\n): NonNullable<FhevmRelayerOptions[\"auth\"]> {\n const type = auth[\"__type\"];\n switch (type) {\n case \"ApiKeyHeader\":\n return { type, value: auth.value, header: auth.header };\n case \"ApiKeyCookie\":\n return { type, value: auth.value, cookie: auth.cookie };\n case \"BearerToken\":\n return { type, token: auth.token };\n default:\n throw new ConfigurationError(`Unknown auth type: ${String(type)}`);\n }\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"fhevm-relayer-CyfdS4_t.js","names":["#chain","#base","#decrypt","#encrypt","#defaultOptions","#encryptInitPromise","#initEncrypt"],"sources":["../../src/chains/to-fhevm-chain.ts","../../src/relayer/fhevm-relayer.ts"],"sourcesContent":["import type { FhevmChain } from \"@fhevm/sdk/chains\";\nimport type { FheChain } from \"./types\";\n\n/**\n * Derive an `@fhevm/sdk` {@link FhevmChain} from zama-sdk's richer\n * {@link FheChain}.\n *\n * `FheChain` carries fields `@fhevm/sdk` does not model (RPC `network`,\n * `registryAddress`, `executorAddress`, cleartext signer keys); those stay on\n * `FheChain` for the token layer. This adapter projects only the subset the\n * FHE runtime needs: contract addresses, relayer URL, and gateway.\n */\nexport function toFhevmChain(chain: FheChain): FhevmChain {\n return {\n id: chain.id,\n fhevm: {\n contracts: {\n acl: { address: chain.aclContractAddress },\n inputVerifier: { address: chain.inputVerifierContractAddress },\n kmsVerifier: { address: chain.kmsContractAddress },\n protocolConfig: undefined,\n },\n relayerUrl: chain.relayerUrl,\n gateway: {\n id: chain.gatewayChainId,\n contracts: {\n decryption: { address: chain.verifyingContractAddressDecryption },\n inputVerification: { address: chain.verifyingContractAddressInputVerification },\n },\n },\n },\n } satisfies FhevmChain;\n}\n","import {\n createFhevmBaseClient,\n createFhevmDecryptClient,\n createFhevmEncryptClient,\n} from \"@fhevm/sdk/viem\";\nimport {\n createFhevmCleartextBaseClient,\n createFhevmCleartextDecryptClient,\n createFhevmCleartextEncryptClient,\n} from \"@fhevm/sdk/viem/cleartext\";\nimport { createPublicClient, custom, http } from \"viem\";\nimport { toFhevmChain } from \"../chains/to-fhevm-chain\";\nimport type { FheChain } from \"../chains/types\";\nimport type {\n FhevmBaseClient,\n FhevmClient,\n FhevmDecryptClient,\n FhevmEncryptClient,\n FhevmRelayerOptions,\n FhevmRelayerSDK,\n RelayerOptions,\n} from \"./types\";\nimport { ConfigurationError } from \"../errors\";\n\n/** Construction config for {@link FhevmRelayer}. */\nexport interface FhevmRelayerConfig {\n /** FHE chain configuration. */\n chain: FheChain;\n /**\n * Cleartext mode for local dev/test chains without FHE infrastructure — reads\n * mock cleartexts from the on-chain executor (discovered automatically)\n * instead of calling the relayer.\n */\n cleartext?: boolean;\n /**\n * Per-transport {@link RelayerOptions}: `@fhevm/sdk` client options plus a\n * default request `timeout` applied to every relayer round-trip on the chain.\n */\n options?: RelayerOptions;\n}\n\n/**\n * Single-chain FHE backend that drives `@fhevm/sdk` on the calling thread with\n * capability-scoped lazy initialization.\n * EIP-712 signing is done by the signer layer; this backend builds the typed\n * data and, on decrypt, reassembles the new SDK's signed permit from the\n * interface's params + the previously returned signature.\n *\n * @remarks\n * Each method delegates to the narrowest base, decrypt, or encrypt client,\n * adding two cross-cutting behaviors that the delegated signatures don't\n * express:\n *\n * - **Lazy init.** Each operation initializes only the capability it requires.\n * Public decrypt avoids WASM, private decrypt loads TKMS only, and encryption\n * alone loads TFHE and the FHE encryption key.\n * - **Option merging.** The chain's default options (`auth`, `timeout`, `debug`)\n * are spread in first, then the per-call `options`, so a per-call value always\n * wins over the chain default. Serialization helpers make no relayer\n * round-trip, so they inject no options.\n */\nexport class FhevmRelayer implements FhevmRelayerSDK {\n readonly #chain: FheChain;\n readonly #base: FhevmBaseClient;\n readonly #decrypt: FhevmDecryptClient;\n readonly #encrypt: FhevmEncryptClient;\n readonly #defaultOptions: Partial<FhevmRelayerOptions>;\n #encryptInitPromise: Promise<void> | undefined;\n\n /**\n * Builds capability-scoped `@fhevm/sdk` clients for the chain and captures\n * the chain's `auth`/`timeout`/`debug` as request defaults. Construction is\n * cheap; each client's one-time init is deferred to its first operation.\n */\n constructor(config: FhevmRelayerConfig) {\n this.#chain = config.chain;\n const { timeout, debug, batchRpcCalls, moduleVersions, fheEncryptionKey } =\n config.options ?? {};\n const params = {\n publicClient: createPublicClient({\n transport:\n typeof this.#chain.network === \"string\"\n ? http(this.#chain.network)\n : custom(this.#chain.network),\n }),\n chain: toFhevmChain(this.#chain),\n options: { batchRpcCalls, moduleVersions, fheEncryptionKey },\n };\n if (config.cleartext) {\n this.#base = createFhevmCleartextBaseClient(params);\n this.#decrypt = createFhevmCleartextDecryptClient(params);\n this.#encrypt = createFhevmCleartextEncryptClient(params);\n } else {\n this.#base = createFhevmBaseClient(params);\n this.#decrypt = createFhevmDecryptClient(params);\n this.#encrypt = createFhevmEncryptClient(params);\n }\n this.#defaultOptions = {\n ...(this.#chain.auth !== undefined && { auth: toFhevmAuth(this.#chain.auth) }),\n ...(timeout !== undefined && { timeout }),\n ...(debug !== undefined && { debug }),\n };\n }\n\n /** The FHE chain this backend is bound to. */\n get chain() {\n return this.#chain;\n }\n\n #initEncrypt = (): Promise<void> => {\n this.#encryptInitPromise ??= this.#encrypt\n .fetchFheEncryptionKeyBytes({ options: this.#defaultOptions })\n .then(() => this.#encrypt.init());\n return this.#encryptInitPromise;\n };\n\n /**\n * Decrypts a single publicly-decryptable value — one whose contract granted\n * public access, so no permit or key pair is needed — into its typed clear\n * value.\n *\n * @example\n * ```ts\n * const { type, value } = await relayer.decryptPublicValue({\n * encryptedValue: handle, // a bytes32 ciphertext reference\n * });\n * ```\n */\n decryptPublicValue: FhevmClient[\"decryptPublicValue\"] = async (parameters) => {\n await this.#base.init();\n return this.#base.decryptPublicValue({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters.options },\n });\n };\n\n /**\n * Batch form of {@link decryptPublicValue}: decrypts many publicly-decryptable\n * values in one relayer round-trip, returning their typed clear values in\n * order.\n *\n * @example\n * ```ts\n * const values = await relayer.decryptPublicValues({\n * encryptedValues: [handleA, handleB],\n * });\n * ```\n */\n decryptPublicValues: FhevmClient[\"decryptPublicValues\"] = async (parameters) => {\n await this.#base.init();\n return this.#base.decryptPublicValues({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters.options },\n });\n };\n\n /**\n * Like {@link decryptPublicValues}, but also returns the KMS signature bundle —\n * the handles list, ABI-encoded cleartexts, and decryption proof — needed to\n * verify or replay the result on-chain.\n *\n * @example\n * ```ts\n * const { clearValues, checkSignaturesArgs } =\n * await relayer.decryptPublicValuesWithSignatures({ encryptedValues: [handle] });\n * // checkSignaturesArgs: { handlesList, abiEncodedCleartexts, decryptionProof }\n * ```\n */\n decryptPublicValuesWithSignatures: FhevmClient[\"decryptPublicValuesWithSignatures\"] = async (\n parameters,\n ) => {\n await this.#base.init();\n return this.#base.decryptPublicValuesWithSignatures({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters.options },\n });\n };\n\n /**\n * Encrypts one typed input under the chain's FHE key, bound to the contract it\n * targets and the user submitting it, and returns the ciphertext handle plus\n * the input proof the contract verifies on-chain. `type` is the FHE type\n * with the `e` prefix (`\"euint64\"`, `\"ebool\"`, `\"eaddress\"`).\n *\n * @example\n * ```ts\n * const { encryptedValue, inputProof } = await relayer.encryptValue({\n * value: { type: \"euint64\", value: 1000n },\n * contractAddress: \"0xToken…\",\n * userAddress: \"0xUser…\",\n * });\n * ```\n */\n encryptValue: FhevmClient[\"encryptValue\"] = async (parameters) => {\n await this.#initEncrypt();\n return this.#encrypt.encryptValue({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters.options },\n });\n };\n\n /**\n * Batch form of {@link encryptValue}: encrypts several inputs for the same\n * contract and user in one call, returning all ciphertext handles under a\n * single shared input proof.\n *\n * @example\n * ```ts\n * const { encryptedValues, inputProof } = await relayer.encryptValues({\n * values: [\n * { type: \"euint64\", value: 1000n },\n * { type: \"ebool\", value: true },\n * ],\n * contractAddress: \"0xToken…\",\n * userAddress: \"0xUser…\",\n * });\n * ```\n */\n encryptValues: FhevmClient[\"encryptValues\"] = async (parameters) => {\n await this.#initEncrypt();\n return this.#encrypt.encryptValues({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters.options },\n });\n };\n\n /**\n * User-decrypts a single access-controlled value: the relayer re-encrypts it\n * to the ephemeral transport key pair, gated by the signed permit, and this\n * returns the typed clear value. Build the key pair with\n * {@link generateTransportKeyPair} and the permit with\n * {@link signDecryptionPermit}.\n *\n * @example\n * ```ts\n * const { type, value } = await relayer.decryptValue({\n * encryptedValue: handle,\n * contractAddress: \"0xToken…\",\n * transportKeyPair,\n * signedPermit,\n * });\n * ```\n */\n decryptValue: FhevmClient[\"decryptValue\"] = async (parameters) => {\n await this.#decrypt.init();\n return this.#decrypt.decryptValue({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters.options },\n });\n };\n\n /**\n * Batch form of {@link decryptValue} for values that all belong to the same\n * contract; returns the typed clear values positionally. For values spanning\n * multiple contracts, use {@link decryptValuesFromPairs}.\n *\n * @example\n * ```ts\n * const values = await relayer.decryptValues({\n * encryptedValues: [handleA, handleB],\n * contractAddress: \"0xToken…\",\n * transportKeyPair,\n * signedPermit,\n * });\n * ```\n */\n decryptValues: FhevmClient[\"decryptValues\"] = async (parameters) => {\n await this.#decrypt.init();\n return this.#decrypt.decryptValues({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters.options },\n });\n };\n\n /**\n * User-decrypts values that span multiple contracts: each pair carries its own\n * `contractAddress`, so one permit covering those contracts decrypts them all\n * in a single round-trip. Returns the typed clear values positionally.\n *\n * @example\n * ```ts\n * const values = await relayer.decryptValuesFromPairs({\n * pairs: [\n * { encryptedValue: handleA, contractAddress: \"0xTokenA…\" },\n * { encryptedValue: handleB, contractAddress: \"0xTokenB…\" },\n * ],\n * transportKeyPair,\n * signedPermit,\n * });\n * ```\n */\n decryptValuesFromPairs: FhevmClient[\"decryptValuesFromPairs\"] = async (parameters) => {\n await this.#decrypt.init();\n return this.#decrypt.decryptValuesFromPairs({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters.options },\n });\n };\n\n /**\n * Fetches the chain's raw FHE public-key bytes — the key encryption uses —\n * served from cache unless `ignoreCache` forces a refetch. Rarely called\n * directly: {@link encryptValue}/{@link encryptValues} fetch the key for you.\n *\n * @example\n * ```ts\n * const keyBytes = await relayer.fetchFheEncryptionKeyBytes();\n * const fresh = await relayer.fetchFheEncryptionKeyBytes({ ignoreCache: true });\n * ```\n */\n fetchFheEncryptionKeyBytes: FhevmClient[\"fetchFheEncryptionKeyBytes\"] = async (parameters) => {\n await this.#initEncrypt();\n return this.#encrypt.fetchFheEncryptionKeyBytes({\n ...parameters,\n options: { ...this.#defaultOptions, ...parameters?.options },\n });\n };\n\n /**\n * Builds the EIP-712 user-decrypt permit and signs it with the given signer,\n * authorizing the transport key pair to decrypt the listed contracts' values\n * for `durationSeconds` starting at `startTimestamp`. Pass `delegatorAddress`\n * to sign a delegated permit — decrypting values owned by that account instead\n * of the signer's own. Persist the result via\n * {@link serializeSignedDecryptionPermit}.\n *\n * @example\n * ```ts\n * const signedPermit = await relayer.signDecryptionPermit({\n * transportKeyPair,\n * contractAddresses: [\"0xToken…\"],\n * startTimestamp: Math.floor(Date.now() / 1000),\n * durationSeconds: 60 * 60 * 24,\n * signerAddress: \"0xUser…\",\n * signer,\n * // delegatorAddress: \"0xOwner…\", // omit for a self permit\n * });\n * ```\n */\n signDecryptionPermit: FhevmClient[\"signDecryptionPermit\"] = async (parameters) => {\n await this.#base.init();\n return this.#base.signDecryptionPermit(parameters);\n };\n\n // Permit/key-pair helpers carry no request options. Parsing initializes the\n // capability needed to validate the restored value; serialization stays local.\n\n /**\n * Serializes a transport key pair to a hex `{ publicKey, privateKey }` pair for\n * storage or transport, so a decryption session can resume without regenerating\n * keys. Reverse of {@link parseTransportKeyPair}. Purely local — no round-trip.\n *\n * @example\n * ```ts\n * const stored = relayer.serializeTransportKeyPair({ transportKeyPair });\n * // { publicKey: \"0x…\", privateKey: \"0x…\" }\n * ```\n */\n serializeTransportKeyPair: FhevmClient[\"serializeTransportKeyPair\"] = (parameters) =>\n this.#decrypt.serializeTransportKeyPair(parameters);\n\n /**\n * Serializes a signed permit to a plain, JSON-stringifiable object (version,\n * EIP-712 payload, signature, signer) for caching or transport. Reverse of\n * {@link parseSignedDecryptionPermit}. Purely local — no round-trip.\n *\n * @example\n * ```ts\n * const serialized = relayer.serializeSignedDecryptionPermit({ signedPermit });\n * localStorage.setItem(\"permit\", JSON.stringify(serialized));\n * ```\n */\n serializeSignedDecryptionPermit: FhevmClient[\"serializeSignedDecryptionPermit\"] = (parameters) =>\n this.#base.serializeSignedDecryptionPermit(parameters);\n\n /**\n * Rebuilds a transport key pair from its serialized hex\n * `{ publicKey, privateKey }` form. Reverse of {@link serializeTransportKeyPair}.\n *\n * @example\n * ```ts\n * const transportKeyPair = await relayer.parseTransportKeyPair({\n * publicKey: stored.publicKey,\n * privateKey: stored.privateKey,\n * });\n * ```\n */\n parseTransportKeyPair: FhevmClient[\"parseTransportKeyPair\"] = async (parameters) => {\n await this.#decrypt.init();\n return this.#decrypt.parseTransportKeyPair(parameters);\n };\n\n /**\n * Rebuilds a signed permit from its serialized form and validates it: checks\n * the EIP-712 structure, verifies the signature against the on-chain verifier,\n * and confirms the permit's public key matches `transportKeyPair`. Reverse of\n * {@link serializeSignedDecryptionPermit}.\n *\n * @throws if the permit is malformed, expired, or its signature is invalid.\n *\n * @example\n * ```ts\n * const signedPermit = await relayer.parseSignedDecryptionPermit({\n * serializedPermit,\n * transportKeyPair,\n * });\n * ```\n */\n parseSignedDecryptionPermit: FhevmClient[\"parseSignedDecryptionPermit\"] = async (parameters) => {\n await this.#base.init();\n return this.#base.parseSignedDecryptionPermit(parameters);\n };\n\n /**\n * Generates a fresh ephemeral transport key pair for a user-decrypt session.\n * The relayer re-encrypts decrypted values to this pair's public key, so only\n * the holder of the private key can read them; bind it to a permit via\n * {@link signDecryptionPermit}.\n *\n * @example\n * ```ts\n * const transportKeyPair = await relayer.generateTransportKeyPair();\n * ```\n */\n generateTransportKeyPair: FhevmClient[\"generateTransportKeyPair\"] = async () => {\n await this.#decrypt.init();\n return this.#decrypt.generateTransportKeyPair();\n };\n}\n\nfunction toFhevmAuth(\n auth: NonNullable<FheChain[\"auth\"]>,\n): NonNullable<FhevmRelayerOptions[\"auth\"]> {\n const type = auth[\"__type\"];\n switch (type) {\n case \"ApiKeyHeader\":\n return { type, value: auth.value, header: auth.header };\n case \"ApiKeyCookie\":\n return { type, value: auth.value, cookie: auth.cookie };\n case \"BearerToken\":\n return { type, token: auth.token };\n default:\n throw new ConfigurationError(`Unknown auth type: ${String(type)}`);\n }\n}\n"],"mappings":"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"}
@@ -1,5 +1,6 @@
1
- import { u as FheChain } from "./index-D66eC3G7.js";
2
- import { Ut as FhevmRelayerSDK, Vt as FhevmClient, Wt as RelayerOptions, c as GenericStorage, n as RelayerConfig } from "./types-C-WTLcHZ.js";
1
+ import { u as FheChain } from "./index-doNE2KoX.js";
2
+ import { Ut as FhevmRelayerSDK, Vt as FhevmClient, Wt as RelayerOptions, c as GenericStorage, n as RelayerConfig } from "./types-nwhfaUCK.js";
3
+ import "./cleartext-Bvx-0y6k.js";
3
4
  //#region src/relayer/fhevm-relayer.d.ts
4
5
  /** Construction config for {@link FhevmRelayer}. */
5
6
  interface FhevmRelayerConfig {
@@ -325,4 +326,4 @@ declare class AsyncLocalMapStorage implements GenericStorage {
325
326
  declare const asyncLocalStorage: AsyncLocalMapStorage;
326
327
  //#endregion
327
328
  export { node as i, asyncLocalStorage as n, NodeRelayerConfig as r, AsyncLocalMapStorage as t };
328
- //# sourceMappingURL=index-BnIp_-Ak.d.ts.map
329
+ //# sourceMappingURL=index-CDJk5ZAg.d.ts.map
@@ -1,5 +1,4 @@
1
1
  import { Address, EIP1193Provider } from "viem";
2
-
3
2
  //#region src/chains/types.d.ts
4
3
  /** Authentication forwarded to a chain's relayer endpoint. */
5
4
  type FheChainAuth = {
@@ -179,4 +178,4 @@ declare const anvil: {
179
178
  declare const chains: Record<number, FheChain>;
180
179
  //#endregion
181
180
  export { hoodi as a, sepolia as c, FheChainAuth as d, hardhat as i, AtLeastOneChain as l, bscTestnet as n, ingenTestnet as o, chains as r, mainnet as s, anvil as t, FheChain as u };
182
- //# sourceMappingURL=index-D66eC3G7.d.ts.map
181
+ //# sourceMappingURL=index-doNE2KoX.d.ts.map
@@ -1,12 +1,11 @@
1
- import { a as hoodi, c as sepolia, d as FheChainAuth, i as hardhat, l as AtLeastOneChain, n as bscTestnet, o as ingenTestnet, r as chains, s as mainnet, t as anvil, u as FheChain } from "./index-D66eC3G7.js";
2
- import { $ as TransferOptions, A as EncryptEndEvent, At as RawLog, B as TransferSubmittedEvent, Bt as EncryptedValue, C as ChainRouter, Ct as decodeUnwrapFinalized, D as DecryptErrorEvent, Dt as findRevokedDelegationForUserDecryption, E as DecryptEndEvent, Et as findDelegatedForUserDecryption, F as SetOperatorSubmittedEvent, Ft as DecryptValuesParameters, G as ZamaSDKEvent, Gt as TypedValue, H as UnshieldPhase2StartedEvent, I as ShieldSubmittedEvent, It as EIP712TypedData, J as ZamaSDKEventType, K as ZamaSDKEventInput, L as TransactionErrorEvent, Lt as EncryptInput, M as EncryptStartEvent, Mt as TransactionResult, N as FinalizeUnwrapSubmittedEvent, Nt as ClearValue, O as DecryptStartEvent, Ot as findUnwrapRequested, P as RevokeDelegationSubmittedEvent, Pt as DecryptPublicValuesResult, Q as ShieldPath, R as TransactionOperation, Rt as EncryptParams, S as WriteFunctionName, St as decodeRevokedDelegationForUserDecryption, T as BaseEvent, Tt as decodeWrap, U as UnshieldPhase2SubmittedEvent, Ut as FhevmRelayerSDK, V as UnshieldPhase1SubmittedEvent, W as UnwrapSubmittedEvent, X as ApprovalStrategy, Y as ZamaSDKEvents, Z as ShieldOptions, _ as ReadContractConfig, _t as decodeAclEvents, a as ZamaConfigBase, at as AclEvent, b as WriteContractArgs, bt as decodeOnChainEvent, c as GenericStorage, ct as DelegatedForUserDecryptionEvent, d as WalletAccount, dt as TOKEN_TOPICS, et as UnshieldOptions, f as WalletAccountChange, ft as Topics, g as ReadContractArgs, gt as decodeAclEvent, h as ContractAbi, ht as WrapEvent, i as ZamaConfig, it as ACL_TOPICS, j as EncryptErrorEvent, jt as TransactionReceipt, k as DelegationSubmittedEvent, kt as findWrap, l as GenericProvider, lt as OnChainEvent, m as WalletAccountStore, mt as UnwrapRequestedEvent, n as RelayerConfig, nt as TransferCallbacks, o as ZamaConfigGeneric, ot as AclTopics, p as WalletAccountListener, pt as UnwrapFinalizedEvent, q as ZamaSDKEventListener, rt as UnshieldCallbacks, s as GenericLogger, st as ConfidentialTransferEvent, t as CleartextRelayerConfig, tt as ShieldCallbacks, u as GenericSigner, ut as RevokedDelegationForUserDecryptionEvent, v as ReadContractReturnType, vt as decodeConfidentialTransfer, w as ApproveUnderlyingSubmittedEvent, wt as decodeUnwrapRequested, x as WriteContractConfig, xt as decodeOnChainEvents, y as ReadFunctionName, yt as decodeDelegatedForUserDecryption, z as TransferFromSubmittedEvent, zt as EncryptResult } from "./types-C-WTLcHZ.js";
3
- import { t as cleartext } from "./cleartext-U6sPs_Kd.js";
4
- import { t as ZamaConfigEthers } from "./types-BpvL50qX.js";
5
- import { n as MutableWalletAccountStore, r as createWalletAccountStore, t as BaseSigner } from "./base-signer-Q2EJECrc.js";
6
- import { $n as getTokenAddressContract, $t as DelegationSelfNotAllowedError, Ar as setOperatorContract, At as SignerRequiredError, Bt as InsufficientConfidentialBalanceError, Cr as confidentialTotalSupplyContract, Ct as BatchDecryptAsOptions, D as DecryptResult, Dr as inferredTotalSupplyContract, Dt as SigningFailedError, Er as finalizeUnwrapContract, Et as TransactionRevertedError, Fr as ResolvedChainRelayer, Ft as ConfigurationError, Gt as DelegationContractIsSelfError, Ht as DecryptionFailedError, Ir as resolveChainRelayers, It as RelayerRequestFailedError, Jt as DelegationExpirationTooSoonError, Kt as DelegationCooldownError, Lr as resolveStorage, Lt as BalanceCheckUnavailableError, Mr as unwrapContract, Mt as WalletNotConnectedError, Nr as unwrapFromBalanceContract, Nt as RpcRateLimitError, O as EncryptedInput, Or as isOperatorContract, Ot as SigningRejectedError, Pr as wrapContract, Pt as NotEntitledError, Qn as getConfidentialTokenAddressContract, Qt as DelegationNotPropagatedError, Rr as createConfig, Rt as BalanceErrorDetails, Sr as confidentialBalanceOfContract, St as BatchBalancesResult, Tr as confidentialTransferFromContract, Tt as matchZamaError, Ut as EncryptionFailedError, Vt as InsufficientERC20BalanceError, Wt as AclPausedError, Xn as TokenWrapperPair, Xt as DelegationExpiryUnchangedError, Yn as PaginatedResult, Yt as DelegationExpiredError, Zn as TokenWrapperPairWithMetadata, Zt as DelegationNotFoundError, _n as WrappersRegistryConfig, _r as approveContract, a as BatchDecryptItem, an as ZamaErrorCode, ar as delegateForUserDecryptionContract, bn as StoredTransportKeyPair, br as nameContract, cr as revokeDelegationContract, dr as ERC7984_INTERFACE_ID, en as InvalidTransportKeyPairError, er as getTokenPairContract, fr as ERC7984_WRAPPER_INTERFACE_ID, gn as WrappersRegistry, gr as allowanceContract, hn as ListPairsOptions, hr as supportsInterfaceContract, i as Decryption, in as ZamaError, ir as isConfidentialTokenValidContract, jr as underlyingContract, jt as WalletAccountNotReadyError, kr as rateContract, kt as SignerNotConfiguredError, lr as transferAndCallContract, mn as DefaultRegistryAddresses, mr as isConfidentialWrapperContract, n as Permits, nn as TransportKeyPairExpiredError, nr as getTokenPairsLengthContract, o as BatchDecryptResult, or as getDelegationExpiryContract, pr as isConfidentialTokenContract, qt as DelegationDelegateEqualsContractError, r as Delegations, rn as ChainMismatchError, rr as getTokenPairsSliceContract, s as DelegatedDecryptOptions, sr as isHandleDelegatedContract, t as ZamaSDK, tn as NoCiphertextError, tr as getTokenPairsContract, ur as ERC1363_INTERFACE_ID, vn as Permission, vr as balanceOfContract, wr as confidentialTransferContract, wt as Token, xr as symbolContract, xt as WrappedToken, yn as SerializedTransportKeyPair, yr as decimalsContract, zt as ERC20ReadFailedError } from "./zama-sdk-q4_qt64Q.js";
7
- import { t as ZamaConfigViem } from "./types-Bov8XY36.js";
1
+ import { a as hoodi, c as sepolia, d as FheChainAuth, i as hardhat, l as AtLeastOneChain, n as bscTestnet, o as ingenTestnet, r as chains, s as mainnet, t as anvil, u as FheChain } from "./index-doNE2KoX.js";
2
+ import { $ as TransferOptions, A as EncryptEndEvent, At as RawLog, B as TransferSubmittedEvent, Bt as EncryptedValue, C as ChainRouter, Ct as decodeUnwrapFinalized, D as DecryptErrorEvent, Dt as findRevokedDelegationForUserDecryption, E as DecryptEndEvent, Et as findDelegatedForUserDecryption, F as SetOperatorSubmittedEvent, Ft as DecryptValuesParameters, G as ZamaSDKEvent, Gt as TypedValue, H as UnshieldPhase2StartedEvent, I as ShieldSubmittedEvent, It as EIP712TypedData, J as ZamaSDKEventType, K as ZamaSDKEventInput, L as TransactionErrorEvent, Lt as EncryptInput, M as EncryptStartEvent, Mt as TransactionResult, N as FinalizeUnwrapSubmittedEvent, Nt as ClearValue, O as DecryptStartEvent, Ot as findUnwrapRequested, P as RevokeDelegationSubmittedEvent, Pt as DecryptPublicValuesResult, Q as ShieldPath, R as TransactionOperation, Rt as EncryptParams, S as WriteFunctionName, St as decodeRevokedDelegationForUserDecryption, T as BaseEvent, Tt as decodeWrap, U as UnshieldPhase2SubmittedEvent, Ut as FhevmRelayerSDK, V as UnshieldPhase1SubmittedEvent, W as UnwrapSubmittedEvent, X as ApprovalStrategy, Y as ZamaSDKEvents, Z as ShieldOptions, _ as ReadContractConfig, _t as decodeAclEvents, a as ZamaConfigBase, at as AclEvent, b as WriteContractArgs, bt as decodeOnChainEvent, c as GenericStorage, ct as DelegatedForUserDecryptionEvent, d as WalletAccount, dt as TOKEN_TOPICS, et as UnshieldOptions, f as WalletAccountChange, ft as Topics, g as ReadContractArgs, gt as decodeAclEvent, h as ContractAbi, ht as WrapEvent, i as ZamaConfig, it as ACL_TOPICS, j as EncryptErrorEvent, jt as TransactionReceipt, k as DelegationSubmittedEvent, kt as findWrap, l as GenericProvider, lt as OnChainEvent, m as WalletAccountStore, mt as UnwrapRequestedEvent, n as RelayerConfig, nt as TransferCallbacks, o as ZamaConfigGeneric, ot as AclTopics, p as WalletAccountListener, pt as UnwrapFinalizedEvent, q as ZamaSDKEventListener, rt as UnshieldCallbacks, s as GenericLogger, st as ConfidentialTransferEvent, t as CleartextRelayerConfig, tt as ShieldCallbacks, u as GenericSigner, ut as RevokedDelegationForUserDecryptionEvent, v as ReadContractReturnType, vt as decodeConfidentialTransfer, w as ApproveUnderlyingSubmittedEvent, wt as decodeUnwrapRequested, x as WriteContractConfig, xt as decodeOnChainEvents, y as ReadFunctionName, yt as decodeDelegatedForUserDecryption, z as TransferFromSubmittedEvent, zt as EncryptResult } from "./types-nwhfaUCK.js";
3
+ import { t as cleartext } from "./cleartext-Bvx-0y6k.js";
4
+ import { t as ZamaConfigEthers } from "./types-D8g0H49N.js";
5
+ import { n as MutableWalletAccountStore, r as createWalletAccountStore, t as BaseSigner } from "./base-signer-D5HdiBp1.js";
6
+ import { $n as TokenWrapperPairWithMetadata, $t as DelegationSelfNotAllowedError, Ar as isOperatorContract, At as SignerRequiredError, Br as createConfig, Bt as InsufficientConfidentialBalanceError, Cr as symbolContract, Ct as BatchDecryptAsOptions, D as DecryptResult, Dr as confidentialTransferFromContract, Dt as SigningFailedError, Er as confidentialTransferContract, Et as TransactionRevertedError, Fr as unwrapFromBalanceContract, Ft as ConfigurationError, Gt as DelegationContractIsSelfError, Ht as DecryptionFailedError, Ir as wrapContract, It as RelayerRequestFailedError, Jt as DelegationExpirationTooSoonError, Kt as DelegationCooldownError, Lr as ResolvedChainRelayer, Lt as BalanceCheckUnavailableError, Mr as setOperatorContract, Mt as WalletNotConnectedError, Nr as underlyingContract, Nt as RpcRateLimitError, O as EncryptedInput, Or as finalizeUnwrapContract, Ot as SigningRejectedError, Pr as unwrapContract, Pt as NotEntitledError, Qn as TokenWrapperPair, Qt as DelegationNotPropagatedError, Rr as resolveChainRelayers, Rt as BalanceErrorDetails, Sn as StoredTransportKeyPair, Sr as nameContract, St as BatchBalancesResult, Tr as confidentialTotalSupplyContract, Tt as matchZamaError, Ut as EncryptionFailedError, Vt as InsufficientERC20BalanceError, Wt as AclPausedError, Xt as DelegationExpiryUnchangedError, Yt as DelegationExpiredError, Zn as PaginatedResult, Zt as DelegationNotFoundError, _n as ListPairsOptions, _r as supportsInterfaceContract, a as BatchDecryptItem, an as ZamaErrorCode, ar as getTokenPairsSliceContract, bn as Permission, br as balanceOfContract, cr as getDelegationExpiryContract, dr as transferAndCallContract, en as InvalidTransportKeyPairError, er as getConfidentialTokenAddressContract, fr as ERC1363_INTERFACE_ID, gn as DefaultRegistryAddresses, gr as isConfidentialWrapperContract, hr as isConfidentialTokenContract, i as Decryption, in as ZamaError, ir as getTokenPairsLengthContract, jr as rateContract, jt as WalletAccountNotReadyError, kr as inferredTotalSupplyContract, kt as SignerNotConfiguredError, lr as isHandleDelegatedContract, mr as ERC7984_WRAPPER_INTERFACE_ID, n as Permits, nn as TransportKeyPairExpiredError, nr as getTokenPairContract, o as BatchDecryptResult, on as isRetryable, or as isConfidentialTokenValidContract, pr as ERC7984_INTERFACE_ID, qt as DelegationDelegateEqualsContractError, r as Delegations, rn as ChainMismatchError, rr as getTokenPairsContract, s as DelegatedDecryptOptions, sn as retryAfterSeconds, sr as delegateForUserDecryptionContract, t as ZamaSDK, tn as NoCiphertextError, tr as getTokenAddressContract, ur as revokeDelegationContract, vn as WrappersRegistry, vr as allowanceContract, wr as confidentialBalanceOfContract, wt as Token, xn as SerializedTransportKeyPair, xr as decimalsContract, xt as WrappedToken, yn as WrappersRegistryConfig, yr as approveContract, zr as resolveStorage, zt as ERC20ReadFailedError } from "./zama-sdk-aaLl2ZlA.js";
7
+ import { t as ZamaConfigViem } from "./types-CObfaH4A.js";
8
8
  import { Address, Hex } from "viem";
9
-
10
9
  //#region src/utils/handles.d.ts
11
10
  declare const ZERO_ENCRYPTED_VALUE: "0x0000000000000000000000000000000000000000000000000000000000000000";
12
11
  /**
@@ -76,5 +75,5 @@ declare class ChromeSessionStorage implements GenericStorage {
76
75
  /** Default singleton for application-wide use. */
77
76
  declare const chromeSessionStorage: ChromeSessionStorage;
78
77
  //#endregion
79
- export { ACL_TOPICS, type AclEvent, AclPausedError, AclTopics, type Address, type ApprovalStrategy, type ApproveUnderlyingSubmittedEvent, type AtLeastOneChain, BalanceCheckUnavailableError, type BalanceErrorDetails, type BaseEvent, BaseSigner, type BatchBalancesResult, type BatchDecryptAsOptions, type BatchDecryptItem, type BatchDecryptResult, ChainMismatchError, type ChainRouter, ChromeSessionStorage, type ClearValue, type CleartextRelayerConfig, type ConfidentialTransferEvent, ConfigurationError, type ContractAbi, type DecryptEndEvent, type DecryptErrorEvent, type EncryptedInput as DecryptInput, type DecryptPublicValuesResult, type DecryptResult, type DecryptStartEvent, type DecryptValuesParameters, Decryption, DecryptionFailedError, DefaultRegistryAddresses, type DelegatedDecryptOptions, type DelegatedForUserDecryptionEvent, DelegationContractIsSelfError, DelegationCooldownError, DelegationDelegateEqualsContractError, DelegationExpirationTooSoonError, DelegationExpiredError, DelegationExpiryUnchangedError, DelegationNotFoundError, DelegationNotPropagatedError, DelegationSelfNotAllowedError, type DelegationSubmittedEvent, Delegations, type EIP712TypedData, ERC1363_INTERFACE_ID, ERC20ReadFailedError, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, type EncryptEndEvent, type EncryptErrorEvent, type EncryptInput, type EncryptParams, type EncryptResult, type EncryptStartEvent, type EncryptedValue, EncryptionFailedError, type FheChain, type FheChainAuth, type FinalizeUnwrapSubmittedEvent, type GenericLogger, type GenericProvider, type GenericSigner, type GenericStorage, type Hex, IndexedDBStorage, InsufficientConfidentialBalanceError, InsufficientERC20BalanceError, InvalidTransportKeyPairError, type ListPairsOptions, MemoryStorage, MutableWalletAccountStore, NoCiphertextError, NotEntitledError, type OnChainEvent, type PaginatedResult, type Permission, Permits, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, type RelayerConfig, RelayerRequestFailedError, type FhevmRelayerSDK as RelayerSDK, type ResolvedChainRelayer, type RevokeDelegationSubmittedEvent, type RevokedDelegationForUserDecryptionEvent, RpcRateLimitError, type SerializedTransportKeyPair, type SetOperatorSubmittedEvent, type ShieldCallbacks, type ShieldOptions, type ShieldPath, type ShieldSubmittedEvent, SignerNotConfiguredError, SignerRequiredError, SigningFailedError, SigningRejectedError, type StoredTransportKeyPair, TOKEN_TOPICS, Token, type TokenWrapperPair, type TokenWrapperPairWithMetadata, Topics, type TransactionErrorEvent, type TransactionOperation, type TransactionReceipt, type TransactionResult, TransactionRevertedError, type TransferCallbacks, type TransferFromSubmittedEvent, type TransferOptions, type TransferSubmittedEvent, TransportKeyPairExpiredError, type TypedValue, type UnshieldCallbacks, type UnshieldOptions, type UnshieldPhase1SubmittedEvent, type UnshieldPhase2StartedEvent, type UnshieldPhase2SubmittedEvent, type UnwrapFinalizedEvent, type UnwrapRequestedEvent, type UnwrapSubmittedEvent, type WalletAccount, type WalletAccountChange, type WalletAccountListener, WalletAccountNotReadyError, type WalletAccountStore, WalletNotConnectedError, type WrapEvent, WrappedToken, WrappersRegistry, type WrappersRegistryConfig, type WriteContractArgs, type WriteContractConfig, type WriteFunctionName, ZERO_ENCRYPTED_VALUE, type ZamaConfig, type ZamaConfigBase, type ZamaConfigEthers, type ZamaConfigGeneric, type ZamaConfigViem, ZamaError, ZamaErrorCode, ZamaSDK, type ZamaSDKEvent, type ZamaSDKEventInput, type ZamaSDKEventListener, type ZamaSDKEventType, ZamaSDKEvents, allowanceContract, anvil, approveContract, balanceOfContract, bscTestnet, chains, chromeSessionStorage, cleartext, confidentialBalanceOfContract, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, createConfig, createWalletAccountStore, decimalsContract, decodeAclEvent, decodeAclEvents, decodeConfidentialTransfer, decodeDelegatedForUserDecryption, decodeOnChainEvent, decodeOnChainEvents, decodeRevokedDelegationForUserDecryption, decodeUnwrapFinalized, decodeUnwrapRequested, decodeWrap, delegateForUserDecryptionContract, finalizeUnwrapContract, findDelegatedForUserDecryption, findRevokedDelegationForUserDecryption, findUnwrapRequested, findWrap, getConfidentialTokenAddressContract, getDelegationExpiryContract, getTokenAddressContract, getTokenPairContract, getTokenPairsContract, getTokenPairsLengthContract, getTokenPairsSliceContract, hardhat, hoodi, indexedDBStorage, inferredTotalSupplyContract, ingenTestnet, isConfidentialTokenContract, isConfidentialTokenValidContract, isConfidentialWrapperContract, isEncryptedValueZero, isHandleDelegatedContract, isOperatorContract, mainnet, matchZamaError, memoryStorage, nameContract, rateContract, resolveChainRelayers, resolveStorage, revokeDelegationContract, sepolia, setOperatorContract, supportsInterfaceContract, symbolContract, transferAndCallContract, underlyingContract, unwrapContract, unwrapFromBalanceContract, wrapContract };
78
+ export { ACL_TOPICS, type AclEvent, AclPausedError, AclTopics, type Address, type ApprovalStrategy, type ApproveUnderlyingSubmittedEvent, type AtLeastOneChain, BalanceCheckUnavailableError, type BalanceErrorDetails, type BaseEvent, BaseSigner, type BatchBalancesResult, type BatchDecryptAsOptions, type BatchDecryptItem, type BatchDecryptResult, ChainMismatchError, type ChainRouter, ChromeSessionStorage, type ClearValue, type CleartextRelayerConfig, type ConfidentialTransferEvent, ConfigurationError, type ContractAbi, type DecryptEndEvent, type DecryptErrorEvent, type EncryptedInput as DecryptInput, type DecryptPublicValuesResult, type DecryptResult, type DecryptStartEvent, type DecryptValuesParameters, Decryption, DecryptionFailedError, DefaultRegistryAddresses, type DelegatedDecryptOptions, type DelegatedForUserDecryptionEvent, DelegationContractIsSelfError, DelegationCooldownError, DelegationDelegateEqualsContractError, DelegationExpirationTooSoonError, DelegationExpiredError, DelegationExpiryUnchangedError, DelegationNotFoundError, DelegationNotPropagatedError, DelegationSelfNotAllowedError, type DelegationSubmittedEvent, Delegations, type EIP712TypedData, ERC1363_INTERFACE_ID, ERC20ReadFailedError, ERC7984_INTERFACE_ID, ERC7984_WRAPPER_INTERFACE_ID, type EncryptEndEvent, type EncryptErrorEvent, type EncryptInput, type EncryptParams, type EncryptResult, type EncryptStartEvent, type EncryptedValue, EncryptionFailedError, type FheChain, type FheChainAuth, type FinalizeUnwrapSubmittedEvent, type GenericLogger, type GenericProvider, type GenericSigner, type GenericStorage, type Hex, IndexedDBStorage, InsufficientConfidentialBalanceError, InsufficientERC20BalanceError, InvalidTransportKeyPairError, type ListPairsOptions, MemoryStorage, MutableWalletAccountStore, NoCiphertextError, NotEntitledError, type OnChainEvent, type PaginatedResult, type Permission, Permits, type RawLog, type ReadContractArgs, type ReadContractConfig, type ReadContractReturnType, type ReadFunctionName, type RelayerConfig, RelayerRequestFailedError, type FhevmRelayerSDK as RelayerSDK, type ResolvedChainRelayer, type RevokeDelegationSubmittedEvent, type RevokedDelegationForUserDecryptionEvent, RpcRateLimitError, type SerializedTransportKeyPair, type SetOperatorSubmittedEvent, type ShieldCallbacks, type ShieldOptions, type ShieldPath, type ShieldSubmittedEvent, SignerNotConfiguredError, SignerRequiredError, SigningFailedError, SigningRejectedError, type StoredTransportKeyPair, TOKEN_TOPICS, Token, type TokenWrapperPair, type TokenWrapperPairWithMetadata, Topics, type TransactionErrorEvent, type TransactionOperation, type TransactionReceipt, type TransactionResult, TransactionRevertedError, type TransferCallbacks, type TransferFromSubmittedEvent, type TransferOptions, type TransferSubmittedEvent, TransportKeyPairExpiredError, type TypedValue, type UnshieldCallbacks, type UnshieldOptions, type UnshieldPhase1SubmittedEvent, type UnshieldPhase2StartedEvent, type UnshieldPhase2SubmittedEvent, type UnwrapFinalizedEvent, type UnwrapRequestedEvent, type UnwrapSubmittedEvent, type WalletAccount, type WalletAccountChange, type WalletAccountListener, WalletAccountNotReadyError, type WalletAccountStore, WalletNotConnectedError, type WrapEvent, WrappedToken, WrappersRegistry, type WrappersRegistryConfig, type WriteContractArgs, type WriteContractConfig, type WriteFunctionName, ZERO_ENCRYPTED_VALUE, type ZamaConfig, type ZamaConfigBase, type ZamaConfigEthers, type ZamaConfigGeneric, type ZamaConfigViem, ZamaError, ZamaErrorCode, ZamaSDK, type ZamaSDKEvent, type ZamaSDKEventInput, type ZamaSDKEventListener, type ZamaSDKEventType, ZamaSDKEvents, allowanceContract, anvil, approveContract, balanceOfContract, bscTestnet, chains, chromeSessionStorage, cleartext, confidentialBalanceOfContract, confidentialTotalSupplyContract, confidentialTransferContract, confidentialTransferFromContract, createConfig, createWalletAccountStore, decimalsContract, decodeAclEvent, decodeAclEvents, decodeConfidentialTransfer, decodeDelegatedForUserDecryption, decodeOnChainEvent, decodeOnChainEvents, decodeRevokedDelegationForUserDecryption, decodeUnwrapFinalized, decodeUnwrapRequested, decodeWrap, delegateForUserDecryptionContract, finalizeUnwrapContract, findDelegatedForUserDecryption, findRevokedDelegationForUserDecryption, findUnwrapRequested, findWrap, getConfidentialTokenAddressContract, getDelegationExpiryContract, getTokenAddressContract, getTokenPairContract, getTokenPairsContract, getTokenPairsLengthContract, getTokenPairsSliceContract, hardhat, hoodi, indexedDBStorage, inferredTotalSupplyContract, ingenTestnet, isConfidentialTokenContract, isConfidentialTokenValidContract, isConfidentialWrapperContract, isEncryptedValueZero, isHandleDelegatedContract, isOperatorContract, isRetryable, mainnet, matchZamaError, memoryStorage, nameContract, rateContract, resolveChainRelayers, resolveStorage, retryAfterSeconds, revokeDelegationContract, sepolia, setOperatorContract, supportsInterfaceContract, symbolContract, transferAndCallContract, underlyingContract, unwrapContract, unwrapFromBalanceContract, wrapContract };
80
79
  //# sourceMappingURL=index.d.ts.map
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{i as e,n as t,r as n,t as r}from"./relayer-BYq9bLh8.js";import{A as i,B as a,C as o,D as s,F as c,H as l,I as u,L as d,M as f,N as p,O as ee,P as te,R as ne,S as re,T as ie,U as ae,V as oe,W as se,_ as ce,a as le,b as ue,c as de,d as fe,f as pe,g as m,h,i as me,j as he,k as ge,l as _e,m as ve,n as ye,o as be,p as xe,r as Se,s as Ce,t as we,u as Te,v as Ee,x as De,z as Oe}from"./wrappers-registry-xZWzyAi4.js";import{A as ke,C as Ae,D as je,E as g,F as _,M as v,N as y,O as Me,P as b,S as Ne,T as Pe,_ as Fe,a as Ie,c as Le,d as Re,f as ze,g as Be,h as Ve,i as x,j as He,k as Ue,l as S,m as We,n as Ge,o as C,p as Ke,r as qe,s as Je,t as w,u as T,v as E,w as Ye,x as Xe,y as Ze}from"./token-CmHTAAWW.js";import{t as Qe}from"./cleartext-BfXTVQu-.js";import{a as $e,c as et,d as tt,f as nt,g as rt,h as it,i as at,l as ot,m as st,n as ct,o as D,p as lt,r as ut,s as dt,t as ft,u as O}from"./base-signer-CI-FYai2.js";import{a as pt,c as mt,i as ht,n as gt,o as _t,r as vt,s as yt,t as bt}from"./chains-CLv9HEJ_.js";import{getAddress as k,keccak256 as xt,toBytes as St}from"viem";import{z as A}from"zod/mini";function Ct(e,t){if(e instanceof n){let n=t[e.code];if(n)return n(e)}return t._?.(e)}var wt=class extends n{constructor(t,n){super(e.TransportKeyPairExpired,t,n),this.name=`TransportKeyPairExpiredError`}},Tt=class extends n{constructor(t,n){super(e.InvalidTransportKeyPair,t,n),this.name=`InvalidTransportKeyPairError`}},j=class extends n{constructor(t,n){super(e.NoCiphertext,t,n),this.name=`NoCiphertextError`}},M=class extends n{encryptedValue;contractAddress;account;constructor(t,n){super(e.NotEntitled,`Account ${t.account} is not entitled to decrypt encrypted value ${t.encryptedValue} on contract ${t.contractAddress}. This is not a transient failure — the account needs an on-chain ACL grant before it can decrypt this encrypted value.`,n),this.name=`NotEntitledError`,this.encryptedValue=t.encryptedValue,this.contractAddress=t.contractAddress,this.account=t.account}},N=class extends n{constructor(t,n){super(e.DelegationSelfNotAllowed,t,n),this.name=`DelegationSelfNotAllowedError`}},Et=class extends n{constructor(t,n){super(e.DelegationCooldown,t,n),this.name=`DelegationCooldownError`}},P=class extends n{constructor(t,n){super(e.DelegationNotFound,t,n),this.name=`DelegationNotFoundError`}},F=class extends n{constructor(t,n){super(e.DelegationExpired,t,n),this.name=`DelegationExpiredError`}},I=class extends n{constructor(t,n){super(e.DelegationExpiryUnchanged,t,n),this.name=`DelegationExpiryUnchangedError`}},L=class extends n{constructor(t,n){super(e.DelegationDelegateEqualsContract,t,n),this.name=`DelegationDelegateEqualsContractError`}},Dt=class extends n{constructor(t,n){super(e.DelegationContractIsSelf,t,n),this.name=`DelegationContractIsSelfError`}},Ot=class extends n{constructor(t,n){super(e.AclPaused,t,n),this.name=`AclPausedError`}},R=class extends n{constructor(t,n){super(e.DelegationExpirationTooSoon,t,n),this.name=`DelegationExpirationTooSoonError`}},z=class extends n{constructor(t,n){super(e.DelegationNotPropagated,t,n),this.name=`DelegationNotPropagatedError`}};function B(e,n,r={}){if(e instanceof b||e instanceof j||e instanceof t||e instanceof z||e instanceof se||e instanceof ae||e instanceof M||e instanceof v)return e;let i=e instanceof Error?e.message:n;if(e instanceof Error&&Xe(e.message))return r.isDelegated?new z(`Delegated decryption was denied by the on-chain ACL check. This is most commonly caused by the delegation not having propagated yet, or by the RPC node serving a stale block. Propagation usually completes within ~10 blocks (a few seconds) and the SDK retries across that window; seeing this means it did not sync in time. Retry shortly (and prefer a fresh, low-lag RPC endpoint). If it persists, the delegator may genuinely lack the on-chain ACL grant.`,{cause:e}):new M({encryptedValue:Pe(e.message)??``,contractAddress:r.contractAddress??``,account:r.account??``},{cause:e});if(Ze(e))return new v(i,{cause:e,retryAfter:E(e)});let a=Fe(e);return a===void 0&&Ye(e)?new v(i,{cause:e,retryAfter:E(e)}):a===400?new j(e instanceof Error?e.message:`No ciphertext for this account`,{cause:e}):r.isDelegated&&a===500?new z(`Delegated decryption failed with a server error. This is most commonly caused by the delegation not having propagated to the gateway yet. Cross-chain sync usually completes within ~10 blocks (a few seconds) and the SDK retries across that window; seeing this means it did not sync in time — retry shortly. If the error persists, the gateway or relayer may be experiencing an unrelated issue.`,{cause:e}):Ne(e)||a!==void 0?new t(i,a,{cause:e,retryAfter:E(e),retryable:Ae(e)||void 0}):new b(n,{cause:e})}function kt(e,r){if(e instanceof n)return e;let i=Fe(e),a=Ae(e);return i!==void 0||Ne(e)?new t(e instanceof Error?e.message:r,i,{cause:e,retryAfter:E(e),retryable:a||void 0}):new _(r,{cause:e})}const At=[{type:`function`,name:`allowance`,inputs:[{name:`owner`,type:`address`,internalType:`address`},{name:`spender`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`approve`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`balanceOf`,inputs:[{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`supportsInterface`,inputs:[{name:`interfaceId`,type:`bytes4`,internalType:`bytes4`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`totalSupply`,inputs:[],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`transfer`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFrom`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`event`,name:`Approval`,inputs:[{name:`owner`,type:`address`,indexed:!0,internalType:`address`},{name:`spender`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1},{type:`event`,name:`Transfer`,inputs:[{name:`from`,type:`address`,indexed:!0,internalType:`address`},{name:`to`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1}];function jt(e,t,n,r=`0x`){return{address:e,abi:At,functionName:`transferAndCall`,args:[t,n,r]}}function Mt(e){return at(e.signer,e.provider,e)}function V(e){return e.startsWith(`0x`)?e:`0x${e}`}var Nt=class{#e;#t;#n;#r;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.router,this.#r=e.decryptionService}#i(e){return l(this.#r,e)}async decryptValues(e,t){let n=this.#i(`decryptValues`),r=await S(`decryptValues`,this.#e,this.#t);return n.decryptValues(e,r.address,t)}async delegatedDecryptValues(e,t,n=t,r){let i=this.#i(`delegatedDecryptValues`),a=await S(`delegatedDecryptValues`,this.#e,this.#t);return i.delegatedDecryptValues(e,t,a.address,n,r)}async decryptPublicValues(e,t){if(e.length===0)return{clearValues:{},decryptionProof:`0x`,abiEncodedClearValues:`0x`};try{let n=await this.#n.relayer.decryptPublicValuesWithSignatures({encryptedValues:e,options:t}),r={};return n.checkSignaturesArgs.handlesList.forEach((e,t)=>{Le(n.clearValues[t],`result.clearValues[${t}]`),r[e]=n.clearValues[t].value}),{clearValues:r,abiEncodedClearValues:n.checkSignaturesArgs.abiEncodedCleartexts,decryptionProof:n.checkSignaturesArgs.decryptionProof}}catch(e){throw B(e,`Public decryption failed`)}}async delegatedBatchDecryptValues({encryptedInputs:e,delegatorAddress:t,accountAddress:n=t,maxConcurrency:r,waitForPropagation:i}){let a=this.#i(`delegatedBatchDecryptValues`),o=await S(`delegatedBatchDecryptValues`,this.#e,this.#t);return a.delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:o.address,accountAddress:n,maxConcurrency:r,waitForPropagation:i})}},Pt=class{#e;#t;#n;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.delegationService}#r(e){return l(this.#e,e)}async delegateDecryption({contractAddress:e,delegateAddress:t,expirationDate:n}){let r=this.#r(`delegateDecryption`),i=await S(`delegateDecryption`,this.#e,this.#t);return this.#n.delegateDecryption(r,{contractAddress:e,delegateAddress:t,delegatorAddress:i.address,expirationDate:n})}async revokeDelegation({contractAddress:e,delegateAddress:t}){let n=this.#r(`revokeDelegation`),r=await S(`revokeDelegation`,this.#e,this.#t);return this.#n.revokeDelegation(n,{contractAddress:e,delegateAddress:t,delegatorAddress:r.address})}async isActive(e){return this.#n.isDelegated(e)}async getExpiry(e){return this.#n.getDelegationExpiry(e)}},Ft=class{#e;#t;#n;#r;#i;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger}#a(e){return l(this.#r,e)}async grantPermit(e){if(e.length===0)return;let t=this.#a(`grantPermit`);await T(`grantPermit`,this.#e,this.#t),await t.grantPermit(e)}async grantDelegationPermit(e,t){if(t.length===0)return;let n=this.#a(`grantDelegationPermit`);await T(`grantDelegationPermit`,this.#e,this.#t),await n.grantPermit(t,e)}async hasPermit(e){return this.#r?this.#r.hasPermit(e):!1}async hasDelegationPermit(e,t){return this.#r?this.#r.hasPermit(t,e):!1}async warmTransportKeyPair(){let e=this.#r;if(!e)return;let t=this.#e?.walletAccount.getSnapshot();t&&await e.warmTransportKeyPair(t.address)}async revokePermits(e){let t=this.#a(`revokePermits`),n=k((await S(`revokePermits`,this.#e,this.#t)).address);try{await t.revokePermits(e)}finally{await d(`clear decrypt cache`,()=>this.#n.clearForRequester(n),this.#i)}}async clear(){let e=this.#a(`clear`),t=k((await S(`clear`,this.#e,this.#t)).address);try{await e.clearCredentials()}finally{await d(`clear decrypt cache`,()=>this.#n.clearForRequester(t),this.#i)}}};const It=A.union([A.bigint(),A.boolean(),ot]),Lt=A.array(A.string());var Rt=class{#e;#t;#n=`zama:decrypt`;#r=`${this.#n}:keys`;#i=Promise.resolve();constructor(e,t){this.#e=e,this.#t=t}async get(e,t,n){try{let r=this.#c(e,t,n),i=await this.#e.get(r);if(i===null)return null;let a=It.safeParse(i);return a.success?a.data:(await this.delete(e,t,n),null)}catch(e){return this.#t.warn(`CachingService.get failed`,{error:e}),null}}async set(e,t,n,r){try{let i=this.#c(e,t,n);await this.#e.set(i,r),this.#i=this.#i.then(()=>this.#u(i).catch(e=>{this.#t.warn(`CachingService index write failed`,{error:e})})),await this.#i}catch(e){this.#t.warn(`CachingService.set failed`,{error:e})}}async delete(e,t,n){let r=this.#c(e,t,n);this.#i=this.#i.then(()=>this.#a(r).catch(e=>{this.#t.warn(`CachingService.delete failed`,{error:e})})),await this.#i}async clearForRequester(e){this.#i=this.#i.then(()=>this.#o(e).catch(e=>{this.#t.warn(`CachingService.clearForRequester failed`,{error:e})})),await this.#i}async clearAll(){this.#i=this.#i.then(()=>this.#s().catch(e=>{this.#t.warn(`CachingService.clearAll failed`,{error:e})})),await this.#i}async#a(e){await this.#e.delete(e).catch(()=>{});let t=await this.#l(),n=t.filter(t=>t!==e);n.length!==t.length&&await this.#e.set(this.#r,n)}async#o(e){let t=k(e),n=`${this.#n}:${t}:`,r=await this.#l(),i=[],a=[];for(let e of r)e.startsWith(n)?i.push(e):a.push(e);await Promise.all(i.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.set(this.#r,a)}async#s(){let e=await this.#l();await Promise.all(e.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.delete(this.#r)}#c(e,t,n){return`${this.#n}:${k(e)}:${k(t)}:${n.toLowerCase()}`}async#l(){let e=await this.#e.get(this.#r);if(e===null)return[];let t=Lt.safeParse(e);return t.success?t.data:(await this.#e.delete(this.#r).catch(()=>{}),[])}async#u(e){let t=await this.#l();t.includes(e)||(t.push(e),await this.#e.set(this.#r,t))}};function zt(e,t){let n=Bt(e,t);if(!n)throw new b(`No permit covers contract ${t} after allow()`);return{privateKey:e.keypair.privateKey,publicKey:e.keypair.publicKey,serializedPermit:n.serializedPermit}}function Bt(e,t){let n=et(t);return e.permissions.find(e=>e.contractAddresses.includes(n))}const Vt=e=>new Promise(t=>setTimeout(t,e));var Ht=class{#e;#t;#n;#r;#i;constructor({cache:e,credentialService:t,delegationService:n,router:r,emitEvent:i}){this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#i=i}async decryptValues(e,t,n){let r=k(t);return this.#s(e,{requesterAddress:r,aclActorAddress:r,resolveCredentials:e=>this.#t.grantPermit(e),decryptContract:({credentials:e,contractAddress:t,encryptedValues:n,options:r})=>this.#o(e,t,n,r),errorMessage:`Failed to decrypt encrypted values`},n)}async delegatedDecryptValues(e,t,n,r,i){let a=k(t),o=k(n);return this.#a(i?.waitForPropagation??!0,()=>this.#s(e,{requesterAddress:k(r),aclActorAddress:a,resolveCredentials:e=>this.#t.grantPermit(e,a),validate:e=>this.#f(e,{delegatorAddress:a,delegateAddress:o}),decryptContract:({credentials:e,contractAddress:t,encryptedValues:n,options:r})=>this.#o(e,t,n,r),errorMessage:`Failed to decrypt delegated encrypted values`,delegated:!0}))}async#a(e,t){let n;for(let r=0;r<16;r++)try{return await t()}catch(t){if(n=t,!(r<15&&e&&t instanceof z))throw t;await Vt(2e3)}throw n}async delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:n,accountAddress:r,maxConcurrency:i=5,waitForPropagation:a=!0}){let o=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:k(e.contractAddress)}));if(o.length===0)return{items:o};let s=k(r);try{let e=await this.delegatedDecryptValues(o.map(({encryptedValue:e,contractAddress:t})=>({encryptedValue:e,contractAddress:t})),t,n,s,{waitForPropagation:a});for(let t of o)this.#l(t,e);return{items:o}}catch(e){if(Be(e))throw e;if(o.length===1){let[n=this.#d()]=o;return n.error=this.#u(e,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:n.contractAddress,account:k(t)}),{items:o}}}let c=!1;return await Ie(o.map(e=>async()=>{if(!c)try{let r=await this.delegatedDecryptValues([{encryptedValue:e.encryptedValue,contractAddress:e.contractAddress}],t,n,s,{waitForPropagation:!1});this.#l(e,r)}catch(n){if(Be(n))throw c=!0,n;e.error=this.#u(n,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:e.contractAddress,account:k(t)})}}),i),{items:o}}async#o(e,t,n,r){let i=zt(e,t),a=await this.#r.relayer.parseTransportKeyPair({publicKey:i.publicKey,privateKey:i.privateKey}),o=await this.#r.relayer.parseSignedDecryptionPermit({transportKeyPair:a,serializedPermit:i.serializedPermit});return this.#r.relayer.decryptValues({transportKeyPair:a,signedPermit:o,encryptedValues:n,contractAddress:t,options:r})}async#s(e,t,r){if(e.length===0)return{};let i=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:k(e.contractAddress)})),a={},o=[];for(let e of i)x(e.encryptedValue)?a[e.encryptedValue]=0n:o.push(e);if(o.length===0)return a;let s=Array.from(new Set(i.map(e=>e.contractAddress))),c=Array.from(new Set(o.map(e=>e.contractAddress)));if(t.validate)try{await t.validate(c)}catch(e){throw Ye(e)?this.#c(e,`the delegation pre-check`):e}let l=[];for(let e of o){let n=await this.#e.get(t.requesterAddress,e.contractAddress,e.encryptedValue);n===null?l.push(e):a[e.encryptedValue]=n}if(l.length===0)return a;let u=await t.resolveCredentials(s),d=new Map;for(let e of l){let t=d.get(e.contractAddress);t?t.push(e.encryptedValue):d.set(e.contractAddress,[e.encryptedValue])}let f=Date.now(),p=l.map(e=>e.encryptedValue);try{this.#i({type:C.DecryptStart,encryptedValues:p}),await Ie([...d.entries()].map(([e,n])=>async()=>{let i;try{i=await t.decryptContract({credentials:u,contractAddress:e,encryptedValues:n,options:r})}catch(n){throw B(n,t.errorMessage,{isDelegated:t.delegated,contractAddress:e,account:t.aclActorAddress})}for(let r=0;r<n.length;r++){let o=n[r],s=i[r]?.value;o===void 0||s===void 0||(a[o]=s,await this.#e.set(t.requesterAddress,e,o,s))}let o=n.filter(e=>a[e]===void 0);if(o.length>0)throw new b(`${t.errorMessage}: relayer returned no clear value for ${o.length} of ${n.length} handle(s) on ${e}`,{cause:AggregateError(o.map(t=>new b(`No clear value for handle ${t} on ${e}`)),`${o.length} handle(s) missing a clear value on ${e}`)})}),5);let e={};for(let t of p){let n=a[t];n!==void 0&&(e[t]=n)}return this.#i({type:C.DecryptEnd,durationMs:Date.now()-f,encryptedValues:p,result:e}),a}catch(e){let r=e instanceof n&&e.cause instanceof Error?e.cause:e;throw this.#i({type:C.DecryptError,error:g(r),durationMs:Date.now()-f,encryptedValues:p}),B(e,t.errorMessage,{isDelegated:t.delegated})}}#c(e,t){return new v(`RPC provider rate-limited ${t}; retry with backoff.`,{cause:e,retryAfter:E(e)})}#l(e,t){let n=t[e.encryptedValue];if(n===void 0){e.error=new b(`Batch delegated decryption returned no value for encrypted value ${e.encryptedValue} on contract ${e.contractAddress}`);return}e.value=n}#u(e,t,r){return e instanceof n?e:B(e,t,r)}#d(){throw new b(`Batch delegated decryption invariant failed: missing item`)}async#f(e,{delegatorAddress:t,delegateAddress:n}){let r=await this.#n.findInactiveDelegations(e,t,n);if(r.size!==0)for(let e of r.values())throw e}};function Ut(e){if(!(e instanceof Error))return null;let t=e.cause;if(typeof t!=`object`||!t||!(`data`in t))return null;let{data:n}=t;return typeof n!=`object`||!n||!(`errorName`in n)?null:typeof n.errorName==`string`?n.errorName:null}const H={AlreadyDelegatedOrRevokedInSameBlock:e=>new Et(`Only one delegate/revoke per (delegator, delegate, contract) per block. Wait for the next block before retrying.`,{cause:e}),SenderCannotBeContractAddress:e=>new Dt(`The contract address cannot be the caller address.`,{cause:e}),EnforcedPause:e=>new Ot(`The ACL contract is paused. Delegation operations are temporarily disabled.`,{cause:e}),SenderCannotBeDelegate:e=>new N(`Cannot delegate to yourself (delegate === msg.sender).`,{cause:e}),DelegateCannotBeContractAddress:e=>new L(`Delegate address cannot be the same as the contract address.`,{cause:e}),ExpirationDateBeforeOneHour:e=>new R(`Expiration date must be at least 1 hour in the future.`,{cause:e}),ExpirationDateAlreadySetToSameValue:e=>new I(`The new expiration date is the same as the current one.`,{cause:e}),NotDelegatedYet:e=>new P(`Cannot revoke: no active delegation exists.`,{cause:e})};function Wt(e){return e in H}function Gt(e,t){let n=Ut(e);if(n&&Wt(n))return H[n](t);let r=e instanceof Error?e.message:String(e);for(let[e,n]of Object.entries(H))if(r.includes(e))return n(t);return null}var Kt=class{#e;#t;#n;#r;constructor({provider:e,router:t,emitEvent:n=()=>{},logger:r}){this.#t=e,this.#e=t,this.#r=r,this.#n=n}async delegateDecryption(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r,expirationDate:i}){if(i&&i.getTime()<Date.now()+36e5)throw new R(`Expiration date must be at least 1 hour in the future`);let a=k(t),o=k(n),s=k(r);if(o===s)throw new N(`Cannot delegate to yourself (delegate === msg.sender).`);if(o===a)throw new L(`Delegate address cannot be the same as the contract address (${a}).`);let c=this.#e.relayer.chain.aclContractAddress,l=i?BigInt(Math.floor(i.getTime()/1e3)):Re,u;try{u=await this.getDelegationExpiry({contractAddress:a,delegatorAddress:s,delegateAddress:o})}catch(e){this.#r.warn(`delegateDecryption: pre-flight expiry check failed`,{error:e}),u=-1n}if(u===l)throw new I(`The new expiration date (${l}) is the same as the current one. No on-chain change needed.`);return this.#i({operation:`delegateDecryption`,signer:e,contractAddress:t,config:ze(c,o,a,l)})}async revokeDelegation(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r}){let i=k(t),a=k(n),o=k(r),s=this.#e.relayer.chain.aclContractAddress,c;try{c=await this.getDelegationExpiry({contractAddress:i,delegatorAddress:o,delegateAddress:a})}catch(e){this.#r.warn(`revokeDelegation: pre-flight expiry check failed`,{error:e}),c=1n}if(c===0n)throw new P(`No active delegation found for delegate ${a} on contract ${i}.`);return this.#i({operation:`revokeDelegation`,signer:e,contractAddress:t,config:Ve(s,a,i)})}async isDelegated(e){let t=await this.getDelegationExpiry(e);return t===0n?!1:t===Re?!0:t>await this.#t.getBlockTimestamp()}async getDelegationExpiry({contractAddress:e,delegatorAddress:t,delegateAddress:n}){let r=this.#e.relayer.chain.aclContractAddress;return this.#t.readContract(Ke(r,k(t),k(n),k(e)))}async#i({operation:e,signer:t,contractAddress:n,config:r}){try{return await Ge({operation:e,signer:t,provider:this.#t,config:r,emit:e=>this.#n(e,n),logger:this.#r})}catch(e){throw this.#a(e),e}}#a(e){if(!(e instanceof y))return;let t=Gt(e.cause??e,e);if(t)throw t}async findInactiveDelegations(e,t,n){let r=new Map;return await Promise.all(e.map(async e=>{try{await this.assertDelegationActive(e,t,n)}catch(t){if(t instanceof P||t instanceof F){let n=k(e);r.set(n,t);return}throw t}})),r}async assertDelegationActive(e,t,n){let r=k(e),i=k(t),a=k(n),o=await this.getDelegationExpiry({contractAddress:r,delegatorAddress:i,delegateAddress:a});if(o===0n)throw new P(`No active delegation from ${i} to ${a} for ${r}`);if(o!==Re&&o<=await this.#t.getBlockTimestamp())throw new F(`Delegation from ${i} to ${a} for ${r} has expired`)}},qt=class{#e;#t;constructor({router:e,emitEvent:t}){this.#e=e,this.#t=t}async encryptValues(e,t){let n=Date.now(),r=k(e.contractAddress);try{this.#t({type:C.EncryptStart},r);let i=await this.#e.relayer.encryptValues({...e,options:t});return this.#t({type:C.EncryptEnd,durationMs:Date.now()-n},r),i}catch(e){throw this.#t({type:C.EncryptError,error:g(e),durationMs:Date.now()-n},r),kt(e,`Encryption failed`)}}},Jt=class{#e;#t;#n;#r;#i;#a=new Set;#o;constructor(e){this.#e=e.signer,this.#t=e.router,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger,this.#e&&(this.#o=this.#e.walletAccount.subscribe(e=>{this.#s(e).catch(e=>{this.#i.warn(`wallet account handler failed`,{error:e})})}))}onWalletAccountChange(e){return this.#a.add(e),()=>{this.#a.delete(e)}}dispose(){this.#o?.(),this.#o=void 0,this.#a.clear()}async#s(e){let t=e.previous,n=e.next,r=n?.chainId;r!==void 0&&await d(`switch relayer chain`,()=>this.#t.switchChain(r),this.#i);let i=this.#r;i&&await d(`credential wallet account change`,()=>i.handleWalletAccountChange(t,n),this.#i),t&&await d(`clear decrypt cache`,()=>this.#n.clearForRequester(t.address),this.#i),await Promise.all(Array.from(this.#a,t=>d(`wallet account listener`,()=>t(e),this.#i)))}};function U(e){return xt(St(e))}const W={ConfidentialTransfer:U(`ConfidentialTransfer(address,address,bytes32)`),Wrap:U(`Wrap(address,uint256,bytes32)`),UnwrapRequested:U(`UnwrapRequested(address,bytes32,bytes32)`),UnwrapFinalized:U(`UnwrapFinalized(address,bytes32,bytes32,uint64)`)};function G(e){return k(V(e.slice(-40)))}function K(e){return e}function q(e,t){let n=2+t*64,r=e.slice(n,n+64);return r.length===64?r:r.padEnd(64,`0`)}function Yt(e,t){return k(V(q(e,t).slice(-40)))}function J(e,t){return BigInt(`0x`+q(e,t))}function Y(e,t){return V(q(e,t))}function Xt(e){return e.topics[0]!==W.ConfidentialTransfer||e.topics.length<4?null:{eventName:`ConfidentialTransfer`,from:G(e.topics[1]),to:G(e.topics[2]),encryptedAmount:K(e.topics[3])}}function X(e){return e.topics[0]!==W.Wrap||e.topics.length<2?null:{eventName:`Wrap`,to:G(e.topics[1]),roundedAmount:J(e.data,0),encryptedWrappedAmount:Y(e.data,1)}}function Zt(e){return e.topics[0]!==W.UnwrapRequested||e.topics.length<3?null:{eventName:`UnwrapRequested`,receiver:G(e.topics[1]),unwrapRequestId:K(e.topics[2]),encryptedAmount:Y(e.data,0)}}function Qt(e){return e.topics[0]!==W.UnwrapFinalized||e.topics.length<3?null:{eventName:`UnwrapFinalized`,receiver:G(e.topics[1]),unwrapRequestId:K(e.topics[2]),encryptedAmount:Y(e.data,0),cleartextAmount:J(e.data,1)}}function $t(e){return Xt(e)??X(e)??Zt(e)??Qt(e)}function en(e){let t=[];for(let n of e){let e=$t(n);e&&t.push(e)}return t}function tn(e){for(let t of e){let e=Zt(t);if(e)return e}return null}function nn(e){for(let t of e){let e=X(t);if(e)return e}return null}const rn=[W.ConfidentialTransfer,W.Wrap,W.UnwrapRequested,W.UnwrapFinalized],Z={DelegatedForUserDecryption:U(`DelegatedForUserDecryption(address,address,address,uint64,uint64,uint64)`),RevokedDelegationForUserDecryption:U(`RevokedDelegationForUserDecryption(address,address,address,uint64,uint64)`)};function an(e){return e.topics[0]!==Z.DelegatedForUserDecryption||e.topics.length<3?null:{eventName:`DelegatedForUserDecryption`,delegator:G(e.topics[1]),delegate:G(e.topics[2]),contractAddress:Yt(e.data,0),delegationCounter:J(e.data,1),oldExpirationDate:J(e.data,2),newExpirationDate:J(e.data,3)}}function Q(e){return e.topics[0]!==Z.RevokedDelegationForUserDecryption||e.topics.length<3?null:{eventName:`RevokedDelegationForUserDecryption`,delegator:G(e.topics[1]),delegate:G(e.topics[2]),contractAddress:Yt(e.data,0),delegationCounter:J(e.data,1),oldExpirationDate:J(e.data,2)}}function on(e){return an(e)??Q(e)}function sn(e){let t=[];for(let n of e){let e=on(n);e&&t.push(e)}return t}function cn(e){for(let t of e){let e=an(t);if(e)return e}return null}function ln(e){for(let t of e){let e=Q(t);if(e)return e}return null}const un=[Z.DelegatedForUserDecryption,Z.RevokedDelegationForUserDecryption];function $(e){return`zama:pending-unshield:${et(e)}`}const dn=A.union([A.pipe(O,A.transform(e=>({unwrapTxHash:e}))),A.pipe(A.object({version:A.literal(1),unwrapTxHash:O,unwrapRequestId:A.optional(O)}),A.transform(({unwrapTxHash:e,unwrapRequestId:t})=>({unwrapTxHash:e,unwrapRequestId:t})))]);async function fn(e,t,n,r){if(r===void 0){await e.set($(t),n);return}await e.set($(t),{version:1,unwrapTxHash:n,unwrapRequestId:r})}async function pn(e,t){return(await mn(e,t))?.unwrapTxHash??null}async function mn(e,t){let n=$(t),r=await e.get(n);if(r==null)return null;let i=dn.safeParse(r);return i.success?i.data:(await e.delete(n),null)}async function hn(e,t){await e.delete($(t))}var gn=class extends w{#e;#t=null;#n=null;#r(e){try{return Le(this.sdk.signer,`WrappedToken.sdk.signer`),this.sdk.signer}catch(t){throw new ne(e,{cause:t})}}async underlying(){return this.#o()}async isPayable(){if(this.#n!==null)return this.#n;try{let e=await this.#o();this.#n=await this.sdk.provider.readContract(xe(e))}catch{this.#n=!1}return this.#n}async allowance(e){let t=await this.#o();return this.sdk.provider.readContract(h(t,k(e),this.address))}async shield(e,t){let r=await S(`shield`,this.sdk.signer,this.sdk.provider),i=await this.isPayable(),a=await this.#o(),o=k(r.address),s;try{s=await this.sdk.provider.readContract(ce(a,o))}catch(e){throw e instanceof n?e:new Me(`Could not read ERC-20 balance for shield validation (token: ${a})`,{cause:g(e)})}if(s<e)throw new ke(`Insufficient ERC-20 balance: requested ${e}, available ${s} (token: ${a})`,{requested:e,available:s,token:a});return i?this.#i(e,a,o,t):this.#a(e,o,t)}async#i(e,t,n,r){this.#r(`shield`);let i=r?.to?k(r.to):n,a=i===n?`0x`:i;return this.submitTransaction({operation:`shield:transferAndCall`,config:jt(t,this.address,e,a),onSubmitted:r?.onShieldSubmitted})}async#a(e,t,n){this.#r(`shield`);let r=n?.approvalStrategy??`exact`;r!==`skip`&&await this.#c(e,r===`max`,n);let i=n?.to?k(n.to):t;return this.submitTransaction({operation:`shield:approveAndWrap`,config:u(this.address,i,e),onSubmitted:n?.onShieldSubmitted})}async approveUnderlying(e){this.#r(`approveUnderlying`);let t=await S(`approveUnderlying`,this.sdk.signer,this.sdk.provider),n=await this.#o(),r=k(t.address),i=e??2n**256n-1n;return i>0n&&await this.sdk.provider.readContract(h(n,r,this.address))>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:m(n,this.address,0n)}),this.submitTransaction({operation:`approveUnderlying`,config:m(n,this.address,i)})}async unshield(e,t){let{skipBalanceCheck:n=!1,onUnwrapSubmitted:r,onFinalizing:i,onFinalizeSubmitted:a}=t??{};n||await this.assertConfidentialBalance(e);let o={onFinalizing:i,onFinalizeSubmitted:a},s=crypto.randomUUID(),c=await this.unwrap(e);return d(`unshield: onUnwrapSubmitted`,()=>r?.(c.txHash),this.sdk.logger),this.#s(c.txHash,s,o)}async unshieldAll(e){let t=crypto.randomUUID(),n=await this.unwrapAll();return d(`unshieldAll: onUnwrapSubmitted`,()=>e?.onUnwrapSubmitted?.(n.txHash),this.sdk.logger),this.#s(n.txHash,t,e)}async resumeUnshield(e,t){return this.#s(e,crypto.randomUUID(),t)}async getPendingUnshield(){return pn(this.sdk.storage,this.address)}async unwrap(e){this.#r(`unwrap`);let t=k((await S(`unwrap`,this.sdk.signer,this.sdk.provider)).address),{encryptedValues:n,inputProof:r}=await this.sdk.encrypt({values:[{value:e,type:`euint64`}],contractAddress:this.address,userAddress:t}),[i]=n;if(!i)throw new _(`Encryption returned no encrypted values`);return this.submitTransaction({operation:`unwrap`,config:te(this.address,t,t,i,r)})}async unwrapAll(){this.#r(`unwrapAll`);let e=k((await S(`unwrapAll`,this.sdk.signer,this.sdk.provider)).address),t=await this.readConfidentialBalanceOf(e);if(x(t))throw new b(`Cannot unshield: balance is zero`);return this.submitTransaction({operation:`unwrapAll`,config:c(this.address,e,e,t)})}async finalizeUnwrap(e){this.#r(`finalizeUnwrap`),await T(`finalizeUnwrap`,this.sdk.signer,this.sdk.provider);let t=await this.sdk.decryption.decryptPublicValues([e]),n=t.clearValues[e];return Je(n,`finalizeUnwrap: clearValue`),this.submitTransaction({operation:`finalizeUnwrap`,config:ee(this.address,e,n,t.decryptionProof)})}async#o(){return this.#e===void 0?(this.#t||=this.sdk.provider.readContract(p(this.address)).then(e=>(this.#e=e,this.#t=null,e)).catch(e=>{throw this.#t=null,e}),this.#t):this.#e}async#s(e,t,r){this.emit({type:C.UnshieldPhase1Submitted,txHash:e,operationId:t}),await d(`unshield: savePendingUnshield`,()=>fn(this.sdk.storage,this.address,e),this.sdk.logger);let i;try{i=await this.sdk.provider.waitForTransactionReceipt(e)}catch(e){throw e instanceof n?e:new y(`Failed to get unshield receipt`,{cause:e})}let a=tn(i.logs);if(!a)throw new y(`No UnwrapRequested event found in unshield receipt`);this.emit({type:C.UnshieldPhase2Started,operationId:t}),d(`unshield: onFinalizing`,()=>r?.onFinalizing?.(),this.sdk.logger);let o=await this.finalizeUnwrap(a.unwrapRequestId??a.encryptedAmount);return this.emit({type:C.UnshieldPhase2Submitted,txHash:o.txHash,operationId:t}),d(`unshield: onFinalizeSubmitted`,()=>r?.onFinalizeSubmitted?.(o.txHash),this.sdk.logger),await d(`unshield: clearPendingUnshield`,()=>hn(this.sdk.storage,this.address),this.sdk.logger),o}async#c(e,t,n){this.#r(`approveUnderlying`);let r=await this.#o(),i=k((await S(`approveUnderlying`,this.sdk.signer,this.sdk.provider)).address),a=await this.sdk.provider.readContract(h(r,i,this.address));if(a>=e)return;a>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:m(r,this.address,0n)});let o=t?2n**256n-1n:e;await this.submitTransaction({operation:`approveUnderlying`,config:m(r,this.address,o),onSubmitted:n?.onApprovalSubmitted})}},_n=class{#e;provider;signer;storage;registry;permits;delegations;decryption;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;constructor(e){this.#e=e.router,this.provider=e.provider,this.signer=e.signer,this.storage=e.storage,this.#r=e.onEvent??function(){},this.#i=e.logger,this.#a=new Rt(e.storage,this.#i),this.#u=new Kt({provider:this.provider,router:e.router,emitEvent:this.emitEvent.bind(this),logger:this.#i});let t={};for(let n of e.chains)n.registryAddress&&(t[n.id]=n.registryAddress);this.registry=new D({provider:this.provider,registryAddresses:t,registryTTL:e.registryTTL}),this.#n=t,this.#t=e.registryTTL,e.signer&&(this.#l=new dt({router:e.router,signer:e.signer,transportKeyPairTTL:e.transportKeyPairTTL,permitTTL:e.permitTTL,storage:this.storage,permitStorage:e.permitStorage,logger:this.#i}),this.#c=new Ht({cache:this.#a,credentialService:this.#l,delegationService:this.#u,router:e.router,emitEvent:this.emitEvent.bind(this)})),this.#s=new qt({router:e.router,emitEvent:this.emitEvent.bind(this)}),this.#o=new Jt({signer:e.signer,router:e.router,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.permits=new Ft({signer:this.signer,provider:this.provider,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.delegations=new Pt({signer:this.signer,provider:this.provider,delegationService:this.#u}),this.decryption=new Nt({signer:this.signer,provider:this.provider,router:e.router,decryptionService:this.#c})}onWalletAccountChange(e){return this.#o.onWalletAccountChange(e)}get logger(){return this.#i}get relayer(){return this.#e.relayer}emitEvent(e,t){try{this.#r({...e,tokenAddress:t,timestamp:Date.now()})}catch(t){this.#i.warn(`${e.type} event listener silently failed`,{error:t})}}createWrappersRegistry(e){return new D({provider:this.provider,registryAddresses:{...this.#n,...e},registryTTL:this.#t})}async encrypt(e,t){return this.#s.encryptValues(e,t)}createToken(e){return new w(this,e)}createWrappedToken(e){return new gn(this,e)}dispose(){this.#o.dispose()}terminate(){this.dispose(),this.signer?.dispose?.()}[Symbol.dispose](){this.terminate()}},vn=class{async get(e){return(await chrome.storage.session.get(e))[e]??null}async set(e,t){await chrome.storage.session.set({[e]:t})}async delete(e){await chrome.storage.session.remove(e)}};const yn=new vn;export{un as ACL_TOPICS,Ot as AclPausedError,Z as AclTopics,je as BalanceCheckUnavailableError,ft as BaseSigner,He as ChainMismatchError,vn as ChromeSessionStorage,r as ConfigurationError,Nt as Decryption,b as DecryptionFailedError,$e as DefaultRegistryAddresses,Dt as DelegationContractIsSelfError,Et as DelegationCooldownError,L as DelegationDelegateEqualsContractError,R as DelegationExpirationTooSoonError,F as DelegationExpiredError,I as DelegationExpiryUnchangedError,P as DelegationNotFoundError,z as DelegationNotPropagatedError,N as DelegationSelfNotAllowedError,Pt as Delegations,de as ERC1363_INTERFACE_ID,Me as ERC20ReadFailedError,_e as ERC7984_INTERFACE_ID,Te as ERC7984_WRAPPER_INTERFACE_ID,_ as EncryptionFailedError,it as IndexedDBStorage,Ue as InsufficientConfidentialBalanceError,ke as InsufficientERC20BalanceError,Tt as InvalidTransportKeyPairError,lt as MemoryStorage,ct as MutableWalletAccountStore,j as NoCiphertextError,M as NotEntitledError,Ft as Permits,t as RelayerRequestFailedError,v as RpcRateLimitError,ne as SignerNotConfiguredError,Oe as SignerRequiredError,ae as SigningFailedError,se as SigningRejectedError,rn as TOKEN_TOPICS,w as Token,W as Topics,y as TransactionRevertedError,wt as TransportKeyPairExpiredError,a as WalletAccountNotReadyError,oe as WalletNotConnectedError,gn as WrappedToken,D as WrappersRegistry,qe as ZERO_ENCRYPTED_VALUE,n as ZamaError,e as ZamaErrorCode,_n as ZamaSDK,C as ZamaSDKEvents,h as allowanceContract,bt as anvil,m as approveContract,ce as balanceOfContract,gt as bscTestnet,vt as chains,yn as chromeSessionStorage,Qe as cleartext,re as confidentialBalanceOfContract,o as confidentialTotalSupplyContract,ie as confidentialTransferContract,s as confidentialTransferFromContract,Mt as createConfig,ut as createWalletAccountStore,Ee as decimalsContract,on as decodeAclEvent,sn as decodeAclEvents,Xt as decodeConfidentialTransfer,an as decodeDelegatedForUserDecryption,$t as decodeOnChainEvent,en as decodeOnChainEvents,Q as decodeRevokedDelegationForUserDecryption,Qt as decodeUnwrapFinalized,Zt as decodeUnwrapRequested,X as decodeWrap,ze as delegateForUserDecryptionContract,ee as finalizeUnwrapContract,cn as findDelegatedForUserDecryption,ln as findRevokedDelegationForUserDecryption,tn as findUnwrapRequested,nn as findWrap,we as getConfidentialTokenAddressContract,Ke as getDelegationExpiryContract,ye as getTokenAddressContract,Se as getTokenPairContract,me as getTokenPairsContract,le as getTokenPairsLengthContract,be as getTokenPairsSliceContract,ht as hardhat,pt as hoodi,rt as indexedDBStorage,ge as inferredTotalSupplyContract,_t as ingenTestnet,fe as isConfidentialTokenContract,Ce as isConfidentialTokenValidContract,pe as isConfidentialWrapperContract,x as isEncryptedValueZero,We as isHandleDelegatedContract,i as isOperatorContract,yt as mainnet,Ct as matchZamaError,st as memoryStorage,ue as nameContract,he as rateContract,tt as resolveChainRelayers,nt as resolveStorage,Ve as revokeDelegationContract,mt as sepolia,f as setOperatorContract,ve as supportsInterfaceContract,De as symbolContract,jt as transferAndCallContract,p as underlyingContract,te as unwrapContract,c as unwrapFromBalanceContract,u as wrapContract};
1
+ import{a as e,c as t,d as n,f as r,g as i,h as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,s as p,t as m}from"./relayer-BUxKmetl.js";import{A as h,B as g,C as ee,D as te,F as ne,H as _,I as re,L as v,M as ie,N as ae,O as oe,P as se,R as ce,S as le,T as ue,U as de,V as fe,W as pe,_ as me,a as he,b as ge,c as _e,d as ve,f as ye,g as y,h as b,i as be,j as xe,k as Se,l as Ce,m as we,n as Te,o as Ee,p as De,r as Oe,s as ke,t as Ae,u as je,v as Me,x as Ne,z as Pe}from"./wrappers-registry-vjouAqDk.js";import{C as x,E as S,S as Fe,T as C,_ as Ie,a as w,b as Le,c as Re,d as T,f as E,g as ze,h as Be,i as Ve,l as He,m as Ue,n as We,o as Ge,p as Ke,r as qe,s as D,t as O,u as k,v as Je,w as A,x as Ye,y as Xe}from"./token-CK6XGnWp.js";import{t as Ze}from"./cleartext-DHEMC21x.js";import{a as Qe,c as $e,d as et,f as tt,g as nt,h as rt,i as it,l as at,m as ot,n as st,o as j,p as ct,r as lt,s as ut,t as dt,u as M}from"./base-signer-Co79VFwf.js";import{a as ft,c as pt,i as mt,n as ht,o as gt,r as _t,s as vt,t as yt}from"./chains-CLv9HEJ_.js";import{getAddress as N,keccak256 as bt,toBytes as xt}from"viem";import{z as P}from"zod/mini";function St(e,t){if(e instanceof f){let n=t[e.code];if(n)return n(e)}return t._?.(e)}var Ct=class extends f{constructor(e,t){super(o.TransportKeyPairExpired,e,t),this.name=`TransportKeyPairExpiredError`}},wt=class extends f{constructor(e,t){super(o.InvalidTransportKeyPair,e,t),this.name=`InvalidTransportKeyPairError`}},Tt=class extends f{constructor(e,t){super(o.NoCiphertext,e,t),this.name=`NoCiphertextError`}},F=class extends f{encryptedValue;contractAddress;account;constructor(e,t){super(o.NotEntitled,`Account ${e.account} is not entitled to decrypt encrypted value ${e.encryptedValue} on contract ${e.contractAddress}. This is not a transient failure — the account needs an on-chain ACL grant before it can decrypt this encrypted value.`,t),this.name=`NotEntitledError`,this.encryptedValue=e.encryptedValue,this.contractAddress=e.contractAddress,this.account=e.account}},I=class extends f{constructor(e,t){super(o.DelegationSelfNotAllowed,e,t),this.name=`DelegationSelfNotAllowedError`}},Et=class extends f{constructor(e,t){super(o.DelegationCooldown,e,t),this.name=`DelegationCooldownError`}},L=class extends f{constructor(e,t){super(o.DelegationNotFound,e,t),this.name=`DelegationNotFoundError`}},R=class extends f{constructor(e,t){super(o.DelegationExpired,e,t),this.name=`DelegationExpiredError`}},z=class extends f{constructor(e,t){super(o.DelegationExpiryUnchanged,e,t),this.name=`DelegationExpiryUnchangedError`}},B=class extends f{constructor(e,t){super(o.DelegationDelegateEqualsContract,e,t),this.name=`DelegationDelegateEqualsContractError`}},Dt=class extends f{constructor(e,t){super(o.DelegationContractIsSelf,e,t),this.name=`DelegationContractIsSelfError`}},Ot=class extends f{constructor(e,t){super(o.AclPaused,e,t),this.name=`AclPausedError`}},V=class extends f{constructor(e,t){super(o.DelegationExpirationTooSoon,e,t),this.name=`DelegationExpirationTooSoonError`}},H=class extends f{constructor(e,t){super(o.DelegationNotPropagated,e,t),this.name=`DelegationNotPropagatedError`}};const kt=[C,Tt,l,H,pe,de,F,x];function U(e,i,o={}){if(kt.some(t=>e instanceof t))return e;let u=e instanceof Error?e.message:i;if(e instanceof Error&&n(e.message))return o.isDelegated?new H(`Delegated decryption was denied by the on-chain ACL check. This is most commonly caused by the delegation not having propagated yet, or by the RPC node serving a stale block. Propagation usually completes within ~10 blocks (a few seconds) and the SDK retries across that window; seeing this means it did not sync in time. Retry shortly (and prefer a fresh, low-lag RPC endpoint). If it persists, the delegator may genuinely lack the on-chain ACL grant.`,{cause:e}):new F({encryptedValue:a(e.message)??``,contractAddress:o.contractAddress??``,account:o.account??``},{cause:e});if(s(e))return new x(u,{cause:e,retryAfter:t(e)});let f=p(e);return f===void 0&&c(e)?new x(u,{cause:e,retryAfter:t(e)}):f===400?new Tt(e instanceof Error?e.message:`No ciphertext for this account`,{cause:e}):o.isDelegated&&f===500?new H(`Delegated decryption failed with a server error. This is most commonly caused by the delegation not having propagated to the gateway yet. Cross-chain sync usually completes within ~10 blocks (a few seconds) and the SDK retries across that window; seeing this means it did not sync in time — retry shortly. If the error persists, the gateway or relayer may be experiencing an unrelated issue.`,{cause:e}):r(e)||f!==void 0?new l(u,f,{cause:e,retryAfter:t(e),retryable:d(e)||void 0}):new C(i,{cause:e})}function At(e,n){if(e instanceof f)return e;let i=p(e),a=d(e);return i!==void 0||r(e)?new l(e instanceof Error?e.message:n,i,{cause:e,retryAfter:t(e),retryable:a||void 0}):new S(n,{cause:e})}const jt=[{type:`function`,name:`allowance`,inputs:[{name:`owner`,type:`address`,internalType:`address`},{name:`spender`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`approve`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`balanceOf`,inputs:[{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`supportsInterface`,inputs:[{name:`interfaceId`,type:`bytes4`,internalType:`bytes4`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`totalSupply`,inputs:[],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`transfer`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFrom`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`event`,name:`Approval`,inputs:[{name:`owner`,type:`address`,indexed:!0,internalType:`address`},{name:`spender`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1},{type:`event`,name:`Transfer`,inputs:[{name:`from`,type:`address`,indexed:!0,internalType:`address`},{name:`to`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1}];function Mt(e,t,n,r=`0x`){return{address:e,abi:jt,functionName:`transferAndCall`,args:[t,n,r]}}function Nt(e){return it(e.signer,e.provider,e)}function W(e){return e.startsWith(`0x`)?e:`0x${e}`}var Pt=class{#e;#t;#n;#r;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.router,this.#r=e.decryptionService}#i(e){return _(this.#r,e)}async decryptValues(e,t){let n=this.#i(`decryptValues`),r=await k(`decryptValues`,this.#e,this.#t);return n.decryptValues(e,r.address,t)}async delegatedDecryptValues(e,t,n=t,r){let i=this.#i(`delegatedDecryptValues`),a=await k(`delegatedDecryptValues`,this.#e,this.#t);return i.delegatedDecryptValues(e,t,a.address,n,r)}async decryptPublicValues(e,t){if(e.length===0)return{clearValues:{},decryptionProof:`0x`,abiEncodedClearValues:`0x`};try{let n=await this.#n.relayer.decryptPublicValuesWithSignatures({encryptedValues:e,options:t}),r={};return n.checkSignaturesArgs.handlesList.forEach((e,t)=>{He(n.clearValues[t],`result.clearValues[${t}]`),r[e]=n.clearValues[t].value}),{clearValues:r,abiEncodedClearValues:n.checkSignaturesArgs.abiEncodedCleartexts,decryptionProof:n.checkSignaturesArgs.decryptionProof}}catch(e){throw U(e,`Public decryption failed`)}}async delegatedBatchDecryptValues({encryptedInputs:e,delegatorAddress:t,accountAddress:n=t,maxConcurrency:r,waitForPropagation:i}){let a=this.#i(`delegatedBatchDecryptValues`),o=await k(`delegatedBatchDecryptValues`,this.#e,this.#t);return a.delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:o.address,accountAddress:n,maxConcurrency:r,waitForPropagation:i})}},Ft=class{#e;#t;#n;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.delegationService}#r(e){return _(this.#e,e)}async delegateDecryption({contractAddress:e,delegateAddress:t,expirationDate:n}){let r=this.#r(`delegateDecryption`),i=await k(`delegateDecryption`,this.#e,this.#t);return this.#n.delegateDecryption(r,{contractAddress:e,delegateAddress:t,delegatorAddress:i.address,expirationDate:n})}async revokeDelegation({contractAddress:e,delegateAddress:t}){let n=this.#r(`revokeDelegation`),r=await k(`revokeDelegation`,this.#e,this.#t);return this.#n.revokeDelegation(n,{contractAddress:e,delegateAddress:t,delegatorAddress:r.address})}async isActive(e){return this.#n.isDelegated(e)}async getExpiry(e){return this.#n.getDelegationExpiry(e)}},It=class{#e;#t;#n;#r;#i;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger}#a(e){return _(this.#r,e)}async grantPermit(e){if(e.length===0)return;let t=this.#a(`grantPermit`);await T(`grantPermit`,this.#e,this.#t),await t.grantPermit(e)}async grantDelegationPermit(e,t){if(t.length===0)return;let n=this.#a(`grantDelegationPermit`);await T(`grantDelegationPermit`,this.#e,this.#t),await n.grantPermit(t,e)}async hasPermit(e){return this.#r?this.#r.hasPermit(e):!1}async hasDelegationPermit(e,t){return this.#r?this.#r.hasPermit(t,e):!1}async warmTransportKeyPair(){let e=this.#r;if(!e)return;let t=this.#e?.walletAccount.getSnapshot();t&&await e.warmTransportKeyPair(t.address)}async revokePermits(e){let t=this.#a(`revokePermits`),n=N((await k(`revokePermits`,this.#e,this.#t)).address);try{await t.revokePermits(e)}finally{await v(`clear decrypt cache`,()=>this.#n.clearForRequester(n),this.#i)}}async clear(){let e=this.#a(`clear`),t=N((await k(`clear`,this.#e,this.#t)).address);try{await e.clearCredentials()}finally{await v(`clear decrypt cache`,()=>this.#n.clearForRequester(t),this.#i)}}};const Lt=P.union([P.bigint(),P.boolean(),at]),Rt=P.array(P.string());var zt=class{#e;#t;#n=`zama:decrypt`;#r=`${this.#n}:keys`;#i=Promise.resolve();constructor(e,t){this.#e=e,this.#t=t}async get(e,t,n){try{let r=this.#c(e,t,n),i=await this.#e.get(r);if(i===null)return null;let a=Lt.safeParse(i);return a.success?a.data:(await this.delete(e,t,n),null)}catch(e){return this.#t.warn(`CachingService.get failed`,{error:e}),null}}async set(e,t,n,r){try{let i=this.#c(e,t,n);await this.#e.set(i,r),this.#i=this.#i.then(()=>this.#u(i).catch(e=>{this.#t.warn(`CachingService index write failed`,{error:e})})),await this.#i}catch(e){this.#t.warn(`CachingService.set failed`,{error:e})}}async delete(e,t,n){let r=this.#c(e,t,n);this.#i=this.#i.then(()=>this.#a(r).catch(e=>{this.#t.warn(`CachingService.delete failed`,{error:e})})),await this.#i}async clearForRequester(e){this.#i=this.#i.then(()=>this.#o(e).catch(e=>{this.#t.warn(`CachingService.clearForRequester failed`,{error:e})})),await this.#i}async clearAll(){this.#i=this.#i.then(()=>this.#s().catch(e=>{this.#t.warn(`CachingService.clearAll failed`,{error:e})})),await this.#i}async#a(e){await this.#e.delete(e).catch(()=>{});let t=await this.#l(),n=t.filter(t=>t!==e);n.length!==t.length&&await this.#e.set(this.#r,n)}async#o(e){let t=N(e),n=`${this.#n}:${t}:`,r=await this.#l(),i=[],a=[];for(let e of r)e.startsWith(n)?i.push(e):a.push(e);await Promise.all(i.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.set(this.#r,a)}async#s(){let e=await this.#l();await Promise.all(e.map(e=>this.#e.delete(e).catch(()=>{}))),await this.#e.delete(this.#r)}#c(e,t,n){return`${this.#n}:${N(e)}:${N(t)}:${n.toLowerCase()}`}async#l(){let e=await this.#e.get(this.#r);if(e===null)return[];let t=Rt.safeParse(e);return t.success?t.data:(await this.#e.delete(this.#r).catch(()=>{}),[])}async#u(e){let t=await this.#l();t.includes(e)||(t.push(e),await this.#e.set(this.#r,t))}};function Bt(e,t){let n=Vt(e,t);if(!n)throw new C(`No permit covers contract ${t} after allow()`);return{privateKey:e.keypair.privateKey,publicKey:e.keypair.publicKey,serializedPermit:n.serializedPermit}}function Vt(e,t){let n=$e(t);return e.permissions.find(e=>e.contractAddresses.includes(n))}const Ht=e=>new Promise(t=>setTimeout(t,e));var Ut=class{#e;#t;#n;#r;#i;constructor({cache:e,credentialService:t,delegationService:n,router:r,emitEvent:i}){this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#i=i}async decryptValues(e,t,n){let r=N(t);return this.#s(e,{requesterAddress:r,aclActorAddress:r,resolveCredentials:e=>this.#t.grantPermit(e),decryptContract:({credentials:e,contractAddress:t,encryptedValues:n,options:r})=>this.#o(e,t,n,r),errorMessage:`Failed to decrypt encrypted values`},n)}async delegatedDecryptValues(e,t,n,r,i){let a=N(t),o=N(n);return this.#a(i?.waitForPropagation??!0,()=>this.#s(e,{requesterAddress:N(r),aclActorAddress:a,resolveCredentials:e=>this.#t.grantPermit(e,a),validate:e=>this.#f(e,{delegatorAddress:a,delegateAddress:o}),decryptContract:({credentials:e,contractAddress:t,encryptedValues:n,options:r})=>this.#o(e,t,n,r),errorMessage:`Failed to decrypt delegated encrypted values`,delegated:!0}))}async#a(e,t){let n;for(let r=0;r<16;r++)try{return await t()}catch(t){if(n=t,!(r<15&&e&&t instanceof H))throw t;await Ht(2e3)}throw n}async delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:n,accountAddress:r,maxConcurrency:i=5,waitForPropagation:a=!0}){let o=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:N(e.contractAddress)}));if(o.length===0)return{items:o};let s=N(r);try{let e=await this.delegatedDecryptValues(o.map(({encryptedValue:e,contractAddress:t})=>({encryptedValue:e,contractAddress:t})),t,n,s,{waitForPropagation:a});for(let t of o)this.#l(t,e);return{items:o}}catch(e){if(Ie(e))throw e;if(o.length===1){let[n=this.#d()]=o;return n.error=this.#u(e,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:n.contractAddress,account:N(t)}),{items:o}}}let c=!1;return await Ge(o.map(e=>async()=>{if(!c)try{let r=await this.delegatedDecryptValues([{encryptedValue:e.encryptedValue,contractAddress:e.contractAddress}],t,n,s,{waitForPropagation:!1});this.#l(e,r)}catch(n){if(Ie(n))throw c=!0,n;e.error=this.#u(n,`Failed to decrypt delegated encrypted values`,{isDelegated:!0,contractAddress:e.contractAddress,account:N(t)})}}),i),{items:o}}async#o(e,t,n,r){let i=Bt(e,t),a=await this.#r.relayer.parseTransportKeyPair({publicKey:i.publicKey,privateKey:i.privateKey}),o=await this.#r.relayer.parseSignedDecryptionPermit({transportKeyPair:a,serializedPermit:i.serializedPermit});return this.#r.relayer.decryptValues({transportKeyPair:a,signedPermit:o,encryptedValues:n,contractAddress:t,options:r})}async#s(e,t,n){if(e.length===0)return{};let r=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:N(e.contractAddress)})),a={},o=[];for(let e of r)w(e.encryptedValue)?a[e.encryptedValue]=0n:o.push(e);if(o.length===0)return a;let s=Array.from(new Set(r.map(e=>e.contractAddress))),l=Array.from(new Set(o.map(e=>e.contractAddress)));if(t.validate)try{await t.validate(l)}catch(e){throw c(e)?this.#c(e,`the delegation pre-check`):e}let u=[];for(let e of o){let n=await this.#e.get(t.requesterAddress,e.contractAddress,e.encryptedValue);n===null?u.push(e):a[e.encryptedValue]=n}if(u.length===0)return a;let d=await t.resolveCredentials(s),p=new Map;for(let e of u){let t=p.get(e.contractAddress);t?t.push(e.encryptedValue):p.set(e.contractAddress,[e.encryptedValue])}let m=[];for(let[e,t]of p)for(let n of Ve(t))m.push({contractAddress:e,encryptedValues:n});let h=Date.now(),g=u.map(e=>e.encryptedValue);try{this.#i({type:D.DecryptStart,encryptedValues:g}),await Ge(m.map(({contractAddress:e,encryptedValues:r})=>async()=>{let i;try{i=await t.decryptContract({credentials:d,contractAddress:e,encryptedValues:r,options:n})}catch(n){throw U(n,t.errorMessage,{isDelegated:t.delegated,contractAddress:e,account:t.aclActorAddress})}for(let n=0;n<r.length;n++){let o=r[n],s=i[n]?.value;o===void 0||s===void 0||(a[o]=s,await this.#e.set(t.requesterAddress,e,o,s))}let o=r.filter(e=>a[e]===void 0);if(o.length>0)throw new C(`${t.errorMessage}: relayer returned no clear value for ${o.length} of ${r.length} handle(s) on ${e}`,{cause:AggregateError(o.map(t=>new C(`No clear value for handle ${t} on ${e}`)),`${o.length} handle(s) missing a clear value on ${e}`)})}),5);let e={};for(let t of g){let n=a[t];n!==void 0&&(e[t]=n)}return this.#i({type:D.DecryptEnd,durationMs:Date.now()-h,encryptedValues:g,result:e}),a}catch(e){let n=e instanceof f&&e.cause instanceof Error?e.cause:e;throw this.#i({type:D.DecryptError,error:i(n),durationMs:Date.now()-h,encryptedValues:g}),U(e,t.errorMessage,{isDelegated:t.delegated})}}#c(e,n){return new x(`RPC provider rate-limited ${n}; retry with backoff.`,{cause:e,retryAfter:t(e)})}#l(e,t){let n=t[e.encryptedValue];if(n===void 0){e.error=new C(`Batch delegated decryption returned no value for encrypted value ${e.encryptedValue} on contract ${e.contractAddress}`);return}e.value=n}#u(e,t,n){return e instanceof f?e:U(e,t,n)}#d(){throw new C(`Batch delegated decryption invariant failed: missing item`)}async#f(e,{delegatorAddress:t,delegateAddress:n}){let r=await this.#n.findInactiveDelegations(e,t,n);if(r.size!==0)for(let e of r.values())throw e}};function Wt(e){if(!(e instanceof Error))return null;let t=e.cause;if(typeof t!=`object`||!t||!(`data`in t))return null;let{data:n}=t;return typeof n!=`object`||!n||!(`errorName`in n)?null:typeof n.errorName==`string`?n.errorName:null}const G={AlreadyDelegatedOrRevokedInSameBlock:e=>new Et(`Only one delegate/revoke per (delegator, delegate, contract) per block. Wait for the next block before retrying.`,{cause:e}),SenderCannotBeContractAddress:e=>new Dt(`The contract address cannot be the caller address.`,{cause:e}),EnforcedPause:e=>new Ot(`The ACL contract is paused. Delegation operations are temporarily disabled.`,{cause:e}),SenderCannotBeDelegate:e=>new I(`Cannot delegate to yourself (delegate === msg.sender).`,{cause:e}),DelegateCannotBeContractAddress:e=>new B(`Delegate address cannot be the same as the contract address.`,{cause:e}),ExpirationDateBeforeOneHour:e=>new V(`Expiration date must be at least 1 hour in the future.`,{cause:e}),ExpirationDateAlreadySetToSameValue:e=>new z(`The new expiration date is the same as the current one.`,{cause:e}),NotDelegatedYet:e=>new L(`Cannot revoke: no active delegation exists.`,{cause:e})};function Gt(e){return e in G}function Kt(e,t){let n=Wt(e);if(n&&Gt(n))return G[n](t);let r=e instanceof Error?e.message:String(e);for(let[e,n]of Object.entries(G))if(r.includes(e))return n(t);return null}var qt=class{#e;#t;#n;#r;constructor({provider:e,router:t,emitEvent:n=()=>{},logger:r}){this.#t=e,this.#e=t,this.#r=r,this.#n=n}async delegateDecryption(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r,expirationDate:i}){if(i&&i.getTime()<Date.now()+36e5)throw new V(`Expiration date must be at least 1 hour in the future`);let a=N(t),o=N(n),s=N(r);if(o===s)throw new I(`Cannot delegate to yourself (delegate === msg.sender).`);if(o===a)throw new B(`Delegate address cannot be the same as the contract address (${a}).`);let c=this.#e.relayer.chain.aclContractAddress,l=i?BigInt(Math.floor(i.getTime()/1e3)):E,u;try{u=await this.getDelegationExpiry({contractAddress:a,delegatorAddress:s,delegateAddress:o})}catch(e){this.#r.warn(`delegateDecryption: pre-flight expiry check failed`,{error:e}),u=-1n}if(u===l)throw new z(`The new expiration date (${l}) is the same as the current one. No on-chain change needed.`);return this.#i({operation:`delegateDecryption`,signer:e,contractAddress:t,config:Ke(c,o,a,l)})}async revokeDelegation(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r}){let i=N(t),a=N(n),o=N(r),s=this.#e.relayer.chain.aclContractAddress,c;try{c=await this.getDelegationExpiry({contractAddress:i,delegatorAddress:o,delegateAddress:a})}catch(e){this.#r.warn(`revokeDelegation: pre-flight expiry check failed`,{error:e}),c=1n}if(c===0n)throw new L(`No active delegation found for delegate ${a} on contract ${i}.`);return this.#i({operation:`revokeDelegation`,signer:e,contractAddress:t,config:ze(s,a,i)})}async isDelegated(e){let t=await this.getDelegationExpiry(e);return t===0n?!1:t===E?!0:t>await this.#t.getBlockTimestamp()}async getDelegationExpiry({contractAddress:e,delegatorAddress:t,delegateAddress:n}){let r=this.#e.relayer.chain.aclContractAddress;return this.#t.readContract(Ue(r,N(t),N(n),N(e)))}async#i({operation:e,signer:t,contractAddress:n,config:r}){try{return await We({operation:e,signer:t,provider:this.#t,config:r,emit:e=>this.#n(e,n),logger:this.#r})}catch(e){throw this.#a(e),e}}#a(e){if(!(e instanceof A))return;let t=Kt(e.cause??e,e);if(t)throw t}async findInactiveDelegations(e,t,n){let r=new Map;return await Promise.all(e.map(async e=>{try{await this.assertDelegationActive(e,t,n)}catch(t){if(t instanceof L||t instanceof R){let n=N(e);r.set(n,t);return}throw t}})),r}async assertDelegationActive(e,t,n){let r=N(e),i=N(t),a=N(n),o=await this.getDelegationExpiry({contractAddress:r,delegatorAddress:i,delegateAddress:a});if(o===0n)throw new L(`No active delegation from ${i} to ${a} for ${r}`);if(o!==E&&o<=await this.#t.getBlockTimestamp())throw new R(`Delegation from ${i} to ${a} for ${r} has expired`)}},Jt=class{#e;#t;constructor({router:e,emitEvent:t}){this.#e=e,this.#t=t}async encryptValues(e,t){let n=Date.now(),r=N(e.contractAddress);try{this.#t({type:D.EncryptStart},r);let i=await this.#e.relayer.encryptValues({...e,options:t});return this.#t({type:D.EncryptEnd,durationMs:Date.now()-n},r),i}catch(e){throw this.#t({type:D.EncryptError,error:i(e),durationMs:Date.now()-n},r),At(e,`Encryption failed`)}}},Yt=class{#e;#t;#n;#r;#i;#a=new Set;#o;constructor(e){this.#e=e.signer,this.#t=e.router,this.#n=e.cachingService,this.#r=e.credentialService,this.#i=e.logger,this.#e&&(this.#o=this.#e.walletAccount.subscribe(e=>{this.#s(e).catch(e=>{this.#i.warn(`wallet account handler failed`,{error:e})})}))}onWalletAccountChange(e){return this.#a.add(e),()=>{this.#a.delete(e)}}dispose(){this.#o?.(),this.#o=void 0,this.#a.clear()}async#s(e){let t=e.previous,n=e.next,r=n?.chainId;r!==void 0&&await v(`switch relayer chain`,()=>this.#t.switchChain(r),this.#i);let i=this.#r;i&&await v(`credential wallet account change`,()=>i.handleWalletAccountChange(t,n),this.#i),t&&await v(`clear decrypt cache`,()=>this.#n.clearForRequester(t.address),this.#i),await Promise.all(Array.from(this.#a,t=>v(`wallet account listener`,()=>t(e),this.#i)))}};function K(e){return bt(xt(e))}const q={ConfidentialTransfer:K(`ConfidentialTransfer(address,address,bytes32)`),Wrap:K(`Wrap(address,uint256,bytes32)`),UnwrapRequested:K(`UnwrapRequested(address,bytes32,bytes32)`),UnwrapFinalized:K(`UnwrapFinalized(address,bytes32,bytes32,uint64)`)};function J(e){return N(W(e.slice(-40)))}function Xt(e){return e}function Zt(e,t){let n=2+t*64,r=e.slice(n,n+64);return r.length===64?r:r.padEnd(64,`0`)}function Qt(e,t){return N(W(Zt(e,t).slice(-40)))}function Y(e,t){return BigInt(`0x`+Zt(e,t))}function $t(e,t){return W(Zt(e,t))}function en(e){return e.topics[0]!==q.ConfidentialTransfer||e.topics.length<4?null:{eventName:`ConfidentialTransfer`,from:J(e.topics[1]),to:J(e.topics[2]),encryptedAmount:Xt(e.topics[3])}}function tn(e){return e.topics[0]!==q.Wrap||e.topics.length<2?null:{eventName:`Wrap`,to:J(e.topics[1]),roundedAmount:Y(e.data,0),encryptedWrappedAmount:$t(e.data,1)}}function nn(e){return e.topics[0]!==q.UnwrapRequested||e.topics.length<3?null:{eventName:`UnwrapRequested`,receiver:J(e.topics[1]),unwrapRequestId:Xt(e.topics[2]),encryptedAmount:$t(e.data,0)}}function rn(e){return e.topics[0]!==q.UnwrapFinalized||e.topics.length<3?null:{eventName:`UnwrapFinalized`,receiver:J(e.topics[1]),unwrapRequestId:Xt(e.topics[2]),encryptedAmount:$t(e.data,0),cleartextAmount:Y(e.data,1)}}function an(e){return en(e)??tn(e)??nn(e)??rn(e)}function on(e){let t=[];for(let n of e){let e=an(n);e&&t.push(e)}return t}function sn(e){for(let t of e){let e=nn(t);if(e)return e}return null}function cn(e){for(let t of e){let e=tn(t);if(e)return e}return null}const ln=[q.ConfidentialTransfer,q.Wrap,q.UnwrapRequested,q.UnwrapFinalized],X={DelegatedForUserDecryption:K(`DelegatedForUserDecryption(address,address,address,uint64,uint64,uint64)`),RevokedDelegationForUserDecryption:K(`RevokedDelegationForUserDecryption(address,address,address,uint64,uint64)`)};function Z(e){return e.topics[0]!==X.DelegatedForUserDecryption||e.topics.length<3?null:{eventName:`DelegatedForUserDecryption`,delegator:J(e.topics[1]),delegate:J(e.topics[2]),contractAddress:Qt(e.data,0),delegationCounter:Y(e.data,1),oldExpirationDate:Y(e.data,2),newExpirationDate:Y(e.data,3)}}function Q(e){return e.topics[0]!==X.RevokedDelegationForUserDecryption||e.topics.length<3?null:{eventName:`RevokedDelegationForUserDecryption`,delegator:J(e.topics[1]),delegate:J(e.topics[2]),contractAddress:Qt(e.data,0),delegationCounter:Y(e.data,1),oldExpirationDate:Y(e.data,2)}}function un(e){return Z(e)??Q(e)}function dn(e){let t=[];for(let n of e){let e=un(n);e&&t.push(e)}return t}function fn(e){for(let t of e){let e=Z(t);if(e)return e}return null}function pn(e){for(let t of e){let e=Q(t);if(e)return e}return null}const mn=[X.DelegatedForUserDecryption,X.RevokedDelegationForUserDecryption];function $(e){return`zama:pending-unshield:${$e(e)}`}const hn=P.union([P.pipe(M,P.transform(e=>({unwrapTxHash:e}))),P.pipe(P.object({version:P.literal(1),unwrapTxHash:M,unwrapRequestId:P.optional(M)}),P.transform(({unwrapTxHash:e,unwrapRequestId:t})=>({unwrapTxHash:e,unwrapRequestId:t})))]);async function gn(e,t,n,r){if(r===void 0){await e.set($(t),n);return}await e.set($(t),{version:1,unwrapTxHash:n,unwrapRequestId:r})}async function _n(e,t){return(await vn(e,t))?.unwrapTxHash??null}async function vn(e,t){let n=$(t),r=await e.get(n);if(r==null)return null;let i=hn.safeParse(r);return i.success?i.data:(await e.delete(n),null)}async function yn(e,t){await e.delete($(t))}var bn=class extends O{#e;#t=null;#n=null;#r(e){try{return He(this.sdk.signer,`WrappedToken.sdk.signer`),this.sdk.signer}catch(t){throw new ce(e,{cause:t})}}async underlying(){return this.#o()}async isPayable(){if(this.#n!==null)return this.#n;try{let e=await this.#o();this.#n=await this.sdk.provider.readContract(De(e))}catch{this.#n=!1}return this.#n}async allowance(e){let t=await this.#o();return this.sdk.provider.readContract(b(t,N(e),this.address))}async shield(e,t){let n=await k(`shield`,this.sdk.signer,this.sdk.provider),r=await this.isPayable(),a=await this.#o(),o=N(n.address),s;try{s=await this.sdk.provider.readContract(me(a,o))}catch(e){throw e instanceof f?e:new Xe(`Could not read ERC-20 balance for shield validation (token: ${a})`,{cause:i(e)})}if(s<e)throw new Ye(`Insufficient ERC-20 balance: requested ${e}, available ${s} (token: ${a})`,{requested:e,available:s,token:a});return r?this.#i(e,a,o,t):this.#a(e,o,t)}async#i(e,t,n,r){this.#r(`shield`);let i=r?.to?N(r.to):n,a=i===n?`0x`:i;return this.submitTransaction({operation:`shield:transferAndCall`,config:Mt(t,this.address,e,a),onSubmitted:r?.onShieldSubmitted})}async#a(e,t,n){this.#r(`shield`);let r=n?.approvalStrategy??`exact`;r!==`skip`&&await this.#c(e,r===`max`,n);let i=n?.to?N(n.to):t;return this.submitTransaction({operation:`shield:approveAndWrap`,config:re(this.address,i,e),onSubmitted:n?.onShieldSubmitted})}async approveUnderlying(e){this.#r(`approveUnderlying`);let t=await k(`approveUnderlying`,this.sdk.signer,this.sdk.provider),n=await this.#o(),r=N(t.address),i=e??2n**256n-1n;return i>0n&&await this.sdk.provider.readContract(b(n,r,this.address))>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:y(n,this.address,0n)}),this.submitTransaction({operation:`approveUnderlying`,config:y(n,this.address,i)})}async unshield(e,t){let{skipBalanceCheck:n=!1,onUnwrapSubmitted:r,onFinalizing:i,onFinalizeSubmitted:a}=t??{};n||await this.assertConfidentialBalance(e);let o={onFinalizing:i,onFinalizeSubmitted:a},s=crypto.randomUUID(),c=await this.unwrap(e);return v(`unshield: onUnwrapSubmitted`,()=>r?.(c.txHash),this.sdk.logger),this.#s(c.txHash,s,o)}async unshieldAll(e){let t=crypto.randomUUID(),n=await this.unwrapAll();return v(`unshieldAll: onUnwrapSubmitted`,()=>e?.onUnwrapSubmitted?.(n.txHash),this.sdk.logger),this.#s(n.txHash,t,e)}async resumeUnshield(e,t){return this.#s(e,crypto.randomUUID(),t)}async getPendingUnshield(){return _n(this.sdk.storage,this.address)}async unwrap(e){this.#r(`unwrap`);let t=N((await k(`unwrap`,this.sdk.signer,this.sdk.provider)).address),{encryptedValues:n,inputProof:r}=await this.sdk.encrypt({values:[{value:e,type:`euint64`}],contractAddress:this.address,userAddress:t}),[i]=n;if(!i)throw new S(`Encryption returned no encrypted values`);return this.submitTransaction({operation:`unwrap`,config:se(this.address,t,t,i,r)})}async unwrapAll(){this.#r(`unwrapAll`);let e=N((await k(`unwrapAll`,this.sdk.signer,this.sdk.provider)).address),t=await this.readConfidentialBalanceOf(e);if(w(t))throw new C(`Cannot unshield: balance is zero`);return this.submitTransaction({operation:`unwrapAll`,config:ne(this.address,e,e,t)})}async finalizeUnwrap(e){this.#r(`finalizeUnwrap`),await T(`finalizeUnwrap`,this.sdk.signer,this.sdk.provider);let t=await this.sdk.decryption.decryptPublicValues([e]),n=t.clearValues[e];return Re(n,`finalizeUnwrap: clearValue`),this.submitTransaction({operation:`finalizeUnwrap`,config:oe(this.address,e,n,t.decryptionProof)})}async#o(){return this.#e===void 0?(this.#t||=this.sdk.provider.readContract(ae(this.address)).then(e=>(this.#e=e,this.#t=null,e)).catch(e=>{throw this.#t=null,e}),this.#t):this.#e}async#s(e,t,n){this.emit({type:D.UnshieldPhase1Submitted,txHash:e,operationId:t}),await v(`unshield: savePendingUnshield`,()=>gn(this.sdk.storage,this.address,e),this.sdk.logger);let r;try{r=await this.sdk.provider.waitForTransactionReceipt(e)}catch(e){throw e instanceof f?e:new A(`Failed to get unshield receipt`,{cause:e})}let i=sn(r.logs);if(!i)throw new A(`No UnwrapRequested event found in unshield receipt`);this.emit({type:D.UnshieldPhase2Started,operationId:t}),v(`unshield: onFinalizing`,()=>n?.onFinalizing?.(),this.sdk.logger);let a=await this.finalizeUnwrap(i.unwrapRequestId??i.encryptedAmount);return this.emit({type:D.UnshieldPhase2Submitted,txHash:a.txHash,operationId:t}),v(`unshield: onFinalizeSubmitted`,()=>n?.onFinalizeSubmitted?.(a.txHash),this.sdk.logger),await v(`unshield: clearPendingUnshield`,()=>yn(this.sdk.storage,this.address),this.sdk.logger),a}async#c(e,t,n){this.#r(`approveUnderlying`);let r=await this.#o(),i=N((await k(`approveUnderlying`,this.sdk.signer,this.sdk.provider)).address),a=await this.sdk.provider.readContract(b(r,i,this.address));if(a>=e)return;a>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:y(r,this.address,0n)});let o=t?2n**256n-1n:e;await this.submitTransaction({operation:`approveUnderlying`,config:y(r,this.address,o),onSubmitted:n?.onApprovalSubmitted})}},xn=class{#e;provider;signer;storage;registry;permits;delegations;decryption;#t;#n;#r;#i;#a;#o;#s;#c;#l;#u;constructor(e){this.#e=e.router,this.provider=e.provider,this.signer=e.signer,this.storage=e.storage,this.#r=e.onEvent??function(){},this.#i=e.logger,this.#a=new zt(e.storage,this.#i),this.#u=new qt({provider:this.provider,router:e.router,emitEvent:this.emitEvent.bind(this),logger:this.#i});let t={};for(let n of e.chains)n.registryAddress&&(t[n.id]=n.registryAddress);this.registry=new j({provider:this.provider,registryAddresses:t,registryTTL:e.registryTTL}),this.#n=t,this.#t=e.registryTTL,e.signer&&(this.#l=new ut({router:e.router,signer:e.signer,transportKeyPairTTL:e.transportKeyPairTTL,permitTTL:e.permitTTL,storage:this.storage,permitStorage:e.permitStorage,logger:this.#i}),this.#c=new Ut({cache:this.#a,credentialService:this.#l,delegationService:this.#u,router:e.router,emitEvent:this.emitEvent.bind(this)})),this.#s=new Jt({router:e.router,emitEvent:this.emitEvent.bind(this)}),this.#o=new Yt({signer:e.signer,router:e.router,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.permits=new It({signer:this.signer,provider:this.provider,cachingService:this.#a,credentialService:this.#l,logger:this.#i}),this.delegations=new Ft({signer:this.signer,provider:this.provider,delegationService:this.#u}),this.decryption=new Pt({signer:this.signer,provider:this.provider,router:e.router,decryptionService:this.#c})}onWalletAccountChange(e){return this.#o.onWalletAccountChange(e)}get logger(){return this.#i}get relayer(){return this.#e.relayer}emitEvent(e,t){try{this.#r({...e,tokenAddress:t,timestamp:Date.now()})}catch(t){this.#i.warn(`${e.type} event listener silently failed`,{error:t})}}createWrappersRegistry(e){return new j({provider:this.provider,registryAddresses:{...this.#n,...e},registryTTL:this.#t})}async encrypt(e,t){return this.#s.encryptValues(e,t)}createToken(e){return new O(this,e)}createWrappedToken(e){return new bn(this,e)}dispose(){this.#o.dispose()}terminate(){this.dispose(),this.signer?.dispose?.()}[Symbol.dispose](){this.terminate()}},Sn=class{async get(e){return(await chrome.storage.session.get(e))[e]??null}async set(e,t){await chrome.storage.session.set({[e]:t})}async delete(e){await chrome.storage.session.remove(e)}};const Cn=new Sn;export{mn as ACL_TOPICS,Ot as AclPausedError,X as AclTopics,Je as BalanceCheckUnavailableError,dt as BaseSigner,Fe as ChainMismatchError,Sn as ChromeSessionStorage,m as ConfigurationError,Pt as Decryption,C as DecryptionFailedError,Qe as DefaultRegistryAddresses,Dt as DelegationContractIsSelfError,Et as DelegationCooldownError,B as DelegationDelegateEqualsContractError,V as DelegationExpirationTooSoonError,R as DelegationExpiredError,z as DelegationExpiryUnchangedError,L as DelegationNotFoundError,H as DelegationNotPropagatedError,I as DelegationSelfNotAllowedError,Ft as Delegations,_e as ERC1363_INTERFACE_ID,Xe as ERC20ReadFailedError,Ce as ERC7984_INTERFACE_ID,je as ERC7984_WRAPPER_INTERFACE_ID,S as EncryptionFailedError,rt as IndexedDBStorage,Le as InsufficientConfidentialBalanceError,Ye as InsufficientERC20BalanceError,wt as InvalidTransportKeyPairError,ct as MemoryStorage,st as MutableWalletAccountStore,Tt as NoCiphertextError,F as NotEntitledError,It as Permits,l as RelayerRequestFailedError,x as RpcRateLimitError,ce as SignerNotConfiguredError,Pe as SignerRequiredError,de as SigningFailedError,pe as SigningRejectedError,ln as TOKEN_TOPICS,O as Token,q as Topics,A as TransactionRevertedError,Ct as TransportKeyPairExpiredError,g as WalletAccountNotReadyError,fe as WalletNotConnectedError,bn as WrappedToken,j as WrappersRegistry,qe as ZERO_ENCRYPTED_VALUE,f as ZamaError,o as ZamaErrorCode,xn as ZamaSDK,D as ZamaSDKEvents,b as allowanceContract,yt as anvil,y as approveContract,me as balanceOfContract,ht as bscTestnet,_t as chains,Cn as chromeSessionStorage,Ze as cleartext,le as confidentialBalanceOfContract,ee as confidentialTotalSupplyContract,ue as confidentialTransferContract,te as confidentialTransferFromContract,Nt as createConfig,lt as createWalletAccountStore,Me as decimalsContract,un as decodeAclEvent,dn as decodeAclEvents,en as decodeConfidentialTransfer,Z as decodeDelegatedForUserDecryption,an as decodeOnChainEvent,on as decodeOnChainEvents,Q as decodeRevokedDelegationForUserDecryption,rn as decodeUnwrapFinalized,nn as decodeUnwrapRequested,tn as decodeWrap,Ke as delegateForUserDecryptionContract,oe as finalizeUnwrapContract,fn as findDelegatedForUserDecryption,pn as findRevokedDelegationForUserDecryption,sn as findUnwrapRequested,cn as findWrap,Ae as getConfidentialTokenAddressContract,Ue as getDelegationExpiryContract,Te as getTokenAddressContract,Oe as getTokenPairContract,be as getTokenPairsContract,he as getTokenPairsLengthContract,Ee as getTokenPairsSliceContract,mt as hardhat,ft as hoodi,nt as indexedDBStorage,Se as inferredTotalSupplyContract,gt as ingenTestnet,ve as isConfidentialTokenContract,ke as isConfidentialTokenValidContract,ye as isConfidentialWrapperContract,w as isEncryptedValueZero,Be as isHandleDelegatedContract,h as isOperatorContract,e as isRetryable,vt as mainnet,St as matchZamaError,ot as memoryStorage,ge as nameContract,xe as rateContract,et as resolveChainRelayers,tt as resolveStorage,u as retryAfterSeconds,ze as revokeDelegationContract,pt as sepolia,ie as setOperatorContract,we as supportsInterfaceContract,Ne as symbolContract,Mt as transferAndCallContract,ae as underlyingContract,se as unwrapContract,ne as unwrapFromBalanceContract,re as wrapContract};
2
2
  //# sourceMappingURL=index.js.map