@zama-fhe/sdk 3.0.0-alpha.2 → 3.0.0-alpha.21
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/README.md +207 -122
- package/dist/cjs/build.cjs +2 -0
- package/dist/cjs/build.cjs.map +1 -0
- package/dist/cjs/chains/index.cjs +1 -0
- package/dist/cjs/chains.cjs +2 -0
- package/dist/cjs/chains.cjs.map +1 -0
- package/dist/cjs/cleartext/index.cjs +1 -1
- package/dist/cjs/eip1193-subscribe.cjs +1 -1
- package/dist/cjs/eip1193-subscribe.cjs.map +1 -1
- package/dist/cjs/encryption.cjs +2 -0
- package/dist/cjs/encryption.cjs.map +1 -0
- package/dist/cjs/ethers/index.cjs +1 -1
- package/dist/cjs/ethers/index.cjs.map +1 -1
- package/dist/cjs/index.cjs +73 -73
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/query/index.cjs +1 -1
- package/dist/cjs/query/index.cjs.map +1 -1
- package/dist/cjs/readonly-token.cjs +1 -1
- package/dist/cjs/readonly-token.cjs.map +1 -1
- package/dist/cjs/relayer-cleartext.cjs +2 -0
- package/dist/cjs/relayer-cleartext.cjs.map +1 -0
- package/dist/cjs/relayer-sdk.worker.js +71 -71
- package/dist/cjs/relayer.cjs +1 -1
- package/dist/cjs/relayer.cjs.map +1 -1
- package/dist/cjs/viem/index.cjs +1 -1
- package/dist/cjs/viem/index.cjs.map +1 -1
- package/dist/cjs/wrappers-registry.cjs +1 -1
- package/dist/cjs/wrappers-registry.cjs.map +1 -1
- package/dist/esm/{assertions-BARApuMj.js → assertions-CfqI3AJv.js} +1 -1
- package/dist/esm/{assertions-BARApuMj.js.map → assertions-CfqI3AJv.js.map} +1 -1
- package/dist/esm/build-CvenCk6R.js +2 -0
- package/dist/esm/build-CvenCk6R.js.map +1 -0
- package/dist/esm/chains/index.d.ts +3 -0
- package/dist/esm/chains/index.js +1 -0
- package/dist/esm/chains-aHmrozPh.js +2 -0
- package/dist/esm/chains-aHmrozPh.js.map +1 -0
- package/dist/esm/cleartext/index.d.ts +2 -86
- package/dist/esm/cleartext/index.js +1 -1
- package/dist/esm/cleartext-BHu6-LCv.d.ts +19 -0
- package/dist/esm/cleartext-I-etE_7S.js +2 -0
- package/dist/esm/cleartext-I-etE_7S.js.map +1 -0
- package/dist/esm/eip1193-subscribe-CcotSOIm.js +2 -0
- package/dist/esm/eip1193-subscribe-CcotSOIm.js.map +1 -0
- package/dist/esm/{encryption-CmIPBcfP.js → encryption-YS-Kb7qm.js} +2 -2
- package/dist/esm/{encryption-CmIPBcfP.js.map → encryption-YS-Kb7qm.js.map} +1 -1
- package/dist/esm/ethers/index.d.ts +53 -8
- package/dist/esm/ethers/index.js +1 -1
- package/dist/esm/ethers/index.js.map +1 -1
- package/dist/esm/{hex-D_B-zoId.js → hex-BZVTzEK6.js} +2 -2
- package/dist/esm/{hex-D_B-zoId.js.map → hex-BZVTzEK6.js.map} +1 -1
- package/dist/esm/{relayer-utils-iSPis4x-.d.ts → index-BTY0MxOt.d.ts} +50 -23
- package/dist/esm/{onchain-events-2VNiL78c.d.ts → index-BdyljG1F.d.ts} +387 -1505
- package/dist/esm/index.d.ts +61 -93
- package/dist/esm/index.js +73 -73
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/memory-storage-CFXqXUcm.js +2 -0
- package/dist/esm/memory-storage-CFXqXUcm.js.map +1 -0
- package/dist/esm/node/index.d.ts +88 -110
- package/dist/esm/node/index.js +1 -1
- package/dist/esm/node/index.js.map +1 -1
- package/dist/esm/node/relayer-sdk.node-worker.js +1 -1
- package/dist/esm/node/relayer-sdk.node-worker.js.map +1 -1
- package/dist/esm/query/index.d.ts +40 -50
- package/dist/esm/query/index.js +1 -1
- package/dist/esm/query/index.js.map +1 -1
- package/dist/esm/readonly-token-DCLOYhws.js +2 -0
- package/dist/esm/readonly-token-DCLOYhws.js.map +1 -0
- package/dist/esm/{relayer-C6u3eOlN.js → relayer-7Hd00A6X.js} +2 -2
- package/dist/esm/relayer-7Hd00A6X.js.map +1 -0
- package/dist/esm/{relayer-sdk.types-CGfXwKcB.d.ts → relayer-cleartext-DJkSUlZ2.d.ts} +263 -106
- package/dist/esm/relayer-cleartext-SZCM9wTx.js +2 -0
- package/dist/esm/relayer-cleartext-SZCM9wTx.js.map +1 -0
- package/dist/esm/relayer-sdk.worker.js +71 -71
- package/dist/esm/types-C1S426x4.d.ts +48 -0
- package/dist/esm/types-CVyJHEya.d.ts +14 -0
- package/dist/esm/types-DePjTTbo.d.ts +30 -0
- package/dist/esm/types-FY7ciI37.d.ts +615 -0
- package/dist/esm/viem/index.d.ts +39 -11
- package/dist/esm/viem/index.js +1 -1
- package/dist/esm/viem/index.js.map +1 -1
- package/dist/esm/wrappers-registry-CXNs4eR0.js +2 -0
- package/dist/esm/wrappers-registry-CXNs4eR0.js.map +1 -0
- package/package.json +17 -3
- package/dist/cjs/cleartext.cjs +0 -2
- package/dist/cjs/cleartext.cjs.map +0 -1
- package/dist/esm/cleartext-Cs28cTsa.js +0 -2
- package/dist/esm/cleartext-Cs28cTsa.js.map +0 -1
- package/dist/esm/eip1193-subscribe-Cl_wlVuQ.js +0 -2
- package/dist/esm/eip1193-subscribe-Cl_wlVuQ.js.map +0 -1
- package/dist/esm/memory-storage-F8xjMzVy.js +0 -2
- package/dist/esm/memory-storage-F8xjMzVy.js.map +0 -1
- package/dist/esm/readonly-token-D4GjTj0q.js +0 -2
- package/dist/esm/readonly-token-D4GjTj0q.js.map +0 -1
- package/dist/esm/relayer-C6u3eOlN.js.map +0 -1
- package/dist/esm/relayer-sdk-DPqytEbO.d.ts +0 -44
- package/dist/esm/relayer-utils-BeoTNDM4.js +0 -2
- package/dist/esm/relayer-utils-BeoTNDM4.js.map +0 -1
- package/dist/esm/wrappers-registry-ydyySM9g.js +0 -2
- package/dist/esm/wrappers-registry-ydyySM9g.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["#readProvider","#eip1193","#signerPromise","#requireSigner","#requireProvider"],"sources":["../../../src/ethers/ethers-signer.ts","../../../src/ethers/contracts.ts"],"sourcesContent":["import { ethers, BrowserProvider, type Signer } from \"ethers\";\nimport {\n getAddress,\n isHex,\n type Abi,\n type Address,\n type ContractFunctionArgs,\n type ContractFunctionName,\n type ContractFunctionReturnType,\n type EIP1193Provider,\n type Hex,\n} from \"viem\";\nimport type { EIP712TypedData } from \"../relayer/relayer-sdk.types\";\nimport type {\n GenericSigner,\n ReadContractConfig,\n SignerLifecycleCallbacks,\n TransactionReceipt,\n WriteContractConfig,\n} from \"../types\";\nimport { eip1193Subscribe } from \"../token/eip1193-subscribe\";\n\n/**\n * Configuration for {@link EthersSigner}.\n *\n * Three variants:\n *\n * - **Browser** — `{ ethereum }`: pass the raw EIP-1193 provider (e.g. `window.ethereum`).\n * A `BrowserProvider` is created internally and `subscribe()` works automatically.\n *\n * - **Node / direct signer** — `{ signer }`: pass an ethers `Signer` (e.g. `Wallet`).\n * `subscribe()` is not available since there is no EIP-1193 provider.\n *\n * - **Read-only** — `{ provider }`: pass an ethers `Provider` for read-only contract calls.\n * Signing and write operations will throw at runtime.\n */\nexport type EthersSignerConfig =\n | { ethereum: EIP1193Provider }\n | { signer: Signer }\n | { provider: ethers.Provider };\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 implements GenericSigner {\n #signerPromise?: Promise<Signer>;\n readonly #readProvider?: ethers.Provider;\n readonly #eip1193?: EIP1193Provider;\n\n constructor(config: EthersSignerConfig) {\n if (\"ethereum\" in config) {\n const browserProvider = new BrowserProvider(config.ethereum);\n this.#signerPromise = browserProvider.getSigner();\n this.#readProvider = browserProvider;\n this.#eip1193 = config.ethereum;\n } else if (\"signer\" in config) {\n this.#signerPromise = Promise.resolve(config.signer);\n this.#readProvider = config.signer.provider ?? undefined;\n } else {\n this.#readProvider = config.provider;\n }\n }\n\n async #requireSigner(): Promise<Signer> {\n if (!this.#signerPromise) {\n throw new TypeError(\"No signer configured — read-only mode\");\n }\n return this.#signerPromise;\n }\n\n #requireProvider(): ethers.Provider {\n if (!this.#readProvider) {\n throw new TypeError(\"Signer has no provider\");\n }\n return this.#readProvider;\n }\n\n async getChainId(): Promise<number> {\n const network = await this.#requireProvider().getNetwork();\n return Number(network.chainId);\n }\n\n async getAddress(): Promise<Address> {\n const signer = await this.#requireSigner();\n return getAddress(await signer.getAddress());\n }\n\n async signTypedData(typedData: EIP712TypedData): Promise<Hex> {\n const signer = await this.#requireSigner();\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.#requireSigner();\n const contract = new ethers.Contract(config.address, config.abi as ethers.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 tx = await contract[config.functionName]!(\n ...(config.args as readonly unknown[]),\n overrides,\n );\n if (!isHex(tx.hash)) {\n throw new TypeError(`Expected hex string, got: ${tx.hash}`);\n }\n return tx.hash;\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 provider = this.#requireProvider();\n const contract = new ethers.Contract(\n config.address,\n config.abi as ethers.InterfaceAbi,\n provider,\n );\n return contract[config.functionName]!(...(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.#requireProvider().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.#requireProvider().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 subscribe(callbacks: SignerLifecycleCallbacks): () => void {\n return eip1193Subscribe(this.#eip1193, () => this.getAddress(), callbacks);\n }\n}\n","import {\n decodeFunctionResult,\n encodeFunctionData,\n isHex,\n type Abi,\n type Address,\n type Hex,\n} from \"viem\";\n\nimport type { Handle } 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 handle: Uint8Array,\n inputProof: Uint8Array,\n) {\n return ethersWrite(signer, confidentialTransferContract(tokenAddress, to, handle, inputProof));\n}\n\nexport function writeUnwrapContract(\n signer: EthersTransactionSigner,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedAmount: Uint8Array,\n inputProof: Uint8Array,\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: Handle,\n) {\n return ethersWrite(signer, unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance));\n}\n\nexport function writeFinalizeUnwrapContract(\n signer: EthersTransactionSigner,\n wrapper: Address,\n unwrapRequestId: Handle,\n burntAmountCleartext: bigint,\n decryptionProof: Hex,\n) {\n return ethersWrite(\n signer,\n finalizeUnwrapContract(wrapper, unwrapRequestId, burntAmountCleartext, decryptionProof),\n );\n}\n\nexport function writeSetOperatorContract(\n signer: EthersTransactionSigner,\n tokenAddress: Address,\n spender: Address,\n timestamp?: number,\n) {\n return ethersWrite(signer, setOperatorContract(tokenAddress, spender, timestamp));\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":"6XAkDA,IAAa,EAAb,KAAmD,CACjD,GACA,GACA,GAEA,YAAY,EAA4B,CACtC,GAAI,aAAc,EAAQ,CACxB,IAAM,EAAkB,IAAI,EAAgB,EAAO,SAAS,CAC5D,MAAA,EAAsB,EAAgB,WAAW,CACjD,MAAA,EAAqB,EACrB,MAAA,EAAgB,EAAO,cACd,WAAY,GACrB,MAAA,EAAsB,QAAQ,QAAQ,EAAO,OAAO,CACpD,MAAA,EAAqB,EAAO,OAAO,UAAY,IAAA,IAE/C,MAAA,EAAqB,EAAO,SAIhC,MAAA,GAAwC,CACtC,GAAI,CAAC,MAAA,EACH,MAAU,UAAU,wCAAwC,CAE9D,OAAO,MAAA,EAGT,IAAoC,CAClC,GAAI,CAAC,MAAA,EACH,MAAU,UAAU,yBAAyB,CAE/C,OAAO,MAAA,EAGT,MAAM,YAA8B,CAClC,IAAM,EAAU,MAAM,MAAA,GAAuB,CAAC,YAAY,CAC1D,OAAO,OAAO,EAAQ,QAAQ,CAGhC,MAAM,YAA+B,CAEnC,OAAO,EAAW,MADH,MAAM,MAAA,GAAqB,EACX,YAAY,CAAC,CAG9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OAAO,EAAY,EAAQ,EAA6B,EAAc,EAAI,EAAQ,EAAW,CAAC,CAGhG,SAAgB,EACd,EACA,EACA,EACA,EACA,EACA,EACA,CACA,OAAO,EAAY,EAAQ,EAAe,EAAgB,EAAM,EAAI,EAAiB,EAAW,CAAC,CAGnG,SAAgB,EACd,EACA,EACA,EACA,EACA,EACA,CACA,OAAO,EAAY,EAAQ,EAA0B,EAAgB,EAAM,EAAI,EAAiB,CAAC,CAGnG,SAAgB,EACd,EACA,EACA,EACA,EACA,EACA,CACA,OAAO,EACL,EACA,EAAuB,EAAS,EAAiB,EAAsB,EAAgB,CACxF,CAGH,SAAgB,EACd,EACA,EACA,EACA,EACA,CACA,OAAO,EAAY,EAAQ,EAAoB,EAAc,EAAS,EAAU,CAAC,CAGnF,SAAgB,EACd,EACA,EACA,EACA,EACA,CACA,OAAO,EAAY,EAAQ,EAAa,EAAgB,EAAI,EAAO,CAAC,CAKtE,SAAgB,EAAuB,EAA8B,EAAmB,CACtF,OAAO,EAAW,EAAU,EAAsB,EAAS,CAAC,CAG9D,SAAgB,EAA6B,EAA8B,EAAmB,CAC5F,OAAO,EAAW,EAAU,EAA4B,EAAS,CAAC,CAGpE,SAAgB,EACd,EACA,EACA,EACA,EACA,CACA,OAAO,EAAW,EAAU,EAA2B,EAAU,EAAW,EAAQ,CAAC,CAGvF,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAW,EAAU,EAAqB,EAAU,EAAM,CAAC,CAGpE,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAW,EAAU,EAAoC,EAAU,EAAa,CAAC,CAG1F,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAW,EAAU,EAAwB,EAAU,EAAyB,CAAC,CAG1F,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAW,EAAU,EAAiC,EAAU,EAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["#readProvider","#signerPromise","#eip1193"],"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 — server\n * indexers, SSR, dashboards, explorers, or dApps before the user has\n * connected their 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 { ethers, BrowserProvider, type Signer } from \"ethers\";\nimport {\n getAddress,\n isHex,\n type Abi,\n type Address,\n type ContractFunctionArgs,\n type ContractFunctionName,\n type EIP1193Provider,\n type Hex,\n} from \"viem\";\nimport type { EIP712TypedData } from \"../relayer/relayer-sdk.types\";\nimport type { GenericSigner, SignerIdentityListener, WriteContractConfig } from \"../types\";\nimport { eip1193Subscribe } from \"../signer/eip1193-subscribe\";\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 `subscribe()` works automatically.\n *\n * - **Node / direct signer** — `{ signer }`: pass an ethers `Signer` (e.g. `Wallet`).\n * `subscribe()` is not available since there is no EIP-1193 provider.\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 implements GenericSigner {\n readonly #signerPromise: Promise<Signer>;\n readonly #eip1193?: EIP1193Provider;\n\n constructor(config: EthersSignerConfig) {\n if (\"ethereum\" in config) {\n const browserProvider = new BrowserProvider(config.ethereum);\n this.#signerPromise = browserProvider.getSigner();\n this.#eip1193 = config.ethereum;\n } else {\n this.#signerPromise = Promise.resolve(config.signer);\n }\n }\n\n async getChainId(): Promise<number> {\n const signer = await this.#signerPromise;\n const provider = signer.provider;\n if (!provider) {\n throw new TypeError(\"Signer has no provider — cannot read chain ID\");\n }\n const network = await provider.getNetwork();\n return Number(network.chainId);\n }\n\n async getAddress(): Promise<Address> {\n const signer = await this.#signerPromise;\n return getAddress(await signer.getAddress());\n }\n\n async signTypedData(typedData: EIP712TypedData): Promise<Hex> {\n const signer = await this.#signerPromise;\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.#signerPromise;\n const contract = new ethers.Contract(config.address, config.abi as ethers.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 tx = await contract[config.functionName]!(\n ...(config.args as readonly unknown[]),\n overrides,\n );\n if (!isHex(tx.hash)) {\n throw new TypeError(`Expected hex string, got: ${tx.hash}`);\n }\n return tx.hash;\n }\n\n subscribe(onIdentityChange: SignerIdentityListener): () => void {\n return eip1193Subscribe({\n provider: this.#eip1193,\n getInitialIdentity: async () => {\n const signer = await this.#signerPromise;\n const provider = signer.provider;\n if (!provider) {\n return undefined;\n }\n const [address, network] = await Promise.all([signer.getAddress(), provider.getNetwork()]);\n const chainId = Number(network.chainId);\n return { address: getAddress(address), chainId };\n },\n onIdentityChange,\n });\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 { Handle } 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 handle: Uint8Array,\n inputProof: Uint8Array,\n) {\n return ethersWrite(signer, confidentialTransferContract(tokenAddress, to, handle, inputProof));\n}\n\nexport function writeUnwrapContract(\n signer: EthersTransactionSigner,\n encryptedErc20: Address,\n from: Address,\n to: Address,\n encryptedAmount: Uint8Array,\n inputProof: Uint8Array,\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: Handle,\n) {\n return ethersWrite(signer, unwrapFromBalanceContract(encryptedErc20, from, to, encryptedBalance));\n}\n\nexport function writeFinalizeUnwrapContract(\n signer: EthersTransactionSigner,\n wrapper: Address,\n unwrapRequestId: Handle,\n burntAmountCleartext: bigint,\n decryptionProof: Hex,\n) {\n return ethersWrite(\n signer,\n finalizeUnwrapContract(wrapper, unwrapRequestId, burntAmountCleartext, decryptionProof),\n );\n}\n\nexport function writeSetOperatorContract(\n signer: EthersTransactionSigner,\n tokenAddress: Address,\n spender: Address,\n timestamp?: number,\n) {\n return ethersWrite(signer, setOperatorContract(tokenAddress, spender, timestamp));\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":"saA0CA,IAAa,EAAb,KAAuD,CACrD,GAEA,YAAY,EAA8B,CACpC,aAAc,EAChB,MAAA,EAAqB,IAAI,EAAgB,EAAO,SAAS,CAEzD,MAAA,EAAqB,EAAO,SAIhC,MAAM,YAA8B,CAClC,IAAM,EAAU,MAAM,MAAA,EAAmB,YAAY,CACrD,OAAO,OAAO,EAAQ,QAAQ,CAGhC,MAAM,aAKJ,EACkF,CAOlF,OANiB,IAAI,EAAO,SAC1B,EAAO,QACP,EAAO,IACP,MAAA,EACD,CACmB,YAAY,EAAO,aAAa,CAC1C,GAAI,EAAO,KAA4B,CAKnD,MAAM,mBAAqC,CACzC,IAAM,EAAQ,MAAM,MAAA,EAAmB,SAAS,SAAS,CACzD,GAAI,CAAC,EACH,MAAU,MAAM,+BAA+B,CAEjD,GAAI,EAAM,YAAc,KACtB,MAAU,MAAM,gCAAgC,CAElD,OAAO,OAAO,EAAM,UAAU,CA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,EAAoB,EAAc,EAAS,EAAU,CAAC,CAGnF,SAAgB,EACd,EACA,EACA,EACA,EACA,CACA,OAAO,EAAY,EAAQ,EAAa,EAAgB,EAAI,EAAO,CAAC,CAKtE,SAAgB,EAAuB,EAA8B,EAAmB,CACtF,OAAO,EAAW,EAAU,EAAsB,EAAS,CAAC,CAG9D,SAAgB,EAA6B,EAA8B,EAAmB,CAC5F,OAAO,EAAW,EAAU,EAA4B,EAAS,CAAC,CAGpE,SAAgB,EACd,EACA,EACA,EACA,EACA,CACA,OAAO,EAAW,EAAU,EAA2B,EAAU,EAAW,EAAQ,CAAC,CAGvF,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAW,EAAU,EAAqB,EAAU,EAAM,CAAC,CAGpE,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAW,EAAU,EAAoC,EAAU,EAAa,CAAC,CAG1F,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAW,EAAU,EAAwB,EAAU,EAAyB,CAAC,CAG1F,SAAgB,EACd,EACA,EACA,EACA,CACA,OAAO,EAAW,EAAU,EAAiC,EAAU,EAAyB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./assertions-
|
|
2
|
-
//# sourceMappingURL=hex-
|
|
1
|
+
import{r as e}from"./assertions-CfqI3AJv.js";function t(e){return e.startsWith(`0x`)?e:`0x${e}`}function n(t){return e(t.startsWith(`0x`),`Expected 0x-prefixed hex, got: ${t}`),t.slice(2)}export{n,t};
|
|
2
|
+
//# sourceMappingURL=hex-BZVTzEK6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hex-
|
|
1
|
+
{"version":3,"file":"hex-BZVTzEK6.js","names":[],"sources":["../../src/utils/hex.ts"],"sourcesContent":["import type { Hex } from \"viem\";\nimport { assertCondition } from \"./assertions\";\n\n/** Normalize a un-prefixed hex payload to a 0x-prefixed `Hex` value. */\nexport function prefixHex(value: string): Hex {\n return (value.startsWith(\"0x\") ? value : `0x${value}`) as Hex;\n}\n\n/** Convert a public `Hex` value back an unprefixed format. */\nexport function unprefixHex(value: Hex): string {\n assertCondition(value.startsWith(\"0x\"), `Expected 0x-prefixed hex, got: ${value}`);\n return value.slice(2);\n}\n"],"mappings":"6CAIA,SAAgB,EAAU,EAAoB,CAC5C,OAAQ,EAAM,WAAW,KAAK,CAAG,EAAQ,KAAK,IAIhD,SAAgB,EAAY,EAAoB,CAE9C,OADA,EAAgB,EAAM,WAAW,KAAK,CAAE,kCAAkC,IAAQ,CAC3E,EAAM,MAAM,EAAE"}
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { FhevmInstanceConfig } from "@zama-fhe/relayer-sdk/bundle";
|
|
1
|
+
import { n as FheChain } from "./types-C1S426x4.js";
|
|
3
2
|
|
|
4
|
-
//#region src/
|
|
3
|
+
//#region src/chains/configs.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Mainnet network configuration (chainId 1).
|
|
7
6
|
*
|
|
8
7
|
* Contract addresses mirror `MainnetConfigV2` from `@zama-fhe/relayer-sdk`.
|
|
9
8
|
* They are duplicated here because the `/bundle` export path only exposes
|
|
10
9
|
* types at build time (runtime values require `/web` or `/node` which pull
|
|
11
|
-
* in WASM). `satisfies
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* Includes `registryAddress` for the on-chain token wrappers registry.
|
|
10
|
+
* in WASM). `satisfies FheChain` ensures structural drift is caught at
|
|
11
|
+
* compile time.
|
|
15
12
|
*/
|
|
16
|
-
declare const
|
|
17
|
-
readonly
|
|
13
|
+
declare const mainnet: {
|
|
14
|
+
readonly id: 1;
|
|
18
15
|
readonly gatewayChainId: 261131;
|
|
19
16
|
readonly relayerUrl: "https://relayer.mainnet.zama.org/v2";
|
|
20
17
|
readonly network: "https://ethereum-rpc.publicnode.com";
|
|
@@ -27,12 +24,9 @@ declare const MainnetConfig: {
|
|
|
27
24
|
};
|
|
28
25
|
/**
|
|
29
26
|
* Sepolia testnet network configuration (chainId 11155111).
|
|
30
|
-
*
|
|
31
|
-
* See {@link MainnetConfig} for why addresses are hardcoded.
|
|
32
|
-
* Includes `registryAddress` for the on-chain token wrappers registry.
|
|
33
27
|
*/
|
|
34
|
-
declare const
|
|
35
|
-
readonly
|
|
28
|
+
declare const sepolia: {
|
|
29
|
+
readonly id: 11155111;
|
|
36
30
|
readonly gatewayChainId: 10901;
|
|
37
31
|
readonly relayerUrl: "https://relayer.testnet.zama.org/v2";
|
|
38
32
|
readonly network: "https://ethereum-sepolia-rpc.publicnode.com";
|
|
@@ -43,18 +37,32 @@ declare const SepoliaConfig: {
|
|
|
43
37
|
readonly verifyingContractAddressInputVerification: "0x483b9dE06E4E4C7D35CCf5837A1668487406D955";
|
|
44
38
|
readonly registryAddress: "0x2f0750Bbb0A246059d80e94c454586a7F27a128e";
|
|
45
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Hoodi testnet configuration (chainId 560048).
|
|
42
|
+
*
|
|
43
|
+
* Hoodi does not have full FHE infrastructure — use with `cleartext()` transport.
|
|
44
|
+
* Contract addresses match the cleartext deployment.
|
|
45
|
+
*/
|
|
46
|
+
declare const hoodi: {
|
|
47
|
+
readonly id: 560048;
|
|
48
|
+
readonly gatewayChainId: 10901;
|
|
49
|
+
readonly relayerUrl: "";
|
|
50
|
+
readonly network: "https://rpc.hoodi.ethpandaops.io";
|
|
51
|
+
readonly aclContractAddress: "0x6D3FAf6f86e1fF9F3B0831Dda920AbA1cBd5bd68";
|
|
52
|
+
readonly kmsContractAddress: "0x901F8942346f7AB3a01F6D7613119Bca447Bb030";
|
|
53
|
+
readonly inputVerifierContractAddress: "0x36772142b74871f255CbD7A3e89B401d3e45825f";
|
|
54
|
+
readonly verifyingContractAddressDecryption: "0x5ffdaAB0373E62E2ea2944776209aEf29E631A64";
|
|
55
|
+
readonly verifyingContractAddressInputVerification: "0x812b06e1CDCE800494b79fFE4f925A504a9A9810";
|
|
56
|
+
readonly registryAddress: "0x1807aE2f693F8530DFB126D0eF98F2F2518F292f";
|
|
57
|
+
readonly executorAddress: "0xC316692627de536368d82e9121F1D44a550894E6";
|
|
58
|
+
};
|
|
46
59
|
/**
|
|
47
60
|
* Hardhat local network configuration (chainId 31337).
|
|
48
61
|
*
|
|
49
62
|
* The addresses in this configuration must match those of your deployment.
|
|
50
|
-
* Ensure that the executor address and other contract addresses correspond to
|
|
51
|
-
* the contracts deployed on your Hardhat network.
|
|
52
|
-
*
|
|
53
|
-
* `registryAddress` is `undefined` — pass it explicitly via
|
|
54
|
-
* `registryAddresses` when creating a `WrappersRegistry`.
|
|
55
63
|
*/
|
|
56
|
-
declare const
|
|
57
|
-
readonly
|
|
64
|
+
declare const hardhat: {
|
|
65
|
+
readonly id: 31337;
|
|
58
66
|
readonly gatewayChainId: 10901;
|
|
59
67
|
readonly relayerUrl: "";
|
|
60
68
|
readonly network: "http://127.0.0.1:8545";
|
|
@@ -64,7 +72,26 @@ declare const HardhatConfig: {
|
|
|
64
72
|
readonly verifyingContractAddressDecryption: "0x5ffdaAB0373E62E2ea2944776209aEf29E631A64";
|
|
65
73
|
readonly verifyingContractAddressInputVerification: "0x812b06e1CDCE800494b79fFE4f925A504a9A9810";
|
|
66
74
|
readonly registryAddress: undefined;
|
|
75
|
+
readonly executorAddress: "0xe3a9105a3a932253A70F126eb1E3b589C643dD24";
|
|
67
76
|
};
|
|
77
|
+
/** Alias for {@link hardhat}. */
|
|
78
|
+
declare const anvil: {
|
|
79
|
+
readonly id: 31337;
|
|
80
|
+
readonly gatewayChainId: 10901;
|
|
81
|
+
readonly relayerUrl: "";
|
|
82
|
+
readonly network: "http://127.0.0.1:8545";
|
|
83
|
+
readonly aclContractAddress: "0x50157CFfD6bBFA2DECe204a89ec419c23ef5755D";
|
|
84
|
+
readonly inputVerifierContractAddress: "0x36772142b74871f255CbD7A3e89B401d3e45825f";
|
|
85
|
+
readonly kmsContractAddress: "0x901F8942346f7AB3a01F6D7613119Bca447Bb030";
|
|
86
|
+
readonly verifyingContractAddressDecryption: "0x5ffdaAB0373E62E2ea2944776209aEf29E631A64";
|
|
87
|
+
readonly verifyingContractAddressInputVerification: "0x812b06e1CDCE800494b79fFE4f925A504a9A9810";
|
|
88
|
+
readonly registryAddress: undefined;
|
|
89
|
+
readonly executorAddress: "0xe3a9105a3a932253A70F126eb1E3b589C643dD24";
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Built-in chain configurations keyed by chain ID.
|
|
93
|
+
*/
|
|
94
|
+
declare const chains: Record<number, FheChain>;
|
|
68
95
|
//#endregion
|
|
69
|
-
export {
|
|
70
|
-
//# sourceMappingURL=
|
|
96
|
+
export { mainnet as a, hoodi as i, chains as n, sepolia as o, hardhat as r, anvil as t };
|
|
97
|
+
//# sourceMappingURL=index-BTY0MxOt.d.ts.map
|