@cofhe/hardhat-plugin 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +8 -8
- package/dist/index.d.mts +40 -30
- package/dist/index.d.ts +40 -30
- package/dist/index.js +57 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/consts.ts +0 -2
- package/src/deploy.ts +13 -9
- package/src/index.ts +102 -53
- package/src/expectResultUtils.ts +0 -24
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/fund.ts","../src/consts.ts","../src/deploy.ts","../src/logging.ts","../src/utils.ts","../src/expectResultUtils.ts"],"sourcesContent":["/* eslint-disable no-empty-pattern */\n/* eslint-disable turbo/no-undeclared-env-vars */\n/* eslint-disable no-unused-vars */\nimport chalk from 'chalk';\nimport { type PublicClient, type WalletClient } from 'viem';\nimport { extendConfig, extendEnvironment, task, types } from 'hardhat/config';\nimport { TASK_TEST, TASK_NODE } from 'hardhat/builtin-tasks/task-names';\nimport { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';\nimport { type CofhesdkClient, type CofhesdkConfig, type CofhesdkInputConfig, type Result } from '@cofhe/sdk';\nimport { createCofhesdkClient, createCofhesdkConfig } from '@cofhe/sdk/node';\nimport { HardhatSignerAdapter } from '@cofhe/sdk/adapters';\n\nimport { localcofheFundAccount } from './fund.js';\nimport {\n MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,\n TASK_COFHE_MOCKS_DEPLOY,\n TASK_COFHE_MOCKS_SET_LOG_OPS,\n TASK_COFHE_USE_FAUCET,\n} from './consts.js';\nimport { deployMocks, type DeployMocksArgs } from './deploy.js';\nimport { mock_setLoggingEnabled, mock_withLogs } from './logging.js';\nimport { mock_expectPlaintext } from './utils.js';\nimport { mock_getPlaintext } from './utils.js';\nimport {\n expectResultError,\n expectResultPartialValue,\n expectResultSuccess,\n expectResultValue,\n} from './expectResultUtils.js';\nexport {\n MockACLArtifact,\n MockQueryDecrypterArtifact,\n MockTaskManagerArtifact,\n MockZkVerifierArtifact,\n TestBedArtifact,\n} from '@cofhe/mock-contracts';\n\n/**\n * Configuration interface for the CoFHE Hardhat plugin.\n * Allows users to configure mock logging and gas warning settings.\n */\ndeclare module 'hardhat/types/config' {\n interface HardhatUserConfig {\n cofhesdk?: {\n /** Whether to log mock operations (default: true) */\n logMocks?: boolean;\n /** Whether to show gas usage warnings for mock operations (default: true) */\n gasWarning?: boolean;\n };\n }\n\n interface HardhatConfig {\n cofhesdk: {\n /** Whether to log mock operations (default: true) */\n logMocks: boolean;\n /** Whether to show gas usage warnings for mock operations (default: true) */\n gasWarning: boolean;\n };\n }\n}\n\nextendConfig((config, userConfig) => {\n // Allow users to override the localcofhe network config\n if (userConfig.networks && userConfig.networks.localcofhe) {\n return;\n }\n\n // Default config\n config.networks.localcofhe = {\n gas: 'auto',\n gasMultiplier: 1.2,\n gasPrice: 'auto',\n timeout: 10_000,\n httpHeaders: {},\n url: 'http://127.0.0.1:42069',\n accounts: [\n '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',\n '0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d',\n '0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a',\n '0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6',\n ],\n };\n\n // Only add Sepolia config if user hasn't defined it\n if (!userConfig.networks?.['eth-sepolia']) {\n config.networks['eth-sepolia'] = {\n url: process.env.SEPOLIA_RPC_URL ?? 'https://ethereum-sepolia.publicnode.com',\n accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],\n chainId: 11155111,\n gas: 'auto',\n gasMultiplier: 1.2,\n gasPrice: 'auto',\n timeout: 60_000,\n httpHeaders: {},\n };\n }\n\n // Only add Arbitrum Sepolia config if user hasn't defined it\n if (!userConfig.networks?.['arb-sepolia']) {\n config.networks['arb-sepolia'] = {\n url: process.env.ARBITRUM_SEPOLIA_RPC_URL ?? 'https://sepolia-rollup.arbitrum.io/rpc',\n accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],\n chainId: 421614,\n gas: 'auto',\n gasMultiplier: 1.2,\n gasPrice: 'auto',\n timeout: 60_000,\n httpHeaders: {},\n };\n }\n\n // Add cofhe config\n config.cofhesdk = {\n logMocks: userConfig.cofhesdk?.logMocks ?? true,\n gasWarning: userConfig.cofhesdk?.gasWarning ?? true,\n };\n});\n\ntype UseFaucetArgs = {\n address?: string;\n};\n\ntask(TASK_COFHE_USE_FAUCET, 'Fund an account from the funder')\n .addOptionalParam('address', 'Address to fund', undefined, types.string)\n .setAction(async ({ address }: UseFaucetArgs, hre) => {\n const { network } = hre;\n const { name: networkName } = network;\n\n if (networkName !== 'localcofhe') {\n console.info(chalk.yellow(`Programmatic faucet only supported for localcofhe`));\n return;\n }\n\n if (!address) {\n console.info(chalk.red(`Failed to get address to fund`));\n return;\n }\n\n console.info(chalk.green(`Getting funds from faucet for ${address}`));\n\n try {\n await localcofheFundAccount(hre, address);\n } catch (e) {\n console.info(chalk.red(`failed to get funds from localcofhe for ${address}: ${e}`));\n }\n });\n\n// DEPLOY TASKS\n\ntask(TASK_COFHE_MOCKS_DEPLOY, 'Deploys the mock contracts on the Hardhat network')\n .addOptionalParam('deployTestBed', 'Whether to deploy the test bed', true, types.boolean)\n .addOptionalParam('silent', 'Whether to suppress output', false, types.boolean)\n .setAction(async ({ deployTestBed, silent }: DeployMocksArgs, hre) => {\n await deployMocks(hre, {\n deployTestBed: deployTestBed ?? true,\n gasWarning: hre.config.cofhesdk.gasWarning ?? true,\n silent: silent ?? false,\n });\n });\n\ntask(TASK_TEST, 'Deploy mock contracts on hardhat').setAction(async ({}, hre, runSuper) => {\n await deployMocks(hre, {\n deployTestBed: true,\n gasWarning: hre.config.cofhesdk.gasWarning ?? true,\n });\n return runSuper();\n});\n\ntask(TASK_NODE, 'Deploy mock contracts on hardhat').setAction(async ({}, hre, runSuper) => {\n await deployMocks(hre, {\n deployTestBed: true,\n gasWarning: hre.config.cofhesdk.gasWarning ?? true,\n });\n return runSuper();\n});\n\n// SET LOG OPS\n\ntask(TASK_COFHE_MOCKS_SET_LOG_OPS, 'Set logging for the Mock CoFHE contracts')\n .addParam('enable', 'Whether to enable logging', false, types.boolean)\n .setAction(async ({ enable }, hre) => {\n await mock_setLoggingEnabled(hre, enable);\n });\n\n// MOCK UTILS\n\nexport * from './utils.js';\nexport * from './expectResultUtils.js';\nexport * from './fund.js';\nexport * from './logging.js';\nexport * from './deploy.js';\n\n/**\n * Runtime environment extensions for the CoFHE Hardhat plugin.\n * Provides access to CoFHE initialization, environment checks, and mock utilities.\n */\ndeclare module 'hardhat/types/runtime' {\n export interface HardhatRuntimeEnvironment {\n cofhesdk: {\n /**\n * Create a CoFHE SDK configuration for use with cofhesdk.createCofhesdkClient(...)\n * @param {CofhesdkInputConfig} config - The CoFHE SDK input configuration\n * @returns {CofhesdkConfig} The CoFHE SDK configuration\n */\n createCofhesdkConfig: (config: CofhesdkInputConfig) => Promise<CofhesdkConfig>;\n /**\n * Create a CoFHE SDK client instance\n * @param {CofhesdkConfig} config - The CoFHE SDK configuration (use createCofhesdkConfig to create with Node.js defaults)\n * @returns {Promise<CofhesdkClient>} The CoFHE SDK client instance\n */\n createCofhesdkClient: (config: CofhesdkConfig) => CofhesdkClient;\n /**\n * Create viem clients from a Hardhat ethers signer, to be used with `cofhesdkClient.connect(...)`\n * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use\n * @returns {Promise<{ publicClient: PublicClient; walletClient: WalletClient }>} The viem clients\n */\n hardhatSignerAdapter: (\n signer: HardhatEthersSigner\n ) => Promise<{ publicClient: PublicClient; walletClient: WalletClient }>;\n\n /**\n * Assert that a Result type returned from a function is successful and return its value (result.success === true)\n * @param {Result<T>} result - The Result to check\n * @returns {T} The inner data of the Result (non null)\n */\n expectResultSuccess: <T>(result: Result<T> | Promise<Result<T>>) => Promise<T>;\n\n /**\n * Assert that a Result type contains an error matching the partial string (result.success === false && result.error.includes(errorPartial))\n * @param {Result<T>} result - The Result to check\n * @param {string} errorPartial - The partial error string to match\n */\n expectResultError: <T>(result: Result<T> | Promise<Result<T>>, errorPartial: string) => Promise<void>;\n\n /**\n * Assert that a Result type contains a specific value (result.success === true && result.data === value)\n * @param {Result<T>} result - The Result to check\n * @param {T} value - The inner data of the Result (non null)\n */\n expectResultValue: <T>(result: Result<T> | Promise<Result<T>>, value: T) => Promise<T>;\n\n /**\n * Assert that a Result type contains a value matching the partial object (result.success === true && result.data.includes(partial))\n * @param {Result<T>} result - The Result to check\n * @param {Partial<T>} partial - The partial object to match against\n * @returns {T} The inner data of the Result (non null)\n */\n expectResultPartialValue: <T>(result: Result<T> | Promise<Result<T>>, partial: Partial<T>) => Promise<T>;\n\n mocks: {\n /**\n * **[MOCKS ONLY]**\n *\n * Execute a block of code with cofhe mock contracts logging enabled.\n *\n * _(If logging only a function, we recommend passing the function name as the closureName (ex \"counter.increment()\"))_\n *\n * Example usage:\n *\n * ```ts\n * await hre.cofhesdk.mocks.withLogs(\"counter.increment()\", async () => {\n * await counter.increment();\n * });\n * ```\n *\n * Expected output:\n * ```\n * ┌──────────────────┬──────────────────────────────────────────────────\n * │ [COFHE-MOCKS] │ \"counter.increment()\" logs:\n * ├──────────────────┴──────────────────────────────────────────────────\n * ├ FHE.add | euint32(4473..3424)[0] + euint32(1157..3648)[1] => euint32(1106..1872)[1]\n * ├ FHE.allowThis | euint32(1106..1872)[1] -> 0x663f..6602\n * ├ FHE.allow | euint32(1106..1872)[1] -> 0x3c44..93bc\n * └─────────────────────────────────────────────────────────────────────\n * ```\n * @param {string} closureName - Name of the code block to log within\n * @param {() => Promise<void>} closure - The async function to execute\n */\n withLogs: (closureName: string, closure: () => Promise<void>) => Promise<void>;\n\n /**\n * **[MOCKS ONLY]**\n *\n * Enable logging from cofhe mock contracts\n * @param {string} closureName - Optional name of the code block to enable logging for\n */\n enableLogs: (closureName?: string) => Promise<void>;\n\n /**\n * **[MOCKS ONLY]**\n *\n * Disable logging from cofhe mock contracts\n */\n disableLogs: () => Promise<void>;\n\n /**\n * **[MOCKS ONLY]**\n *\n * Deploy the cofhe mock contracts (normally this is done automatically)\n * @param {DeployMocksArgs} options - Deployment options\n */\n deployMocks: (options: DeployMocksArgs) => Promise<void>;\n\n /**\n * **[MOCKS ONLY]**\n *\n * Get the plaintext value for a ciphertext hash\n * @param {bigint} ctHash - The ciphertext hash to look up\n * @returns {Promise<bigint>} The plaintext value\n */\n getPlaintext: (ctHash: bigint) => Promise<bigint>;\n\n /**\n * **[MOCKS ONLY]**\n *\n * Assert that a ciphertext hash represents an expected plaintext value\n * @param {bigint} ctHash - The ciphertext hash to check\n * @param {bigint} expectedValue - The expected plaintext value\n */\n expectPlaintext: (ctHash: bigint, expectedValue: bigint) => Promise<void>;\n };\n };\n }\n}\n\nextendEnvironment((hre) => {\n hre.cofhesdk = {\n createCofhesdkConfig: async (config: CofhesdkInputConfig) => {\n // Create zkv wallet client\n // This wallet interacts with the MockZkVerifier contract so that the user's connected wallet doesn't have to\n const zkvHhSigner = await hre.ethers.getImpersonatedSigner(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);\n const { walletClient: zkvWalletClient } = await HardhatSignerAdapter(zkvHhSigner);\n\n // Inject zkv wallet client into config\n const configWithZkvWalletClient = {\n ...config,\n _internal: {\n ...config._internal,\n zkvWalletClient,\n },\n };\n\n return createCofhesdkConfig(configWithZkvWalletClient);\n },\n createCofhesdkClient: (config: CofhesdkConfig) => {\n return createCofhesdkClient(config);\n },\n hardhatSignerAdapter: async (signer: HardhatEthersSigner) => {\n return HardhatSignerAdapter(signer);\n },\n expectResultSuccess: async <T>(result: Result<T> | Promise<Result<T>>) => {\n const awaitedResult = await result;\n return expectResultSuccess(awaitedResult);\n },\n expectResultError: async <T>(result: Result<T> | Promise<Result<T>>, errorPartial: string) => {\n const awaitedResult = await result;\n return expectResultError(awaitedResult, errorPartial);\n },\n expectResultValue: async <T>(result: Result<T> | Promise<Result<T>>, value: T) => {\n const awaitedResult = await result;\n return expectResultValue(awaitedResult, value);\n },\n expectResultPartialValue: async <T>(result: Result<T> | Promise<Result<T>>, partial: Partial<T>) => {\n const awaitedResult = await result;\n return expectResultPartialValue(awaitedResult, partial);\n },\n mocks: {\n withLogs: async (closureName: string, closure: () => Promise<void>) => {\n return mock_withLogs(hre, closureName, closure);\n },\n enableLogs: async (closureName?: string) => {\n return mock_setLoggingEnabled(hre, true, closureName);\n },\n disableLogs: async () => {\n return mock_setLoggingEnabled(hre, false);\n },\n deployMocks: async (options: DeployMocksArgs) => {\n return deployMocks(hre, options);\n },\n getPlaintext: async (ctHash: bigint) => {\n const [signer] = await hre.ethers.getSigners();\n return mock_getPlaintext(signer.provider, ctHash);\n },\n expectPlaintext: async (ctHash: bigint, expectedValue: bigint) => {\n const [signer] = await hre.ethers.getSigners();\n return mock_expectPlaintext(signer.provider, ctHash, expectedValue);\n },\n },\n };\n});\n","/* eslint-disable turbo/no-undeclared-env-vars */\nimport { type HardhatRuntimeEnvironment } from 'hardhat/types';\nimport '@nomicfoundation/hardhat-ethers';\n\n/**\n * Sends funds to the specified address\n * @param hre Hardhat Runtime Environment\n * @param toAddress Address to send funds to\n * @param amount Amount to send in ETH (default: 10)\n * @returns Transaction receipt or null if failed\n */\nexport async function localcofheFundAccount(hre: HardhatRuntimeEnvironment, toAddress: string, amount: string = '10') {\n // Load private key from environment\n const privateKey =\n process.env.FUNDER_PRIVATE_KEY ?? '0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659';\n if (!privateKey) {\n console.error('Error: FUNDER_PRIVATE_KEY environment variable not set');\n return null;\n }\n\n try {\n // Create wallet from private key\n const wallet = new hre.ethers.Wallet(privateKey, hre.ethers.provider);\n\n // Get wallet balance\n const balance = await hre.ethers.provider.getBalance(wallet.address);\n console.log(`Funder wallet address: ${wallet.address}`);\n console.log(`Funder wallet balance: ${hre.ethers.formatEther(balance)} ETH`);\n\n // Check if wallet has enough funds\n const amountToSend = hre.ethers.parseEther(amount);\n if (balance < amountToSend) {\n console.error(\n `Error: Funder wallet doesn't have enough funds. Current balance: ${hre.ethers.formatEther(balance)} ETH`\n );\n return null;\n }\n\n // Send transaction\n console.log(`Sending ${amount} ETH to ${toAddress}...`);\n const tx = await wallet.sendTransaction({\n to: toAddress,\n value: amountToSend,\n });\n\n console.log(`Transaction sent! Hash: ${tx.hash}`);\n console.log('Waiting for confirmation...');\n\n // Wait for transaction to be mined\n const receipt = await tx.wait();\n console.log(`Transaction confirmed in block ${receipt?.blockNumber}`);\n console.log(`Successfully sent ${amount} ETH to ${toAddress}`);\n\n return receipt;\n } catch (error) {\n console.error('Error sending funds:', error);\n return null;\n }\n}\n\n/**\n * Checks a wallet's balance and funds it if below 1 ETH\n * @param hre Hardhat Runtime Environment\n * @param walletAddress Address of the wallet to check and potentially fund\n * @returns Promise that resolves when the funding operation completes (if needed)\n */\nexport async function localcofheFundWalletIfNeeded(hre: HardhatRuntimeEnvironment, walletAddress: string) {\n // Check wallet balance and fund if needed\n const walletBalance = await hre.ethers.provider.getBalance(walletAddress);\n console.log(`Wallet balance: ${hre.ethers.formatEther(walletBalance)} ETH`);\n\n if (walletBalance < hre.ethers.parseEther('1')) {\n console.log(`Wallet balance is less than 1 ETH. Funding ${walletAddress}...`);\n const receipt = await localcofheFundAccount(hre, walletAddress);\n if (receipt) {\n const newBalance = await hre.ethers.provider.getBalance(walletAddress);\n console.log(`Wallet new balance: ${hre.ethers.formatEther(newBalance)} ETH`);\n } else {\n console.error(`Failed to fund ${walletAddress}`);\n }\n }\n}\n","export const TASK_COFHE_USE_FAUCET = 'task:cofhe:usefaucet';\nexport const TASK_COFHE_MOCKS_SET_LOG_OPS = 'task:cofhe-mocks:setlogops';\nexport const TASK_COFHE_MOCKS_DEPLOY = 'task:cofhe-mocks:deploy';\n\nexport const TASK_MANAGER_ADDRESS = '0xeA30c4B8b44078Bbf8a6ef5b9f1eC1626C7848D9';\nexport const MOCKS_ACL_ADDRESS = '0x0000000000000000000000000000000000000400';\nexport const MOCKS_ZK_VERIFIER_ADDRESS = '0x0000000000000000000000000000000000000100';\nexport const MOCKS_QUERY_DECRYPTER_ADDRESS = '0x0000000000000000000000000000000000000200';\nexport const TEST_BED_ADDRESS = '0x0000000000000000000000000000000000000300';\nexport const MOCKS_ZK_VERIFIER_SIGNER_ADDRESS = '0x6E12D8C87503D4287c294f2Fdef96ACd9DFf6bd2';\n","import { type HardhatRuntimeEnvironment } from 'hardhat/types';\nimport chalk from 'chalk';\nimport { Contract } from 'ethers';\n\nimport {\n TASK_MANAGER_ADDRESS,\n MOCKS_ZK_VERIFIER_ADDRESS,\n MOCKS_QUERY_DECRYPTER_ADDRESS,\n TEST_BED_ADDRESS,\n MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,\n MOCKS_ACL_ADDRESS,\n} from './consts.js';\n\nimport {\n MockTaskManagerArtifact,\n MockACLArtifact,\n MockZkVerifierArtifact,\n MockQueryDecrypterArtifact,\n TestBedArtifact,\n} from '@cofhe/mock-contracts';\n\n// Deploy\n\nconst deployMockTaskManager = async (hre: HardhatRuntimeEnvironment) => {\n const [signer] = await hre.ethers.getSigners();\n\n // Deploy MockTaskManager\n await hardhatSetCode(hre, TASK_MANAGER_ADDRESS, MockTaskManagerArtifact.deployedBytecode);\n const taskManager = await hre.ethers.getContractAt(MockTaskManagerArtifact.abi, TASK_MANAGER_ADDRESS);\n\n // Initialize MockTaskManager\n const initTx = await taskManager.initialize(signer.address);\n await initTx.wait();\n\n // Check if MockTaskManager exists\n const tmExists = await taskManager.exists();\n if (!tmExists) {\n throw new Error('MockTaskManager does not exist');\n }\n\n return taskManager;\n};\n\nconst deployMockACL = async (hre: HardhatRuntimeEnvironment): Promise<Contract> => {\n // Deploy MockACL\n await hardhatSetCode(hre, MOCKS_ACL_ADDRESS, MockACLArtifact.deployedBytecode);\n const acl = await hre.ethers.getContractAt(MockACLArtifact.abi, MOCKS_ACL_ADDRESS);\n\n // Check if ACL exists\n const exists = await acl.exists();\n if (!exists) {\n logError('MockACL does not exist', 2);\n throw new Error('MockACL does not exist');\n }\n\n return acl;\n};\n\nconst deployMockZkVerifier = async (hre: HardhatRuntimeEnvironment) => {\n await hardhatSetCode(hre, MOCKS_ZK_VERIFIER_ADDRESS, MockZkVerifierArtifact.deployedBytecode);\n const zkVerifier = await hre.ethers.getContractAt(MockZkVerifierArtifact.abi, MOCKS_ZK_VERIFIER_ADDRESS);\n\n const zkVerifierExists = await zkVerifier.exists();\n if (!zkVerifierExists) {\n logError('MockZkVerifier does not exist', 2);\n throw new Error('MockZkVerifier does not exist');\n }\n\n return zkVerifier;\n};\n\nconst deployMockQueryDecrypter = async (hre: HardhatRuntimeEnvironment, acl: Contract) => {\n await hardhatSetCode(hre, MOCKS_QUERY_DECRYPTER_ADDRESS, MockQueryDecrypterArtifact.deployedBytecode);\n const queryDecrypter = await hre.ethers.getContractAt(MockQueryDecrypterArtifact.abi, MOCKS_QUERY_DECRYPTER_ADDRESS);\n\n // Initialize MockQueryDecrypter\n const initTx = await queryDecrypter.initialize(TASK_MANAGER_ADDRESS, await acl.getAddress());\n await initTx.wait();\n\n // Check if MockQueryDecrypter exists\n const queryDecrypterExists = await queryDecrypter.exists();\n if (!queryDecrypterExists) {\n logError('MockQueryDecrypter does not exist', 2);\n throw new Error('MockQueryDecrypter does not exist');\n }\n\n return queryDecrypter;\n};\n\nconst deployTestBedContract = async (hre: HardhatRuntimeEnvironment) => {\n await hardhatSetCode(hre, TEST_BED_ADDRESS, TestBedArtifact.deployedBytecode);\n const testBed = await hre.ethers.getContractAt(TestBedArtifact.abi, TEST_BED_ADDRESS);\n await testBed.waitForDeployment();\n return testBed;\n};\n\n// Funding\n\nconst fundZkVerifierSigner = async (hre: HardhatRuntimeEnvironment) => {\n const zkVerifierSigner = await hre.ethers.getSigner(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);\n await hre.network.provider.send('hardhat_setBalance', [\n zkVerifierSigner.address,\n '0x' + hre.ethers.parseEther('10').toString(16),\n ]);\n};\n\n// Initializations\n\nconst setTaskManagerACL = async (taskManager: Contract, acl: Contract) => {\n const setAclTx = await taskManager.setACLContract(await acl.getAddress());\n await setAclTx.wait();\n};\n\nexport type DeployMocksArgs = {\n deployTestBed?: boolean;\n gasWarning?: boolean;\n silent?: boolean;\n};\n\nexport const deployMocks = async (\n hre: HardhatRuntimeEnvironment,\n options: DeployMocksArgs = {\n deployTestBed: true,\n gasWarning: true,\n silent: false,\n }\n) => {\n // Check if network is Hardhat, if not log skip message and return\n const isHardhat = await checkNetworkAndSkip(hre);\n if (!isHardhat) return;\n\n const logEmptyIfNoisy = () => {\n if (!options.silent) {\n logEmpty();\n }\n };\n const logSuccessIfNoisy = (message: string, indent = 0) => {\n if (!options.silent) {\n logSuccess(message, indent);\n }\n };\n const logDeploymentIfNoisy = (contractName: string, address: string) => {\n if (!options.silent) {\n logDeployment(contractName, address);\n }\n };\n const logWarningIfNoisy = (message: string, indent = 0) => {\n if (!options.silent) {\n logWarning(message, indent);\n }\n };\n\n // Log start message\n logEmptyIfNoisy();\n logSuccessIfNoisy(chalk.bold('cofhe-hardhat-plugin :: deploy mocks'), 0);\n logEmptyIfNoisy();\n\n // Compile mock contracts\n logEmptyIfNoisy();\n logSuccessIfNoisy('Mock contracts compiled', 1);\n\n // Deploy mock contracts\n const taskManager = await deployMockTaskManager(hre);\n logDeploymentIfNoisy('MockTaskManager', await taskManager.getAddress());\n\n const acl = await deployMockACL(hre);\n logDeploymentIfNoisy('MockACL', await acl.getAddress());\n\n await setTaskManagerACL(taskManager, acl);\n logSuccessIfNoisy('ACL address set in TaskManager', 2);\n\n await fundZkVerifierSigner(hre);\n logSuccessIfNoisy(`ZkVerifier signer (${MOCKS_ZK_VERIFIER_SIGNER_ADDRESS}) funded`, 1);\n\n const zkVerifierSignerBalance = await hre.ethers.provider.getBalance(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);\n logSuccessIfNoisy(`ETH balance: ${zkVerifierSignerBalance.toString()}`, 2);\n\n const zkVerifier = await deployMockZkVerifier(hre);\n logDeploymentIfNoisy('MockZkVerifier', await zkVerifier.getAddress());\n\n const queryDecrypter = await deployMockQueryDecrypter(hre, acl);\n logDeploymentIfNoisy('MockQueryDecrypter', await queryDecrypter.getAddress());\n\n if (options.deployTestBed) {\n logSuccessIfNoisy('TestBed deployment enabled', 2);\n const testBed = await deployTestBedContract(hre);\n logDeploymentIfNoisy('TestBed', await testBed.getAddress());\n }\n\n // Log success message\n logEmptyIfNoisy();\n logSuccessIfNoisy(chalk.bold('cofhe-hardhat-plugin :: mocks deployed successfully'), 0);\n\n // Log warning about mocks increased gas costs\n if (options.gasWarning) {\n logEmptyIfNoisy();\n logWarningIfNoisy(\n \"When using mocks, FHE operations (eg FHE.add / FHE.mul) report a higher gas price due to additional on-chain mocking logic. Deploy your contracts on a testnet chain to check the true gas costs.\\n(Disable this warning by setting '@cofhe/sdk.gasWarning' to false in your hardhat config\",\n 0\n );\n }\n\n logEmptyIfNoisy();\n};\n\n// Utils\n\nconst hardhatSetCode = async (hre: HardhatRuntimeEnvironment, address: string, bytecode: string) => {\n await hre.network.provider.send('hardhat_setCode', [address, bytecode]);\n};\n\n// Network\n\nconst checkNetworkAndSkip = async (hre: HardhatRuntimeEnvironment) => {\n const network = hre.network.name;\n const isHardhat = network === 'hardhat';\n if (!isHardhat) logSuccess(`cofhe-hardhat-plugin - deploy mocks - skipped on non-hardhat network ${network}`, 0);\n return isHardhat;\n};\n\n// Logging\n\nconst logEmpty = () => {\n console.log('');\n};\n\nconst logSuccess = (message: string, indent = 1) => {\n console.log(chalk.green(`${' '.repeat(indent)}✓ ${message}`));\n};\n\nconst logWarning = (message: string, indent = 1) => {\n console.log(chalk.bold(chalk.yellow(`${' '.repeat(indent)}⚠ NOTE:`)), message);\n};\n\nconst logError = (message: string, indent = 1) => {\n console.log(chalk.red(`${' '.repeat(indent)}✗ ${message}`));\n};\n\nconst logDeployment = (contractName: string, address: string) => {\n const paddedName = `${contractName} deployed`.padEnd(36);\n logSuccess(`${paddedName} ${chalk.bold(address)}`);\n};\n","import chalk from 'chalk';\nimport { type HardhatRuntimeEnvironment } from 'hardhat/types';\nimport { TASK_MANAGER_ADDRESS } from './consts';\nimport { MockTaskManagerArtifact } from '@cofhe/mock-contracts';\n\nconst getDeployedMockTaskManager = async (hre: HardhatRuntimeEnvironment) => {\n // Fetch the deployed MockTaskManager\n const taskManager = await hre.ethers.getContractAt(MockTaskManagerArtifact.abi, TASK_MANAGER_ADDRESS);\n\n return taskManager;\n};\n\nconst getLoggingEnabled = async (hre: HardhatRuntimeEnvironment) => {\n const taskManager = await getDeployedMockTaskManager(hre);\n return await taskManager.logOps();\n};\n\nconst setLoggingEnabled = async (hre: HardhatRuntimeEnvironment, enabled: boolean) => {\n const taskManager = await getDeployedMockTaskManager(hre);\n await taskManager.setLogOps(enabled);\n};\n\n// prettier-ignore\nconst printLogsEnabledMessage = (closureMessage: string) => {\n console.log(\"┌──────────────────┬──────────────────────────────────────────────────\");\n console.log(`│ [COFHE-MOCKS] │ ${closureMessage}`);\n console.log(\"├──────────────────┴──────────────────────────────────────────────────\");\n};\n\n// prettier-ignore\nconst printLogsBlockEnd = () => {\n console.log(\"└─────────────────────────────────────────────────────────────────────\");\n};\n\nexport const mock_setLoggingEnabled = async (\n hre: HardhatRuntimeEnvironment,\n enabled: boolean,\n closureName?: string\n) => {\n try {\n const initiallyEnabled = await getLoggingEnabled(hre);\n\n await setLoggingEnabled(hre, enabled);\n\n // Only print if enabling logs\n if (enabled) {\n printLogsEnabledMessage(`${closureName ? `\"${chalk.bold(closureName)}\" logs:` : 'Logs:'}`);\n }\n\n // Only print if disabling logs AND logs currently enabled\n if (!enabled && initiallyEnabled) {\n printLogsBlockEnd();\n }\n } catch (error) {\n console.log(chalk.red('mock_setLoggingEnabled error'), error);\n }\n};\n\nexport const mock_withLogs = async (\n hre: HardhatRuntimeEnvironment,\n closureName: string,\n closure: () => Promise<void>\n) => {\n const initiallyEnabled = await getLoggingEnabled(hre);\n\n await setLoggingEnabled(hre, true);\n printLogsEnabledMessage(`\"${chalk.bold(closureName)}\" logs:`);\n await closure();\n printLogsBlockEnd();\n\n // If logs were disabled, disable them again\n if (!initiallyEnabled) {\n await setLoggingEnabled(hre, false);\n }\n};\n","import { TASK_MANAGER_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS } from './consts.js';\nimport { expect } from 'chai';\nimport { ethers } from 'ethers';\nimport { type HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';\n\nconst mock_checkIsTestnet = async (fnName: string, provider: HardhatEthersProvider | ethers.JsonRpcProvider) => {\n // Testnet is checked by testing if MockZkVerifier is deployed\n\n // Get bytecode at ZK_VERIFIER_ADDRESS\n const bytecode = await provider.getCode(MOCKS_ZK_VERIFIER_ADDRESS);\n\n // If bytecode is empty, we are on a testnet\n const isTestnet = bytecode.length === 0;\n\n // Log if we are on a testnet\n if (isTestnet) {\n console.log(`${fnName} - skipped on non-testnet chain`);\n }\n\n return isTestnet;\n};\n\nexport const mock_getPlaintext = async (provider: HardhatEthersProvider | ethers.JsonRpcProvider, ctHash: bigint) => {\n // Skip with log if called on a non-testnet chain\n if (await mock_checkIsTestnet(mock_getPlaintext.name, provider)) return;\n\n // Connect to MockTaskManager\n const taskManager = new ethers.Contract(\n TASK_MANAGER_ADDRESS,\n ['function mockStorage(uint256) view returns (uint256)'],\n provider\n );\n\n // Fetch the plaintext\n const plaintext = await taskManager.mockStorage(ctHash);\n\n return plaintext;\n};\n\nexport const mock_getPlaintextExists = async (\n provider: HardhatEthersProvider | ethers.JsonRpcProvider,\n ctHash: bigint\n) => {\n // Skip with log if called on a non-testnet chain\n if (await mock_checkIsTestnet(mock_getPlaintextExists.name, provider)) return;\n\n // Connect to MockTaskManager\n const taskManager = new ethers.Contract(\n TASK_MANAGER_ADDRESS,\n ['function inMockStorage(uint256) view returns (bool)'],\n provider\n );\n\n // Fetch the plaintext exists\n const plaintextExists = await taskManager.inMockStorage(ctHash);\n\n return plaintextExists;\n};\n\nexport const mock_expectPlaintext = async (\n provider: HardhatEthersProvider | ethers.JsonRpcProvider,\n ctHash: bigint,\n expectedValue: bigint\n) => {\n // Skip with log if called on a non-testnet chain\n if (await mock_checkIsTestnet(mock_expectPlaintext.name, provider)) return;\n\n // Expect the plaintext to exist\n const plaintextExists = await mock_getPlaintextExists(provider, ctHash);\n expect(plaintextExists).equal(true, 'Plaintext does not exist');\n\n // Expect the plaintext to have the expected value\n const plaintext = await mock_getPlaintext(provider, ctHash);\n expect(plaintext).equal(expectedValue, 'Plaintext value is incorrect');\n};\n","import { type Result } from '@cofhe/sdk';\nimport { expect } from 'chai';\n\nexport const expectResultError = <T>(result: Result<T>, errorPartial: string) => {\n expect(result.success).to.eq(false, 'Result should be an error');\n expect(result.error).to.include(errorPartial, `Error should contain error partial: ${errorPartial}`);\n};\n\nexport const expectResultSuccess = <T>(result: Result<T>): T => {\n expect(result.success).to.eq(true, 'Result should be a success');\n return result.data!;\n};\n\nexport const expectResultValue = <T>(result: Result<T>, value: T): T => {\n expect(result.success).to.eq(true, 'Result should be a success');\n expect(result.data).to.eq(value, `Result should have the expected value ${value}`);\n return result.data!;\n};\n\nexport const expectResultPartialValue = <T>(result: Result<T>, partial: Partial<T>): T => {\n expect(result.success).to.eq(true, 'Result should be a success');\n expect(result.data).to.include(partial, `Result should have the expected partial ${partial}`);\n return result.data!;\n};\n"],"mappings":";AAGA,OAAOA,YAAW;AAClB,OAAqD;AACrD,SAAS,cAAc,mBAAmB,MAAM,aAAa;AAC7D,SAAS,WAAW,iBAAiB;AACrC,OAAoC;AACpC,OAAgG;AAChG,SAAS,sBAAsB,4BAA4B;AAC3D,SAAS,4BAA4B;;;AC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UAAU,MAAM;AAAA,MAClD;AAAA,MACA,iBAAiB,OAAO,QAAgB,kBAA0B;AAChE,cAAM,CAAC,MAAM,IAAI,MAAM,IAAI,OAAO,WAAW;AAC7C,eAAO,qBAAqB,OAAO,UAAU,QAAQ,aAAa;AAAA,MACpE;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["chalk","chalk","MockTaskManagerArtifact","chalk","expect","MockACLArtifact","MockQueryDecrypterArtifact","MockTaskManagerArtifact","MockZkVerifierArtifact","TestBedArtifact","chalk"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/fund.ts","../src/consts.ts","../src/deploy.ts","../src/logging.ts","../src/utils.ts"],"sourcesContent":["/* eslint-disable no-empty-pattern */\n/* eslint-disable turbo/no-undeclared-env-vars */\nimport chalk from 'chalk';\nimport { type PublicClient, type WalletClient } from 'viem';\nimport { extendConfig, extendEnvironment, task, types } from 'hardhat/config';\nimport { TASK_TEST, TASK_NODE } from 'hardhat/builtin-tasks/task-names';\nimport { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';\nimport {\n MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,\n type CofhesdkClient,\n type CofhesdkConfig,\n type CofhesdkInputConfig,\n} from '@cofhe/sdk';\nimport { createCofhesdkClient, createCofhesdkConfig } from '@cofhe/sdk/node';\nimport { HardhatSignerAdapter } from '@cofhe/sdk/adapters';\n\nimport { localcofheFundAccount } from './fund.js';\nimport { TASK_COFHE_MOCKS_DEPLOY, TASK_COFHE_MOCKS_SET_LOG_OPS, TASK_COFHE_USE_FAUCET } from './consts.js';\nimport { deployMocks, type DeployMocksArgs } from './deploy.js';\nimport { mock_setLoggingEnabled, mock_withLogs } from './logging.js';\nimport { mock_expectPlaintext } from './utils.js';\nimport { mock_getPlaintext } from './utils.js';\nimport type { Contract } from 'ethers';\nimport {\n MockACLArtifact,\n MockQueryDecrypterArtifact,\n MockTaskManagerArtifact,\n MockZkVerifierArtifact,\n TestBedArtifact,\n} from '@cofhe/mock-contracts';\nimport { hardhat } from '@cofhe/sdk/chains';\nexport {\n MockACLArtifact,\n MockQueryDecrypterArtifact,\n MockTaskManagerArtifact,\n MockZkVerifierArtifact,\n TestBedArtifact,\n} from '@cofhe/mock-contracts';\n\n/**\n * Configuration interface for the CoFHE Hardhat plugin.\n * Allows users to configure mock logging and gas warning settings.\n */\ndeclare module 'hardhat/types/config' {\n interface HardhatUserConfig {\n cofhesdk?: {\n /** Whether to log mock operations (default: true) */\n logMocks?: boolean;\n /** Whether to show gas usage warnings for mock operations (default: true) */\n gasWarning?: boolean;\n };\n }\n\n interface HardhatConfig {\n cofhesdk: {\n /** Whether to log mock operations (default: true) */\n logMocks: boolean;\n /** Whether to show gas usage warnings for mock operations (default: true) */\n gasWarning: boolean;\n };\n }\n}\n\nextendConfig((config, userConfig) => {\n // Allow users to override the localcofhe network config\n if (userConfig.networks && userConfig.networks.localcofhe) {\n return;\n }\n\n // Default config\n config.networks.localcofhe = {\n gas: 'auto',\n gasMultiplier: 1.2,\n gasPrice: 'auto',\n timeout: 10_000,\n httpHeaders: {},\n url: 'http://127.0.0.1:42069',\n accounts: [\n '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',\n '0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d',\n '0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a',\n '0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6',\n ],\n };\n\n // Only add Sepolia config if user hasn't defined it\n if (!userConfig.networks?.['eth-sepolia']) {\n config.networks['eth-sepolia'] = {\n url: process.env.SEPOLIA_RPC_URL ?? 'https://ethereum-sepolia.publicnode.com',\n accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],\n chainId: 11155111,\n gas: 'auto',\n gasMultiplier: 1.2,\n gasPrice: 'auto',\n timeout: 60_000,\n httpHeaders: {},\n };\n }\n\n // Only add Arbitrum Sepolia config if user hasn't defined it\n if (!userConfig.networks?.['arb-sepolia']) {\n config.networks['arb-sepolia'] = {\n url: process.env.ARBITRUM_SEPOLIA_RPC_URL ?? 'https://sepolia-rollup.arbitrum.io/rpc',\n accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],\n chainId: 421614,\n gas: 'auto',\n gasMultiplier: 1.2,\n gasPrice: 'auto',\n timeout: 60_000,\n httpHeaders: {},\n };\n }\n\n // Add cofhe config\n config.cofhesdk = {\n logMocks: userConfig.cofhesdk?.logMocks ?? true,\n gasWarning: userConfig.cofhesdk?.gasWarning ?? true,\n };\n});\n\ntype UseFaucetArgs = {\n address?: string;\n};\n\ntask(TASK_COFHE_USE_FAUCET, 'Fund an account from the funder')\n .addOptionalParam('address', 'Address to fund', undefined, types.string)\n .setAction(async ({ address }: UseFaucetArgs, hre) => {\n const { network } = hre;\n const { name: networkName } = network;\n\n if (networkName !== 'localcofhe') {\n console.info(chalk.yellow(`Programmatic faucet only supported for localcofhe`));\n return;\n }\n\n if (!address) {\n console.info(chalk.red(`Failed to get address to fund`));\n return;\n }\n\n console.info(chalk.green(`Getting funds from faucet for ${address}`));\n\n try {\n await localcofheFundAccount(hre, address);\n } catch (e) {\n console.info(chalk.red(`failed to get funds from localcofhe for ${address}: ${e}`));\n }\n });\n\n// DEPLOY TASKS\n\ntask(TASK_COFHE_MOCKS_DEPLOY, 'Deploys the mock contracts on the Hardhat network')\n .addOptionalParam('deployTestBed', 'Whether to deploy the test bed', true, types.boolean)\n .addOptionalParam('silent', 'Whether to suppress output', false, types.boolean)\n .setAction(async ({ deployTestBed, silent }: DeployMocksArgs, hre) => {\n await deployMocks(hre, {\n deployTestBed: deployTestBed ?? true,\n gasWarning: hre.config.cofhesdk.gasWarning ?? true,\n silent: silent ?? false,\n });\n });\n\ntask(TASK_TEST, 'Deploy mock contracts on hardhat').setAction(async ({}, hre, runSuper) => {\n await deployMocks(hre, {\n deployTestBed: true,\n gasWarning: hre.config.cofhesdk.gasWarning ?? true,\n });\n return runSuper();\n});\n\ntask(TASK_NODE, 'Deploy mock contracts on hardhat').setAction(async ({}, hre, runSuper) => {\n await deployMocks(hre, {\n deployTestBed: true,\n gasWarning: hre.config.cofhesdk.gasWarning ?? true,\n });\n return runSuper();\n});\n\n// SET LOG OPS\n\ntask(TASK_COFHE_MOCKS_SET_LOG_OPS, 'Set logging for the Mock CoFHE contracts')\n .addParam('enable', 'Whether to enable logging', false, types.boolean)\n .setAction(async ({ enable }, hre) => {\n await mock_setLoggingEnabled(hre, enable);\n });\n\n// MOCK UTILS\n\nexport * from './utils.js';\nexport * from './fund.js';\nexport * from './logging.js';\nexport * from './deploy.js';\n\n/**\n * Runtime environment extensions for the CoFHE Hardhat plugin.\n * Provides access to CoFHE initialization, environment checks, and mock utilities.\n */\ndeclare module 'hardhat/types/runtime' {\n export interface HardhatRuntimeEnvironment {\n cofhesdk: {\n /**\n * Create a CoFHE SDK configuration for use with cofhesdk.createCofhesdkClient(...)\n * @param {CofhesdkInputConfig} config - The CoFHE SDK input configuration\n * @returns {CofhesdkConfig} The CoFHE SDK configuration\n */\n createCofhesdkConfig: (config: CofhesdkInputConfig) => Promise<CofhesdkConfig>;\n /**\n * Create a CoFHE SDK client instance\n * @param {CofhesdkConfig} config - The CoFHE SDK configuration (use createCofhesdkConfig to create with Node.js defaults)\n * @returns {Promise<CofhesdkClient>} The CoFHE SDK client instance\n */\n createCofhesdkClient: (config: CofhesdkConfig) => CofhesdkClient;\n /**\n * Create viem clients from a Hardhat ethers signer, to be used with `cofhesdkClient.connect(...)`\n * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use\n * @returns {Promise<{ publicClient: PublicClient; walletClient: WalletClient }>} The viem clients\n */\n hardhatSignerAdapter: (\n signer: HardhatEthersSigner\n ) => Promise<{ publicClient: PublicClient; walletClient: WalletClient }>;\n /**\n * Connect a CoFHE SDK client with a Hardhat ethers signer\n * @param {CofhesdkClient} client - The CoFHE SDK client to connect\n * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use\n * @returns {Promise<void>}\n */\n connectWithHardhatSigner: (client: CofhesdkClient, signer: HardhatEthersSigner) => Promise<void>;\n /**\n * Create and connect to a batteries included client.\n * Also generates a self-usage a permit for the signer.\n * If customization is needed, use createCofhesdkClient and connectWithHardhatSigner.\n * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use (optional - defaults to first signer)\n * @returns {Promise<CofhesdkClient>} The CoFHE SDK client instance\n */\n createBatteriesIncludedCofhesdkClient: (signer?: HardhatEthersSigner) => Promise<CofhesdkClient>;\n\n mocks: {\n /**\n * **[MOCKS ONLY]**\n *\n * Execute a block of code with cofhe mock contracts logging enabled.\n *\n * _(If logging only a function, we recommend passing the function name as the closureName (ex \"counter.increment()\"))_\n *\n * Example usage:\n *\n * ```ts\n * await hre.cofhesdk.mocks.withLogs(\"counter.increment()\", async () => {\n * await counter.increment();\n * });\n * ```\n *\n * Expected output:\n * ```\n * ┌──────────────────┬──────────────────────────────────────────────────\n * │ [COFHE-MOCKS] │ \"counter.increment()\" logs:\n * ├──────────────────┴──────────────────────────────────────────────────\n * ├ FHE.add | euint32(4473..3424)[0] + euint32(1157..3648)[1] => euint32(1106..1872)[1]\n * ├ FHE.allowThis | euint32(1106..1872)[1] -> 0x663f..6602\n * ├ FHE.allow | euint32(1106..1872)[1] -> 0x3c44..93bc\n * └─────────────────────────────────────────────────────────────────────\n * ```\n * @param {string} closureName - Name of the code block to log within\n * @param {() => Promise<void>} closure - The async function to execute\n */\n withLogs: (closureName: string, closure: () => Promise<void>) => Promise<void>;\n\n /**\n * **[MOCKS ONLY]**\n *\n * Enable logging from cofhe mock contracts\n * @param {string} closureName - Optional name of the code block to enable logging for\n */\n enableLogs: (closureName?: string) => Promise<void>;\n\n /**\n * **[MOCKS ONLY]**\n *\n * Disable logging from cofhe mock contracts\n */\n disableLogs: () => Promise<void>;\n\n /**\n * **[MOCKS ONLY]**\n *\n * Deploy the cofhe mock contracts (normally this is done automatically)\n * @param {DeployMocksArgs} options - Deployment options\n */\n deployMocks: (options: DeployMocksArgs) => Promise<void>;\n\n /**\n * **[MOCKS ONLY]**\n *\n * Get the plaintext value for a ciphertext hash\n * @param {bigint} ctHash - The ciphertext hash to look up\n * @returns {Promise<bigint>} The plaintext value\n */\n getPlaintext: (ctHash: bigint) => Promise<bigint>;\n\n /**\n * **[MOCKS ONLY]**\n *\n * Assert that a ciphertext hash represents an expected plaintext value\n * @param {bigint} ctHash - The ciphertext hash to check\n * @param {bigint} expectedValue - The expected plaintext value\n */\n expectPlaintext: (ctHash: bigint, expectedValue: bigint) => Promise<void>;\n\n /**\n * Get the MockTaskManager contract\n * @returns {Promise<Contract>} The MockTaskManager contract\n */\n getMockTaskManager: () => Promise<Contract>;\n\n /**\n * Get the MockACL contract\n * @returns {Promise<Contract>} The MockACL contract\n */\n getMockACL: () => Promise<Contract>;\n\n /**\n * Get the MockQueryDecrypter contract\n * @returns {Promise<Contract>} The MockQueryDecrypter contract\n */\n getMockQueryDecrypter: () => Promise<Contract>;\n\n /**\n * Get the MockZkVerifier contract\n * @returns {Promise<Contract>} The MockZkVerifier contract\n */\n getMockZkVerifier: () => Promise<Contract>;\n\n /**\n * Get the TestBed contract\n * @returns {Promise<Contract>} The TestBed contract\n */\n getTestBed: () => Promise<Contract>;\n };\n };\n }\n}\n\nextendEnvironment((hre) => {\n hre.cofhesdk = {\n createCofhesdkConfig: async (config: CofhesdkInputConfig) => {\n // Create zkv wallet client\n // This wallet interacts with the MockZkVerifier contract so that the user's connected wallet doesn't have to\n const zkvHhSigner = await hre.ethers.getImpersonatedSigner(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);\n const { walletClient: zkvWalletClient } = await HardhatSignerAdapter(zkvHhSigner);\n\n // Inject zkv wallet client into config\n const configWithZkvWalletClient = {\n environment: 'hardhat' as const,\n ...config,\n _internal: {\n ...config._internal,\n zkvWalletClient,\n },\n };\n\n return createCofhesdkConfig(configWithZkvWalletClient);\n },\n createCofhesdkClient: (config: CofhesdkConfig) => {\n return createCofhesdkClient(config);\n },\n hardhatSignerAdapter: async (signer: HardhatEthersSigner) => {\n return HardhatSignerAdapter(signer);\n },\n connectWithHardhatSigner: async (client: CofhesdkClient, signer: HardhatEthersSigner) => {\n const { publicClient, walletClient } = await HardhatSignerAdapter(signer);\n return client.connect(publicClient, walletClient);\n },\n createBatteriesIncludedCofhesdkClient: async (signer?: HardhatEthersSigner) => {\n // Get signer if not provided\n if (!signer) {\n [signer] = await hre.ethers.getSigners();\n }\n\n // Create config\n const config = await hre.cofhesdk.createCofhesdkConfig({\n environment: 'hardhat',\n supportedChains: [hardhat],\n });\n\n // Create client\n const client = hre.cofhesdk.createCofhesdkClient(config);\n\n // Connect client\n await hre.cofhesdk.connectWithHardhatSigner(client, signer);\n\n // Create self-usage permit\n await client.permits.createSelf({\n issuer: signer.address,\n });\n\n // Return client\n return client;\n },\n mocks: {\n withLogs: async (closureName: string, closure: () => Promise<void>) => {\n return mock_withLogs(hre, closureName, closure);\n },\n enableLogs: async (closureName?: string) => {\n return mock_setLoggingEnabled(hre, true, closureName);\n },\n disableLogs: async () => {\n return mock_setLoggingEnabled(hre, false);\n },\n deployMocks: async (options: DeployMocksArgs) => {\n return deployMocks(hre, options);\n },\n getPlaintext: async (ctHash: bigint) => {\n const [signer] = await hre.ethers.getSigners();\n return mock_getPlaintext(signer.provider, ctHash);\n },\n expectPlaintext: async (ctHash: bigint, expectedValue: bigint) => {\n const [signer] = await hre.ethers.getSigners();\n return mock_expectPlaintext(signer.provider, ctHash, expectedValue);\n },\n getMockTaskManager: async () => {\n return await hre.ethers.getContractAt(MockTaskManagerArtifact.abi, MockTaskManagerArtifact.fixedAddress);\n },\n getMockACL: async () => {\n const tm = await hre.ethers.getContractAt(MockTaskManagerArtifact.abi, MockTaskManagerArtifact.fixedAddress);\n const aclAddress = await tm.acl();\n return await hre.ethers.getContractAt(MockACLArtifact.abi, aclAddress);\n },\n getMockQueryDecrypter: async () => {\n return await hre.ethers.getContractAt(MockQueryDecrypterArtifact.abi, MockQueryDecrypterArtifact.fixedAddress);\n },\n getMockZkVerifier: async () => {\n return await hre.ethers.getContractAt(MockZkVerifierArtifact.abi, MockZkVerifierArtifact.fixedAddress);\n },\n getTestBed: async () => {\n return await hre.ethers.getContractAt(TestBedArtifact.abi, TestBedArtifact.fixedAddress);\n },\n },\n };\n});\n","/* eslint-disable turbo/no-undeclared-env-vars */\nimport { type HardhatRuntimeEnvironment } from 'hardhat/types';\nimport '@nomicfoundation/hardhat-ethers';\n\n/**\n * Sends funds to the specified address\n * @param hre Hardhat Runtime Environment\n * @param toAddress Address to send funds to\n * @param amount Amount to send in ETH (default: 10)\n * @returns Transaction receipt or null if failed\n */\nexport async function localcofheFundAccount(hre: HardhatRuntimeEnvironment, toAddress: string, amount: string = '10') {\n // Load private key from environment\n const privateKey =\n process.env.FUNDER_PRIVATE_KEY ?? '0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659';\n if (!privateKey) {\n console.error('Error: FUNDER_PRIVATE_KEY environment variable not set');\n return null;\n }\n\n try {\n // Create wallet from private key\n const wallet = new hre.ethers.Wallet(privateKey, hre.ethers.provider);\n\n // Get wallet balance\n const balance = await hre.ethers.provider.getBalance(wallet.address);\n console.log(`Funder wallet address: ${wallet.address}`);\n console.log(`Funder wallet balance: ${hre.ethers.formatEther(balance)} ETH`);\n\n // Check if wallet has enough funds\n const amountToSend = hre.ethers.parseEther(amount);\n if (balance < amountToSend) {\n console.error(\n `Error: Funder wallet doesn't have enough funds. Current balance: ${hre.ethers.formatEther(balance)} ETH`\n );\n return null;\n }\n\n // Send transaction\n console.log(`Sending ${amount} ETH to ${toAddress}...`);\n const tx = await wallet.sendTransaction({\n to: toAddress,\n value: amountToSend,\n });\n\n console.log(`Transaction sent! Hash: ${tx.hash}`);\n console.log('Waiting for confirmation...');\n\n // Wait for transaction to be mined\n const receipt = await tx.wait();\n console.log(`Transaction confirmed in block ${receipt?.blockNumber}`);\n console.log(`Successfully sent ${amount} ETH to ${toAddress}`);\n\n return receipt;\n } catch (error) {\n console.error('Error sending funds:', error);\n return null;\n }\n}\n\n/**\n * Checks a wallet's balance and funds it if below 1 ETH\n * @param hre Hardhat Runtime Environment\n * @param walletAddress Address of the wallet to check and potentially fund\n * @returns Promise that resolves when the funding operation completes (if needed)\n */\nexport async function localcofheFundWalletIfNeeded(hre: HardhatRuntimeEnvironment, walletAddress: string) {\n // Check wallet balance and fund if needed\n const walletBalance = await hre.ethers.provider.getBalance(walletAddress);\n console.log(`Wallet balance: ${hre.ethers.formatEther(walletBalance)} ETH`);\n\n if (walletBalance < hre.ethers.parseEther('1')) {\n console.log(`Wallet balance is less than 1 ETH. Funding ${walletAddress}...`);\n const receipt = await localcofheFundAccount(hre, walletAddress);\n if (receipt) {\n const newBalance = await hre.ethers.provider.getBalance(walletAddress);\n console.log(`Wallet new balance: ${hre.ethers.formatEther(newBalance)} ETH`);\n } else {\n console.error(`Failed to fund ${walletAddress}`);\n }\n }\n}\n","export const TASK_COFHE_USE_FAUCET = 'task:cofhe:usefaucet';\nexport const TASK_COFHE_MOCKS_SET_LOG_OPS = 'task:cofhe-mocks:setlogops';\nexport const TASK_COFHE_MOCKS_DEPLOY = 'task:cofhe-mocks:deploy';\n\nexport const TASK_MANAGER_ADDRESS = '0xeA30c4B8b44078Bbf8a6ef5b9f1eC1626C7848D9';\nexport const MOCKS_ZK_VERIFIER_ADDRESS = '0x0000000000000000000000000000000000000100';\nexport const MOCKS_QUERY_DECRYPTER_ADDRESS = '0x0000000000000000000000000000000000000200';\nexport const TEST_BED_ADDRESS = '0x0000000000000000000000000000000000000300';\n","import { type HardhatRuntimeEnvironment } from 'hardhat/types';\nimport chalk from 'chalk';\nimport { Contract } from 'ethers';\n\nimport {\n TASK_MANAGER_ADDRESS,\n MOCKS_ZK_VERIFIER_ADDRESS,\n MOCKS_QUERY_DECRYPTER_ADDRESS,\n TEST_BED_ADDRESS,\n} from './consts.js';\n\nimport {\n MockTaskManagerArtifact,\n MockACLArtifact,\n MockZkVerifierArtifact,\n MockQueryDecrypterArtifact,\n TestBedArtifact,\n} from '@cofhe/mock-contracts';\nimport { MOCKS_ZK_VERIFIER_SIGNER_ADDRESS } from '@cofhe/sdk';\n\n// Deploy\n\nconst deployMockTaskManager = async (hre: HardhatRuntimeEnvironment) => {\n const [signer] = await hre.ethers.getSigners();\n\n // Deploy MockTaskManager\n await hardhatSetCode(hre, TASK_MANAGER_ADDRESS, MockTaskManagerArtifact.deployedBytecode);\n const taskManager = await hre.ethers.getContractAt(MockTaskManagerArtifact.abi, TASK_MANAGER_ADDRESS);\n\n // Initialize MockTaskManager\n const initTx = await taskManager.initialize(signer.address);\n await initTx.wait();\n\n // Check if MockTaskManager exists\n const tmExists = await taskManager.exists();\n if (!tmExists) {\n throw new Error('MockTaskManager does not exist');\n }\n\n return taskManager;\n};\n\nconst deployMockACL = async (hre: HardhatRuntimeEnvironment): Promise<Contract> => {\n // Deploy MockACL (uses ethers to deploy to ensure constructor called and EIP712 domain set)\n const acl = await ethersDeployContract(hre, MockACLArtifact.abi, MockACLArtifact.bytecode);\n\n // Check if ACL exists\n const exists = await acl.exists();\n if (!exists) {\n logError('MockACL does not exist', 2);\n throw new Error('MockACL does not exist');\n }\n\n return acl;\n};\n\nconst deployMockZkVerifier = async (hre: HardhatRuntimeEnvironment) => {\n await hardhatSetCode(hre, MOCKS_ZK_VERIFIER_ADDRESS, MockZkVerifierArtifact.deployedBytecode);\n const zkVerifier = await hre.ethers.getContractAt(MockZkVerifierArtifact.abi, MOCKS_ZK_VERIFIER_ADDRESS);\n\n const zkVerifierExists = await zkVerifier.exists();\n if (!zkVerifierExists) {\n logError('MockZkVerifier does not exist', 2);\n throw new Error('MockZkVerifier does not exist');\n }\n\n return zkVerifier;\n};\n\nconst deployMockQueryDecrypter = async (hre: HardhatRuntimeEnvironment, acl: Contract) => {\n await hardhatSetCode(hre, MOCKS_QUERY_DECRYPTER_ADDRESS, MockQueryDecrypterArtifact.deployedBytecode);\n const queryDecrypter = await hre.ethers.getContractAt(MockQueryDecrypterArtifact.abi, MOCKS_QUERY_DECRYPTER_ADDRESS);\n\n // Initialize MockQueryDecrypter\n const initTx = await queryDecrypter.initialize(TASK_MANAGER_ADDRESS, await acl.getAddress());\n await initTx.wait();\n\n // Check if MockQueryDecrypter exists\n const queryDecrypterExists = await queryDecrypter.exists();\n if (!queryDecrypterExists) {\n logError('MockQueryDecrypter does not exist', 2);\n throw new Error('MockQueryDecrypter does not exist');\n }\n\n return queryDecrypter;\n};\n\nconst deployTestBedContract = async (hre: HardhatRuntimeEnvironment) => {\n await hardhatSetCode(hre, TEST_BED_ADDRESS, TestBedArtifact.deployedBytecode);\n const testBed = await hre.ethers.getContractAt(TestBedArtifact.abi, TEST_BED_ADDRESS);\n await testBed.waitForDeployment();\n return testBed;\n};\n\n// Funding\n\nconst fundZkVerifierSigner = async (hre: HardhatRuntimeEnvironment) => {\n const zkVerifierSigner = await hre.ethers.getSigner(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);\n await hre.network.provider.send('hardhat_setBalance', [\n zkVerifierSigner.address,\n '0x' + hre.ethers.parseEther('10').toString(16),\n ]);\n};\n\n// Initializations\n\nconst setTaskManagerACL = async (taskManager: Contract, acl: Contract) => {\n const setAclTx = await taskManager.setACLContract(await acl.getAddress());\n await setAclTx.wait();\n};\n\nexport type DeployMocksArgs = {\n deployTestBed?: boolean;\n gasWarning?: boolean;\n silent?: boolean;\n};\n\nexport const deployMocks = async (\n hre: HardhatRuntimeEnvironment,\n options: DeployMocksArgs = {\n deployTestBed: true,\n gasWarning: true,\n silent: false,\n }\n) => {\n // Check if network is Hardhat, if not log skip message and return\n const isHardhat = await checkNetworkAndSkip(hre);\n if (!isHardhat) return;\n\n const logEmptyIfNoisy = () => {\n if (!options.silent) {\n logEmpty();\n }\n };\n const logSuccessIfNoisy = (message: string, indent = 0) => {\n if (!options.silent) {\n logSuccess(message, indent);\n }\n };\n const logDeploymentIfNoisy = (contractName: string, address: string) => {\n if (!options.silent) {\n logDeployment(contractName, address);\n }\n };\n const logWarningIfNoisy = (message: string, indent = 0) => {\n if (!options.silent) {\n logWarning(message, indent);\n }\n };\n\n // Log start message\n logEmptyIfNoisy();\n logSuccessIfNoisy(chalk.bold('cofhe-hardhat-plugin :: deploy mocks'), 0);\n logEmptyIfNoisy();\n\n // Deploy mock contracts\n const taskManager = await deployMockTaskManager(hre);\n logDeploymentIfNoisy('MockTaskManager', await taskManager.getAddress());\n\n const acl = await deployMockACL(hre);\n logDeploymentIfNoisy('MockACL', await acl.getAddress());\n\n await setTaskManagerACL(taskManager, acl);\n logSuccessIfNoisy('ACL address set in TaskManager', 2);\n\n await fundZkVerifierSigner(hre);\n logSuccessIfNoisy(`ZkVerifier signer (${MOCKS_ZK_VERIFIER_SIGNER_ADDRESS}) funded`, 1);\n\n const zkVerifierSignerBalance = await hre.ethers.provider.getBalance(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);\n logSuccessIfNoisy(`ETH balance: ${zkVerifierSignerBalance.toString()}`, 2);\n\n const zkVerifier = await deployMockZkVerifier(hre);\n logDeploymentIfNoisy('MockZkVerifier', await zkVerifier.getAddress());\n\n const queryDecrypter = await deployMockQueryDecrypter(hre, acl);\n logDeploymentIfNoisy('MockQueryDecrypter', await queryDecrypter.getAddress());\n\n if (options.deployTestBed) {\n logSuccessIfNoisy('TestBed deployment enabled', 2);\n const testBed = await deployTestBedContract(hre);\n logDeploymentIfNoisy('TestBed', await testBed.getAddress());\n }\n\n // Log success message\n logEmptyIfNoisy();\n logSuccessIfNoisy(chalk.bold('cofhe-hardhat-plugin :: mocks deployed successfully'), 0);\n\n // Log warning about mocks increased gas costs\n if (options.gasWarning) {\n logEmptyIfNoisy();\n logWarningIfNoisy(\n \"When using mocks, FHE operations (eg FHE.add / FHE.mul) report a higher gas price due to additional on-chain mocking logic. Deploy your contracts on a testnet chain to check the true gas costs.\\n(Disable this warning by setting '@cofhe/sdk.gasWarning' to false in your hardhat config\",\n 0\n );\n }\n\n logEmptyIfNoisy();\n};\n\n// Utils\n\nconst hardhatSetCode = async (hre: HardhatRuntimeEnvironment, address: string, bytecode: string) => {\n await hre.network.provider.send('hardhat_setCode', [address, bytecode]);\n};\n\nconst ethersDeployContract = async (hre: HardhatRuntimeEnvironment, abi: any, bytecode: string) => {\n const [signer] = await hre.ethers.getSigners();\n\n const factory = new hre.ethers.ContractFactory(abi, bytecode, signer);\n const contract = await factory.deploy(/* constructor args */);\n await contract.waitForDeployment();\n\n return contract as Contract;\n};\n\n// Network\n\nconst checkNetworkAndSkip = async (hre: HardhatRuntimeEnvironment) => {\n const network = hre.network.name;\n const isHardhat = network === 'hardhat';\n if (!isHardhat) logSuccess(`cofhe-hardhat-plugin - deploy mocks - skipped on non-hardhat network ${network}`, 0);\n return isHardhat;\n};\n\n// Logging\n\nconst logEmpty = () => {\n console.log('');\n};\n\nconst logSuccess = (message: string, indent = 1) => {\n console.log(chalk.green(`${' '.repeat(indent)}✓ ${message}`));\n};\n\nconst logWarning = (message: string, indent = 1) => {\n console.log(chalk.bold(chalk.yellow(`${' '.repeat(indent)}⚠ NOTE:`)), message);\n};\n\nconst logError = (message: string, indent = 1) => {\n console.log(chalk.red(`${' '.repeat(indent)}✗ ${message}`));\n};\n\nconst logDeployment = (contractName: string, address: string) => {\n const paddedName = `${contractName} deployed`.padEnd(36);\n logSuccess(`${paddedName} ${chalk.bold(address)}`);\n};\n","import chalk from 'chalk';\nimport { type HardhatRuntimeEnvironment } from 'hardhat/types';\nimport { TASK_MANAGER_ADDRESS } from './consts';\nimport { MockTaskManagerArtifact } from '@cofhe/mock-contracts';\n\nconst getDeployedMockTaskManager = async (hre: HardhatRuntimeEnvironment) => {\n // Fetch the deployed MockTaskManager\n const taskManager = await hre.ethers.getContractAt(MockTaskManagerArtifact.abi, TASK_MANAGER_ADDRESS);\n\n return taskManager;\n};\n\nconst getLoggingEnabled = async (hre: HardhatRuntimeEnvironment) => {\n const taskManager = await getDeployedMockTaskManager(hre);\n return await taskManager.logOps();\n};\n\nconst setLoggingEnabled = async (hre: HardhatRuntimeEnvironment, enabled: boolean) => {\n const taskManager = await getDeployedMockTaskManager(hre);\n await taskManager.setLogOps(enabled);\n};\n\n// prettier-ignore\nconst printLogsEnabledMessage = (closureMessage: string) => {\n console.log(\"┌──────────────────┬──────────────────────────────────────────────────\");\n console.log(`│ [COFHE-MOCKS] │ ${closureMessage}`);\n console.log(\"├──────────────────┴──────────────────────────────────────────────────\");\n};\n\n// prettier-ignore\nconst printLogsBlockEnd = () => {\n console.log(\"└─────────────────────────────────────────────────────────────────────\");\n};\n\nexport const mock_setLoggingEnabled = async (\n hre: HardhatRuntimeEnvironment,\n enabled: boolean,\n closureName?: string\n) => {\n try {\n const initiallyEnabled = await getLoggingEnabled(hre);\n\n await setLoggingEnabled(hre, enabled);\n\n // Only print if enabling logs\n if (enabled) {\n printLogsEnabledMessage(`${closureName ? `\"${chalk.bold(closureName)}\" logs:` : 'Logs:'}`);\n }\n\n // Only print if disabling logs AND logs currently enabled\n if (!enabled && initiallyEnabled) {\n printLogsBlockEnd();\n }\n } catch (error) {\n console.log(chalk.red('mock_setLoggingEnabled error'), error);\n }\n};\n\nexport const mock_withLogs = async (\n hre: HardhatRuntimeEnvironment,\n closureName: string,\n closure: () => Promise<void>\n) => {\n const initiallyEnabled = await getLoggingEnabled(hre);\n\n await setLoggingEnabled(hre, true);\n printLogsEnabledMessage(`\"${chalk.bold(closureName)}\" logs:`);\n await closure();\n printLogsBlockEnd();\n\n // If logs were disabled, disable them again\n if (!initiallyEnabled) {\n await setLoggingEnabled(hre, false);\n }\n};\n","import { TASK_MANAGER_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS } from './consts.js';\nimport { expect } from 'chai';\nimport { ethers } from 'ethers';\nimport { type HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';\n\nconst mock_checkIsTestnet = async (fnName: string, provider: HardhatEthersProvider | ethers.JsonRpcProvider) => {\n // Testnet is checked by testing if MockZkVerifier is deployed\n\n // Get bytecode at ZK_VERIFIER_ADDRESS\n const bytecode = await provider.getCode(MOCKS_ZK_VERIFIER_ADDRESS);\n\n // If bytecode is empty, we are on a testnet\n const isTestnet = bytecode.length === 0;\n\n // Log if we are on a testnet\n if (isTestnet) {\n console.log(`${fnName} - skipped on non-testnet chain`);\n }\n\n return isTestnet;\n};\n\nexport const mock_getPlaintext = async (provider: HardhatEthersProvider | ethers.JsonRpcProvider, ctHash: bigint) => {\n // Skip with log if called on a non-testnet chain\n if (await mock_checkIsTestnet(mock_getPlaintext.name, provider)) return;\n\n // Connect to MockTaskManager\n const taskManager = new ethers.Contract(\n TASK_MANAGER_ADDRESS,\n ['function mockStorage(uint256) view returns (uint256)'],\n provider\n );\n\n // Fetch the plaintext\n const plaintext = await taskManager.mockStorage(ctHash);\n\n return plaintext;\n};\n\nexport const mock_getPlaintextExists = async (\n provider: HardhatEthersProvider | ethers.JsonRpcProvider,\n ctHash: bigint\n) => {\n // Skip with log if called on a non-testnet chain\n if (await mock_checkIsTestnet(mock_getPlaintextExists.name, provider)) return;\n\n // Connect to MockTaskManager\n const taskManager = new ethers.Contract(\n TASK_MANAGER_ADDRESS,\n ['function inMockStorage(uint256) view returns (bool)'],\n provider\n );\n\n // Fetch the plaintext exists\n const plaintextExists = await taskManager.inMockStorage(ctHash);\n\n return plaintextExists;\n};\n\nexport const mock_expectPlaintext = async (\n provider: HardhatEthersProvider | ethers.JsonRpcProvider,\n ctHash: bigint,\n expectedValue: bigint\n) => {\n // Skip with log if called on a non-testnet chain\n if (await mock_checkIsTestnet(mock_expectPlaintext.name, provider)) return;\n\n // Expect the plaintext to exist\n const plaintextExists = await mock_getPlaintextExists(provider, ctHash);\n expect(plaintextExists).equal(true, 'Plaintext does not exist');\n\n // Expect the plaintext to have the expected value\n const plaintext = await mock_getPlaintext(provider, ctHash);\n expect(plaintext).equal(expectedValue, 'Plaintext value is incorrect');\n};\n"],"mappings":";AAEA,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AAU,QAAQ,aAAa;AAAA,MACpE;AAAA,MACA,oBAAoB,YAAY;AAC9B,eAAO,MAAM,IAAI,OAAO,cAAcJ,yBAAwB,KAAKA,yBAAwB,YAAY;AAAA,MACzG;AAAA,MACA,YAAY,YAAY;AACtB,cAAM,KAAK,MAAM,IAAI,OAAO,cAAcA,yBAAwB,KAAKA,yBAAwB,YAAY;AAC3G,cAAM,aAAa,MAAM,GAAG,IAAI;AAChC,eAAO,MAAM,IAAI,OAAO,cAAcF,iBAAgB,KAAK,UAAU;AAAA,MACvE;AAAA,MACA,uBAAuB,YAAY;AACjC,eAAO,MAAM,IAAI,OAAO,cAAcC,4BAA2B,KAAKA,4BAA2B,YAAY;AAAA,MAC/G;AAAA,MACA,mBAAmB,YAAY;AAC7B,eAAO,MAAM,IAAI,OAAO,cAAcE,wBAAuB,KAAKA,wBAAuB,YAAY;AAAA,MACvG;AAAA,MACA,YAAY,YAAY;AACtB,eAAO,MAAM,IAAI,OAAO,cAAcC,iBAAgB,KAAKA,iBAAgB,YAAY;AAAA,MACzF;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":["chalk","MOCKS_ZK_VERIFIER_SIGNER_ADDRESS","chalk","MockTaskManagerArtifact","chalk","MockACLArtifact","MockQueryDecrypterArtifact","MockTaskManagerArtifact","MockZkVerifierArtifact","TestBedArtifact","chalk","MOCKS_ZK_VERIFIER_SIGNER_ADDRESS"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cofhe/hardhat-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"@openzeppelin/contracts-upgradeable": "^5.0.0",
|
|
23
23
|
"chalk": "^4.1.2",
|
|
24
24
|
"fast-glob": "^3.3.2",
|
|
25
|
-
"viem": "^2.
|
|
25
|
+
"viem": "^2.38.6",
|
|
26
26
|
"chai": "^4.2.0",
|
|
27
|
-
"@cofhe/sdk": "0.
|
|
28
|
-
"@cofhe/mock-contracts": "0.
|
|
27
|
+
"@cofhe/sdk": "0.2.0",
|
|
28
|
+
"@cofhe/mock-contracts": "0.2.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@nomicfoundation/hardhat-ethers": "^3.0.5",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"prettier-plugin-solidity": "^1.3.0",
|
|
43
43
|
"tsup": "^8.0.2",
|
|
44
44
|
"typescript": "5.5.4",
|
|
45
|
-
"@cofhe/tsconfig": "0.1.
|
|
46
|
-
"@cofhe/eslint-config": "0.
|
|
45
|
+
"@cofhe/tsconfig": "0.1.1",
|
|
46
|
+
"@cofhe/eslint-config": "0.2.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"hardhat": "^2.0.0",
|
package/src/consts.ts
CHANGED
|
@@ -3,8 +3,6 @@ export const TASK_COFHE_MOCKS_SET_LOG_OPS = 'task:cofhe-mocks:setlogops';
|
|
|
3
3
|
export const TASK_COFHE_MOCKS_DEPLOY = 'task:cofhe-mocks:deploy';
|
|
4
4
|
|
|
5
5
|
export const TASK_MANAGER_ADDRESS = '0xeA30c4B8b44078Bbf8a6ef5b9f1eC1626C7848D9';
|
|
6
|
-
export const MOCKS_ACL_ADDRESS = '0x0000000000000000000000000000000000000400';
|
|
7
6
|
export const MOCKS_ZK_VERIFIER_ADDRESS = '0x0000000000000000000000000000000000000100';
|
|
8
7
|
export const MOCKS_QUERY_DECRYPTER_ADDRESS = '0x0000000000000000000000000000000000000200';
|
|
9
8
|
export const TEST_BED_ADDRESS = '0x0000000000000000000000000000000000000300';
|
|
10
|
-
export const MOCKS_ZK_VERIFIER_SIGNER_ADDRESS = '0x6E12D8C87503D4287c294f2Fdef96ACd9DFf6bd2';
|
package/src/deploy.ts
CHANGED
|
@@ -7,8 +7,6 @@ import {
|
|
|
7
7
|
MOCKS_ZK_VERIFIER_ADDRESS,
|
|
8
8
|
MOCKS_QUERY_DECRYPTER_ADDRESS,
|
|
9
9
|
TEST_BED_ADDRESS,
|
|
10
|
-
MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,
|
|
11
|
-
MOCKS_ACL_ADDRESS,
|
|
12
10
|
} from './consts.js';
|
|
13
11
|
|
|
14
12
|
import {
|
|
@@ -18,6 +16,7 @@ import {
|
|
|
18
16
|
MockQueryDecrypterArtifact,
|
|
19
17
|
TestBedArtifact,
|
|
20
18
|
} from '@cofhe/mock-contracts';
|
|
19
|
+
import { MOCKS_ZK_VERIFIER_SIGNER_ADDRESS } from '@cofhe/sdk';
|
|
21
20
|
|
|
22
21
|
// Deploy
|
|
23
22
|
|
|
@@ -42,9 +41,8 @@ const deployMockTaskManager = async (hre: HardhatRuntimeEnvironment) => {
|
|
|
42
41
|
};
|
|
43
42
|
|
|
44
43
|
const deployMockACL = async (hre: HardhatRuntimeEnvironment): Promise<Contract> => {
|
|
45
|
-
// Deploy MockACL
|
|
46
|
-
await
|
|
47
|
-
const acl = await hre.ethers.getContractAt(MockACLArtifact.abi, MOCKS_ACL_ADDRESS);
|
|
44
|
+
// Deploy MockACL (uses ethers to deploy to ensure constructor called and EIP712 domain set)
|
|
45
|
+
const acl = await ethersDeployContract(hre, MockACLArtifact.abi, MockACLArtifact.bytecode);
|
|
48
46
|
|
|
49
47
|
// Check if ACL exists
|
|
50
48
|
const exists = await acl.exists();
|
|
@@ -155,10 +153,6 @@ export const deployMocks = async (
|
|
|
155
153
|
logSuccessIfNoisy(chalk.bold('cofhe-hardhat-plugin :: deploy mocks'), 0);
|
|
156
154
|
logEmptyIfNoisy();
|
|
157
155
|
|
|
158
|
-
// Compile mock contracts
|
|
159
|
-
logEmptyIfNoisy();
|
|
160
|
-
logSuccessIfNoisy('Mock contracts compiled', 1);
|
|
161
|
-
|
|
162
156
|
// Deploy mock contracts
|
|
163
157
|
const taskManager = await deployMockTaskManager(hre);
|
|
164
158
|
logDeploymentIfNoisy('MockTaskManager', await taskManager.getAddress());
|
|
@@ -209,6 +203,16 @@ const hardhatSetCode = async (hre: HardhatRuntimeEnvironment, address: string, b
|
|
|
209
203
|
await hre.network.provider.send('hardhat_setCode', [address, bytecode]);
|
|
210
204
|
};
|
|
211
205
|
|
|
206
|
+
const ethersDeployContract = async (hre: HardhatRuntimeEnvironment, abi: any, bytecode: string) => {
|
|
207
|
+
const [signer] = await hre.ethers.getSigners();
|
|
208
|
+
|
|
209
|
+
const factory = new hre.ethers.ContractFactory(abi, bytecode, signer);
|
|
210
|
+
const contract = await factory.deploy(/* constructor args */);
|
|
211
|
+
await contract.waitForDeployment();
|
|
212
|
+
|
|
213
|
+
return contract as Contract;
|
|
214
|
+
};
|
|
215
|
+
|
|
212
216
|
// Network
|
|
213
217
|
|
|
214
218
|
const checkNetworkAndSkip = async (hre: HardhatRuntimeEnvironment) => {
|
package/src/index.ts
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
/* eslint-disable no-empty-pattern */
|
|
2
2
|
/* eslint-disable turbo/no-undeclared-env-vars */
|
|
3
|
-
/* eslint-disable no-unused-vars */
|
|
4
3
|
import chalk from 'chalk';
|
|
5
4
|
import { type PublicClient, type WalletClient } from 'viem';
|
|
6
5
|
import { extendConfig, extendEnvironment, task, types } from 'hardhat/config';
|
|
7
6
|
import { TASK_TEST, TASK_NODE } from 'hardhat/builtin-tasks/task-names';
|
|
8
7
|
import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';
|
|
9
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,
|
|
10
|
+
type CofhesdkClient,
|
|
11
|
+
type CofhesdkConfig,
|
|
12
|
+
type CofhesdkInputConfig,
|
|
13
|
+
} from '@cofhe/sdk';
|
|
10
14
|
import { createCofhesdkClient, createCofhesdkConfig } from '@cofhe/sdk/node';
|
|
11
15
|
import { HardhatSignerAdapter } from '@cofhe/sdk/adapters';
|
|
12
16
|
|
|
13
17
|
import { localcofheFundAccount } from './fund.js';
|
|
14
|
-
import {
|
|
15
|
-
MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,
|
|
16
|
-
TASK_COFHE_MOCKS_DEPLOY,
|
|
17
|
-
TASK_COFHE_MOCKS_SET_LOG_OPS,
|
|
18
|
-
TASK_COFHE_USE_FAUCET,
|
|
19
|
-
} from './consts.js';
|
|
18
|
+
import { TASK_COFHE_MOCKS_DEPLOY, TASK_COFHE_MOCKS_SET_LOG_OPS, TASK_COFHE_USE_FAUCET } from './consts.js';
|
|
20
19
|
import { deployMocks, type DeployMocksArgs } from './deploy.js';
|
|
21
20
|
import { mock_setLoggingEnabled, mock_withLogs } from './logging.js';
|
|
22
21
|
import { mock_expectPlaintext } from './utils.js';
|
|
23
22
|
import { mock_getPlaintext } from './utils.js';
|
|
23
|
+
import type { Contract } from 'ethers';
|
|
24
24
|
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
MockACLArtifact,
|
|
26
|
+
MockQueryDecrypterArtifact,
|
|
27
|
+
MockTaskManagerArtifact,
|
|
28
|
+
MockZkVerifierArtifact,
|
|
29
|
+
TestBedArtifact,
|
|
30
|
+
} from '@cofhe/mock-contracts';
|
|
31
|
+
import { hardhat } from '@cofhe/sdk/chains';
|
|
30
32
|
export {
|
|
31
33
|
MockACLArtifact,
|
|
32
34
|
MockQueryDecrypterArtifact,
|
|
@@ -185,7 +187,6 @@ task(TASK_COFHE_MOCKS_SET_LOG_OPS, 'Set logging for the Mock CoFHE contracts')
|
|
|
185
187
|
// MOCK UTILS
|
|
186
188
|
|
|
187
189
|
export * from './utils.js';
|
|
188
|
-
export * from './expectResultUtils.js';
|
|
189
190
|
export * from './fund.js';
|
|
190
191
|
export * from './logging.js';
|
|
191
192
|
export * from './deploy.js';
|
|
@@ -217,35 +218,21 @@ declare module 'hardhat/types/runtime' {
|
|
|
217
218
|
hardhatSignerAdapter: (
|
|
218
219
|
signer: HardhatEthersSigner
|
|
219
220
|
) => Promise<{ publicClient: PublicClient; walletClient: WalletClient }>;
|
|
220
|
-
|
|
221
221
|
/**
|
|
222
|
-
*
|
|
223
|
-
* @param {
|
|
224
|
-
* @
|
|
225
|
-
|
|
226
|
-
expectResultSuccess: <T>(result: Result<T> | Promise<Result<T>>) => Promise<T>;
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Assert that a Result type contains an error matching the partial string (result.success === false && result.error.includes(errorPartial))
|
|
230
|
-
* @param {Result<T>} result - The Result to check
|
|
231
|
-
* @param {string} errorPartial - The partial error string to match
|
|
232
|
-
*/
|
|
233
|
-
expectResultError: <T>(result: Result<T> | Promise<Result<T>>, errorPartial: string) => Promise<void>;
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Assert that a Result type contains a specific value (result.success === true && result.data === value)
|
|
237
|
-
* @param {Result<T>} result - The Result to check
|
|
238
|
-
* @param {T} value - The inner data of the Result (non null)
|
|
222
|
+
* Connect a CoFHE SDK client with a Hardhat ethers signer
|
|
223
|
+
* @param {CofhesdkClient} client - The CoFHE SDK client to connect
|
|
224
|
+
* @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use
|
|
225
|
+
* @returns {Promise<void>}
|
|
239
226
|
*/
|
|
240
|
-
|
|
241
|
-
|
|
227
|
+
connectWithHardhatSigner: (client: CofhesdkClient, signer: HardhatEthersSigner) => Promise<void>;
|
|
242
228
|
/**
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
* @
|
|
229
|
+
* Create and connect to a batteries included client.
|
|
230
|
+
* Also generates a self-usage a permit for the signer.
|
|
231
|
+
* If customization is needed, use createCofhesdkClient and connectWithHardhatSigner.
|
|
232
|
+
* @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use (optional - defaults to first signer)
|
|
233
|
+
* @returns {Promise<CofhesdkClient>} The CoFHE SDK client instance
|
|
247
234
|
*/
|
|
248
|
-
|
|
235
|
+
createBatteriesIncludedCofhesdkClient: (signer?: HardhatEthersSigner) => Promise<CofhesdkClient>;
|
|
249
236
|
|
|
250
237
|
mocks: {
|
|
251
238
|
/**
|
|
@@ -318,6 +305,36 @@ declare module 'hardhat/types/runtime' {
|
|
|
318
305
|
* @param {bigint} expectedValue - The expected plaintext value
|
|
319
306
|
*/
|
|
320
307
|
expectPlaintext: (ctHash: bigint, expectedValue: bigint) => Promise<void>;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Get the MockTaskManager contract
|
|
311
|
+
* @returns {Promise<Contract>} The MockTaskManager contract
|
|
312
|
+
*/
|
|
313
|
+
getMockTaskManager: () => Promise<Contract>;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Get the MockACL contract
|
|
317
|
+
* @returns {Promise<Contract>} The MockACL contract
|
|
318
|
+
*/
|
|
319
|
+
getMockACL: () => Promise<Contract>;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Get the MockQueryDecrypter contract
|
|
323
|
+
* @returns {Promise<Contract>} The MockQueryDecrypter contract
|
|
324
|
+
*/
|
|
325
|
+
getMockQueryDecrypter: () => Promise<Contract>;
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Get the MockZkVerifier contract
|
|
329
|
+
* @returns {Promise<Contract>} The MockZkVerifier contract
|
|
330
|
+
*/
|
|
331
|
+
getMockZkVerifier: () => Promise<Contract>;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Get the TestBed contract
|
|
335
|
+
* @returns {Promise<Contract>} The TestBed contract
|
|
336
|
+
*/
|
|
337
|
+
getTestBed: () => Promise<Contract>;
|
|
321
338
|
};
|
|
322
339
|
};
|
|
323
340
|
}
|
|
@@ -333,6 +350,7 @@ extendEnvironment((hre) => {
|
|
|
333
350
|
|
|
334
351
|
// Inject zkv wallet client into config
|
|
335
352
|
const configWithZkvWalletClient = {
|
|
353
|
+
environment: 'hardhat' as const,
|
|
336
354
|
...config,
|
|
337
355
|
_internal: {
|
|
338
356
|
...config._internal,
|
|
@@ -348,21 +366,35 @@ extendEnvironment((hre) => {
|
|
|
348
366
|
hardhatSignerAdapter: async (signer: HardhatEthersSigner) => {
|
|
349
367
|
return HardhatSignerAdapter(signer);
|
|
350
368
|
},
|
|
351
|
-
|
|
352
|
-
const
|
|
353
|
-
return
|
|
354
|
-
},
|
|
355
|
-
expectResultError: async <T>(result: Result<T> | Promise<Result<T>>, errorPartial: string) => {
|
|
356
|
-
const awaitedResult = await result;
|
|
357
|
-
return expectResultError(awaitedResult, errorPartial);
|
|
358
|
-
},
|
|
359
|
-
expectResultValue: async <T>(result: Result<T> | Promise<Result<T>>, value: T) => {
|
|
360
|
-
const awaitedResult = await result;
|
|
361
|
-
return expectResultValue(awaitedResult, value);
|
|
369
|
+
connectWithHardhatSigner: async (client: CofhesdkClient, signer: HardhatEthersSigner) => {
|
|
370
|
+
const { publicClient, walletClient } = await HardhatSignerAdapter(signer);
|
|
371
|
+
return client.connect(publicClient, walletClient);
|
|
362
372
|
},
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
373
|
+
createBatteriesIncludedCofhesdkClient: async (signer?: HardhatEthersSigner) => {
|
|
374
|
+
// Get signer if not provided
|
|
375
|
+
if (!signer) {
|
|
376
|
+
[signer] = await hre.ethers.getSigners();
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
// Create config
|
|
380
|
+
const config = await hre.cofhesdk.createCofhesdkConfig({
|
|
381
|
+
environment: 'hardhat',
|
|
382
|
+
supportedChains: [hardhat],
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
// Create client
|
|
386
|
+
const client = hre.cofhesdk.createCofhesdkClient(config);
|
|
387
|
+
|
|
388
|
+
// Connect client
|
|
389
|
+
await hre.cofhesdk.connectWithHardhatSigner(client, signer);
|
|
390
|
+
|
|
391
|
+
// Create self-usage permit
|
|
392
|
+
await client.permits.createSelf({
|
|
393
|
+
issuer: signer.address,
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
// Return client
|
|
397
|
+
return client;
|
|
366
398
|
},
|
|
367
399
|
mocks: {
|
|
368
400
|
withLogs: async (closureName: string, closure: () => Promise<void>) => {
|
|
@@ -385,6 +417,23 @@ extendEnvironment((hre) => {
|
|
|
385
417
|
const [signer] = await hre.ethers.getSigners();
|
|
386
418
|
return mock_expectPlaintext(signer.provider, ctHash, expectedValue);
|
|
387
419
|
},
|
|
420
|
+
getMockTaskManager: async () => {
|
|
421
|
+
return await hre.ethers.getContractAt(MockTaskManagerArtifact.abi, MockTaskManagerArtifact.fixedAddress);
|
|
422
|
+
},
|
|
423
|
+
getMockACL: async () => {
|
|
424
|
+
const tm = await hre.ethers.getContractAt(MockTaskManagerArtifact.abi, MockTaskManagerArtifact.fixedAddress);
|
|
425
|
+
const aclAddress = await tm.acl();
|
|
426
|
+
return await hre.ethers.getContractAt(MockACLArtifact.abi, aclAddress);
|
|
427
|
+
},
|
|
428
|
+
getMockQueryDecrypter: async () => {
|
|
429
|
+
return await hre.ethers.getContractAt(MockQueryDecrypterArtifact.abi, MockQueryDecrypterArtifact.fixedAddress);
|
|
430
|
+
},
|
|
431
|
+
getMockZkVerifier: async () => {
|
|
432
|
+
return await hre.ethers.getContractAt(MockZkVerifierArtifact.abi, MockZkVerifierArtifact.fixedAddress);
|
|
433
|
+
},
|
|
434
|
+
getTestBed: async () => {
|
|
435
|
+
return await hre.ethers.getContractAt(TestBedArtifact.abi, TestBedArtifact.fixedAddress);
|
|
436
|
+
},
|
|
388
437
|
},
|
|
389
438
|
};
|
|
390
439
|
});
|
package/src/expectResultUtils.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type Result } from '@cofhe/sdk';
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
|
|
4
|
-
export const expectResultError = <T>(result: Result<T>, errorPartial: string) => {
|
|
5
|
-
expect(result.success).to.eq(false, 'Result should be an error');
|
|
6
|
-
expect(result.error).to.include(errorPartial, `Error should contain error partial: ${errorPartial}`);
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const expectResultSuccess = <T>(result: Result<T>): T => {
|
|
10
|
-
expect(result.success).to.eq(true, 'Result should be a success');
|
|
11
|
-
return result.data!;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const expectResultValue = <T>(result: Result<T>, value: T): T => {
|
|
15
|
-
expect(result.success).to.eq(true, 'Result should be a success');
|
|
16
|
-
expect(result.data).to.eq(value, `Result should have the expected value ${value}`);
|
|
17
|
-
return result.data!;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const expectResultPartialValue = <T>(result: Result<T>, partial: Partial<T>): T => {
|
|
21
|
-
expect(result.success).to.eq(true, 'Result should be a success');
|
|
22
|
-
expect(result.data).to.include(partial, `Result should have the expected partial ${partial}`);
|
|
23
|
-
return result.data!;
|
|
24
|
-
};
|