@zama-fhe/sdk 3.2.0 → 3.3.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.
- package/dist/cjs/base-signer.cjs +1 -1
- package/dist/cjs/ethers/index.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/query/index.cjs +1 -1
- package/dist/cjs/query/index.cjs.map +1 -1
- package/dist/cjs/token.cjs +1 -1
- package/dist/cjs/token.cjs.map +1 -1
- package/dist/cjs/viem/index.cjs +1 -1
- package/dist/cjs/wrappers-registry.cjs +1 -1
- package/dist/cjs/wrappers-registry.cjs.map +1 -1
- package/dist/esm/base-signer-DaRQNB29.js +2 -0
- package/dist/esm/{base-signer-BVqcM5jt.js.map → base-signer-DaRQNB29.js.map} +1 -1
- package/dist/esm/{cleartext-DMW5nK1M.d.ts → cleartext-4WhQWHZF.d.ts} +2 -2
- package/dist/esm/ethers/index.d.ts +2 -2
- package/dist/esm/ethers/index.js +1 -1
- package/dist/esm/ethers/index.js.map +1 -1
- package/dist/esm/{index-DoVo9J1n.d.ts → index-BRIQ3Msg.d.ts} +56 -2
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node/index.d.ts +2 -2
- package/dist/esm/node/index.js +1 -1
- package/dist/esm/node/index.js.map +1 -1
- package/dist/esm/query/index.d.ts +26 -3
- package/dist/esm/query/index.js +1 -1
- package/dist/esm/query/index.js.map +1 -1
- package/dist/esm/token-BTgHqRIL.js +2 -0
- package/dist/esm/token-BTgHqRIL.js.map +1 -0
- package/dist/esm/{types-BjDu-RZg.d.ts → types-C4JRzs5M.d.ts} +13 -1
- package/dist/esm/{types-DiZhtG8i.d.ts → types-Cb7AvEOP.d.ts} +2 -2
- package/dist/esm/{types-Xg_On_yY.d.ts → types-DJp9eoXC.d.ts} +2 -2
- package/dist/esm/viem/index.d.ts +2 -2
- package/dist/esm/viem/index.js +1 -1
- package/dist/esm/web/index.d.ts +1 -1
- package/dist/esm/{wrappers-registry-BWWG0aze.js → wrappers-registry-ChxQp8ty.js} +2 -2
- package/dist/esm/wrappers-registry-ChxQp8ty.js.map +1 -0
- package/package.json +1 -1
- package/dist/esm/base-signer-BVqcM5jt.js +0 -2
- package/dist/esm/token-TQ-VFHS4.js +0 -2
- package/dist/esm/token-TQ-VFHS4.js.map +0 -1
- package/dist/esm/wrappers-registry-BWWG0aze.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["#readProvider","#browserProvider","#directSigner","#eip1193","#unsubscribeProvider","#loadBrowserWalletAccount","#refreshFromEthereum","#refreshFromSigner","#resolveSigner","#walletAccountFromSigner","#accountPromise"],"sources":["../../../src/ethers/ethers-provider.ts","../../../src/ethers/ethers-signer.ts","../../../src/ethers/config.ts","../../../src/ethers/contracts.ts"],"sourcesContent":["import { ethers, BrowserProvider } from \"ethers\";\nimport type {\n Abi,\n ContractFunctionArgs,\n ContractFunctionName,\n ContractFunctionReturnType,\n EIP1193Provider,\n Hex,\n} from \"viem\";\nimport type { GenericProvider, ReadContractConfig, TransactionReceipt } from \"../types\";\n\n/**\n * Configuration for {@link EthersProvider}.\n *\n * Two variants:\n *\n * - **EIP-1193** — `{ ethereum }`: pass the raw EIP-1193 provider (e.g. `window.ethereum`).\n * A `BrowserProvider` is created internally.\n *\n * - **Pre-built** — `{ provider }`: pass any ethers `Provider`\n * (e.g. `JsonRpcProvider`, `WebSocketProvider`).\n */\nexport type EthersProviderConfig = { ethereum: EIP1193Provider } | { provider: ethers.Provider };\n\n/**\n * Read-only {@link GenericProvider} backed by ethers v6.\n *\n * Use this for integrations that only need public chain reads before the user has connected their\n * wallet.\n *\n * @example\n * ```ts\n * // Dedicated RPC\n * const provider = new EthersProvider({\n * provider: new ethers.JsonRpcProvider(ALCHEMY_URL),\n * });\n *\n * // Wallet-sourced RPC (shares transport with EthersSigner)\n * const provider = new EthersProvider({ ethereum: window.ethereum });\n * ```\n */\nexport class EthersProvider implements GenericProvider {\n readonly #readProvider: ethers.Provider;\n\n constructor(config: EthersProviderConfig) {\n if (\"ethereum\" in config) {\n this.#readProvider = new BrowserProvider(config.ethereum);\n } else {\n this.#readProvider = config.provider;\n }\n }\n\n async getChainId(): Promise<number> {\n const network = await this.#readProvider.getNetwork();\n return Number(network.chainId);\n }\n\n async readContract<\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<TAbi, \"pure\" | \"view\">,\n const TArgs extends ContractFunctionArgs<TAbi, \"pure\" | \"view\", TFunctionName>,\n >(\n config: ReadContractConfig<TAbi, TFunctionName, TArgs>,\n ): Promise<ContractFunctionReturnType<TAbi, \"pure\" | \"view\", TFunctionName, TArgs>> {\n const contract = new ethers.Contract(\n config.address,\n config.abi as ethers.InterfaceAbi,\n this.#readProvider,\n );\n const fn = contract.getFunction(config.functionName);\n return fn(...(config.args as readonly unknown[])) as Promise<\n ContractFunctionReturnType<TAbi, \"pure\" | \"view\", TFunctionName, TArgs>\n >;\n }\n\n async getBlockTimestamp(): Promise<bigint> {\n const block = await this.#readProvider.getBlock(\"latest\");\n if (!block) {\n throw new Error(\"Failed to fetch latest block\");\n }\n if (block.timestamp === null) {\n throw new Error(\"Latest block has no timestamp\");\n }\n return BigInt(block.timestamp);\n }\n\n async waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt> {\n const receipt = await this.#readProvider.waitForTransaction(hash);\n if (!receipt) {\n throw new Error(\"Transaction receipt not found\");\n }\n return {\n logs: receipt.logs.map((log) => ({\n topics: log.topics.filter((t): t is Hex => t !== null),\n data: log.data as Hex,\n })),\n };\n }\n}\n","import { BrowserProvider, Contract, type InterfaceAbi, type Signer } from \"ethers\";\nimport {\n getAddress,\n isHex,\n type Abi,\n type ContractFunctionArgs,\n type ContractFunctionName,\n type EIP1193Provider,\n type Hex,\n} from \"viem\";\nimport {\n SignerNotConfiguredError,\n WalletAccountNotReadyError,\n WalletNotConnectedError,\n} from \"../errors\";\nimport type { EIP712TypedData } from \"../relayer/relayer-sdk.types\";\nimport { BaseSigner } from \"../signer/base-signer\";\nimport { eip1193Subscribe } from \"../signer/eip1193-subscribe\";\nimport type { WalletAccount, WriteContractConfig } from \"../types\";\nimport { swallow } from \"../utils\";\n\n/**\n * Configuration for {@link EthersSigner}.\n *\n * Two variants:\n *\n * - **Browser** — `{ ethereum }`: pass the raw EIP-1193 provider (e.g. `window.ethereum`).\n * A `BrowserProvider` is created internally and wallet events update `walletAccount`.\n *\n * - **Node / direct signer** — `{ signer }`: pass an ethers `Signer` (e.g. `Wallet`).\n * The initial wallet account is discovered asynchronously and emitted through\n * `walletAccount` once available.\n *\n * For public chain reads, construct a separate {@link EthersProvider}.\n */\nexport type EthersSignerConfig = { ethereum: EIP1193Provider } | { signer: Signer };\n\n/**\n * GenericSigner backed by ethers.\n *\n * Accepts either a raw EIP-1193 provider (`{ ethereum }`) which creates a\n * `BrowserProvider` internally, or a `Signer` directly (`{ signer }`)\n * for Node.js scripts.\n *\n * @param config - {@link EthersSignerConfig}\n */\nexport class EthersSigner extends BaseSigner {\n readonly #browserProvider?: BrowserProvider;\n readonly #directSigner?: Signer;\n readonly #eip1193?: EIP1193Provider;\n readonly #unsubscribeProvider: () => void;\n #accountPromise: Promise<WalletAccount | undefined> | undefined;\n\n constructor(config: EthersSignerConfig) {\n super();\n if (\"ethereum\" in config) {\n this.#browserProvider = new BrowserProvider(config.ethereum);\n this.#eip1193 = config.ethereum;\n this.#unsubscribeProvider = eip1193Subscribe({\n provider: config.ethereum,\n getInitialWalletAccount: () => this.#loadBrowserWalletAccount(),\n onWalletAccountChange: ({ next }) => {\n this.walletAccount.setSnapshot(next);\n },\n });\n } else {\n this.#directSigner = config.signer;\n this.#unsubscribeProvider = () => {};\n // The signer is constructed before `createConfig`, so it cannot reach the\n // SDK-wide logger; this best-effort refresh stays silent. A failed refresh\n // still surfaces via the typed WalletAccountNotReadyError on next use.\n void swallow(\"refresh wallet account\", async () => {\n await this.refreshWalletAccount();\n });\n }\n }\n\n override requireWalletAccount(operation: string): WalletAccount {\n const account = this.walletAccount.getSnapshot();\n if (!account && !this.walletAccount.isReady()) {\n throw new WalletAccountNotReadyError(operation);\n }\n if (!account) {\n throw new WalletNotConnectedError(operation);\n }\n return account;\n }\n\n refreshWalletAccount(): Promise<WalletAccount | undefined> {\n if (this.#eip1193) {\n return this.#refreshFromEthereum();\n }\n if (this.#directSigner) {\n return this.#refreshFromSigner(this.#directSigner);\n }\n return Promise.resolve(undefined);\n }\n\n protected override onDispose(): void {\n this.#unsubscribeProvider();\n }\n\n async #resolveSigner(): Promise<Signer> {\n if (this.#directSigner) {\n return this.#directSigner;\n }\n if (!this.#browserProvider) {\n throw new SignerNotConfiguredError(\"resolveSigner\");\n }\n return this.#browserProvider.getSigner();\n }\n\n async #walletAccountFromSigner(signer: Signer): Promise<WalletAccount | undefined> {\n const provider = signer.provider;\n if (!provider) {\n return undefined;\n }\n const [address, network] = await Promise.all([signer.getAddress(), provider.getNetwork()]);\n return { address: getAddress(address), chainId: Number(network.chainId) };\n }\n\n async signTypedData(typedData: EIP712TypedData): Promise<Hex> {\n const signer = await this.#resolveSigner();\n const { domain, types, message } = typedData;\n const { EIP712Domain: _, ...sigTypes } = types;\n const mutableSigTypes = Object.fromEntries(\n Object.entries(sigTypes).map(([key, fields]) => [key, [...fields]]),\n );\n const sig = await signer.signTypedData(domain, mutableSigTypes, message);\n if (!isHex(sig)) {\n throw new TypeError(`Expected hex string, got: ${sig}`);\n }\n return sig;\n }\n\n async writeContract<\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<TAbi, \"nonpayable\" | \"payable\">,\n const TArgs extends ContractFunctionArgs<TAbi, \"nonpayable\" | \"payable\", TFunctionName>,\n >(config: WriteContractConfig<TAbi, TFunctionName, TArgs>): Promise<Hex> {\n const signer = await this.#resolveSigner();\n const contract = new Contract(config.address, config.abi as InterfaceAbi, signer);\n const overrides: { gasLimit?: bigint; value?: bigint } = {};\n if (config.value !== undefined) {\n overrides.value = config.value;\n }\n if (config.gas !== undefined) {\n overrides.gasLimit = config.gas;\n }\n const fn = contract.getFunction(config.functionName);\n const tx = await fn(...(config.args as readonly unknown[]), overrides);\n if (!isHex(tx.hash)) {\n throw new TypeError(`Expected hex string, got: ${tx.hash}`);\n }\n return tx.hash;\n }\n\n async #refreshFromSigner(signer: Signer): Promise<WalletAccount | undefined> {\n this.#accountPromise ??= this.#walletAccountFromSigner(signer)\n .then((account) => {\n this.walletAccount.setSnapshot(account);\n return account;\n })\n .finally(() => {\n this.#accountPromise = undefined;\n });\n return this.#accountPromise;\n }\n\n async #refreshFromEthereum(): Promise<WalletAccount | undefined> {\n const account = await this.#loadBrowserWalletAccount();\n this.walletAccount.setSnapshot(account);\n return account;\n }\n\n async #loadBrowserWalletAccount(): Promise<WalletAccount | undefined> {\n const ethereum = this.#eip1193;\n if (!ethereum) {\n return undefined;\n }\n const [accounts, chainIdValue] = await Promise.all([\n ethereum.request({ method: \"eth_accounts\" }),\n ethereum.request({ method: \"eth_chainId\" }),\n ]);\n if (!Array.isArray(accounts) || typeof accounts[0] !== \"string\") {\n return undefined;\n }\n const chainId = Number(chainIdValue);\n if (!Number.isSafeInteger(chainId) || chainId <= 0) {\n return undefined;\n }\n return { address: getAddress(accounts[0]), chainId };\n }\n}\n","import type { FheChain } from \"../chains\";\nimport { buildZamaConfig } from \"../config/build\";\nimport type { ZamaConfig } from \"../config/types\";\nimport { EthersProvider } from \"./ethers-provider\";\nimport { EthersSigner } from \"./ethers-signer\";\nimport type { ZamaConfigEthers } from \"./types\";\n\n/** Create a {@link ZamaConfig} from ethers types. */\nexport function createConfig<const TChains extends readonly [FheChain, ...FheChain[]]>(\n params: ZamaConfigEthers<TChains>,\n): ZamaConfig {\n if (\"signer\" in params && params.signer) {\n const signer = new EthersSigner({ signer: params.signer });\n if (!params.signer.provider) {\n throw new Error(\"createConfig requires a Signer with an attached provider for chain reads\");\n }\n const provider = new EthersProvider({ provider: params.signer.provider });\n return buildZamaConfig(signer, provider, params);\n }\n\n const signer = new EthersSigner({ ethereum: params.ethereum });\n const provider =\n \"provider\" in params && params.provider\n ? new EthersProvider({ provider: params.provider })\n : new EthersProvider({ ethereum: params.ethereum });\n return buildZamaConfig(signer, provider, params);\n}\n","import {\n decodeFunctionResult,\n encodeFunctionData,\n isHex,\n type Abi,\n type Address,\n type Hex,\n} from \"viem\";\n\nimport type { EncryptedValue } from \"../relayer/relayer-sdk.types\";\n\nimport {\n confidentialBalanceOfContract,\n confidentialTransferContract,\n finalizeUnwrapContract,\n setOperatorContract,\n supportsInterfaceContract,\n underlyingContract,\n unwrapContract,\n unwrapFromBalanceContract,\n wrapContract,\n getTokenPairsContract,\n getTokenPairsLengthContract,\n getTokenPairsSliceContract,\n getTokenPairContract,\n getConfidentialTokenAddressContract,\n getTokenAddressContract,\n isConfidentialTokenValidContract,\n} from \"../contracts\";\n\ninterface TransactionRequestConfig {\n address: Address;\n abi: readonly unknown[];\n functionName: string;\n args: readonly unknown[];\n gas?: bigint;\n value?: bigint;\n}\n\ninterface EthersTransactionRequest {\n to: Address;\n data: Hex;\n gasLimit?: bigint;\n value?: bigint;\n}\n\ninterface EthersTransactionResponse {\n hash: string;\n}\n\ninterface EthersCallProvider {\n call(tx: EthersTransactionRequest): Promise<string>;\n}\n\ninterface EthersTransactionSigner extends EthersCallProvider {\n sendTransaction(tx: EthersTransactionRequest): Promise<EthersTransactionResponse>;\n}\n\nfunction toTransactionRequest(config: TransactionRequestConfig): EthersTransactionRequest {\n return {\n to: config.address,\n data: encodeFunctionData({\n abi: config.abi as Abi,\n functionName: config.functionName as never,\n args: config.args as never,\n }),\n ...(config.gas !== undefined ? { gasLimit: config.gas } : {}),\n ...(config.value !== undefined ? { value: config.value } : {}),\n };\n}\n\nasync function ethersRead<T>(\n provider: EthersCallProvider,\n config: TransactionRequestConfig,\n): Promise<T> {\n const data = await provider.call(toTransactionRequest(config));\n if (!isHex(data)) {\n throw new TypeError(`Expected hex string, got: ${data}`);\n }\n return decodeFunctionResult({\n abi: config.abi as Abi,\n functionName: config.functionName as never,\n data,\n }) as T;\n}\n\nasync function ethersWrite(\n signer: EthersTransactionSigner,\n config: TransactionRequestConfig,\n): Promise<Hex> {\n const tx = await signer.sendTransaction(toTransactionRequest(config));\n if (!isHex(tx.hash)) {\n throw new TypeError(`Expected hex string, got: ${tx.hash}`);\n }\n return tx.hash;\n}\n\n// ── Read helpers ────────────────────────────────────────────\n\nexport function readConfidentialBalanceOfContract(\n provider: EthersCallProvider,\n tokenAddress: Address,\n userAddress: Address,\n) {\n return ethersRead(provider, confidentialBalanceOfContract(tokenAddress, userAddress));\n}\n\nexport function readUnderlyingTokenContract(provider: EthersCallProvider, wrapperAddress: Address) {\n return ethersRead(provider, underlyingContract(wrapperAddress));\n}\n\nexport function readSupportsInterfaceContract(\n provider: EthersCallProvider,\n tokenAddress: Address,\n interfaceId: Address,\n) {\n return ethersRead(provider, supportsInterfaceContract(tokenAddress, interfaceId));\n}\n\n// ── Write helpers ───────────────────────────────────────────\n\nexport function writeConfidentialTransferContract(\n signer: EthersTransactionSigner,\n tokenAddress: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return ethersWrite(\n signer,\n confidentialTransferContract(tokenAddress, to, encryptedAmount, inputProof),\n );\n}\n\nexport function writeUnwrapContract(\n signer: EthersTransactionSigner,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return ethersWrite(signer, unwrapContract(encryptedErc20, from, to, encryptedAmount, inputProof));\n}\n\nexport function writeUnwrapFromBalanceContract(\n signer: EthersTransactionSigner,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedBalance: EncryptedValue,\n) {\n return ethersWrite(signer, unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance));\n}\n\nexport function writeFinalizeUnwrapContract(\n signer: EthersTransactionSigner,\n wrapper: Address,\n unwrapRequestId: EncryptedValue,\n unwrapAmountCleartext: bigint,\n decryptionProof: Hex,\n) {\n return ethersWrite(\n signer,\n finalizeUnwrapContract(wrapper, unwrapRequestId, unwrapAmountCleartext, decryptionProof),\n );\n}\n\nexport function writeSetOperatorContract(\n signer: EthersTransactionSigner,\n tokenAddress: Address,\n operator: Address,\n until?: number,\n) {\n return ethersWrite(signer, setOperatorContract(tokenAddress, operator, until));\n}\n\nexport function writeWrapContract(\n signer: EthersTransactionSigner,\n wrapperAddress: Address,\n to: Address,\n amount: bigint,\n) {\n return ethersWrite(signer, wrapContract(wrapperAddress, to, amount));\n}\n\n// ── Registry read helpers ──────────────────────────────────\n\nexport function readTokenPairsContract(provider: EthersCallProvider, registry: Address) {\n return ethersRead(provider, getTokenPairsContract(registry));\n}\n\nexport function readTokenPairsLengthContract(provider: EthersCallProvider, registry: Address) {\n return ethersRead(provider, getTokenPairsLengthContract(registry));\n}\n\nexport function readTokenPairsSliceContract(\n provider: EthersCallProvider,\n registry: Address,\n fromIndex: bigint,\n toIndex: bigint,\n) {\n return ethersRead(provider, getTokenPairsSliceContract(registry, fromIndex, toIndex));\n}\n\nexport function readTokenPairContract(\n provider: EthersCallProvider,\n registry: Address,\n index: bigint,\n) {\n return ethersRead(provider, getTokenPairContract(registry, index));\n}\n\nexport function readConfidentialTokenAddressContract(\n provider: EthersCallProvider,\n registry: Address,\n tokenAddress: Address,\n) {\n return ethersRead(provider, getConfidentialTokenAddressContract(registry, tokenAddress));\n}\n\nexport function readTokenAddressContract(\n provider: EthersCallProvider,\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return ethersRead(provider, getTokenAddressContract(registry, confidentialTokenAddress));\n}\n\nexport function readIsConfidentialTokenValidContract(\n provider: EthersCallProvider,\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return ethersRead(provider, isConfidentialTokenValidContract(registry, confidentialTokenAddress));\n}\n"],"mappings":"6dAyCA,IAAa,EAAb,KAAuD,CACrD,GAEA,YA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AAC,CACzF,CAEA,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAW,EAAU,EAAwB,EAAU,CAAwB,CAAC,CACzF,CAEA,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAW,EAAU,EAAiC,EAAU,CAAwB,CAAC,CAClG"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["#readProvider","#browserProvider","#directSigner","#eip1193","#unsubscribeProvider","#loadBrowserWalletAccount","#refreshFromEthereum","#refreshFromSigner","#resolveSigner","#walletAccountFromSigner","#accountPromise"],"sources":["../../../src/ethers/ethers-provider.ts","../../../src/ethers/ethers-signer.ts","../../../src/ethers/config.ts","../../../src/ethers/contracts.ts"],"sourcesContent":["import { ethers, BrowserProvider } from \"ethers\";\nimport type {\n Abi,\n ContractFunctionArgs,\n ContractFunctionName,\n ContractFunctionReturnType,\n EIP1193Provider,\n Hex,\n} from \"viem\";\nimport type { GenericProvider, ReadContractConfig, TransactionReceipt } from \"../types\";\n\n/**\n * Configuration for {@link EthersProvider}.\n *\n * Two variants:\n *\n * - **EIP-1193** — `{ ethereum }`: pass the raw EIP-1193 provider (e.g. `window.ethereum`).\n * A `BrowserProvider` is created internally.\n *\n * - **Pre-built** — `{ provider }`: pass any ethers `Provider`\n * (e.g. `JsonRpcProvider`, `WebSocketProvider`).\n */\nexport type EthersProviderConfig = { ethereum: EIP1193Provider } | { provider: ethers.Provider };\n\n/**\n * Read-only {@link GenericProvider} backed by ethers v6.\n *\n * Use this for integrations that only need public chain reads before the user has connected their\n * wallet.\n *\n * @example\n * ```ts\n * // Dedicated RPC\n * const provider = new EthersProvider({\n * provider: new ethers.JsonRpcProvider(ALCHEMY_URL),\n * });\n *\n * // Wallet-sourced RPC (shares transport with EthersSigner)\n * const provider = new EthersProvider({ ethereum: window.ethereum });\n * ```\n */\nexport class EthersProvider implements GenericProvider {\n readonly #readProvider: ethers.Provider;\n\n constructor(config: EthersProviderConfig) {\n if (\"ethereum\" in config) {\n this.#readProvider = new BrowserProvider(config.ethereum);\n } else {\n this.#readProvider = config.provider;\n }\n }\n\n async getChainId(): Promise<number> {\n const network = await this.#readProvider.getNetwork();\n return Number(network.chainId);\n }\n\n async readContract<\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<TAbi, \"pure\" | \"view\">,\n const TArgs extends ContractFunctionArgs<TAbi, \"pure\" | \"view\", TFunctionName>,\n >(\n config: ReadContractConfig<TAbi, TFunctionName, TArgs>,\n ): Promise<ContractFunctionReturnType<TAbi, \"pure\" | \"view\", TFunctionName, TArgs>> {\n const contract = new ethers.Contract(\n config.address,\n config.abi as ethers.InterfaceAbi,\n this.#readProvider,\n );\n const fn = contract.getFunction(config.functionName);\n return fn(...(config.args as readonly unknown[])) as Promise<\n ContractFunctionReturnType<TAbi, \"pure\" | \"view\", TFunctionName, TArgs>\n >;\n }\n\n async getBlockTimestamp(): Promise<bigint> {\n const block = await this.#readProvider.getBlock(\"latest\");\n if (!block) {\n throw new Error(\"Failed to fetch latest block\");\n }\n if (block.timestamp === null) {\n throw new Error(\"Latest block has no timestamp\");\n }\n return BigInt(block.timestamp);\n }\n\n async waitForTransactionReceipt(hash: Hex): Promise<TransactionReceipt> {\n const receipt = await this.#readProvider.waitForTransaction(hash);\n if (!receipt) {\n throw new Error(\"Transaction receipt not found\");\n }\n return {\n logs: receipt.logs.map((log) => ({\n topics: log.topics.filter((t): t is Hex => t !== null),\n data: log.data as Hex,\n })),\n };\n }\n}\n","import { BrowserProvider, Contract, type InterfaceAbi, type Signer } from \"ethers\";\nimport {\n getAddress,\n isHex,\n type Abi,\n type ContractFunctionArgs,\n type ContractFunctionName,\n type EIP1193Provider,\n type Hex,\n} from \"viem\";\nimport {\n SignerNotConfiguredError,\n WalletAccountNotReadyError,\n WalletNotConnectedError,\n} from \"../errors\";\nimport type { EIP712TypedData } from \"../relayer/relayer-sdk.types\";\nimport { BaseSigner } from \"../signer/base-signer\";\nimport { eip1193Subscribe } from \"../signer/eip1193-subscribe\";\nimport type { WalletAccount, WriteContractConfig } from \"../types\";\nimport { swallow } from \"../utils\";\n\n/**\n * Configuration for {@link EthersSigner}.\n *\n * Two variants:\n *\n * - **Browser** — `{ ethereum }`: pass the raw EIP-1193 provider (e.g. `window.ethereum`).\n * A `BrowserProvider` is created internally and wallet events update `walletAccount`.\n *\n * - **Node / direct signer** — `{ signer }`: pass an ethers `Signer` (e.g. `Wallet`).\n * The initial wallet account is discovered asynchronously and emitted through\n * `walletAccount` once available.\n *\n * For public chain reads, construct a separate {@link EthersProvider}.\n */\nexport type EthersSignerConfig = { ethereum: EIP1193Provider } | { signer: Signer };\n\n/**\n * GenericSigner backed by ethers.\n *\n * Accepts either a raw EIP-1193 provider (`{ ethereum }`) which creates a\n * `BrowserProvider` internally, or a `Signer` directly (`{ signer }`)\n * for Node.js scripts.\n *\n * @param config - {@link EthersSignerConfig}\n */\nexport class EthersSigner extends BaseSigner {\n readonly #browserProvider?: BrowserProvider;\n readonly #directSigner?: Signer;\n readonly #eip1193?: EIP1193Provider;\n readonly #unsubscribeProvider: () => void;\n #accountPromise: Promise<WalletAccount | undefined> | undefined;\n\n constructor(config: EthersSignerConfig) {\n super();\n if (\"ethereum\" in config) {\n this.#browserProvider = new BrowserProvider(config.ethereum);\n this.#eip1193 = config.ethereum;\n this.#unsubscribeProvider = eip1193Subscribe({\n provider: config.ethereum,\n getInitialWalletAccount: () => this.#loadBrowserWalletAccount(),\n onWalletAccountChange: ({ next }) => {\n this.walletAccount.setSnapshot(next);\n },\n });\n } else {\n this.#directSigner = config.signer;\n this.#unsubscribeProvider = () => {};\n // The signer is constructed before `createConfig`, so it cannot reach the\n // SDK-wide logger; this best-effort refresh stays silent. A failed refresh\n // still surfaces via the typed WalletAccountNotReadyError on next use.\n void swallow(\"refresh wallet account\", async () => {\n await this.refreshWalletAccount();\n });\n }\n }\n\n override requireWalletAccount(operation: string): WalletAccount {\n const account = this.walletAccount.getSnapshot();\n if (!account && !this.walletAccount.isReady()) {\n throw new WalletAccountNotReadyError(operation);\n }\n if (!account) {\n throw new WalletNotConnectedError(operation);\n }\n return account;\n }\n\n refreshWalletAccount(): Promise<WalletAccount | undefined> {\n if (this.#eip1193) {\n return this.#refreshFromEthereum();\n }\n if (this.#directSigner) {\n return this.#refreshFromSigner(this.#directSigner);\n }\n return Promise.resolve(undefined);\n }\n\n protected override onDispose(): void {\n this.#unsubscribeProvider();\n }\n\n async #resolveSigner(): Promise<Signer> {\n if (this.#directSigner) {\n return this.#directSigner;\n }\n if (!this.#browserProvider) {\n throw new SignerNotConfiguredError(\"resolveSigner\");\n }\n return this.#browserProvider.getSigner();\n }\n\n async #walletAccountFromSigner(signer: Signer): Promise<WalletAccount | undefined> {\n const provider = signer.provider;\n if (!provider) {\n return undefined;\n }\n const [address, network] = await Promise.all([signer.getAddress(), provider.getNetwork()]);\n return { address: getAddress(address), chainId: Number(network.chainId) };\n }\n\n async signTypedData(typedData: EIP712TypedData): Promise<Hex> {\n const signer = await this.#resolveSigner();\n const { domain, types, message } = typedData;\n const { EIP712Domain: _, ...sigTypes } = types;\n const mutableSigTypes = Object.fromEntries(\n Object.entries(sigTypes).map(([key, fields]) => [key, [...fields]]),\n );\n const sig = await signer.signTypedData(domain, mutableSigTypes, message);\n if (!isHex(sig)) {\n throw new TypeError(`Expected hex string, got: ${sig}`);\n }\n return sig;\n }\n\n async writeContract<\n const TAbi extends Abi | readonly unknown[],\n TFunctionName extends ContractFunctionName<TAbi, \"nonpayable\" | \"payable\">,\n const TArgs extends ContractFunctionArgs<TAbi, \"nonpayable\" | \"payable\", TFunctionName>,\n >(config: WriteContractConfig<TAbi, TFunctionName, TArgs>): Promise<Hex> {\n const signer = await this.#resolveSigner();\n const contract = new Contract(config.address, config.abi as InterfaceAbi, signer);\n const overrides: { gasLimit?: bigint; value?: bigint } = {};\n if (config.value !== undefined) {\n overrides.value = config.value;\n }\n if (config.gas !== undefined) {\n overrides.gasLimit = config.gas;\n }\n const fn = contract.getFunction(config.functionName);\n const tx = await fn(...(config.args as readonly unknown[]), overrides);\n if (!isHex(tx.hash)) {\n throw new TypeError(`Expected hex string, got: ${tx.hash}`);\n }\n return tx.hash;\n }\n\n async #refreshFromSigner(signer: Signer): Promise<WalletAccount | undefined> {\n this.#accountPromise ??= this.#walletAccountFromSigner(signer)\n .then((account) => {\n this.walletAccount.setSnapshot(account);\n return account;\n })\n .finally(() => {\n this.#accountPromise = undefined;\n });\n return this.#accountPromise;\n }\n\n async #refreshFromEthereum(): Promise<WalletAccount | undefined> {\n const account = await this.#loadBrowserWalletAccount();\n this.walletAccount.setSnapshot(account);\n return account;\n }\n\n async #loadBrowserWalletAccount(): Promise<WalletAccount | undefined> {\n const ethereum = this.#eip1193;\n if (!ethereum) {\n return undefined;\n }\n const [accounts, chainIdValue] = await Promise.all([\n ethereum.request({ method: \"eth_accounts\" }),\n ethereum.request({ method: \"eth_chainId\" }),\n ]);\n if (!Array.isArray(accounts) || typeof accounts[0] !== \"string\") {\n return undefined;\n }\n const chainId = Number(chainIdValue);\n if (!Number.isSafeInteger(chainId) || chainId <= 0) {\n return undefined;\n }\n return { address: getAddress(accounts[0]), chainId };\n }\n}\n","import type { FheChain } from \"../chains\";\nimport { buildZamaConfig } from \"../config/build\";\nimport type { ZamaConfig } from \"../config/types\";\nimport { EthersProvider } from \"./ethers-provider\";\nimport { EthersSigner } from \"./ethers-signer\";\nimport type { ZamaConfigEthers } from \"./types\";\n\n/** Create a {@link ZamaConfig} from ethers types. */\nexport function createConfig<const TChains extends readonly [FheChain, ...FheChain[]]>(\n params: ZamaConfigEthers<TChains>,\n): ZamaConfig {\n if (\"signer\" in params && params.signer) {\n const signer = new EthersSigner({ signer: params.signer });\n if (!params.signer.provider) {\n throw new Error(\"createConfig requires a Signer with an attached provider for chain reads\");\n }\n const provider = new EthersProvider({ provider: params.signer.provider });\n return buildZamaConfig(signer, provider, params);\n }\n\n const signer = new EthersSigner({ ethereum: params.ethereum });\n const provider =\n \"provider\" in params && params.provider\n ? new EthersProvider({ provider: params.provider })\n : new EthersProvider({ ethereum: params.ethereum });\n return buildZamaConfig(signer, provider, params);\n}\n","import {\n decodeFunctionResult,\n encodeFunctionData,\n isHex,\n type Abi,\n type Address,\n type Hex,\n} from \"viem\";\n\nimport type { EncryptedValue } from \"../relayer/relayer-sdk.types\";\n\nimport {\n confidentialBalanceOfContract,\n confidentialTransferContract,\n finalizeUnwrapContract,\n setOperatorContract,\n supportsInterfaceContract,\n underlyingContract,\n unwrapContract,\n unwrapFromBalanceContract,\n wrapContract,\n getTokenPairsContract,\n getTokenPairsLengthContract,\n getTokenPairsSliceContract,\n getTokenPairContract,\n getConfidentialTokenAddressContract,\n getTokenAddressContract,\n isConfidentialTokenValidContract,\n} from \"../contracts\";\n\ninterface TransactionRequestConfig {\n address: Address;\n abi: readonly unknown[];\n functionName: string;\n args: readonly unknown[];\n gas?: bigint;\n value?: bigint;\n}\n\ninterface EthersTransactionRequest {\n to: Address;\n data: Hex;\n gasLimit?: bigint;\n value?: bigint;\n}\n\ninterface EthersTransactionResponse {\n hash: string;\n}\n\ninterface EthersCallProvider {\n call(tx: EthersTransactionRequest): Promise<string>;\n}\n\ninterface EthersTransactionSigner extends EthersCallProvider {\n sendTransaction(tx: EthersTransactionRequest): Promise<EthersTransactionResponse>;\n}\n\nfunction toTransactionRequest(config: TransactionRequestConfig): EthersTransactionRequest {\n return {\n to: config.address,\n data: encodeFunctionData({\n abi: config.abi as Abi,\n functionName: config.functionName as never,\n args: config.args as never,\n }),\n ...(config.gas !== undefined ? { gasLimit: config.gas } : {}),\n ...(config.value !== undefined ? { value: config.value } : {}),\n };\n}\n\nasync function ethersRead<T>(\n provider: EthersCallProvider,\n config: TransactionRequestConfig,\n): Promise<T> {\n const data = await provider.call(toTransactionRequest(config));\n if (!isHex(data)) {\n throw new TypeError(`Expected hex string, got: ${data}`);\n }\n return decodeFunctionResult({\n abi: config.abi as Abi,\n functionName: config.functionName as never,\n data,\n }) as T;\n}\n\nasync function ethersWrite(\n signer: EthersTransactionSigner,\n config: TransactionRequestConfig,\n): Promise<Hex> {\n const tx = await signer.sendTransaction(toTransactionRequest(config));\n if (!isHex(tx.hash)) {\n throw new TypeError(`Expected hex string, got: ${tx.hash}`);\n }\n return tx.hash;\n}\n\n// ── Read helpers ────────────────────────────────────────────\n\nexport function readConfidentialBalanceOfContract(\n provider: EthersCallProvider,\n tokenAddress: Address,\n userAddress: Address,\n) {\n return ethersRead(provider, confidentialBalanceOfContract(tokenAddress, userAddress));\n}\n\nexport function readUnderlyingTokenContract(provider: EthersCallProvider, wrapperAddress: Address) {\n return ethersRead(provider, underlyingContract(wrapperAddress));\n}\n\nexport function readSupportsInterfaceContract(\n provider: EthersCallProvider,\n tokenAddress: Address,\n interfaceId: Address,\n) {\n return ethersRead(provider, supportsInterfaceContract(tokenAddress, interfaceId));\n}\n\n// ── Write helpers ───────────────────────────────────────────\n\nexport function writeConfidentialTransferContract(\n signer: EthersTransactionSigner,\n tokenAddress: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return ethersWrite(\n signer,\n confidentialTransferContract(tokenAddress, to, encryptedAmount, inputProof),\n );\n}\n\nexport function writeUnwrapContract(\n signer: EthersTransactionSigner,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedAmount: EncryptedValue,\n inputProof: Hex,\n) {\n return ethersWrite(signer, unwrapContract(encryptedErc20, from, to, encryptedAmount, inputProof));\n}\n\nexport function writeUnwrapFromBalanceContract(\n signer: EthersTransactionSigner,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedBalance: EncryptedValue,\n) {\n return ethersWrite(signer, unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance));\n}\n\nexport function writeFinalizeUnwrapContract(\n signer: EthersTransactionSigner,\n wrapper: Address,\n unwrapRequestId: EncryptedValue,\n unwrapAmountCleartext: bigint,\n decryptionProof: Hex,\n) {\n return ethersWrite(\n signer,\n finalizeUnwrapContract(wrapper, unwrapRequestId, unwrapAmountCleartext, decryptionProof),\n );\n}\n\nexport function writeSetOperatorContract(\n signer: EthersTransactionSigner,\n tokenAddress: Address,\n operator: Address,\n until?: number,\n) {\n return ethersWrite(signer, setOperatorContract(tokenAddress, operator, until));\n}\n\nexport function writeWrapContract(\n signer: EthersTransactionSigner,\n wrapperAddress: Address,\n to: Address,\n amount: bigint,\n) {\n return ethersWrite(signer, wrapContract(wrapperAddress, to, amount));\n}\n\n// ── Registry read helpers ──────────────────────────────────\n\nexport function readTokenPairsContract(provider: EthersCallProvider, registry: Address) {\n return ethersRead(provider, getTokenPairsContract(registry));\n}\n\nexport function readTokenPairsLengthContract(provider: EthersCallProvider, registry: Address) {\n return ethersRead(provider, getTokenPairsLengthContract(registry));\n}\n\nexport function readTokenPairsSliceContract(\n provider: EthersCallProvider,\n registry: Address,\n fromIndex: bigint,\n toIndex: bigint,\n) {\n return ethersRead(provider, getTokenPairsSliceContract(registry, fromIndex, toIndex));\n}\n\nexport function readTokenPairContract(\n provider: EthersCallProvider,\n registry: Address,\n index: bigint,\n) {\n return ethersRead(provider, getTokenPairContract(registry, index));\n}\n\nexport function readConfidentialTokenAddressContract(\n provider: EthersCallProvider,\n registry: Address,\n tokenAddress: Address,\n) {\n return ethersRead(provider, getConfidentialTokenAddressContract(registry, tokenAddress));\n}\n\nexport function readTokenAddressContract(\n provider: EthersCallProvider,\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return ethersRead(provider, getTokenAddressContract(registry, confidentialTokenAddress));\n}\n\nexport function readIsConfidentialTokenValidContract(\n provider: EthersCallProvider,\n registry: Address,\n confidentialTokenAddress: Address,\n) {\n return ethersRead(provider, isConfidentialTokenValidContract(registry, confidentialTokenAddress));\n}\n"],"mappings":"wdAyCA,IAAa,EAAb,KAAuD,CACrD,GAEA,YAAY,EAA8B,CACpC,aAAc,EAChB,KAAKA,GAAgB,IAAI,EAAgB,EAAO,QAAQ,EAExD,KAAKA,GAAgB,EAAO,QAEhC,CAEA,MAAM,YAA8B,CAClC,IAAM,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,OAAO,EAAW,EAAU,EAAiC,EAAU,CAAwB,CAAC,CAClG"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as FheChain } from "./types-BgczXqW2.js";
|
|
2
2
|
import { A as TransferCallbacks, D as TransferOptions, F as WalletAccount, J as WriteContractConfig, L as WalletAccountListener, M as GenericStorage, N as GenericProvider, O as UnshieldOptions, P as GenericSigner, T as ShieldOptions, V as TransactionResult, a as StoredTransportKeyPairWithPermits, d as EncryptParams, f as EncryptResult, ft as GenericLogger, g as PublicDecryptResult, j as UnshieldCallbacks, p as EncryptedValue, s as ClearValue } from "./relayer-cleartext-DkKKjfI6.js";
|
|
3
|
-
import { E as TransactionOperation, P as ZamaSDKEventInput, a as ZamaConfig, n as RelayerConfig, s as ZamaConfigGeneric, u as RelayerDispatcher } from "./types-
|
|
3
|
+
import { E as TransactionOperation, P as ZamaSDKEventInput, a as ZamaConfig, n as RelayerConfig, s as ZamaConfigGeneric, u as RelayerDispatcher } from "./types-C4JRzs5M.js";
|
|
4
4
|
import { Address, Hex } from "viem";
|
|
5
5
|
import { z } from "zod/mini";
|
|
6
6
|
import { UserDecryptResults } from "@zama-fhe/relayer-sdk/bundle";
|
|
@@ -19706,6 +19706,60 @@ declare class Token {
|
|
|
19706
19706
|
* ```
|
|
19707
19707
|
*/
|
|
19708
19708
|
confidentialTransferFrom(from: Address, to: Address, amount: bigint, callbacks?: TransferCallbacks): Promise<TransactionResult>;
|
|
19709
|
+
/**
|
|
19710
|
+
* ERC-7984 `confidentialTransferAndCall`: encrypted transfer that also invokes
|
|
19711
|
+
* the recipient's receiver hook (`onConfidentialTransferReceived`) in a single
|
|
19712
|
+
* transaction. The caller crafts the opaque `data` payload — the SDK does not
|
|
19713
|
+
* encode, validate, or interpret it.
|
|
19714
|
+
*
|
|
19715
|
+
* Balance validation follows the same rules as {@link Token.confidentialTransfer}.
|
|
19716
|
+
*
|
|
19717
|
+
* @param to - Recipient address. Must implement the ERC-7984 receiver hook.
|
|
19718
|
+
* @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
|
|
19719
|
+
* @param data - Opaque bytes forwarded to the recipient's receiver hook.
|
|
19720
|
+
* @param options - Optional: `skipBalanceCheck` (default `false`).
|
|
19721
|
+
* @returns The transaction hash and mined receipt.
|
|
19722
|
+
*
|
|
19723
|
+
* @throws if signer and provider are on different chains. {@link ChainMismatchError}
|
|
19724
|
+
* @throws if the balance is less than `amount`. {@link InsufficientConfidentialBalanceError}
|
|
19725
|
+
* @throws if balance validation requires decryption that is not possible. {@link BalanceCheckUnavailableError}
|
|
19726
|
+
* @throws if FHE encryption fails. {@link EncryptionFailedError}
|
|
19727
|
+
* @throws if the on-chain transfer reverts. {@link TransactionRevertedError}
|
|
19728
|
+
*
|
|
19729
|
+
* @example
|
|
19730
|
+
* ```ts
|
|
19731
|
+
* const txHash = await token.confidentialTransferAndCall(
|
|
19732
|
+
* "0xRecipient",
|
|
19733
|
+
* 1000n,
|
|
19734
|
+
* "0xabcd", // caller-encoded payload forwarded to the receiver hook
|
|
19735
|
+
* );
|
|
19736
|
+
* ```
|
|
19737
|
+
*/
|
|
19738
|
+
confidentialTransferAndCall(to: Address, amount: bigint, data: Hex, options?: TransferOptions): Promise<TransactionResult>;
|
|
19739
|
+
/**
|
|
19740
|
+
* ERC-7984 `confidentialTransferFromAndCall`: operator-initiated encrypted
|
|
19741
|
+
* transfer that also invokes the recipient's receiver hook in a single
|
|
19742
|
+
* transaction. The caller must be an approved operator for `from` and crafts
|
|
19743
|
+
* the opaque `data` payload — the SDK does not encode or interpret it.
|
|
19744
|
+
*
|
|
19745
|
+
* @param from - The address to transfer from (caller must be an approved operator).
|
|
19746
|
+
* @param to - Recipient address. Must implement the ERC-7984 receiver hook.
|
|
19747
|
+
* @param amount - Plaintext amount to transfer (encrypted automatically via FHE).
|
|
19748
|
+
* @param data - Opaque bytes forwarded to the recipient's receiver hook.
|
|
19749
|
+
* @param callbacks - Optional progress callbacks.
|
|
19750
|
+
* @returns The transaction hash and mined receipt.
|
|
19751
|
+
*
|
|
19752
|
+
* @example
|
|
19753
|
+
* ```ts
|
|
19754
|
+
* const txHash = await token.confidentialTransferFromAndCall(
|
|
19755
|
+
* "0xFrom",
|
|
19756
|
+
* "0xRecipient",
|
|
19757
|
+
* 500n,
|
|
19758
|
+
* "0xabcd",
|
|
19759
|
+
* );
|
|
19760
|
+
* ```
|
|
19761
|
+
*/
|
|
19762
|
+
confidentialTransferFromAndCall(from: Address, to: Address, amount: bigint, data: Hex, callbacks?: TransferCallbacks): Promise<TransactionResult>;
|
|
19709
19763
|
/**
|
|
19710
19764
|
* Set operator approval for the confidential token.
|
|
19711
19765
|
* Defaults to 1 hour from now if `until` is not specified.
|
|
@@ -20346,4 +20400,4 @@ declare function loadPendingUnshieldRequest(storage: GenericStorage, wrapperAddr
|
|
|
20346
20400
|
declare function clearPendingUnshield(storage: GenericStorage, wrapperAddress: Address): Promise<void>;
|
|
20347
20401
|
//#endregion
|
|
20348
20402
|
export { DecryptResult as $, DelegationExpiredError as A, decimalsContract as At, ConfigurationError as B, rateContract as Bt, InsufficientConfidentialBalanceError as C, ERC7984_WRAPPER_INTERFACE_ID as Ct, DelegationCooldownError as D, allowanceContract as Dt, DelegationContractIsSelfError as E, supportsInterfaceContract as Et, SignerNotConfiguredError as F, confidentialTransferContract as Ft, TransactionRevertedError as G, wrapContract as Gt, InvalidTransportKeyPairError as H, underlyingContract as Ht, SignerRequiredError as I, confidentialTransferFromContract as It, SigningFailedError as J, resolveStorage as Jt, DecryptionFailedError as K, ResolvedChainRelayer as Kt, WalletAccountNotReadyError as L, finalizeUnwrapContract as Lt, DelegationNotFoundError as M, symbolContract as Mt, DelegationNotPropagatedError as N, confidentialBalanceOfContract as Nt, DelegationDelegateEqualsContractError as O, approveContract as Ot, DelegationSelfNotAllowedError as P, confidentialTotalSupplyContract as Pt, matchZamaError as Q, WalletNotConnectedError as R, inferredTotalSupplyContract as Rt, ERC20ReadFailedError as S, ERC7984_INTERFACE_ID as St, AclPausedError as T, isConfidentialWrapperContract as Tt, NoCiphertextError as U, unwrapContract as Ut, RelayerRequestFailedError as V, setOperatorContract as Vt, TransportKeyPairExpiredError as W, unwrapFromBalanceContract as Wt, ZamaError as X, SigningRejectedError as Y, createConfig as Yt, ZamaErrorCode as Z, Decryption as _, getDelegationExpiryContract as _t, savePendingUnshield as a, QueryFactoryOptions as at, BalanceCheckUnavailableError as b, transferAndCallContract as bt, ListPairsOptions as c, TokenWrapperPairWithMetadata as ct, WrappedToken as d, getTokenPairContract as dt, EncryptedInput as et, BatchBalancesResult as f, getTokenPairsContract as ft, Delegations as g, delegateForUserDecryptionContract as gt, Permits as h, isConfidentialTokenValidContract as ht, loadPendingUnshieldRequest as i, MutationFactoryOptions as it, DelegationExpiryUnchangedError as j, nameContract as jt, DelegationExpirationTooSoonError as k, balanceOfContract as kt, WrappersRegistry as l, getConfidentialTokenAddressContract as lt, Token as m, getTokenPairsSliceContract as mt, clearPendingUnshield as n, SignerQueryContext as nt, ZamaSDK as o, PaginatedResult as ot, BatchDecryptAsOptions as p, getTokenPairsLengthContract as pt, EncryptionFailedError as q, resolveChainRelayers as qt, loadPendingUnshield as r, zamaQueryKeys as rt, DefaultRegistryAddresses as s, TokenWrapperPair as st, PendingUnshieldRequest as t, decryptValuesQueryOptions as tt, WrappersRegistryConfig as u, getTokenAddressContract as ut, BatchDecryptItem as v, isHandleDelegatedContract as vt, InsufficientERC20BalanceError as w, isConfidentialTokenContract as wt, BalanceErrorDetails as x, ERC1363_INTERFACE_ID as xt, BatchDecryptResult as y, revokeDelegationContract as yt, ChainMismatchError as z, isOperatorContract as zt };
|
|
20349
|
-
//# sourceMappingURL=index-
|
|
20403
|
+
//# sourceMappingURL=index-BRIQ3Msg.d.ts.map
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { n as FheChain, t as AtLeastOneChain } from "./types-BgczXqW2.js";
|
|
2
2
|
import { a as hoodi, c as sepolia, i as hardhat, n as bscTestnet, o as ingenTestnet, r as chains, s as mainnet, t as anvil } from "./index-CYBH0nyo.js";
|
|
3
3
|
import { A as TransferCallbacks, B as TransactionReceipt, D as TransferOptions, E as ShieldPath, F as WalletAccount, G as ReadContractReturnType, H as ContractAbi, I as WalletAccountChange, J as WriteContractConfig, K as ReadFunctionName, L as WalletAccountListener, M as GenericStorage, N as GenericProvider, O as UnshieldOptions, P as GenericSigner, R as WalletAccountStore, T as ShieldOptions, U as ReadContractArgs, V as TransactionResult, W as ReadContractConfig, Y as WriteFunctionName, _ as PublicParamsData, c as DelegatedUserDecryptParams, d as EncryptParams, f as EncryptResult, ft as GenericLogger, g as PublicDecryptResult, h as NetworkType, i as StoredTransportKeyPair, j as UnshieldCallbacks, k as ShieldCallbacks, l as EIP712TypedData, m as FheEncryptionKey, n as RelayerSDK, o as TransportKeyPair, p as EncryptedValue, q as WriteContractArgs, r as Permission, s as ClearValue, u as EncryptInput, v as RelayerSDKStatus, w as ApprovalStrategy, x as UserDecryptParams, z as RawLog } from "./relayer-cleartext-DkKKjfI6.js";
|
|
4
|
-
import { $ as decodeDelegatedForUserDecryption, A as UnshieldPhase2StartedEvent, B as AclTopics, C as SetOperatorSubmittedEvent, D as TransferFromSubmittedEvent, E as TransactionOperation, F as ZamaSDKEventListener, G as TOKEN_TOPICS, H as DelegatedForUserDecryptionEvent, I as ZamaSDKEventType, J as UnwrapRequestedEvent, K as Topics, L as ZamaSDKEvents, M as UnwrapSubmittedEvent, N as ZamaSDKEvent, O as TransferSubmittedEvent, P as ZamaSDKEventInput, Q as decodeConfidentialTransfer, R as ACL_TOPICS, S as RevokeDelegationSubmittedEvent, T as TransactionErrorEvent, U as OnChainEvent, V as ConfidentialTransferEvent, W as RevokedDelegationForUserDecryptionEvent, X as decodeAclEvent, Y as WrapEvent, Z as decodeAclEvents, _ as DelegationSubmittedEvent, a as ZamaConfig, at as decodeWrap, b as EncryptStartEvent, ct as findUnwrapRequested, d as WorkerLike, et as decodeOnChainEvent, f as ApproveUnderlyingSubmittedEvent, g as DecryptStartEvent, h as DecryptErrorEvent, it as decodeUnwrapRequested, j as UnshieldPhase2SubmittedEvent, k as UnshieldPhase1SubmittedEvent, lt as findWrap, m as DecryptEndEvent, n as RelayerConfig, nt as decodeRevokedDelegationForUserDecryption, o as ZamaConfigBase, ot as findDelegatedForUserDecryption, p as BaseEvent, q as UnwrapFinalizedEvent, rt as decodeUnwrapFinalized, s as ZamaConfigGeneric, st as findRevokedDelegationForUserDecryption, t as CleartextRelayerConfig, tt as decodeOnChainEvents, u as RelayerDispatcher, v as EncryptEndEvent, w as ShieldSubmittedEvent, x as FinalizeUnwrapSubmittedEvent, y as EncryptErrorEvent, z as AclEvent } from "./types-
|
|
5
|
-
import { t as ZamaConfigEthers } from "./types-
|
|
4
|
+
import { $ as decodeDelegatedForUserDecryption, A as UnshieldPhase2StartedEvent, B as AclTopics, C as SetOperatorSubmittedEvent, D as TransferFromSubmittedEvent, E as TransactionOperation, F as ZamaSDKEventListener, G as TOKEN_TOPICS, H as DelegatedForUserDecryptionEvent, I as ZamaSDKEventType, J as UnwrapRequestedEvent, K as Topics, L as ZamaSDKEvents, M as UnwrapSubmittedEvent, N as ZamaSDKEvent, O as TransferSubmittedEvent, P as ZamaSDKEventInput, Q as decodeConfidentialTransfer, R as ACL_TOPICS, S as RevokeDelegationSubmittedEvent, T as TransactionErrorEvent, U as OnChainEvent, V as ConfidentialTransferEvent, W as RevokedDelegationForUserDecryptionEvent, X as decodeAclEvent, Y as WrapEvent, Z as decodeAclEvents, _ as DelegationSubmittedEvent, a as ZamaConfig, at as decodeWrap, b as EncryptStartEvent, ct as findUnwrapRequested, d as WorkerLike, et as decodeOnChainEvent, f as ApproveUnderlyingSubmittedEvent, g as DecryptStartEvent, h as DecryptErrorEvent, it as decodeUnwrapRequested, j as UnshieldPhase2SubmittedEvent, k as UnshieldPhase1SubmittedEvent, lt as findWrap, m as DecryptEndEvent, n as RelayerConfig, nt as decodeRevokedDelegationForUserDecryption, o as ZamaConfigBase, ot as findDelegatedForUserDecryption, p as BaseEvent, q as UnwrapFinalizedEvent, rt as decodeUnwrapFinalized, s as ZamaConfigGeneric, st as findRevokedDelegationForUserDecryption, t as CleartextRelayerConfig, tt as decodeOnChainEvents, u as RelayerDispatcher, v as EncryptEndEvent, w as ShieldSubmittedEvent, x as FinalizeUnwrapSubmittedEvent, y as EncryptErrorEvent, z as AclEvent } from "./types-C4JRzs5M.js";
|
|
5
|
+
import { t as ZamaConfigEthers } from "./types-DJp9eoXC.js";
|
|
6
6
|
import { n as MutableWalletAccountStore, r as createWalletAccountStore, t as BaseSigner } from "./base-signer-ByGw5ReU.js";
|
|
7
|
-
import { t as cleartext } from "./cleartext-
|
|
8
|
-
import { $ as DecryptResult, A as DelegationExpiredError, At as decimalsContract, B as ConfigurationError, Bt as rateContract, C as InsufficientConfidentialBalanceError, Ct as ERC7984_WRAPPER_INTERFACE_ID, D as DelegationCooldownError, Dt as allowanceContract, E as DelegationContractIsSelfError, Et as supportsInterfaceContract, F as SignerNotConfiguredError, Ft as confidentialTransferContract, G as TransactionRevertedError, Gt as wrapContract, H as InvalidTransportKeyPairError, Ht as underlyingContract, I as SignerRequiredError, It as confidentialTransferFromContract, J as SigningFailedError, Jt as resolveStorage, K as DecryptionFailedError, Kt as ResolvedChainRelayer, L as WalletAccountNotReadyError, Lt as finalizeUnwrapContract, M as DelegationNotFoundError, Mt as symbolContract, N as DelegationNotPropagatedError, Nt as confidentialBalanceOfContract, O as DelegationDelegateEqualsContractError, Ot as approveContract, P as DelegationSelfNotAllowedError, Pt as confidentialTotalSupplyContract, Q as matchZamaError, R as WalletNotConnectedError, Rt as inferredTotalSupplyContract, S as ERC20ReadFailedError, St as ERC7984_INTERFACE_ID, T as AclPausedError, Tt as isConfidentialWrapperContract, U as NoCiphertextError, Ut as unwrapContract, V as RelayerRequestFailedError, Vt as setOperatorContract, W as TransportKeyPairExpiredError, Wt as unwrapFromBalanceContract, X as ZamaError, Y as SigningRejectedError, Yt as createConfig, Z as ZamaErrorCode, _ as Decryption, _t as getDelegationExpiryContract, a as savePendingUnshield, b as BalanceCheckUnavailableError, bt as transferAndCallContract, c as ListPairsOptions, ct as TokenWrapperPairWithMetadata, d as WrappedToken, dt as getTokenPairContract, et as EncryptedInput, f as BatchBalancesResult, ft as getTokenPairsContract, g as Delegations, gt as delegateForUserDecryptionContract, h as Permits, ht as isConfidentialTokenValidContract, i as loadPendingUnshieldRequest, j as DelegationExpiryUnchangedError, jt as nameContract, k as DelegationExpirationTooSoonError, kt as balanceOfContract, l as WrappersRegistry, lt as getConfidentialTokenAddressContract, m as Token, mt as getTokenPairsSliceContract, n as clearPendingUnshield, o as ZamaSDK, ot as PaginatedResult, p as BatchDecryptAsOptions, pt as getTokenPairsLengthContract, q as EncryptionFailedError, qt as resolveChainRelayers, r as loadPendingUnshield, s as DefaultRegistryAddresses, st as TokenWrapperPair, t as PendingUnshieldRequest, u as WrappersRegistryConfig, ut as getTokenAddressContract, v as BatchDecryptItem, vt as isHandleDelegatedContract, w as InsufficientERC20BalanceError, wt as isConfidentialTokenContract, x as BalanceErrorDetails, xt as ERC1363_INTERFACE_ID, y as BatchDecryptResult, yt as revokeDelegationContract, z as ChainMismatchError, zt as isOperatorContract } from "./index-
|
|
9
|
-
import { t as ZamaConfigViem } from "./types-
|
|
7
|
+
import { t as cleartext } from "./cleartext-4WhQWHZF.js";
|
|
8
|
+
import { $ as DecryptResult, A as DelegationExpiredError, At as decimalsContract, B as ConfigurationError, Bt as rateContract, C as InsufficientConfidentialBalanceError, Ct as ERC7984_WRAPPER_INTERFACE_ID, D as DelegationCooldownError, Dt as allowanceContract, E as DelegationContractIsSelfError, Et as supportsInterfaceContract, F as SignerNotConfiguredError, Ft as confidentialTransferContract, G as TransactionRevertedError, Gt as wrapContract, H as InvalidTransportKeyPairError, Ht as underlyingContract, I as SignerRequiredError, It as confidentialTransferFromContract, J as SigningFailedError, Jt as resolveStorage, K as DecryptionFailedError, Kt as ResolvedChainRelayer, L as WalletAccountNotReadyError, Lt as finalizeUnwrapContract, M as DelegationNotFoundError, Mt as symbolContract, N as DelegationNotPropagatedError, Nt as confidentialBalanceOfContract, O as DelegationDelegateEqualsContractError, Ot as approveContract, P as DelegationSelfNotAllowedError, Pt as confidentialTotalSupplyContract, Q as matchZamaError, R as WalletNotConnectedError, Rt as inferredTotalSupplyContract, S as ERC20ReadFailedError, St as ERC7984_INTERFACE_ID, T as AclPausedError, Tt as isConfidentialWrapperContract, U as NoCiphertextError, Ut as unwrapContract, V as RelayerRequestFailedError, Vt as setOperatorContract, W as TransportKeyPairExpiredError, Wt as unwrapFromBalanceContract, X as ZamaError, Y as SigningRejectedError, Yt as createConfig, Z as ZamaErrorCode, _ as Decryption, _t as getDelegationExpiryContract, a as savePendingUnshield, b as BalanceCheckUnavailableError, bt as transferAndCallContract, c as ListPairsOptions, ct as TokenWrapperPairWithMetadata, d as WrappedToken, dt as getTokenPairContract, et as EncryptedInput, f as BatchBalancesResult, ft as getTokenPairsContract, g as Delegations, gt as delegateForUserDecryptionContract, h as Permits, ht as isConfidentialTokenValidContract, i as loadPendingUnshieldRequest, j as DelegationExpiryUnchangedError, jt as nameContract, k as DelegationExpirationTooSoonError, kt as balanceOfContract, l as WrappersRegistry, lt as getConfidentialTokenAddressContract, m as Token, mt as getTokenPairsSliceContract, n as clearPendingUnshield, o as ZamaSDK, ot as PaginatedResult, p as BatchDecryptAsOptions, pt as getTokenPairsLengthContract, q as EncryptionFailedError, qt as resolveChainRelayers, r as loadPendingUnshield, s as DefaultRegistryAddresses, st as TokenWrapperPair, t as PendingUnshieldRequest, u as WrappersRegistryConfig, ut as getTokenAddressContract, v as BatchDecryptItem, vt as isHandleDelegatedContract, w as InsufficientERC20BalanceError, wt as isConfidentialTokenContract, x as BalanceErrorDetails, xt as ERC1363_INTERFACE_ID, y as BatchDecryptResult, yt as revokeDelegationContract, z as ChainMismatchError, zt as isOperatorContract } from "./index-BRIQ3Msg.js";
|
|
9
|
+
import { t as ZamaConfigViem } from "./types-Cb7AvEOP.js";
|
|
10
10
|
import { Address, Hex } from "viem";
|
|
11
11
|
import { FheTypeName, FhevmInstanceConfig, InputProofBytesType, KmsDelegatedUserDecryptEIP712Type as KmsDelegatedDecryptEIP712Type, ZKProofLike } from "@zama-fhe/relayer-sdk/bundle";
|
|
12
12
|
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,i as t,n,r,t as i}from"./relayer-D-nicEYJ.js";import{A as a,B as o,C as s,D as c,E as l,F as u,H as d,I as ee,L as te,M as ne,N as re,O as ie,P as f,R as ae,S as oe,T as se,V as ce,_ as le,a as ue,b as de,c as fe,d as pe,f as me,g as p,h as m,i as he,j as ge,k as _e,l as ve,m as ye,n as be,o as xe,p as Se,r as Ce,s as we,t as Te,u as Ee,v as De,w as Oe,x as ke,z as Ae}from"./wrappers-registry-BWWG0aze.js";import{n as h,t as g}from"./encryption-BGmINekJ.js";import{_ as je,a as Me,b as _,c as v,d as Ne,f as Pe,g as Fe,h as Ie,i as y,l as b,m as Le,n as Re,o as x,p as ze,r as Be,s as S,t as C,u as Ve,v as He,y as Ue}from"./token-TQ-VFHS4.js";import{r as w,t as We}from"./error-W1N-FGwV.js";import{t as Ge}from"./cleartext-CTla3A3O.js";import{a as Ke,c as qe,d as Je,f as T,i as Ye,l as Xe,n as Ze,o as E,r as Qe,s as $e,t as et,u as tt}from"./base-signer-BVqcM5jt.js";import{n as nt,t as rt}from"./indexeddb-storage-Mi-fCWN3.js";import{n as it,t as at}from"./memory-storage-fp9RY5BQ.js";import{i as ot,t as st}from"./assertions-CnPIS0VN.js";import{t as D}from"./hex-CxtyupeQ.js";import{a as ct,c as lt,i as ut,n as dt,o as ft,r as pt,s as mt,t as ht}from"./chains-CXcO1DBP.js";import{getAddress as O,keccak256 as gt,toBytes as _t}from"viem";import{z as k}from"zod/mini";var vt=class extends r{constructor(e,n){super(t.TransportKeyPairExpired,e,n),this.name=`TransportKeyPairExpiredError`}},yt=class extends r{constructor(e,n){super(t.InvalidTransportKeyPair,e,n),this.name=`InvalidTransportKeyPairError`}},A=class extends r{constructor(e,n){super(t.NoCiphertext,e,n),this.name=`NoCiphertextError`}},j=class extends r{constructor(e,n){super(t.DelegationSelfNotAllowed,e,n),this.name=`DelegationSelfNotAllowedError`}},bt=class extends r{constructor(e,n){super(t.DelegationCooldown,e,n),this.name=`DelegationCooldownError`}},M=class extends r{constructor(e,n){super(t.DelegationNotFound,e,n),this.name=`DelegationNotFoundError`}},N=class extends r{constructor(e,n){super(t.DelegationExpired,e,n),this.name=`DelegationExpiredError`}},P=class extends r{constructor(e,n){super(t.DelegationExpiryUnchanged,e,n),this.name=`DelegationExpiryUnchangedError`}},F=class extends r{constructor(e,n){super(t.DelegationDelegateEqualsContract,e,n),this.name=`DelegationDelegateEqualsContractError`}},xt=class extends r{constructor(e,n){super(t.DelegationContractIsSelf,e,n),this.name=`DelegationContractIsSelfError`}},St=class extends r{constructor(e,n){super(t.AclPaused,e,n),this.name=`AclPausedError`}},I=class extends r{constructor(e,n){super(t.DelegationExpirationTooSoon,e,n),this.name=`DelegationExpirationTooSoonError`}},L=class extends r{constructor(e,n){super(t.DelegationNotPropagated,e,n),this.name=`DelegationNotPropagatedError`}};function R(e,t,r=!1){if(e instanceof g||e instanceof A||e instanceof n||e instanceof L||e instanceof d||e instanceof ce)return e;let i=We(e);return i===400?new A(e instanceof Error?e.message:`No ciphertext for this account`,{cause:e}):r&&i===500?new L(`Delegated decryption failed with a server error. This is most commonly caused by the delegation not having propagated to the gateway yet — after granting delegation, allow 1–2 minutes for cross-chain synchronization before retrying. If the error persists, the gateway or relayer may be experiencing an unrelated issue.`,{cause:e}):i===void 0?new g(t,{cause:e}):new n(e instanceof Error?e.message:t,i,{cause:e})}function Ct(e,t){if(e instanceof r)return e;let i=We(e);return i===void 0?new h(t,{cause:e}):new n(e instanceof Error?e.message:t,i,{cause:e})}const wt=[{type:`function`,name:`allowance`,inputs:[{name:`owner`,type:`address`,internalType:`address`},{name:`spender`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`approve`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`balanceOf`,inputs:[{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`supportsInterface`,inputs:[{name:`interfaceId`,type:`bytes4`,internalType:`bytes4`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`totalSupply`,inputs:[],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`transfer`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFrom`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`event`,name:`Approval`,inputs:[{name:`owner`,type:`address`,indexed:!0,internalType:`address`},{name:`spender`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1},{type:`event`,name:`Transfer`,inputs:[{name:`from`,type:`address`,indexed:!0,internalType:`address`},{name:`to`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1}];function Tt(e,t,n,r=`0x`){return{address:e,abi:wt,functionName:`transferAndCall`,args:[t,n,r]}}function Et(e){return Ye(e.signer,e.provider,e)}var Dt=class{#e;#t;#n;#r;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.relayer,this.#r=e.decryptionService}#i(e){return o(this.#r,e)}async decryptValues(e){let t=this.#i(`decryptValues`),n=await S(`decryptValues`,this.#e,this.#t);return t.userDecrypt(e,n.address)}async delegatedDecryptValues(e,t,n=t){let r=this.#i(`delegatedDecryptValues`),i=await S(`delegatedDecryptValues`,this.#e,this.#t);return r.delegatedUserDecrypt(e,t,i.address,n)}async decryptPublicValues(e){if(e.length===0)return{clearValues:{},decryptionProof:`0x`,abiEncodedClearValues:`0x`};try{return await this.#n.publicDecrypt(e)}catch(e){throw R(e,`Public decryption failed`)}}async delegatedBatchDecryptValues({encryptedInputs:e,delegatorAddress:t,accountAddress:n=t,maxConcurrency:r}){let i=this.#i(`delegatedBatchDecryptValues`),a=await S(`delegatedBatchDecryptValues`,this.#e,this.#t);return i.delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:a.address,accountAddress:n,maxConcurrency:r})}},Ot=class{#e;#t;#n;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.delegationService}#r(e){return o(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)}},kt=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 o(this.#r,e)}async grantPermit(e){if(e.length===0)return;let t=this.#a(`grantPermit`);await v(`grantPermit`,this.#e,this.#t),await t.grantPermit(e)}async grantDelegationPermit(e,t){if(t.length===0)return;let n=this.#a(`grantDelegationPermit`);await v(`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=O((await S(`revokePermits`,this.#e,this.#t)).address);try{await t.revokePermits(e)}finally{await u(`clear decrypt cache`,()=>this.#n.clearForRequester(n),this.#i)}}async clear(){let e=this.#a(`clear`),t=O((await S(`clear`,this.#e,this.#t)).address);try{await e.clearCredentials()}finally{await u(`clear decrypt cache`,()=>this.#n.clearForRequester(t),this.#i)}}};const At=k.union([k.bigint(),k.boolean(),Je]),jt=k.array(k.string());var Mt=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=At.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=O(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}:${O(e)}:${O(t)}:${n.toLowerCase()}`}async#l(){let e=await this.#e.get(this.#r);if(e===null)return[];let t=jt.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 Nt(e,t){let n=It(e,t);if(!n)throw new g(`No permit covers contract ${t} after allow()`);return Ft(e,n)}function Pt(e,t){let n=It(e,t);if(!n)throw new g(`No delegated permit covers contract ${t} after allow()`);return{...Ft(e,n),delegatorAddress:n.delegatorAddress}}function Ft(e,t){return{signedContractAddresses:t.signedContractAddresses,privateKey:e.keypair.privateKey,publicKey:e.keypair.publicKey,signature:t.signature,startTimestamp:t.startTimestamp,durationDays:t.durationDays}}function It(e,t){let n=tt(t);return e.permits.find(e=>e.signedContractAddresses.includes(n))}var Lt=class{#e;#t;#n;#r;#i;constructor({cache:e,credentialService:t,delegationService:n,relayer:r,emitEvent:i}){this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#i=i}async userDecrypt(e,t){let n=O(t);return this.#a(e,{requesterAddress:n,resolveCredentials:e=>this.#t.grantPermit(e),decryptContract:async({credentials:e,contractAddress:t,encryptedValues:r})=>this.#r.userDecrypt({encryptedValues:r,contractAddress:t,...Nt(e,t),signerAddress:n}),errorMessage:`Failed to decrypt encrypted values`})}async delegatedUserDecrypt(e,t,n,r){let i=O(t),a=O(n);return this.#a(e,{requesterAddress:O(r),resolveCredentials:e=>this.#t.grantPermit(e,i),validate:e=>this.#l(e,{delegatorAddress:i,delegateAddress:a}),decryptContract:async({credentials:e,contractAddress:t,encryptedValues:n})=>this.#r.delegatedUserDecrypt({encryptedValues:n,contractAddress:t,...Pt(e,t),delegateAddress:a}),errorMessage:`Failed to decrypt delegated encrypted values`,delegated:!0})}async delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:n,accountAddress:r,maxConcurrency:i=5}){let a=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:O(e.contractAddress)}));if(a.length===0)return{items:a};let o=O(r);try{let e=await this.delegatedUserDecrypt(a.map(({encryptedValue:e,contractAddress:t})=>({encryptedValue:e,contractAddress:t})),t,n,o);for(let t of a)this.#o(t,e);return{items:a}}catch(e){if(Le(e))throw e;if(a.length===1){let[t=this.#c()]=a;return t.error=this.#s(e,`Failed to decrypt delegated encrypted values`,!0),{items:a}}}return await Me(a.map(e=>async()=>{try{let r=await this.delegatedUserDecrypt([{encryptedValue:e.encryptedValue,contractAddress:e.contractAddress}],t,n,o);this.#o(e,r)}catch(t){if(Le(t))throw t;e.error=this.#s(t,`Failed to decrypt delegated encrypted values`,!0)}}),i),{items:a}}async#a(e,t){if(e.length===0)return{};let n=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:O(e.contractAddress)})),r={},i=[];for(let e of n)y(e.encryptedValue)?r[e.encryptedValue]=0n:i.push(e);if(i.length===0)return r;let a=Array.from(new Set(n.map(e=>e.contractAddress))),o=Array.from(new Set(i.map(e=>e.contractAddress)));t.validate&&await t.validate(o);let s=[];for(let e of i){let n=await this.#e.get(t.requesterAddress,e.contractAddress,e.encryptedValue);n===null?s.push(e):r[e.encryptedValue]=n}if(s.length===0)return r;let c=await t.resolveCredentials(a),l=new Map;for(let e of s){let t=l.get(e.contractAddress);t?t.push(e.encryptedValue):l.set(e.contractAddress,[e.encryptedValue])}let u=Date.now(),d=s.map(e=>e.encryptedValue);try{this.#i({type:x.DecryptStart,encryptedValues:d}),await Me([...l.entries()].map(([e,n])=>async()=>{let i=await t.decryptContract({credentials:c,contractAddress:e,encryptedValues:n});for(let[n,a]of Object.entries(i))r[n]=a,await this.#e.set(t.requesterAddress,e,n,a)}),5);let e={};for(let t of d){let n=r[t];n!==void 0&&(e[t]=n)}return this.#i({type:x.DecryptEnd,durationMs:Date.now()-u,encryptedValues:d,result:e}),r}catch(e){throw this.#i({type:x.DecryptError,error:w(e),durationMs:Date.now()-u,encryptedValues:d}),R(e,t.errorMessage,t.delegated)}}#o(e,t){let n=t[e.encryptedValue];if(n===void 0){e.error=new g(`Batch delegated decryption returned no value for encrypted value ${e.encryptedValue} on contract ${e.contractAddress}`);return}e.value=n}#s(e,t,n=!1){return e instanceof r?e:R(e,t,n)}#c(){throw new g(`Batch delegated decryption invariant failed: missing item`)}async#l(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 Rt(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 z={AlreadyDelegatedOrRevokedInSameBlock:e=>new bt(`Only one delegate/revoke per (delegator, delegate, contract) per block. Wait for the next block before retrying.`,{cause:e}),SenderCannotBeContractAddress:e=>new xt(`The contract address cannot be the caller address.`,{cause:e}),EnforcedPause:e=>new St(`The ACL contract is paused. Delegation operations are temporarily disabled.`,{cause:e}),SenderCannotBeDelegate:e=>new j(`Cannot delegate to yourself (delegate === msg.sender).`,{cause:e}),DelegateCannotBeContractAddress:e=>new F(`Delegate address cannot be the same as the contract address.`,{cause:e}),ExpirationDateBeforeOneHour:e=>new I(`Expiration date must be at least 1 hour in the future.`,{cause:e}),ExpirationDateAlreadySetToSameValue:e=>new P(`The new expiration date is the same as the current one.`,{cause:e}),NotDelegatedYet:e=>new M(`Cannot revoke: no active delegation exists.`,{cause:e})};function zt(e){return e in z}function Bt(e,t){let n=Rt(e);if(n&&zt(n))return z[n](t);let r=e instanceof Error?e.message:String(e);for(let[e,n]of Object.entries(z))if(r.includes(e))return n(t);return null}var Vt=class{#e;#t;#n;#r;constructor({provider:e,relayer:t,emitEvent:n=()=>{},logger:r}){this.#e=e,this.#t=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 I(`Expiration date must be at least 1 hour in the future`);let a=O(t),o=O(n),s=O(r);if(o===s)throw new j(`Cannot delegate to yourself (delegate === msg.sender).`);if(o===a)throw new F(`Delegate address cannot be the same as the contract address (${a}).`);let c=await this.#t.getAclAddress(),l=i?BigInt(Math.floor(i.getTime()/1e3)):b,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 P(`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:Ve(c,o,a,l)})}async revokeDelegation(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r}){let i=O(t),a=O(n),o=O(r),s=await this.#t.getAclAddress(),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 M(`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===b?!0:t>await this.#e.getBlockTimestamp()}async getDelegationExpiry({contractAddress:e,delegatorAddress:t,delegateAddress:n}){let r=await this.#t.getAclAddress();return this.#e.readContract(Ne(r,O(t),O(n),O(e)))}async#i({operation:e,signer:t,contractAddress:n,config:r}){try{return await Re({operation:e,signer:t,provider:this.#e,config:r,emit:e=>this.#n(e,n),logger:this.#r})}catch(e){throw this.#a(e),e}}#a(e){if(!(e instanceof _))return;let t=Bt(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 M||t instanceof N){let n=O(e);r.set(n,t);return}throw t}})),r}async assertDelegationActive(e,t,n){let r=O(e),i=O(t),a=O(n),o=await this.getDelegationExpiry({contractAddress:r,delegatorAddress:i,delegateAddress:a});if(o===0n)throw new M(`No active delegation from ${i} to ${a} for ${r}`);if(o!==b&&o<=await this.#e.getBlockTimestamp())throw new N(`Delegation from ${i} to ${a} for ${r} has expired`)}},Ht=class{#e;#t;constructor({relayer:e,emitEvent:t}){this.#e=e,this.#t=t}async encrypt(e){let t=Date.now();try{this.#t({type:x.EncryptStart},e.contractAddress);let n=await this.#e.encrypt(e);return this.#t({type:x.EncryptEnd,durationMs:Date.now()-t},e.contractAddress),n}catch(n){throw this.#t({type:x.EncryptError,error:w(n),durationMs:Date.now()-t},e.contractAddress),Ct(n,`Encryption failed`)}}},Ut=class{#e;#t;#n;#r;#i;#a=new Set;#o;constructor(e){this.#e=e.signer,this.#t=e.relayer,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 u(`switch relayer chain`,()=>this.#t.switchChain(r),this.#i);let i=this.#r;i&&await u(`credential wallet account change`,()=>i.handleWalletAccountChange(t,n),this.#i),t&&await u(`clear decrypt cache`,()=>this.#n.clearForRequester(t.address),this.#i),await Promise.all(Array.from(this.#a,t=>u(`wallet account listener`,()=>t(e),this.#i)))}};function B(e){return gt(_t(e))}const V={ConfidentialTransfer:B(`ConfidentialTransfer(address,address,bytes32)`),Wrap:B(`Wrap(address,uint256,bytes32)`),UnwrapRequested:B(`UnwrapRequested(address,bytes32,bytes32)`),UnwrapFinalized:B(`UnwrapFinalized(address,bytes32,bytes32,uint64)`)};function H(e){return O(D(e.slice(-40)))}function U(e){return e}function W(e,t){let n=2+t*64,r=e.slice(n,n+64);return r.length===64?r:r.padEnd(64,`0`)}function Wt(e,t){return O(D(W(e,t).slice(-40)))}function G(e,t){return BigInt(`0x`+W(e,t))}function K(e,t){return D(W(e,t))}function Gt(e){return e.topics[0]!==V.ConfidentialTransfer||e.topics.length<4?null:{eventName:`ConfidentialTransfer`,from:H(e.topics[1]),to:H(e.topics[2]),encryptedAmount:U(e.topics[3])}}function q(e){return e.topics[0]!==V.Wrap||e.topics.length<2?null:{eventName:`Wrap`,to:H(e.topics[1]),roundedAmount:G(e.data,0),encryptedWrappedAmount:K(e.data,1)}}function J(e){return e.topics[0]!==V.UnwrapRequested||e.topics.length<3?null:{eventName:`UnwrapRequested`,receiver:H(e.topics[1]),unwrapRequestId:U(e.topics[2]),encryptedAmount:K(e.data,0)}}function Y(e){return e.topics[0]!==V.UnwrapFinalized||e.topics.length<3?null:{eventName:`UnwrapFinalized`,receiver:H(e.topics[1]),unwrapRequestId:U(e.topics[2]),encryptedAmount:K(e.data,0),cleartextAmount:G(e.data,1)}}function Kt(e){return Gt(e)??q(e)??J(e)??Y(e)}function qt(e){let t=[];for(let n of e){let e=Kt(n);e&&t.push(e)}return t}function Jt(e){for(let t of e){let e=J(t);if(e)return e}return null}function Yt(e){for(let t of e){let e=q(t);if(e)return e}return null}const Xt=[V.ConfidentialTransfer,V.Wrap,V.UnwrapRequested,V.UnwrapFinalized],X={DelegatedForUserDecryption:B(`DelegatedForUserDecryption(address,address,address,uint64,uint64,uint64)`),RevokedDelegationForUserDecryption:B(`RevokedDelegationForUserDecryption(address,address,address,uint64,uint64)`)};function Z(e){return e.topics[0]!==X.DelegatedForUserDecryption||e.topics.length<3?null:{eventName:`DelegatedForUserDecryption`,delegator:H(e.topics[1]),delegate:H(e.topics[2]),contractAddress:Wt(e.data,0),delegationCounter:G(e.data,1),oldExpirationDate:G(e.data,2),newExpirationDate:G(e.data,3)}}function Q(e){return e.topics[0]!==X.RevokedDelegationForUserDecryption||e.topics.length<3?null:{eventName:`RevokedDelegationForUserDecryption`,delegator:H(e.topics[1]),delegate:H(e.topics[2]),contractAddress:Wt(e.data,0),delegationCounter:G(e.data,1),oldExpirationDate:G(e.data,2)}}function Zt(e){return Z(e)??Q(e)}function Qt(e){let t=[];for(let n of e){let e=Zt(n);e&&t.push(e)}return t}function $t(e){for(let t of e){let e=Z(t);if(e)return e}return null}function en(e){for(let t of e){let e=Q(t);if(e)return e}return null}const tn=[X.DelegatedForUserDecryption,X.RevokedDelegationForUserDecryption];var nn=class extends C{#e;#t=null;#n=null;#r(e){try{return ot(this.sdk.signer,`WrappedToken.sdk.signer`),this.sdk.signer}catch(t){throw new ee(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(Se(e))}catch{this.#n=!1}return this.#n}async allowance(e){let t=await this.#o();return this.sdk.provider.readContract(m(t,O(e),this.address))}async shield(e,t){let n=await S(`shield`,this.sdk.signer,this.sdk.provider),i=await this.isPayable(),a=await this.#o(),o=O(n.address),s;try{s=await this.sdk.provider.readContract(le(a,o))}catch(e){throw e instanceof r?e:new Fe(`Could not read ERC-20 balance for shield validation (token: ${a})`,{cause:w(e)})}if(s<e)throw new He(`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?O(r.to):n,a=i===n?`0x`:i;return this.submitTransaction({operation:`shield:transferAndCall`,config:Tt(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?O(n.to):t;return this.submitTransaction({operation:`shield:approveAndWrap`,config:f(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=O(t.address),i=e??2n**256n-1n;return i>0n&&await this.sdk.provider.readContract(m(n,r,this.address))>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:p(n,this.address,0n)}),this.submitTransaction({operation:`approveUnderlying`,config:p(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 u(`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 u(`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 unwrap(e){this.#r(`unwrap`);let t=O((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 h(`Encryption returned no encrypted values`);return this.submitTransaction({operation:`unwrap`,config:ne(this.address,t,t,i,r)})}async unwrapAll(){this.#r(`unwrapAll`);let e=O((await S(`unwrapAll`,this.sdk.signer,this.sdk.provider)).address),t=await this.readConfidentialBalanceOf(e);if(y(t))throw new g(`Cannot unshield: balance is zero`);return this.submitTransaction({operation:`unwrapAll`,config:re(this.address,e,e,t)})}async finalizeUnwrap(e){this.#r(`finalizeUnwrap`),await v(`finalizeUnwrap`,this.sdk.signer,this.sdk.provider);let t=await this.sdk.decryption.decryptPublicValues([e]),n=t.clearValues[e];return st(n,`finalizeUnwrap: clearValue`),this.submitTransaction({operation:`finalizeUnwrap`,config:l(this.address,e,n,t.decryptionProof)})}async#o(){return this.#e===void 0?(this.#t||=this.sdk.provider.readContract(ge(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:x.UnshieldPhase1Submitted,txHash:e,operationId:t});let i;try{i=await this.sdk.provider.waitForTransactionReceipt(e)}catch(e){throw e instanceof r?e:new _(`Failed to get unshield receipt`,{cause:e})}let a=Jt(i.logs);if(!a)throw new _(`No UnwrapRequested event found in unshield receipt`);this.emit({type:x.UnshieldPhase2Started,operationId:t}),u(`unshield: onFinalizing`,()=>n?.onFinalizing?.(),this.sdk.logger);let o=await this.finalizeUnwrap(a.unwrapRequestId??a.encryptedAmount);return this.emit({type:x.UnshieldPhase2Submitted,txHash:o.txHash,operationId:t}),u(`unshield: onFinalizeSubmitted`,()=>n?.onFinalizeSubmitted?.(o.txHash),this.sdk.logger),o}async#c(e,t,n){this.#r(`approveUnderlying`);let r=await this.#o(),i=O((await S(`approveUnderlying`,this.sdk.signer,this.sdk.provider)).address),a=await this.sdk.provider.readContract(m(r,i,this.address));if(a>=e)return;a>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:p(r,this.address,0n)});let o=t?2n**256n-1n:e;await this.submitTransaction({operation:`approveUnderlying`,config:p(r,this.address,o),onSubmitted:n?.onApprovalSubmitted})}},rn=class{relayer;provider;signer;storage;registry;permits;delegations;decryption;#e;#t;#n;#r;#i;#a;#o;#s;#c;constructor(e){this.relayer=e.relayer,this.provider=e.provider,this.signer=e.signer,this.storage=e.storage,this.#t=e.onEvent??function(){},this.#n=e.logger,this.#r=new Mt(e.storage,this.#n),this.#c=new Vt({provider:this.provider,relayer:this.relayer,emitEvent:this.emitEvent.bind(this),logger:this.#n});let t={};for(let n of e.chains)n.registryAddress&&(t[n.id]=n.registryAddress);this.registry=new E({provider:this.provider,registryAddresses:t,registryTTL:e.registryTTL}),this.#e=e.registryTTL,e.signer&&(this.#s=new Xe({relayer:this.relayer,signer:e.signer,transportKeyPairTTL:e.transportKeyPairTTL,permitTTL:e.permitTTL,storage:this.storage,permitStorage:e.permitStorage,logger:this.#n}),this.#o=new Lt({cache:this.#r,credentialService:this.#s,delegationService:this.#c,relayer:this.relayer,emitEvent:this.emitEvent.bind(this)})),this.#a=new Ht({relayer:this.relayer,emitEvent:this.emitEvent.bind(this)}),this.#i=new Ut({signer:e.signer,relayer:this.relayer,cachingService:this.#r,credentialService:this.#s,logger:this.#n}),this.permits=new kt({signer:this.signer,provider:this.provider,cachingService:this.#r,credentialService:this.#s,logger:this.#n}),this.delegations=new Ot({signer:this.signer,provider:this.provider,delegationService:this.#c}),this.decryption=new Dt({signer:this.signer,provider:this.provider,relayer:this.relayer,decryptionService:this.#o})}onWalletAccountChange(e){return this.#i.onWalletAccountChange(e)}get logger(){return this.#n}emitEvent(e,t){try{this.#t({...e,tokenAddress:t,timestamp:Date.now()})}catch(t){this.#n.warn(`${e.type} event listener silently failed`,{error:t})}}createWrappersRegistry(e){return new E({provider:this.provider,registryAddresses:e,registryTTL:this.#e})}async encrypt(e){return this.#a.encrypt(e)}createToken(e){return new C(this,e)}createWrappedToken(e){return new nn(this,e)}dispose(){this.#i.dispose()}terminate(){this.dispose(),this.relayer.terminate(),this.signer?.dispose?.()}[Symbol.dispose](){this.terminate()}};function $(e){return`zama:pending-unshield:${tt(e)}`}const an=k.union([k.pipe(T,k.transform(e=>({unwrapTxHash:e}))),k.pipe(k.object({version:k.literal(1),unwrapTxHash:T,unwrapRequestId:k.optional(T)}),k.transform(({unwrapTxHash:e,unwrapRequestId:t})=>({unwrapTxHash:e,unwrapRequestId:t})))]);async function on(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 sn(e,t){return(await cn(e,t))?.unwrapTxHash??null}async function cn(e,t){let n=$(t),r=await e.get(n);if(r==null)return null;let i=an.safeParse(r);return i.success?i.data:(await e.delete(n),null)}async function ln(e,t){await e.delete($(t))}var un=class{async get(e){return(await chrome.storage.session.get(e))[e]??null}async set(e,t){await chrome.storage.session.set({[e]:t})}async delete(e){await chrome.storage.session.remove(e)}};const dn=new un;export{tn as ACL_TOPICS,St as AclPausedError,X as AclTopics,Ie as BalanceCheckUnavailableError,et as BaseSigner,Ue as ChainMismatchError,un as ChromeSessionStorage,i as ConfigurationError,Dt as Decryption,g as DecryptionFailedError,Ke as DefaultRegistryAddresses,xt as DelegationContractIsSelfError,bt as DelegationCooldownError,F as DelegationDelegateEqualsContractError,I as DelegationExpirationTooSoonError,N as DelegationExpiredError,P as DelegationExpiryUnchangedError,M as DelegationNotFoundError,L as DelegationNotPropagatedError,j as DelegationSelfNotAllowedError,Ot as Delegations,fe as ERC1363_INTERFACE_ID,Fe as ERC20ReadFailedError,ve as ERC7984_INTERFACE_ID,Ee as ERC7984_WRAPPER_INTERFACE_ID,h as EncryptionFailedError,rt as IndexedDBStorage,je as InsufficientConfidentialBalanceError,He as InsufficientERC20BalanceError,yt as InvalidTransportKeyPairError,at as MemoryStorage,Ze as MutableWalletAccountStore,A as NoCiphertextError,kt as Permits,n as RelayerRequestFailedError,ee as SignerNotConfiguredError,te as SignerRequiredError,ce as SigningFailedError,d as SigningRejectedError,Xt as TOKEN_TOPICS,C as Token,V as Topics,_ as TransactionRevertedError,vt as TransportKeyPairExpiredError,ae as WalletAccountNotReadyError,Ae as WalletNotConnectedError,nn as WrappedToken,E as WrappersRegistry,Be as ZERO_ENCRYPTED_VALUE,r as ZamaError,t as ZamaErrorCode,rn as ZamaSDK,x as ZamaSDKEvents,m as allowanceContract,ht as anvil,p as approveContract,le as balanceOfContract,dt as bscTestnet,pt as chains,dn as chromeSessionStorage,ln as clearPendingUnshield,Ge as cleartext,oe as confidentialBalanceOfContract,s as confidentialTotalSupplyContract,Oe as confidentialTransferContract,se as confidentialTransferFromContract,Et as createConfig,Qe as createWalletAccountStore,De as decimalsContract,Zt as decodeAclEvent,Qt as decodeAclEvents,Gt as decodeConfidentialTransfer,Z as decodeDelegatedForUserDecryption,Kt as decodeOnChainEvent,qt as decodeOnChainEvents,Q as decodeRevokedDelegationForUserDecryption,Y as decodeUnwrapFinalized,J as decodeUnwrapRequested,q as decodeWrap,Ve as delegateForUserDecryptionContract,l as finalizeUnwrapContract,$t as findDelegatedForUserDecryption,en as findRevokedDelegationForUserDecryption,Jt as findUnwrapRequested,Yt as findWrap,Te as getConfidentialTokenAddressContract,Ne as getDelegationExpiryContract,be as getTokenAddressContract,Ce as getTokenPairContract,he as getTokenPairsContract,ue as getTokenPairsLengthContract,xe as getTokenPairsSliceContract,ut as hardhat,ct as hoodi,nt as indexedDBStorage,c as inferredTotalSupplyContract,ft as ingenTestnet,pe as isConfidentialTokenContract,we as isConfidentialTokenValidContract,me as isConfidentialWrapperContract,y as isEncryptedValueZero,Pe as isHandleDelegatedContract,ie as isOperatorContract,sn as loadPendingUnshield,cn as loadPendingUnshieldRequest,mt as mainnet,e as matchZamaError,it as memoryStorage,de as nameContract,_e as rateContract,$e as resolveChainRelayers,qe as resolveStorage,ze as revokeDelegationContract,on as savePendingUnshield,lt as sepolia,a as setOperatorContract,ye as supportsInterfaceContract,ke as symbolContract,Tt as transferAndCallContract,ge as underlyingContract,ne as unwrapContract,re as unwrapFromBalanceContract,f as wrapContract};
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./relayer-D-nicEYJ.js";import{A as a,B as o,C as s,D as c,F as l,H as u,I as d,L as f,M as ee,N as te,O as ne,P as re,R as ie,S as ae,T as oe,U as se,V as ce,W as le,_ as ue,a as de,b as fe,c as pe,d as me,f as he,g as p,h as m,i as ge,j as _e,k as ve,l as ye,m as be,n as xe,o as Se,p as Ce,r as we,s as Te,t as Ee,u as De,v as Oe,x as ke,z as Ae}from"./wrappers-registry-ChxQp8ty.js";import{n as h,t as g}from"./encryption-BGmINekJ.js";import{_ as je,a as Me,b as _,c as v,d as Ne,f as Pe,g as Fe,h as Ie,i as y,l as b,m as Le,n as Re,o as x,p as ze,r as Be,s as S,t as C,u as Ve,v as He,y as Ue}from"./token-BTgHqRIL.js";import{r as w,t as We}from"./error-W1N-FGwV.js";import{t as Ge}from"./cleartext-CTla3A3O.js";import{a as Ke,c as qe,d as Je,f as T,i as Ye,l as Xe,n as Ze,o as E,r as Qe,s as $e,t as et,u as tt}from"./base-signer-DaRQNB29.js";import{n as nt,t as rt}from"./indexeddb-storage-Mi-fCWN3.js";import{n as it,t as at}from"./memory-storage-fp9RY5BQ.js";import{i as ot,t as st}from"./assertions-CnPIS0VN.js";import{t as D}from"./hex-CxtyupeQ.js";import{a as ct,c as lt,i as ut,n as dt,o as ft,r as pt,s as mt,t as ht}from"./chains-CXcO1DBP.js";import{getAddress as O,keccak256 as gt,toBytes as _t}from"viem";import{z as k}from"zod/mini";var vt=class extends r{constructor(e,n){super(t.TransportKeyPairExpired,e,n),this.name=`TransportKeyPairExpiredError`}},yt=class extends r{constructor(e,n){super(t.InvalidTransportKeyPair,e,n),this.name=`InvalidTransportKeyPairError`}},A=class extends r{constructor(e,n){super(t.NoCiphertext,e,n),this.name=`NoCiphertextError`}},j=class extends r{constructor(e,n){super(t.DelegationSelfNotAllowed,e,n),this.name=`DelegationSelfNotAllowedError`}},bt=class extends r{constructor(e,n){super(t.DelegationCooldown,e,n),this.name=`DelegationCooldownError`}},M=class extends r{constructor(e,n){super(t.DelegationNotFound,e,n),this.name=`DelegationNotFoundError`}},N=class extends r{constructor(e,n){super(t.DelegationExpired,e,n),this.name=`DelegationExpiredError`}},P=class extends r{constructor(e,n){super(t.DelegationExpiryUnchanged,e,n),this.name=`DelegationExpiryUnchangedError`}},F=class extends r{constructor(e,n){super(t.DelegationDelegateEqualsContract,e,n),this.name=`DelegationDelegateEqualsContractError`}},xt=class extends r{constructor(e,n){super(t.DelegationContractIsSelf,e,n),this.name=`DelegationContractIsSelfError`}},St=class extends r{constructor(e,n){super(t.AclPaused,e,n),this.name=`AclPausedError`}},I=class extends r{constructor(e,n){super(t.DelegationExpirationTooSoon,e,n),this.name=`DelegationExpirationTooSoonError`}},L=class extends r{constructor(e,n){super(t.DelegationNotPropagated,e,n),this.name=`DelegationNotPropagatedError`}};function R(e,t,r=!1){if(e instanceof g||e instanceof A||e instanceof n||e instanceof L||e instanceof le||e instanceof se)return e;let i=We(e);return i===400?new A(e instanceof Error?e.message:`No ciphertext for this account`,{cause:e}):r&&i===500?new L(`Delegated decryption failed with a server error. This is most commonly caused by the delegation not having propagated to the gateway yet — after granting delegation, allow 1–2 minutes for cross-chain synchronization before retrying. If the error persists, the gateway or relayer may be experiencing an unrelated issue.`,{cause:e}):i===void 0?new g(t,{cause:e}):new n(e instanceof Error?e.message:t,i,{cause:e})}function Ct(e,t){if(e instanceof r)return e;let i=We(e);return i===void 0?new h(t,{cause:e}):new n(e instanceof Error?e.message:t,i,{cause:e})}const wt=[{type:`function`,name:`allowance`,inputs:[{name:`owner`,type:`address`,internalType:`address`},{name:`spender`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`approve`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`approveAndCall`,inputs:[{name:`spender`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`balanceOf`,inputs:[{name:`account`,type:`address`,internalType:`address`}],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`supportsInterface`,inputs:[{name:`interfaceId`,type:`bytes4`,internalType:`bytes4`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`view`},{type:`function`,name:`totalSupply`,inputs:[],outputs:[{name:``,type:`uint256`,internalType:`uint256`}],stateMutability:`view`},{type:`function`,name:`transfer`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferAndCall`,inputs:[{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFrom`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`},{name:`data`,type:`bytes`,internalType:`bytes`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`function`,name:`transferFromAndCall`,inputs:[{name:`from`,type:`address`,internalType:`address`},{name:`to`,type:`address`,internalType:`address`},{name:`value`,type:`uint256`,internalType:`uint256`}],outputs:[{name:``,type:`bool`,internalType:`bool`}],stateMutability:`nonpayable`},{type:`event`,name:`Approval`,inputs:[{name:`owner`,type:`address`,indexed:!0,internalType:`address`},{name:`spender`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1},{type:`event`,name:`Transfer`,inputs:[{name:`from`,type:`address`,indexed:!0,internalType:`address`},{name:`to`,type:`address`,indexed:!0,internalType:`address`},{name:`value`,type:`uint256`,indexed:!1,internalType:`uint256`}],anonymous:!1}];function Tt(e,t,n,r=`0x`){return{address:e,abi:wt,functionName:`transferAndCall`,args:[t,n,r]}}function Et(e){return Ye(e.signer,e.provider,e)}var Dt=class{#e;#t;#n;#r;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.relayer,this.#r=e.decryptionService}#i(e){return u(this.#r,e)}async decryptValues(e){let t=this.#i(`decryptValues`),n=await S(`decryptValues`,this.#e,this.#t);return t.userDecrypt(e,n.address)}async delegatedDecryptValues(e,t,n=t){let r=this.#i(`delegatedDecryptValues`),i=await S(`delegatedDecryptValues`,this.#e,this.#t);return r.delegatedUserDecrypt(e,t,i.address,n)}async decryptPublicValues(e){if(e.length===0)return{clearValues:{},decryptionProof:`0x`,abiEncodedClearValues:`0x`};try{return await this.#n.publicDecrypt(e)}catch(e){throw R(e,`Public decryption failed`)}}async delegatedBatchDecryptValues({encryptedInputs:e,delegatorAddress:t,accountAddress:n=t,maxConcurrency:r}){let i=this.#i(`delegatedBatchDecryptValues`),a=await S(`delegatedBatchDecryptValues`,this.#e,this.#t);return i.delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:a.address,accountAddress:n,maxConcurrency:r})}},Ot=class{#e;#t;#n;constructor(e){this.#e=e.signer,this.#t=e.provider,this.#n=e.delegationService}#r(e){return u(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)}},kt=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 u(this.#r,e)}async grantPermit(e){if(e.length===0)return;let t=this.#a(`grantPermit`);await v(`grantPermit`,this.#e,this.#t),await t.grantPermit(e)}async grantDelegationPermit(e,t){if(t.length===0)return;let n=this.#a(`grantDelegationPermit`);await v(`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=O((await S(`revokePermits`,this.#e,this.#t)).address);try{await t.revokePermits(e)}finally{await f(`clear decrypt cache`,()=>this.#n.clearForRequester(n),this.#i)}}async clear(){let e=this.#a(`clear`),t=O((await S(`clear`,this.#e,this.#t)).address);try{await e.clearCredentials()}finally{await f(`clear decrypt cache`,()=>this.#n.clearForRequester(t),this.#i)}}};const At=k.union([k.bigint(),k.boolean(),Je]),jt=k.array(k.string());var Mt=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=At.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=O(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}:${O(e)}:${O(t)}:${n.toLowerCase()}`}async#l(){let e=await this.#e.get(this.#r);if(e===null)return[];let t=jt.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 Nt(e,t){let n=It(e,t);if(!n)throw new g(`No permit covers contract ${t} after allow()`);return Ft(e,n)}function Pt(e,t){let n=It(e,t);if(!n)throw new g(`No delegated permit covers contract ${t} after allow()`);return{...Ft(e,n),delegatorAddress:n.delegatorAddress}}function Ft(e,t){return{signedContractAddresses:t.signedContractAddresses,privateKey:e.keypair.privateKey,publicKey:e.keypair.publicKey,signature:t.signature,startTimestamp:t.startTimestamp,durationDays:t.durationDays}}function It(e,t){let n=tt(t);return e.permits.find(e=>e.signedContractAddresses.includes(n))}var Lt=class{#e;#t;#n;#r;#i;constructor({cache:e,credentialService:t,delegationService:n,relayer:r,emitEvent:i}){this.#e=e,this.#t=t,this.#n=n,this.#r=r,this.#i=i}async userDecrypt(e,t){let n=O(t);return this.#a(e,{requesterAddress:n,resolveCredentials:e=>this.#t.grantPermit(e),decryptContract:async({credentials:e,contractAddress:t,encryptedValues:r})=>this.#r.userDecrypt({encryptedValues:r,contractAddress:t,...Nt(e,t),signerAddress:n}),errorMessage:`Failed to decrypt encrypted values`})}async delegatedUserDecrypt(e,t,n,r){let i=O(t),a=O(n);return this.#a(e,{requesterAddress:O(r),resolveCredentials:e=>this.#t.grantPermit(e,i),validate:e=>this.#l(e,{delegatorAddress:i,delegateAddress:a}),decryptContract:async({credentials:e,contractAddress:t,encryptedValues:n})=>this.#r.delegatedUserDecrypt({encryptedValues:n,contractAddress:t,...Pt(e,t),delegateAddress:a}),errorMessage:`Failed to decrypt delegated encrypted values`,delegated:!0})}async delegatedBatchDecryptHandlesAs({encryptedInputs:e,delegatorAddress:t,delegateAddress:n,accountAddress:r,maxConcurrency:i=5}){let a=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:O(e.contractAddress)}));if(a.length===0)return{items:a};let o=O(r);try{let e=await this.delegatedUserDecrypt(a.map(({encryptedValue:e,contractAddress:t})=>({encryptedValue:e,contractAddress:t})),t,n,o);for(let t of a)this.#o(t,e);return{items:a}}catch(e){if(Le(e))throw e;if(a.length===1){let[t=this.#c()]=a;return t.error=this.#s(e,`Failed to decrypt delegated encrypted values`,!0),{items:a}}}return await Me(a.map(e=>async()=>{try{let r=await this.delegatedUserDecrypt([{encryptedValue:e.encryptedValue,contractAddress:e.contractAddress}],t,n,o);this.#o(e,r)}catch(t){if(Le(t))throw t;e.error=this.#s(t,`Failed to decrypt delegated encrypted values`,!0)}}),i),{items:a}}async#a(e,t){if(e.length===0)return{};let n=e.map(e=>({encryptedValue:e.encryptedValue,contractAddress:O(e.contractAddress)})),r={},i=[];for(let e of n)y(e.encryptedValue)?r[e.encryptedValue]=0n:i.push(e);if(i.length===0)return r;let a=Array.from(new Set(n.map(e=>e.contractAddress))),o=Array.from(new Set(i.map(e=>e.contractAddress)));t.validate&&await t.validate(o);let s=[];for(let e of i){let n=await this.#e.get(t.requesterAddress,e.contractAddress,e.encryptedValue);n===null?s.push(e):r[e.encryptedValue]=n}if(s.length===0)return r;let c=await t.resolveCredentials(a),l=new Map;for(let e of s){let t=l.get(e.contractAddress);t?t.push(e.encryptedValue):l.set(e.contractAddress,[e.encryptedValue])}let u=Date.now(),d=s.map(e=>e.encryptedValue);try{this.#i({type:x.DecryptStart,encryptedValues:d}),await Me([...l.entries()].map(([e,n])=>async()=>{let i=await t.decryptContract({credentials:c,contractAddress:e,encryptedValues:n});for(let[n,a]of Object.entries(i))r[n]=a,await this.#e.set(t.requesterAddress,e,n,a)}),5);let e={};for(let t of d){let n=r[t];n!==void 0&&(e[t]=n)}return this.#i({type:x.DecryptEnd,durationMs:Date.now()-u,encryptedValues:d,result:e}),r}catch(e){throw this.#i({type:x.DecryptError,error:w(e),durationMs:Date.now()-u,encryptedValues:d}),R(e,t.errorMessage,t.delegated)}}#o(e,t){let n=t[e.encryptedValue];if(n===void 0){e.error=new g(`Batch delegated decryption returned no value for encrypted value ${e.encryptedValue} on contract ${e.contractAddress}`);return}e.value=n}#s(e,t,n=!1){return e instanceof r?e:R(e,t,n)}#c(){throw new g(`Batch delegated decryption invariant failed: missing item`)}async#l(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 Rt(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 z={AlreadyDelegatedOrRevokedInSameBlock:e=>new bt(`Only one delegate/revoke per (delegator, delegate, contract) per block. Wait for the next block before retrying.`,{cause:e}),SenderCannotBeContractAddress:e=>new xt(`The contract address cannot be the caller address.`,{cause:e}),EnforcedPause:e=>new St(`The ACL contract is paused. Delegation operations are temporarily disabled.`,{cause:e}),SenderCannotBeDelegate:e=>new j(`Cannot delegate to yourself (delegate === msg.sender).`,{cause:e}),DelegateCannotBeContractAddress:e=>new F(`Delegate address cannot be the same as the contract address.`,{cause:e}),ExpirationDateBeforeOneHour:e=>new I(`Expiration date must be at least 1 hour in the future.`,{cause:e}),ExpirationDateAlreadySetToSameValue:e=>new P(`The new expiration date is the same as the current one.`,{cause:e}),NotDelegatedYet:e=>new M(`Cannot revoke: no active delegation exists.`,{cause:e})};function zt(e){return e in z}function Bt(e,t){let n=Rt(e);if(n&&zt(n))return z[n](t);let r=e instanceof Error?e.message:String(e);for(let[e,n]of Object.entries(z))if(r.includes(e))return n(t);return null}var Vt=class{#e;#t;#n;#r;constructor({provider:e,relayer:t,emitEvent:n=()=>{},logger:r}){this.#e=e,this.#t=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 I(`Expiration date must be at least 1 hour in the future`);let a=O(t),o=O(n),s=O(r);if(o===s)throw new j(`Cannot delegate to yourself (delegate === msg.sender).`);if(o===a)throw new F(`Delegate address cannot be the same as the contract address (${a}).`);let c=await this.#t.getAclAddress(),l=i?BigInt(Math.floor(i.getTime()/1e3)):b,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 P(`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:Ve(c,o,a,l)})}async revokeDelegation(e,{contractAddress:t,delegateAddress:n,delegatorAddress:r}){let i=O(t),a=O(n),o=O(r),s=await this.#t.getAclAddress(),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 M(`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===b?!0:t>await this.#e.getBlockTimestamp()}async getDelegationExpiry({contractAddress:e,delegatorAddress:t,delegateAddress:n}){let r=await this.#t.getAclAddress();return this.#e.readContract(Ne(r,O(t),O(n),O(e)))}async#i({operation:e,signer:t,contractAddress:n,config:r}){try{return await Re({operation:e,signer:t,provider:this.#e,config:r,emit:e=>this.#n(e,n),logger:this.#r})}catch(e){throw this.#a(e),e}}#a(e){if(!(e instanceof _))return;let t=Bt(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 M||t instanceof N){let n=O(e);r.set(n,t);return}throw t}})),r}async assertDelegationActive(e,t,n){let r=O(e),i=O(t),a=O(n),o=await this.getDelegationExpiry({contractAddress:r,delegatorAddress:i,delegateAddress:a});if(o===0n)throw new M(`No active delegation from ${i} to ${a} for ${r}`);if(o!==b&&o<=await this.#e.getBlockTimestamp())throw new N(`Delegation from ${i} to ${a} for ${r} has expired`)}},Ht=class{#e;#t;constructor({relayer:e,emitEvent:t}){this.#e=e,this.#t=t}async encrypt(e){let t=Date.now();try{this.#t({type:x.EncryptStart},e.contractAddress);let n=await this.#e.encrypt(e);return this.#t({type:x.EncryptEnd,durationMs:Date.now()-t},e.contractAddress),n}catch(n){throw this.#t({type:x.EncryptError,error:w(n),durationMs:Date.now()-t},e.contractAddress),Ct(n,`Encryption failed`)}}},Ut=class{#e;#t;#n;#r;#i;#a=new Set;#o;constructor(e){this.#e=e.signer,this.#t=e.relayer,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 f(`switch relayer chain`,()=>this.#t.switchChain(r),this.#i);let i=this.#r;i&&await f(`credential wallet account change`,()=>i.handleWalletAccountChange(t,n),this.#i),t&&await f(`clear decrypt cache`,()=>this.#n.clearForRequester(t.address),this.#i),await Promise.all(Array.from(this.#a,t=>f(`wallet account listener`,()=>t(e),this.#i)))}};function B(e){return gt(_t(e))}const V={ConfidentialTransfer:B(`ConfidentialTransfer(address,address,bytes32)`),Wrap:B(`Wrap(address,uint256,bytes32)`),UnwrapRequested:B(`UnwrapRequested(address,bytes32,bytes32)`),UnwrapFinalized:B(`UnwrapFinalized(address,bytes32,bytes32,uint64)`)};function H(e){return O(D(e.slice(-40)))}function U(e){return e}function W(e,t){let n=2+t*64,r=e.slice(n,n+64);return r.length===64?r:r.padEnd(64,`0`)}function Wt(e,t){return O(D(W(e,t).slice(-40)))}function G(e,t){return BigInt(`0x`+W(e,t))}function K(e,t){return D(W(e,t))}function Gt(e){return e.topics[0]!==V.ConfidentialTransfer||e.topics.length<4?null:{eventName:`ConfidentialTransfer`,from:H(e.topics[1]),to:H(e.topics[2]),encryptedAmount:U(e.topics[3])}}function q(e){return e.topics[0]!==V.Wrap||e.topics.length<2?null:{eventName:`Wrap`,to:H(e.topics[1]),roundedAmount:G(e.data,0),encryptedWrappedAmount:K(e.data,1)}}function J(e){return e.topics[0]!==V.UnwrapRequested||e.topics.length<3?null:{eventName:`UnwrapRequested`,receiver:H(e.topics[1]),unwrapRequestId:U(e.topics[2]),encryptedAmount:K(e.data,0)}}function Kt(e){return e.topics[0]!==V.UnwrapFinalized||e.topics.length<3?null:{eventName:`UnwrapFinalized`,receiver:H(e.topics[1]),unwrapRequestId:U(e.topics[2]),encryptedAmount:K(e.data,0),cleartextAmount:G(e.data,1)}}function qt(e){return Gt(e)??q(e)??J(e)??Kt(e)}function Jt(e){let t=[];for(let n of e){let e=qt(n);e&&t.push(e)}return t}function Yt(e){for(let t of e){let e=J(t);if(e)return e}return null}function Xt(e){for(let t of e){let e=q(t);if(e)return e}return null}const Zt=[V.ConfidentialTransfer,V.Wrap,V.UnwrapRequested,V.UnwrapFinalized],Y={DelegatedForUserDecryption:B(`DelegatedForUserDecryption(address,address,address,uint64,uint64,uint64)`),RevokedDelegationForUserDecryption:B(`RevokedDelegationForUserDecryption(address,address,address,uint64,uint64)`)};function X(e){return e.topics[0]!==Y.DelegatedForUserDecryption||e.topics.length<3?null:{eventName:`DelegatedForUserDecryption`,delegator:H(e.topics[1]),delegate:H(e.topics[2]),contractAddress:Wt(e.data,0),delegationCounter:G(e.data,1),oldExpirationDate:G(e.data,2),newExpirationDate:G(e.data,3)}}function Z(e){return e.topics[0]!==Y.RevokedDelegationForUserDecryption||e.topics.length<3?null:{eventName:`RevokedDelegationForUserDecryption`,delegator:H(e.topics[1]),delegate:H(e.topics[2]),contractAddress:Wt(e.data,0),delegationCounter:G(e.data,1),oldExpirationDate:G(e.data,2)}}function Qt(e){return X(e)??Z(e)}function $t(e){let t=[];for(let n of e){let e=Qt(n);e&&t.push(e)}return t}function en(e){for(let t of e){let e=X(t);if(e)return e}return null}function tn(e){for(let t of e){let e=Z(t);if(e)return e}return null}const nn=[Y.DelegatedForUserDecryption,Y.RevokedDelegationForUserDecryption];var Q=class extends C{#e;#t=null;#n=null;#r(e){try{return ot(this.sdk.signer,`WrappedToken.sdk.signer`),this.sdk.signer}catch(t){throw new ie(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(Ce(e))}catch{this.#n=!1}return this.#n}async allowance(e){let t=await this.#o();return this.sdk.provider.readContract(m(t,O(e),this.address))}async shield(e,t){let n=await S(`shield`,this.sdk.signer,this.sdk.provider),i=await this.isPayable(),a=await this.#o(),o=O(n.address),s;try{s=await this.sdk.provider.readContract(ue(a,o))}catch(e){throw e instanceof r?e:new Fe(`Could not read ERC-20 balance for shield validation (token: ${a})`,{cause:w(e)})}if(s<e)throw new He(`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?O(r.to):n,a=i===n?`0x`:i;return this.submitTransaction({operation:`shield:transferAndCall`,config:Tt(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?O(n.to):t;return this.submitTransaction({operation:`shield:approveAndWrap`,config:d(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=O(t.address),i=e??2n**256n-1n;return i>0n&&await this.sdk.provider.readContract(m(n,r,this.address))>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:p(n,this.address,0n)}),this.submitTransaction({operation:`approveUnderlying`,config:p(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 f(`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 f(`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 unwrap(e){this.#r(`unwrap`);let t=O((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 h(`Encryption returned no encrypted values`);return this.submitTransaction({operation:`unwrap`,config:re(this.address,t,t,i,r)})}async unwrapAll(){this.#r(`unwrapAll`);let e=O((await S(`unwrapAll`,this.sdk.signer,this.sdk.provider)).address),t=await this.readConfidentialBalanceOf(e);if(y(t))throw new g(`Cannot unshield: balance is zero`);return this.submitTransaction({operation:`unwrapAll`,config:l(this.address,e,e,t)})}async finalizeUnwrap(e){this.#r(`finalizeUnwrap`),await v(`finalizeUnwrap`,this.sdk.signer,this.sdk.provider);let t=await this.sdk.decryption.decryptPublicValues([e]),n=t.clearValues[e];return st(n,`finalizeUnwrap: clearValue`),this.submitTransaction({operation:`finalizeUnwrap`,config:ne(this.address,e,n,t.decryptionProof)})}async#o(){return this.#e===void 0?(this.#t||=this.sdk.provider.readContract(te(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:x.UnshieldPhase1Submitted,txHash:e,operationId:t});let i;try{i=await this.sdk.provider.waitForTransactionReceipt(e)}catch(e){throw e instanceof r?e:new _(`Failed to get unshield receipt`,{cause:e})}let a=Yt(i.logs);if(!a)throw new _(`No UnwrapRequested event found in unshield receipt`);this.emit({type:x.UnshieldPhase2Started,operationId:t}),f(`unshield: onFinalizing`,()=>n?.onFinalizing?.(),this.sdk.logger);let o=await this.finalizeUnwrap(a.unwrapRequestId??a.encryptedAmount);return this.emit({type:x.UnshieldPhase2Submitted,txHash:o.txHash,operationId:t}),f(`unshield: onFinalizeSubmitted`,()=>n?.onFinalizeSubmitted?.(o.txHash),this.sdk.logger),o}async#c(e,t,n){this.#r(`approveUnderlying`);let r=await this.#o(),i=O((await S(`approveUnderlying`,this.sdk.signer,this.sdk.provider)).address),a=await this.sdk.provider.readContract(m(r,i,this.address));if(a>=e)return;a>0n&&await this.submitTransaction({operation:`approveUnderlying:reset`,config:p(r,this.address,0n)});let o=t?2n**256n-1n:e;await this.submitTransaction({operation:`approveUnderlying`,config:p(r,this.address,o),onSubmitted:n?.onApprovalSubmitted})}},rn=class{relayer;provider;signer;storage;registry;permits;delegations;decryption;#e;#t;#n;#r;#i;#a;#o;#s;#c;constructor(e){this.relayer=e.relayer,this.provider=e.provider,this.signer=e.signer,this.storage=e.storage,this.#t=e.onEvent??function(){},this.#n=e.logger,this.#r=new Mt(e.storage,this.#n),this.#c=new Vt({provider:this.provider,relayer:this.relayer,emitEvent:this.emitEvent.bind(this),logger:this.#n});let t={};for(let n of e.chains)n.registryAddress&&(t[n.id]=n.registryAddress);this.registry=new E({provider:this.provider,registryAddresses:t,registryTTL:e.registryTTL}),this.#e=e.registryTTL,e.signer&&(this.#s=new Xe({relayer:this.relayer,signer:e.signer,transportKeyPairTTL:e.transportKeyPairTTL,permitTTL:e.permitTTL,storage:this.storage,permitStorage:e.permitStorage,logger:this.#n}),this.#o=new Lt({cache:this.#r,credentialService:this.#s,delegationService:this.#c,relayer:this.relayer,emitEvent:this.emitEvent.bind(this)})),this.#a=new Ht({relayer:this.relayer,emitEvent:this.emitEvent.bind(this)}),this.#i=new Ut({signer:e.signer,relayer:this.relayer,cachingService:this.#r,credentialService:this.#s,logger:this.#n}),this.permits=new kt({signer:this.signer,provider:this.provider,cachingService:this.#r,credentialService:this.#s,logger:this.#n}),this.delegations=new Ot({signer:this.signer,provider:this.provider,delegationService:this.#c}),this.decryption=new Dt({signer:this.signer,provider:this.provider,relayer:this.relayer,decryptionService:this.#o})}onWalletAccountChange(e){return this.#i.onWalletAccountChange(e)}get logger(){return this.#n}emitEvent(e,t){try{this.#t({...e,tokenAddress:t,timestamp:Date.now()})}catch(t){this.#n.warn(`${e.type} event listener silently failed`,{error:t})}}createWrappersRegistry(e){return new E({provider:this.provider,registryAddresses:e,registryTTL:this.#e})}async encrypt(e){return this.#a.encrypt(e)}createToken(e){return new C(this,e)}createWrappedToken(e){return new Q(this,e)}dispose(){this.#i.dispose()}terminate(){this.dispose(),this.relayer.terminate(),this.signer?.dispose?.()}[Symbol.dispose](){this.terminate()}};function $(e){return`zama:pending-unshield:${tt(e)}`}const an=k.union([k.pipe(T,k.transform(e=>({unwrapTxHash:e}))),k.pipe(k.object({version:k.literal(1),unwrapTxHash:T,unwrapRequestId:k.optional(T)}),k.transform(({unwrapTxHash:e,unwrapRequestId:t})=>({unwrapTxHash:e,unwrapRequestId:t})))]);async function on(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 sn(e,t){return(await cn(e,t))?.unwrapTxHash??null}async function cn(e,t){let n=$(t),r=await e.get(n);if(r==null)return null;let i=an.safeParse(r);return i.success?i.data:(await e.delete(n),null)}async function ln(e,t){await e.delete($(t))}var un=class{async get(e){return(await chrome.storage.session.get(e))[e]??null}async set(e,t){await chrome.storage.session.set({[e]:t})}async delete(e){await chrome.storage.session.remove(e)}};const dn=new un;export{nn as ACL_TOPICS,St as AclPausedError,Y as AclTopics,Ie as BalanceCheckUnavailableError,et as BaseSigner,Ue as ChainMismatchError,un as ChromeSessionStorage,i as ConfigurationError,Dt as Decryption,g as DecryptionFailedError,Ke as DefaultRegistryAddresses,xt as DelegationContractIsSelfError,bt as DelegationCooldownError,F as DelegationDelegateEqualsContractError,I as DelegationExpirationTooSoonError,N as DelegationExpiredError,P as DelegationExpiryUnchangedError,M as DelegationNotFoundError,L as DelegationNotPropagatedError,j as DelegationSelfNotAllowedError,Ot as Delegations,pe as ERC1363_INTERFACE_ID,Fe as ERC20ReadFailedError,ye as ERC7984_INTERFACE_ID,De as ERC7984_WRAPPER_INTERFACE_ID,h as EncryptionFailedError,rt as IndexedDBStorage,je as InsufficientConfidentialBalanceError,He as InsufficientERC20BalanceError,yt as InvalidTransportKeyPairError,at as MemoryStorage,Ze as MutableWalletAccountStore,A as NoCiphertextError,kt as Permits,n as RelayerRequestFailedError,ie as SignerNotConfiguredError,Ae as SignerRequiredError,se as SigningFailedError,le as SigningRejectedError,Zt as TOKEN_TOPICS,C as Token,V as Topics,_ as TransactionRevertedError,vt as TransportKeyPairExpiredError,o as WalletAccountNotReadyError,ce as WalletNotConnectedError,Q as WrappedToken,E as WrappersRegistry,Be as ZERO_ENCRYPTED_VALUE,r as ZamaError,t as ZamaErrorCode,rn as ZamaSDK,x as ZamaSDKEvents,m as allowanceContract,ht as anvil,p as approveContract,ue as balanceOfContract,dt as bscTestnet,pt as chains,dn as chromeSessionStorage,ln as clearPendingUnshield,Ge as cleartext,ae as confidentialBalanceOfContract,s as confidentialTotalSupplyContract,oe as confidentialTransferContract,c as confidentialTransferFromContract,Et as createConfig,Qe as createWalletAccountStore,Oe as decimalsContract,Qt as decodeAclEvent,$t as decodeAclEvents,Gt as decodeConfidentialTransfer,X as decodeDelegatedForUserDecryption,qt as decodeOnChainEvent,Jt as decodeOnChainEvents,Z as decodeRevokedDelegationForUserDecryption,Kt as decodeUnwrapFinalized,J as decodeUnwrapRequested,q as decodeWrap,Ve as delegateForUserDecryptionContract,ne as finalizeUnwrapContract,en as findDelegatedForUserDecryption,tn as findRevokedDelegationForUserDecryption,Yt as findUnwrapRequested,Xt as findWrap,Ee as getConfidentialTokenAddressContract,Ne as getDelegationExpiryContract,xe as getTokenAddressContract,we as getTokenPairContract,ge as getTokenPairsContract,de as getTokenPairsLengthContract,Se as getTokenPairsSliceContract,ut as hardhat,ct as hoodi,nt as indexedDBStorage,ve as inferredTotalSupplyContract,ft as ingenTestnet,me as isConfidentialTokenContract,Te as isConfidentialTokenValidContract,he as isConfidentialWrapperContract,y as isEncryptedValueZero,Pe as isHandleDelegatedContract,a as isOperatorContract,sn as loadPendingUnshield,cn as loadPendingUnshieldRequest,mt as mainnet,e as matchZamaError,it as memoryStorage,fe as nameContract,_e as rateContract,$e as resolveChainRelayers,qe as resolveStorage,ze as revokeDelegationContract,on as savePendingUnshield,lt as sepolia,ee as setOperatorContract,be as supportsInterfaceContract,ke as symbolContract,Tt as transferAndCallContract,te as underlyingContract,re as unwrapContract,l as unwrapFromBalanceContract,d as wrapContract};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|