@cofhe/hardhat-plugin 0.5.1 → 0.6.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 +24 -0
- package/README.md +2 -7
- package/dist/index.d.mts +2 -8
- package/dist/index.d.ts +2 -8
- package/dist/index.js +9 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/deploy.ts +0 -12
- package/src/index.ts +5 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @cofhe/hardhat-plugin Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 566f126: Remove the legacy `TestBed` mock surface and stop auto-deploying `SimpleTest` through the Hardhat plugins. Core mock contracts still deploy automatically, while tests that need `SimpleTest` should deploy it explicitly from their own artifacts.
|
|
8
|
+
|
|
9
|
+
This also removes `TEST_BED_ADDRESS` and cleans up duplicate `SimpleTest` exports from `@cofhe/mock-contracts`.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [bf23270]
|
|
14
|
+
- Updated dependencies [2711f9b]
|
|
15
|
+
- Updated dependencies [566f126]
|
|
16
|
+
- @cofhe/sdk@0.6.0
|
|
17
|
+
- @cofhe/mock-contracts@0.6.0
|
|
18
|
+
|
|
19
|
+
## 0.5.2
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [2fbb918]
|
|
24
|
+
- @cofhe/sdk@0.5.2
|
|
25
|
+
- @cofhe/mock-contracts@0.5.2
|
|
26
|
+
|
|
3
27
|
## 0.5.1
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -59,7 +59,7 @@ Key differences from the real CoFHE system:
|
|
|
59
59
|
|
|
60
60
|
### Mock Contracts Deployment
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
Core mock contracts are automatically deployed when using the Hardhat network:
|
|
63
63
|
|
|
64
64
|
- Running tests: `npx hardhat test`
|
|
65
65
|
- Starting a local node: `npx hardhat node`
|
|
@@ -73,14 +73,9 @@ COFHE_SKIP_MOCKS_DEPLOY=1
|
|
|
73
73
|
You can also manually deploy mock contracts:
|
|
74
74
|
|
|
75
75
|
```bash
|
|
76
|
-
npx hardhat
|
|
76
|
+
npx hardhat task:cofhe-mocks:deploy
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
Options:
|
|
80
|
-
|
|
81
|
-
- `--deploy-test-bed`: Deploy the TestBed contract (default: true)
|
|
82
|
-
- `--log-mocks`: Log mock operations (default: true)
|
|
83
|
-
|
|
84
79
|
### Utility Functions
|
|
85
80
|
|
|
86
81
|
The plugin exports several utility functions for working with mock contracts:
|
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ import { PublicClient, WalletClient } from 'viem';
|
|
|
2
2
|
import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';
|
|
3
3
|
import { CofheInputConfig, CofheConfig, CofheClient } from '@cofhe/sdk';
|
|
4
4
|
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
|
5
|
-
import { MockArtifact, MockTaskManager, MockACL, MockThresholdNetwork, MockZkVerifier
|
|
5
|
+
import { MockArtifact, MockTaskManager, MockACL, MockThresholdNetwork, MockZkVerifier } from '@cofhe/mock-contracts';
|
|
6
6
|
import * as ethers from 'ethers';
|
|
7
7
|
import { Contract, ethers as ethers$1 } from 'ethers';
|
|
8
8
|
import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';
|
|
@@ -15,7 +15,6 @@ import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/
|
|
|
15
15
|
*/
|
|
16
16
|
type LogMocksDeploy = '' | 'v' | 'vv';
|
|
17
17
|
type DeployMocksArgs = {
|
|
18
|
-
deployTestBed?: boolean;
|
|
19
18
|
gasWarning?: boolean;
|
|
20
19
|
mocksDeployVerbosity?: LogMocksDeploy;
|
|
21
20
|
};
|
|
@@ -170,7 +169,7 @@ declare module 'hardhat/types/runtime' {
|
|
|
170
169
|
/**
|
|
171
170
|
* **[MOCKS ONLY]**
|
|
172
171
|
*
|
|
173
|
-
* Deploy the cofhe mock contracts
|
|
172
|
+
* Deploy the cofhe mock contracts.
|
|
174
173
|
* @param {DeployMocksArgs} options - Deployment options
|
|
175
174
|
*/
|
|
176
175
|
deployMocks: (options?: DeployMocksArgs) => Promise<void>;
|
|
@@ -210,11 +209,6 @@ declare module 'hardhat/types/runtime' {
|
|
|
210
209
|
* @returns {Promise<MockZkVerifier>} The MockZkVerifier contract
|
|
211
210
|
*/
|
|
212
211
|
getMockZkVerifier: () => Promise<MockZkVerifier>;
|
|
213
|
-
/**
|
|
214
|
-
* Get the TestBed contract (typed via typechain)
|
|
215
|
-
* @returns {Promise<TestBed>} The TestBed contract
|
|
216
|
-
*/
|
|
217
|
-
getTestBed: () => Promise<TestBed>;
|
|
218
212
|
};
|
|
219
213
|
};
|
|
220
214
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { PublicClient, WalletClient } from 'viem';
|
|
|
2
2
|
import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';
|
|
3
3
|
import { CofheInputConfig, CofheConfig, CofheClient } from '@cofhe/sdk';
|
|
4
4
|
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
|
5
|
-
import { MockArtifact, MockTaskManager, MockACL, MockThresholdNetwork, MockZkVerifier
|
|
5
|
+
import { MockArtifact, MockTaskManager, MockACL, MockThresholdNetwork, MockZkVerifier } from '@cofhe/mock-contracts';
|
|
6
6
|
import * as ethers from 'ethers';
|
|
7
7
|
import { Contract, ethers as ethers$1 } from 'ethers';
|
|
8
8
|
import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';
|
|
@@ -15,7 +15,6 @@ import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/
|
|
|
15
15
|
*/
|
|
16
16
|
type LogMocksDeploy = '' | 'v' | 'vv';
|
|
17
17
|
type DeployMocksArgs = {
|
|
18
|
-
deployTestBed?: boolean;
|
|
19
18
|
gasWarning?: boolean;
|
|
20
19
|
mocksDeployVerbosity?: LogMocksDeploy;
|
|
21
20
|
};
|
|
@@ -170,7 +169,7 @@ declare module 'hardhat/types/runtime' {
|
|
|
170
169
|
/**
|
|
171
170
|
* **[MOCKS ONLY]**
|
|
172
171
|
*
|
|
173
|
-
* Deploy the cofhe mock contracts
|
|
172
|
+
* Deploy the cofhe mock contracts.
|
|
174
173
|
* @param {DeployMocksArgs} options - Deployment options
|
|
175
174
|
*/
|
|
176
175
|
deployMocks: (options?: DeployMocksArgs) => Promise<void>;
|
|
@@ -210,11 +209,6 @@ declare module 'hardhat/types/runtime' {
|
|
|
210
209
|
* @returns {Promise<MockZkVerifier>} The MockZkVerifier contract
|
|
211
210
|
*/
|
|
212
211
|
getMockZkVerifier: () => Promise<MockZkVerifier>;
|
|
213
|
-
/**
|
|
214
|
-
* Get the TestBed contract (typed via typechain)
|
|
215
|
-
* @returns {Promise<TestBed>} The TestBed contract
|
|
216
|
-
*/
|
|
217
|
-
getTestBed: () => Promise<TestBed>;
|
|
218
212
|
};
|
|
219
213
|
};
|
|
220
214
|
}
|
package/dist/index.js
CHANGED
|
@@ -186,7 +186,6 @@ var mock_expectPlaintext = async (provider, ctHash, expectedValue) => {
|
|
|
186
186
|
|
|
187
187
|
// src/deploy.ts
|
|
188
188
|
var deployMocks = async (hre, options = {
|
|
189
|
-
deployTestBed: true,
|
|
190
189
|
gasWarning: true,
|
|
191
190
|
mocksDeployVerbosity: "v"
|
|
192
191
|
}) => {
|
|
@@ -216,10 +215,6 @@ var deployMocks = async (hre, options = {
|
|
|
216
215
|
logDeployment("MockZkVerifier", await zkVerifier.getAddress());
|
|
217
216
|
const thresholdNetwork = await deployMockThresholdNetwork(hre, acl);
|
|
218
217
|
logDeployment("MockThresholdNetwork", await thresholdNetwork.getAddress());
|
|
219
|
-
if (options.deployTestBed) {
|
|
220
|
-
const testBed = await deployTestBedContract(hre);
|
|
221
|
-
logDeployment("TestBed", await testBed.getAddress());
|
|
222
|
-
}
|
|
223
218
|
log("v", import_chalk.default.bold("cofhe-hardhat-plugin :: mocks deployed"), 0);
|
|
224
219
|
if (options.gasWarning) {
|
|
225
220
|
logEmpty("v");
|
|
@@ -295,9 +290,6 @@ var deployMockThresholdNetwork = async (hre, acl) => {
|
|
|
295
290
|
}
|
|
296
291
|
return thresholdNetwork;
|
|
297
292
|
};
|
|
298
|
-
var deployTestBedContract = async (hre) => {
|
|
299
|
-
return deployMockContractFromArtifact(hre, import_mock_contracts.TestBedArtifact);
|
|
300
|
-
};
|
|
301
293
|
var verbosity = "v";
|
|
302
294
|
var log = (minVerbosity, message, indent = 1) => {
|
|
303
295
|
if (verbosity === "")
|
|
@@ -479,13 +471,14 @@ function generateMockContractsStubContent() {
|
|
|
479
471
|
console.info(import_chalk3.default.red(`failed to get funds from localcofhe for ${address}: ${e}`));
|
|
480
472
|
}
|
|
481
473
|
});
|
|
482
|
-
(0, import_config.task)(TASK_COFHE_MOCKS_DEPLOY, "Deploys the mock contracts on the Hardhat network").
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
}
|
|
474
|
+
(0, import_config.task)(TASK_COFHE_MOCKS_DEPLOY, "Deploys the mock contracts on the Hardhat network").setAction(
|
|
475
|
+
async ({}, hre) => {
|
|
476
|
+
await deployMocks(hre, {
|
|
477
|
+
gasWarning: hre.config.cofhe.gasWarning ?? true,
|
|
478
|
+
mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
);
|
|
489
482
|
(0, import_config.task)(import_task_names.TASK_TEST, "Deploy mock contracts on hardhat").setAction(async ({}, hre, runSuper) => {
|
|
490
483
|
const skipAutoDeploy = (() => {
|
|
491
484
|
const raw = process.env.COFHE_SKIP_MOCKS_DEPLOY ?? "";
|
|
@@ -494,7 +487,6 @@ function generateMockContractsStubContent() {
|
|
|
494
487
|
})();
|
|
495
488
|
if (!skipAutoDeploy) {
|
|
496
489
|
await deployMocks(hre, {
|
|
497
|
-
deployTestBed: true,
|
|
498
490
|
gasWarning: hre.config.cofhe.gasWarning ?? true,
|
|
499
491
|
mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity
|
|
500
492
|
});
|
|
@@ -509,7 +501,6 @@ function generateMockContractsStubContent() {
|
|
|
509
501
|
})();
|
|
510
502
|
if (!skipAutoDeploy) {
|
|
511
503
|
await deployMocks(hre, {
|
|
512
|
-
deployTestBed: true,
|
|
513
504
|
gasWarning: hre.config.cofhe.gasWarning ?? true,
|
|
514
505
|
mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity
|
|
515
506
|
});
|
|
@@ -595,8 +586,7 @@ function buildHardhatPluginMocksConfig(mocksConfig) {
|
|
|
595
586
|
return hre.ethers.getContractAt(aclArtifact.abi, aclAddress);
|
|
596
587
|
},
|
|
597
588
|
getMockThresholdNetwork: async () => getFixedMockContract(hre, import_mock_contracts3.MockThresholdNetworkArtifact),
|
|
598
|
-
getMockZkVerifier: async () => getFixedMockContract(hre, import_mock_contracts3.MockZkVerifierArtifact)
|
|
599
|
-
getTestBed: async () => getFixedMockContract(hre, import_mock_contracts3.TestBedArtifact)
|
|
589
|
+
getMockZkVerifier: async () => getFixedMockContract(hre, import_mock_contracts3.MockZkVerifierArtifact)
|
|
600
590
|
}
|
|
601
591
|
};
|
|
602
592
|
});
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/fund.ts","../src/consts.ts","../src/deploy.ts","../src/utils.ts","../src/logging.ts"],"sourcesContent":["/* eslint-disable no-empty-pattern */\n/* eslint-disable turbo/no-undeclared-env-vars */\nimport chalk from 'chalk';\nimport path from 'path';\nimport fs from 'fs';\nimport { type PublicClient, type WalletClient } from 'viem';\nimport { extendConfig, extendEnvironment, task, subtask, types } from 'hardhat/config';\nimport { TASK_TEST, TASK_NODE, TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from 'hardhat/builtin-tasks/task-names';\nimport { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';\nimport {\n type CofheClient,\n type CofheConfig,\n type CofheInputConfig,\n MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,\n} from '@cofhe/sdk';\nimport { createCofheClient, createCofheConfig } 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, type LogMocksDeploy } from './deploy.js';\nimport { mock_setLoggingEnabled, mock_withLogs } from './logging.js';\nimport { getFixedMockContract, mock_expectPlaintext } from './utils.js';\nimport { mock_getPlaintext } from './utils.js';\nimport { hardhat } from '@cofhe/sdk/chains';\nimport {\n MockThresholdNetworkArtifact,\n MockTaskManagerArtifact,\n MockZkVerifierArtifact,\n TestBedArtifact,\n type MockACL,\n type MockTaskManager,\n type MockThresholdNetwork,\n type MockZkVerifier,\n type TestBed,\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 cofhe?: {\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 * Controls deploy-mocks console output.\n * - `''` — silent, no output\n * - `'v'` — single summary line (default)\n * - `'vv'` — full per-contract deployment logs\n */\n mocksDeployVerbosity?: LogMocksDeploy;\n };\n }\n\n interface HardhatConfig {\n cofhe: {\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 mocksDeployVerbosity: LogMocksDeploy;\n };\n }\n}\n\nconst MOCK_STUBS_DIR_NAME = 'cofhe-stubs';\nconst MOCK_STUBS_FILE_NAME = 'CofheMocksImports.sol';\n\n/**\n * Returns the absolute paths of every .sol file shipped inside the\n * @cofhe/mock-contracts/contracts directory.\n */\nfunction getMockContractsSolFiles(): string[] {\n let contractsDir: string;\n try {\n const pkgJson = require.resolve('@cofhe/mock-contracts/package.json');\n contractsDir = path.join(path.dirname(pkgJson), 'contracts');\n } catch {\n contractsDir = path.join(process.cwd(), 'node_modules', '@cofhe', 'mock-contracts', 'contracts');\n }\n\n if (!fs.existsSync(contractsDir)) {\n return [];\n }\n\n return fs\n .readdirSync(contractsDir)\n .filter((f) => f.endsWith('.sol'))\n .map((f) => path.join(contractsDir, f));\n}\n\n/**\n * Generates a stub Solidity file that imports every contract from\n * @cofhe/mock-contracts/contracts. Writing it to the Hardhat cache directory\n * (which is inside the project root) means:\n * - localPathToSourceName() accepts it (no HH1007)\n * - Hardhat resolves the npm-style \"@cofhe/mock-contracts/...\" imports\n * the same way it resolves any other node_modules dependency\n * - All mock contract artifacts end up in hre.artifacts, giving Hardhat\n * full ABI knowledge so it can decode reverts and traces\n */\nfunction generateMockContractsStubContent(): string {\n const imports = getMockContractsSolFiles()\n .map((f) => `import \"@cofhe/mock-contracts/contracts/${path.basename(f)}\";`)\n .join('\\n');\n\n return [\n '// SPDX-License-Identifier: UNLICENSED',\n '// Auto-generated by @cofhe/hardhat-plugin — do not edit.',\n '// Importing mock contracts here causes Hardhat to compile them and register',\n '// their artifacts, enabling proper revert decoding during tests.',\n 'pragma solidity >=0.8.25 <0.9.0;',\n '',\n imports,\n '',\n ].join('\\n');\n}\n\nsubtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(async (taskArgs: { sourcePath?: string }, hre, runSuper) => {\n const existing: string[] = await runSuper(taskArgs);\n\n // Write the stub inside the Hardhat cache dir so that it lives within the\n // project root — a requirement of localPathToSourceName (HH1007).\n const stubDir = path.join(hre.config.paths.cache, MOCK_STUBS_DIR_NAME);\n const stubPath = path.join(stubDir, MOCK_STUBS_FILE_NAME);\n fs.mkdirSync(stubDir, { recursive: true });\n fs.writeFileSync(stubPath, generateMockContractsStubContent(), 'utf8');\n\n return [...new Set([...existing, stubPath])];\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.cofhe = {\n logMocks: userConfig.cofhe?.logMocks ?? false,\n gasWarning: userConfig.cofhe?.gasWarning ?? false,\n mocksDeployVerbosity: (userConfig.cofhe?.mocksDeployVerbosity ?? 'v') as LogMocksDeploy,\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 .setAction(async ({ deployTestBed }: DeployMocksArgs, hre) => {\n await deployMocks(hre, {\n deployTestBed: deployTestBed ?? true,\n gasWarning: hre.config.cofhe.gasWarning ?? true,\n mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity,\n });\n });\n\n// Hardhat plugin auto-deploys mocks for every hardhat test run by overriding TASK_TEST and calling deployMocks(...) before runSuper()\ntask(TASK_TEST, 'Deploy mock contracts on hardhat').setAction(async ({}, hre, runSuper) => {\n const skipAutoDeploy = (() => {\n const raw = process.env.COFHE_SKIP_MOCKS_DEPLOY ?? '';\n const normalized = raw.trim().toLowerCase();\n return normalized === '1' || normalized === 'true' || normalized === 'yes';\n })();\n\n if (!skipAutoDeploy) {\n await deployMocks(hre, {\n deployTestBed: true,\n gasWarning: hre.config.cofhe.gasWarning ?? true,\n mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity,\n });\n }\n return runSuper();\n});\n\ntask(TASK_NODE, 'Deploy mock contracts on hardhat').setAction(async ({}, hre, runSuper) => {\n const skipAutoDeploy = (() => {\n const raw = process.env.COFHE_SKIP_MOCKS_DEPLOY ?? '';\n const normalized = raw.trim().toLowerCase();\n return normalized === '1' || normalized === 'true' || normalized === 'yes';\n })();\n\n if (!skipAutoDeploy) {\n await deployMocks(hre, {\n deployTestBed: true,\n gasWarning: hre.config.cofhe.gasWarning ?? true,\n mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity,\n });\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 './consts.js';\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 cofhe: {\n /**\n * Create a CoFHE configuration for use with hre.cofhe.createClient(...)\n * @param {CofheInputConfig} config - The CoFHE input configuration\n * @returns {CofheConfig} The CoFHE configuration\n */\n createConfig: (config: CofheInputConfig) => Promise<CofheConfig>;\n /**\n * Create a CoFHE client instance\n * @param {CofheConfig} config - The CoFHE configuration (use createCofheConfig to create with Node.js defaults)\n * @returns {Promise<CofheClient>} The CoFHE client instance\n */\n createClient: (config: CofheConfig) => CofheClient;\n /**\n * Create viem clients from a Hardhat ethers signer, to be used with `cofheClient.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 client with a Hardhat ethers signer\n * @param {CofheClient} client - The CoFHE client to connect\n * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use\n * @returns {Promise<void>}\n */\n connectWithHardhatSigner: (client: CofheClient, 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 createCofheClient and connectWithHardhatSigner.\n * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use (optional - defaults to first signer)\n * @returns {Promise<CofheClient>} The CoFHE client instance\n */\n createClientWithBatteries: (signer?: HardhatEthersSigner) => Promise<CofheClient>;\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.cofhe.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 | string} ctHash - The ciphertext hash to look up\n * @returns {Promise<bigint>} The plaintext value\n */\n getPlaintext: (ctHash: bigint | string) => Promise<bigint>;\n\n /**\n * **[MOCKS ONLY]**\n *\n * Assert that a ciphertext hash represents an expected plaintext value\n * @param {bigint | string} ctHash - The ciphertext hash to check\n * @param {bigint} expectedValue - The expected plaintext value\n */\n expectPlaintext: (ctHash: bigint | string, expectedValue: bigint) => Promise<void>;\n\n /**\n * Get the MockTaskManager contract (typed via typechain)\n * @returns {Promise<MockTaskManager>} The MockTaskManager contract\n */\n getMockTaskManager: () => Promise<MockTaskManager>;\n\n /**\n * Get the MockACL contract (typed via typechain)\n * @returns {Promise<MockACL>} The MockACL contract\n */\n getMockACL: () => Promise<MockACL>;\n\n /**\n * Get the MockThresholdNetwork contract (typed via typechain)\n * @returns {Promise<MockThresholdNetwork>} The MockThresholdNetwork contract\n */\n getMockThresholdNetwork: () => Promise<MockThresholdNetwork>;\n\n /**\n * Get the MockZkVerifier contract (typed via typechain)\n * @returns {Promise<MockZkVerifier>} The MockZkVerifier contract\n */\n getMockZkVerifier: () => Promise<MockZkVerifier>;\n\n /**\n * Get the TestBed contract (typed via typechain)\n * @returns {Promise<TestBed>} The TestBed contract\n */\n getTestBed: () => Promise<TestBed>;\n };\n };\n }\n}\n\n/**\n * Builds the mocks config for the hardhat plugin.\n * Defaults `encryptDelay` to `0` so tests run without artificial wait times,\n * unless the user has explicitly provided a value.\n */\nexport function buildHardhatPluginMocksConfig(\n mocksConfig: CofheInputConfig['mocks']\n): NonNullable<CofheInputConfig['mocks']> {\n return {\n ...mocksConfig,\n encryptDelay: mocksConfig?.encryptDelay ?? 0,\n };\n}\n\nextendEnvironment((hre) => {\n hre.cofhe = {\n createConfig: async (config: CofheInputConfig) => {\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 // Set encryptDelay to 0 on hardhat to avoid waiting for delays during tests\n const configWithZkvWalletClient = {\n environment: 'hardhat' as const,\n ...config,\n mocks: buildHardhatPluginMocksConfig(config.mocks),\n _internal: {\n ...config._internal,\n zkvWalletClient,\n },\n };\n\n return createCofheConfig(configWithZkvWalletClient);\n },\n createClient: (config: CofheConfig) => {\n return createCofheClient(config);\n },\n hardhatSignerAdapter: async (signer: HardhatEthersSigner) => {\n return HardhatSignerAdapter(signer);\n },\n connectWithHardhatSigner: async (client: CofheClient, signer: HardhatEthersSigner) => {\n const { publicClient, walletClient } = await HardhatSignerAdapter(signer);\n return client.connect(publicClient, walletClient);\n },\n createClientWithBatteries: 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.cofhe.createConfig({\n environment: 'hardhat',\n supportedChains: [hardhat],\n });\n\n // Create client\n const client = hre.cofhe.createClient(config);\n\n // Connect client\n await hre.cofhe.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, { mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity, ...options });\n },\n getPlaintext: async (ctHash: bigint | string) => {\n const [signer] = await hre.ethers.getSigners();\n return mock_getPlaintext(signer.provider, ctHash);\n },\n expectPlaintext: async (ctHash: bigint | string, expectedValue: bigint) => {\n const [signer] = await hre.ethers.getSigners();\n return mock_expectPlaintext(signer.provider, ctHash, expectedValue);\n },\n getMockTaskManager: async () =>\n getFixedMockContract(hre, MockTaskManagerArtifact) as unknown as Promise<MockTaskManager>,\n getMockACL: async () => {\n const taskManager = await getFixedMockContract(hre, MockTaskManagerArtifact);\n const aclAddress = await taskManager.acl();\n const aclArtifact = await hre.artifacts.readArtifact('MockACL');\n return hre.ethers.getContractAt(aclArtifact.abi, aclAddress) as unknown as MockACL;\n },\n getMockThresholdNetwork: async () =>\n getFixedMockContract(hre, MockThresholdNetworkArtifact) as unknown as Promise<MockThresholdNetwork>,\n getMockZkVerifier: async () =>\n getFixedMockContract(hre, MockZkVerifierArtifact) as unknown as Promise<MockZkVerifier>,\n getTestBed: async () => getFixedMockContract(hre, TestBedArtifact) as unknown as Promise<TestBed>,\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","import { type HardhatRuntimeEnvironment } from 'hardhat/types';\nimport chalk from 'chalk';\nimport { Contract, Wallet } from 'ethers';\n\nimport {\n MockTaskManagerArtifact,\n MockACLArtifact,\n MockZkVerifierArtifact,\n MockThresholdNetworkArtifact,\n TestBedArtifact,\n} from '@cofhe/mock-contracts';\n\nimport {\n TASK_MANAGER_ADDRESS,\n MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,\n MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY,\n MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY,\n} from '@cofhe/sdk';\nimport { deployMockContractFromArtifact } from './utils';\n\n// Deployment\n\n/**\n * Controls deploy-mocks console output.\n * - `''` — silent, no output\n * - `'v'` — single summary line (default)\n * - `'vv'` — full per-contract deployment logs\n */\nexport type LogMocksDeploy = '' | 'v' | 'vv';\n\nexport type DeployMocksArgs = {\n deployTestBed?: boolean;\n gasWarning?: boolean;\n mocksDeployVerbosity?: LogMocksDeploy;\n};\n\nexport const deployMocks = async (\n hre: HardhatRuntimeEnvironment,\n options: DeployMocksArgs = {\n deployTestBed: true,\n gasWarning: true,\n mocksDeployVerbosity: 'v',\n }\n) => {\n verbosity = options.mocksDeployVerbosity ?? 'v';\n\n // Check if network is Hardhat, if not log skip message and return\n const isHardhat = await getIsHardhat(hre);\n if (!isHardhat) {\n log('v', `cofhe-hardhat-plugin - deploy mocks - skipped on non-hardhat network ${hre.network.name}`, 0);\n return;\n }\n\n // Compile mock contracts before deploying so that hre.artifacts.readArtifact()\n // resolves correctly and Hardhat can decode reverts against these contracts.\n // The subtask override in index.ts adds the mock-contracts source files to the\n // compilation pipeline, so they are compiled alongside the project's own contracts.\n // Calling compile here is safe: Hardhat caches results, so a second compile\n // triggered by TASK_TEST's runSuper() will be a fast no-op.\n await hre.run('compile', { quiet: true });\n\n log('vv', chalk.bold('cofhe-hardhat-plugin :: deploy mocks'), 0);\n\n // Deploy mock contracts\n const taskManager = await deployMockTaskManager(hre);\n logDeployment('MockTaskManager', await taskManager.getAddress());\n\n const acl = await deployMockACL(hre);\n logDeployment('MockACL', await acl.getAddress());\n\n await linkTaskManagerAndACL(taskManager, acl);\n log('vv', 'ACL address set in TaskManager', 2);\n\n await setVerifierSigner(taskManager);\n log('vv', 'Verifier signer set', 2);\n\n await setDecryptResultSigner(taskManager);\n log('vv', 'Decrypt result signer set', 2);\n\n await fundZkVerifierSigner(hre);\n log('vv', `ZkVerifier signer (${MOCKS_ZK_VERIFIER_SIGNER_ADDRESS}) funded`, 1);\n\n const zkVerifierSignerBalance = await getZkVerifierSignerBalance(hre);\n log('vv', `ETH balance: ${zkVerifierSignerBalance.toString()}`, 2);\n\n const zkVerifier = await deployMockZkVerifier(hre);\n logDeployment('MockZkVerifier', await zkVerifier.getAddress());\n\n const thresholdNetwork = await deployMockThresholdNetwork(hre, acl);\n logDeployment('MockThresholdNetwork', await thresholdNetwork.getAddress());\n\n if (options.deployTestBed) {\n const testBed = await deployTestBedContract(hre);\n logDeployment('TestBed', await testBed.getAddress());\n }\n\n log('v', chalk.bold('cofhe-hardhat-plugin :: mocks deployed'), 0);\n\n if (options.gasWarning) {\n logEmpty('v');\n logWarning(\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.gasWarning: false' in your hardhat config)\",\n 0\n );\n }\n\n logEmpty('v');\n};\n\n// Network\n\nconst getIsHardhat = async (hre: HardhatRuntimeEnvironment) => {\n return hre.network.name === 'hardhat';\n};\n\nconst deployMockTaskManager = async (hre: HardhatRuntimeEnvironment) => {\n const [signer] = await hre.ethers.getSigners();\n\n // Deploy MockTaskManager\n const taskManager = await deployMockContractFromArtifact(hre, MockTaskManagerArtifact);\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 deployMockContractFromArtifact(hre, MockACLArtifact);\n\n // Check if ACL exists\n const exists = await acl.exists();\n if (!exists) {\n throw new Error('MockACL does not exist');\n }\n\n return acl;\n};\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\nconst getZkVerifierSignerBalance = async (hre: HardhatRuntimeEnvironment) => {\n return hre.ethers.provider.getBalance(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);\n};\n\nconst linkTaskManagerAndACL = async (taskManager: Contract, acl: Contract) => {\n const aclAddress = await acl.getAddress();\n const linkAclTx = await taskManager.setACLContract(aclAddress);\n await linkAclTx.wait();\n};\n\nconst setVerifierSigner = async (taskManager: Contract) => {\n const signer = new Wallet(MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY);\n const setSignerTx = await taskManager.setVerifierSigner(signer.address);\n await setSignerTx.wait();\n};\n\nconst setDecryptResultSigner = async (taskManager: Contract) => {\n const signer = new Wallet(MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY);\n const setSignerTx = await taskManager.setDecryptResultSigner(signer.address);\n await setSignerTx.wait();\n};\n\nconst deployMockZkVerifier = async (hre: HardhatRuntimeEnvironment) => {\n const zkVerifier = await deployMockContractFromArtifact(hre, MockZkVerifierArtifact);\n\n const zkVerifierExists = await zkVerifier.exists();\n if (!zkVerifierExists) {\n throw new Error('MockZkVerifier does not exist');\n }\n\n return zkVerifier;\n};\n\nconst deployMockThresholdNetwork = async (hre: HardhatRuntimeEnvironment, acl: Contract) => {\n const thresholdNetwork = await deployMockContractFromArtifact(hre, MockThresholdNetworkArtifact);\n\n // Initialize MockThresholdNetwork\n const initTx = await thresholdNetwork.initialize(TASK_MANAGER_ADDRESS, await acl.getAddress());\n await initTx.wait();\n\n // Check if MockThresholdNetwork exists\n const exists = await thresholdNetwork.exists();\n if (!exists) {\n throw new Error('MockThresholdNetwork does not exist');\n }\n\n return thresholdNetwork;\n};\n\nconst deployTestBedContract = async (hre: HardhatRuntimeEnvironment) => {\n return deployMockContractFromArtifact(hre, TestBedArtifact);\n};\n\n// Logging\n\nlet verbosity: LogMocksDeploy = 'v';\n\n/**\n * Emit a green ✓ line at `minVerbosity` or above.\n * - `minVerbosity = 'v'` → prints for both 'v' and 'vv'\n * - `minVerbosity = 'vv'` → prints only for 'vv'\n */\nconst log = (minVerbosity: 'v' | 'vv', message: string, indent = 1) => {\n if (verbosity === '') return;\n if (minVerbosity === 'vv' && verbosity !== 'vv') return;\n console.log(chalk.green(`${' '.repeat(indent)}✓ ${message}`));\n};\n\nconst logEmpty = (minVerbosity: 'v' | 'vv' = 'v') => {\n if (verbosity === '') return;\n if (minVerbosity === 'vv' && verbosity !== 'vv') return;\n console.log('');\n};\n\nconst logWarning = (message: string, indent = 1) => {\n if (verbosity === '') return;\n console.log(chalk.bold(chalk.yellow(`${' '.repeat(indent)}⚠ NOTE:`)), message);\n};\n\nconst logDeployment = (contractName: string, address: string) => {\n if (verbosity !== 'vv') return;\n const paddedName = `${contractName} deployed`.padEnd(36);\n console.log(chalk.green(` ✓ ${paddedName} ${chalk.bold(address)}`));\n};\n","import { TASK_MANAGER_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS } from '@cofhe/sdk';\nimport { expect } from 'chai';\nimport { Contract, ethers } from 'ethers';\nimport { type HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';\nimport type { MockArtifact } from '@cofhe/mock-contracts';\nimport type { HardhatRuntimeEnvironment } from 'hardhat/types';\n\n// Deployment utils\n\n/// Deploys a mock contract from a pre-built artifact from the mock-contracts package.\n/// ABI and bytecode are sourced from Hardhat's artifact registry (populated during compilation)\n/// so that Hardhat can decode reverts and trace calls against these contracts.\n/// If the mock contract should be deployed to a fixed address, `hardhat_setCode` is used.\n/// Otherwise, ethers.js deploys it to a normal address.\nexport const deployMockContractFromArtifact = async (hre: HardhatRuntimeEnvironment, artifact: MockArtifact) => {\n const hardhatArtifact = await hre.artifacts.readArtifact(artifact.contractName);\n\n if (artifact.isFixed) {\n await hre.network.provider.send('hardhat_setCode', [artifact.fixedAddress, hardhatArtifact.deployedBytecode]);\n return hre.ethers.getContractAt(hardhatArtifact.abi, artifact.fixedAddress);\n }\n\n const [signer] = await hre.ethers.getSigners();\n const factory = new hre.ethers.ContractFactory(hardhatArtifact.abi, hardhatArtifact.bytecode, signer);\n const contract = await factory.deploy();\n await contract.waitForDeployment();\n return contract as Contract;\n};\n\nexport const getFixedMockContract = async (hre: HardhatRuntimeEnvironment, artifact: MockArtifact) => {\n if (!artifact.isFixed) {\n throw new Error('Artifact is not fixed');\n }\n const hardhatArtifact = await hre.artifacts.readArtifact(artifact.contractName);\n return hre.ethers.getContractAt(hardhatArtifact.abi, artifact.fixedAddress);\n};\n\n// Testing utils\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 (\n provider: HardhatEthersProvider | ethers.JsonRpcProvider,\n ctHash: bigint | string\n) => {\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(BigInt(ctHash));\n\n return plaintext;\n};\n\nexport const mock_getPlaintextExists = async (\n provider: HardhatEthersProvider | ethers.JsonRpcProvider,\n ctHash: bigint | string\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(BigInt(ctHash));\n\n return plaintextExists;\n};\n\nexport const mock_expectPlaintext = async (\n provider: HardhatEthersProvider | ethers.JsonRpcProvider,\n ctHash: bigint | string,\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 chalk from 'chalk';\nimport { type HardhatRuntimeEnvironment } from 'hardhat/types';\nimport { getFixedMockContract } from './utils';\nimport { MockTaskManagerArtifact } from '@cofhe/mock-contracts';\n\nconst getLoggingEnabled = async (hre: HardhatRuntimeEnvironment): Promise<boolean> => {\n const taskManager = await getFixedMockContract(hre, MockTaskManagerArtifact);\n return taskManager.logOps();\n};\n\nconst setLoggingEnabled = async (hre: HardhatRuntimeEnvironment, enabled: boolean) => {\n const taskManager = await getFixedMockContract(hre, MockTaskManagerArtifact);\n const tx = await taskManager.setLogOps(enabled);\n await tx.wait();\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 try {\n await closure();\n } finally {\n printLogsBlockEnd();\n\n // If logs were disabled, disable them again\n if (!initiallyEnabled) {\n await setLoggingEnabled(hre, false);\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAAkB;AAClB,kBAAiB;AACjB,gBAAe;AACf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AC1C,eAAO,uBAAuB,KAAK,MAAM,WAAW;AAAA,MACtD;AAAA,MACA,aAAa,YAAY;AACvB,eAAO,uBAAuB,KAAK,KAAK;AAAA,MAC1C;AAAA,MACA,aAAa,OAAO,UAA2B,CAAC,MAAM;AACpD,eAAO,YAAY,KAAK,EAAE,sBAAsB,IAAI,OAAO,MAAM,sBAAsB,GAAG,QAAQ,CAAC;AAAA,MACrG;AAAA,MACA,cAAc,OAAO,WAA4B;AAC/C,cAAM,CAAC,MAAM,IAAI,MAAM,IAAI,OAAO,WAAW;AAC7C,eAAO,kBAAkB,OAAO,UAAU,MAAM;AAAA,MAClD;AAAA,MACA,iBAAiB,OAAO,QAAyB,kBAA0B;AACzE,cAAM,CAAC,MAAM,IAAI,MAAM,IAAI,OAAO,WAAW;AAC7C,eAAO,qBAAqB,OAAO,UAAU,QAAQ,aAAa;AAAA,MACpE;AAAA,MACA,oBAAoB,YAClB,qBAAqB,KAAK,8CAAuB;AAAA,MACnD,YAAY,YAAY;AACtB,cAAM,cAAc,MAAM,qBAAqB,KAAK,8CAAuB;AAC3E,cAAM,aAAa,MAAM,YAAY,IAAI;AACzC,cAAM,cAAc,MAAM,IAAI,UAAU,aAAa,SAAS;AAC9D,eAAO,IAAI,OAAO,cAAc,YAAY,KAAK,UAAU;AAAA,MAC7D;AAAA,MACA,yBAAyB,YACvB,qBAAqB,KAAK,mDAA4B;AAAA,MACxD,mBAAmB,YACjB,qBAAqB,KAAK,6CAAsB;AAAA,MAClD,YAAY,YAAY,qBAAqB,KAAK,sCAAe;AAAA,IACnE;AAAA,EACF;AACF,CAAC;","names":["import_chalk","import_sdk","import_types","import_ethers","import_sdk","chalk","import_chalk","import_types","import_mock_contracts","chalk","import_mock_contracts","path","fs","chalk"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/fund.ts","../src/consts.ts","../src/deploy.ts","../src/utils.ts","../src/logging.ts"],"sourcesContent":["/* eslint-disable no-empty-pattern */\n/* eslint-disable turbo/no-undeclared-env-vars */\nimport chalk from 'chalk';\nimport path from 'path';\nimport fs from 'fs';\nimport { type PublicClient, type WalletClient } from 'viem';\nimport { extendConfig, extendEnvironment, task, subtask, types } from 'hardhat/config';\nimport { TASK_TEST, TASK_NODE, TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from 'hardhat/builtin-tasks/task-names';\nimport { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';\nimport {\n type CofheClient,\n type CofheConfig,\n type CofheInputConfig,\n MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,\n} from '@cofhe/sdk';\nimport { createCofheClient, createCofheConfig } 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, type LogMocksDeploy } from './deploy.js';\nimport { mock_setLoggingEnabled, mock_withLogs } from './logging.js';\nimport { getFixedMockContract, mock_expectPlaintext } from './utils.js';\nimport { mock_getPlaintext } from './utils.js';\nimport { hardhat } from '@cofhe/sdk/chains';\nimport {\n MockThresholdNetworkArtifact,\n MockTaskManagerArtifact,\n MockZkVerifierArtifact,\n type MockACL,\n type MockTaskManager,\n type MockThresholdNetwork,\n type MockZkVerifier,\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 cofhe?: {\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 * Controls deploy-mocks console output.\n * - `''` — silent, no output\n * - `'v'` — single summary line (default)\n * - `'vv'` — full per-contract deployment logs\n */\n mocksDeployVerbosity?: LogMocksDeploy;\n };\n }\n\n interface HardhatConfig {\n cofhe: {\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 mocksDeployVerbosity: LogMocksDeploy;\n };\n }\n}\n\nconst MOCK_STUBS_DIR_NAME = 'cofhe-stubs';\nconst MOCK_STUBS_FILE_NAME = 'CofheMocksImports.sol';\n\n/**\n * Returns the absolute paths of every .sol file shipped inside the\n * @cofhe/mock-contracts/contracts directory.\n */\nfunction getMockContractsSolFiles(): string[] {\n let contractsDir: string;\n try {\n const pkgJson = require.resolve('@cofhe/mock-contracts/package.json');\n contractsDir = path.join(path.dirname(pkgJson), 'contracts');\n } catch {\n contractsDir = path.join(process.cwd(), 'node_modules', '@cofhe', 'mock-contracts', 'contracts');\n }\n\n if (!fs.existsSync(contractsDir)) {\n return [];\n }\n\n return fs\n .readdirSync(contractsDir)\n .filter((f) => f.endsWith('.sol'))\n .map((f) => path.join(contractsDir, f));\n}\n\n/**\n * Generates a stub Solidity file that imports every contract from\n * @cofhe/mock-contracts/contracts. Writing it to the Hardhat cache directory\n * (which is inside the project root) means:\n * - localPathToSourceName() accepts it (no HH1007)\n * - Hardhat resolves the npm-style \"@cofhe/mock-contracts/...\" imports\n * the same way it resolves any other node_modules dependency\n * - All mock contract artifacts end up in hre.artifacts, giving Hardhat\n * full ABI knowledge so it can decode reverts and traces\n */\nfunction generateMockContractsStubContent(): string {\n const imports = getMockContractsSolFiles()\n .map((f) => `import \"@cofhe/mock-contracts/contracts/${path.basename(f)}\";`)\n .join('\\n');\n\n return [\n '// SPDX-License-Identifier: UNLICENSED',\n '// Auto-generated by @cofhe/hardhat-plugin — do not edit.',\n '// Importing mock contracts here causes Hardhat to compile them and register',\n '// their artifacts, enabling proper revert decoding during tests.',\n 'pragma solidity >=0.8.25 <0.9.0;',\n '',\n imports,\n '',\n ].join('\\n');\n}\n\nsubtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(async (taskArgs: { sourcePath?: string }, hre, runSuper) => {\n const existing: string[] = await runSuper(taskArgs);\n\n // Write the stub inside the Hardhat cache dir so that it lives within the\n // project root — a requirement of localPathToSourceName (HH1007).\n const stubDir = path.join(hre.config.paths.cache, MOCK_STUBS_DIR_NAME);\n const stubPath = path.join(stubDir, MOCK_STUBS_FILE_NAME);\n fs.mkdirSync(stubDir, { recursive: true });\n fs.writeFileSync(stubPath, generateMockContractsStubContent(), 'utf8');\n\n return [...new Set([...existing, stubPath])];\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.cofhe = {\n logMocks: userConfig.cofhe?.logMocks ?? false,\n gasWarning: userConfig.cofhe?.gasWarning ?? false,\n mocksDeployVerbosity: (userConfig.cofhe?.mocksDeployVerbosity ?? 'v') as LogMocksDeploy,\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').setAction(\n async ({}: DeployMocksArgs, hre) => {\n await deployMocks(hre, {\n gasWarning: hre.config.cofhe.gasWarning ?? true,\n mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity,\n });\n }\n);\n\n// Hardhat plugin auto-deploys mocks for every hardhat test run by overriding TASK_TEST and calling deployMocks(...) before runSuper()\ntask(TASK_TEST, 'Deploy mock contracts on hardhat').setAction(async ({}, hre, runSuper) => {\n const skipAutoDeploy = (() => {\n const raw = process.env.COFHE_SKIP_MOCKS_DEPLOY ?? '';\n const normalized = raw.trim().toLowerCase();\n return normalized === '1' || normalized === 'true' || normalized === 'yes';\n })();\n\n if (!skipAutoDeploy) {\n await deployMocks(hre, {\n gasWarning: hre.config.cofhe.gasWarning ?? true,\n mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity,\n });\n }\n return runSuper();\n});\n\ntask(TASK_NODE, 'Deploy mock contracts on hardhat').setAction(async ({}, hre, runSuper) => {\n const skipAutoDeploy = (() => {\n const raw = process.env.COFHE_SKIP_MOCKS_DEPLOY ?? '';\n const normalized = raw.trim().toLowerCase();\n return normalized === '1' || normalized === 'true' || normalized === 'yes';\n })();\n\n if (!skipAutoDeploy) {\n await deployMocks(hre, {\n gasWarning: hre.config.cofhe.gasWarning ?? true,\n mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity,\n });\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 './consts.js';\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 cofhe: {\n /**\n * Create a CoFHE configuration for use with hre.cofhe.createClient(...)\n * @param {CofheInputConfig} config - The CoFHE input configuration\n * @returns {CofheConfig} The CoFHE configuration\n */\n createConfig: (config: CofheInputConfig) => Promise<CofheConfig>;\n /**\n * Create a CoFHE client instance\n * @param {CofheConfig} config - The CoFHE configuration (use createCofheConfig to create with Node.js defaults)\n * @returns {Promise<CofheClient>} The CoFHE client instance\n */\n createClient: (config: CofheConfig) => CofheClient;\n /**\n * Create viem clients from a Hardhat ethers signer, to be used with `cofheClient.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 client with a Hardhat ethers signer\n * @param {CofheClient} client - The CoFHE client to connect\n * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use\n * @returns {Promise<void>}\n */\n connectWithHardhatSigner: (client: CofheClient, 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 createCofheClient and connectWithHardhatSigner.\n * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use (optional - defaults to first signer)\n * @returns {Promise<CofheClient>} The CoFHE client instance\n */\n createClientWithBatteries: (signer?: HardhatEthersSigner) => Promise<CofheClient>;\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.cofhe.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.\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 | string} ctHash - The ciphertext hash to look up\n * @returns {Promise<bigint>} The plaintext value\n */\n getPlaintext: (ctHash: bigint | string) => Promise<bigint>;\n\n /**\n * **[MOCKS ONLY]**\n *\n * Assert that a ciphertext hash represents an expected plaintext value\n * @param {bigint | string} ctHash - The ciphertext hash to check\n * @param {bigint} expectedValue - The expected plaintext value\n */\n expectPlaintext: (ctHash: bigint | string, expectedValue: bigint) => Promise<void>;\n\n /**\n * Get the MockTaskManager contract (typed via typechain)\n * @returns {Promise<MockTaskManager>} The MockTaskManager contract\n */\n getMockTaskManager: () => Promise<MockTaskManager>;\n\n /**\n * Get the MockACL contract (typed via typechain)\n * @returns {Promise<MockACL>} The MockACL contract\n */\n getMockACL: () => Promise<MockACL>;\n\n /**\n * Get the MockThresholdNetwork contract (typed via typechain)\n * @returns {Promise<MockThresholdNetwork>} The MockThresholdNetwork contract\n */\n getMockThresholdNetwork: () => Promise<MockThresholdNetwork>;\n\n /**\n * Get the MockZkVerifier contract (typed via typechain)\n * @returns {Promise<MockZkVerifier>} The MockZkVerifier contract\n */\n getMockZkVerifier: () => Promise<MockZkVerifier>;\n };\n };\n }\n}\n\n/**\n * Builds the mocks config for the hardhat plugin.\n * Defaults `encryptDelay` to `0` so tests run without artificial wait times,\n * unless the user has explicitly provided a value.\n */\nexport function buildHardhatPluginMocksConfig(\n mocksConfig: CofheInputConfig['mocks']\n): NonNullable<CofheInputConfig['mocks']> {\n return {\n ...mocksConfig,\n encryptDelay: mocksConfig?.encryptDelay ?? 0,\n };\n}\n\nextendEnvironment((hre) => {\n hre.cofhe = {\n createConfig: async (config: CofheInputConfig) => {\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 // Set encryptDelay to 0 on hardhat to avoid waiting for delays during tests\n const configWithZkvWalletClient = {\n environment: 'hardhat' as const,\n ...config,\n mocks: buildHardhatPluginMocksConfig(config.mocks),\n _internal: {\n ...config._internal,\n zkvWalletClient,\n },\n };\n\n return createCofheConfig(configWithZkvWalletClient);\n },\n createClient: (config: CofheConfig) => {\n return createCofheClient(config);\n },\n hardhatSignerAdapter: async (signer: HardhatEthersSigner) => {\n return HardhatSignerAdapter(signer);\n },\n connectWithHardhatSigner: async (client: CofheClient, signer: HardhatEthersSigner) => {\n const { publicClient, walletClient } = await HardhatSignerAdapter(signer);\n return client.connect(publicClient, walletClient);\n },\n createClientWithBatteries: 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.cofhe.createConfig({\n environment: 'hardhat',\n supportedChains: [hardhat],\n });\n\n // Create client\n const client = hre.cofhe.createClient(config);\n\n // Connect client\n await hre.cofhe.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, { mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity, ...options });\n },\n getPlaintext: async (ctHash: bigint | string) => {\n const [signer] = await hre.ethers.getSigners();\n return mock_getPlaintext(signer.provider, ctHash);\n },\n expectPlaintext: async (ctHash: bigint | string, expectedValue: bigint) => {\n const [signer] = await hre.ethers.getSigners();\n return mock_expectPlaintext(signer.provider, ctHash, expectedValue);\n },\n getMockTaskManager: async () =>\n getFixedMockContract(hre, MockTaskManagerArtifact) as unknown as Promise<MockTaskManager>,\n getMockACL: async () => {\n const taskManager = await getFixedMockContract(hre, MockTaskManagerArtifact);\n const aclAddress = await taskManager.acl();\n const aclArtifact = await hre.artifacts.readArtifact('MockACL');\n return hre.ethers.getContractAt(aclArtifact.abi, aclAddress) as unknown as MockACL;\n },\n getMockThresholdNetwork: async () =>\n getFixedMockContract(hre, MockThresholdNetworkArtifact) as unknown as Promise<MockThresholdNetwork>,\n getMockZkVerifier: async () =>\n getFixedMockContract(hre, MockZkVerifierArtifact) as unknown as Promise<MockZkVerifier>,\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","import { type HardhatRuntimeEnvironment } from 'hardhat/types';\nimport chalk from 'chalk';\nimport { Contract, Wallet } from 'ethers';\n\nimport {\n MockTaskManagerArtifact,\n MockACLArtifact,\n MockZkVerifierArtifact,\n MockThresholdNetworkArtifact,\n} from '@cofhe/mock-contracts';\n\nimport {\n TASK_MANAGER_ADDRESS,\n MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,\n MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY,\n MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY,\n} from '@cofhe/sdk';\nimport { deployMockContractFromArtifact } from './utils';\n\n// Deployment\n\n/**\n * Controls deploy-mocks console output.\n * - `''` — silent, no output\n * - `'v'` — single summary line (default)\n * - `'vv'` — full per-contract deployment logs\n */\nexport type LogMocksDeploy = '' | 'v' | 'vv';\n\nexport type DeployMocksArgs = {\n gasWarning?: boolean;\n mocksDeployVerbosity?: LogMocksDeploy;\n};\n\nexport const deployMocks = async (\n hre: HardhatRuntimeEnvironment,\n options: DeployMocksArgs = {\n gasWarning: true,\n mocksDeployVerbosity: 'v',\n }\n) => {\n verbosity = options.mocksDeployVerbosity ?? 'v';\n\n // Check if network is Hardhat, if not log skip message and return\n const isHardhat = await getIsHardhat(hre);\n if (!isHardhat) {\n log('v', `cofhe-hardhat-plugin - deploy mocks - skipped on non-hardhat network ${hre.network.name}`, 0);\n return;\n }\n\n // Compile mock contracts before deploying so that hre.artifacts.readArtifact()\n // resolves correctly and Hardhat can decode reverts against these contracts.\n // The subtask override in index.ts adds the mock-contracts source files to the\n // compilation pipeline, so they are compiled alongside the project's own contracts.\n // Calling compile here is safe: Hardhat caches results, so a second compile\n // triggered by TASK_TEST's runSuper() will be a fast no-op.\n await hre.run('compile', { quiet: true });\n\n log('vv', chalk.bold('cofhe-hardhat-plugin :: deploy mocks'), 0);\n\n // Deploy mock contracts\n const taskManager = await deployMockTaskManager(hre);\n logDeployment('MockTaskManager', await taskManager.getAddress());\n\n const acl = await deployMockACL(hre);\n logDeployment('MockACL', await acl.getAddress());\n\n await linkTaskManagerAndACL(taskManager, acl);\n log('vv', 'ACL address set in TaskManager', 2);\n\n await setVerifierSigner(taskManager);\n log('vv', 'Verifier signer set', 2);\n\n await setDecryptResultSigner(taskManager);\n log('vv', 'Decrypt result signer set', 2);\n\n await fundZkVerifierSigner(hre);\n log('vv', `ZkVerifier signer (${MOCKS_ZK_VERIFIER_SIGNER_ADDRESS}) funded`, 1);\n\n const zkVerifierSignerBalance = await getZkVerifierSignerBalance(hre);\n log('vv', `ETH balance: ${zkVerifierSignerBalance.toString()}`, 2);\n\n const zkVerifier = await deployMockZkVerifier(hre);\n logDeployment('MockZkVerifier', await zkVerifier.getAddress());\n\n const thresholdNetwork = await deployMockThresholdNetwork(hre, acl);\n logDeployment('MockThresholdNetwork', await thresholdNetwork.getAddress());\n\n log('v', chalk.bold('cofhe-hardhat-plugin :: mocks deployed'), 0);\n\n if (options.gasWarning) {\n logEmpty('v');\n logWarning(\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.gasWarning: false' in your hardhat config)\",\n 0\n );\n }\n\n logEmpty('v');\n};\n\n// Network\n\nconst getIsHardhat = async (hre: HardhatRuntimeEnvironment) => {\n return hre.network.name === 'hardhat';\n};\n\nconst deployMockTaskManager = async (hre: HardhatRuntimeEnvironment) => {\n const [signer] = await hre.ethers.getSigners();\n\n // Deploy MockTaskManager\n const taskManager = await deployMockContractFromArtifact(hre, MockTaskManagerArtifact);\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 deployMockContractFromArtifact(hre, MockACLArtifact);\n\n // Check if ACL exists\n const exists = await acl.exists();\n if (!exists) {\n throw new Error('MockACL does not exist');\n }\n\n return acl;\n};\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\nconst getZkVerifierSignerBalance = async (hre: HardhatRuntimeEnvironment) => {\n return hre.ethers.provider.getBalance(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);\n};\n\nconst linkTaskManagerAndACL = async (taskManager: Contract, acl: Contract) => {\n const aclAddress = await acl.getAddress();\n const linkAclTx = await taskManager.setACLContract(aclAddress);\n await linkAclTx.wait();\n};\n\nconst setVerifierSigner = async (taskManager: Contract) => {\n const signer = new Wallet(MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY);\n const setSignerTx = await taskManager.setVerifierSigner(signer.address);\n await setSignerTx.wait();\n};\n\nconst setDecryptResultSigner = async (taskManager: Contract) => {\n const signer = new Wallet(MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY);\n const setSignerTx = await taskManager.setDecryptResultSigner(signer.address);\n await setSignerTx.wait();\n};\n\nconst deployMockZkVerifier = async (hre: HardhatRuntimeEnvironment) => {\n const zkVerifier = await deployMockContractFromArtifact(hre, MockZkVerifierArtifact);\n\n const zkVerifierExists = await zkVerifier.exists();\n if (!zkVerifierExists) {\n throw new Error('MockZkVerifier does not exist');\n }\n\n return zkVerifier;\n};\n\nconst deployMockThresholdNetwork = async (hre: HardhatRuntimeEnvironment, acl: Contract) => {\n const thresholdNetwork = await deployMockContractFromArtifact(hre, MockThresholdNetworkArtifact);\n\n // Initialize MockThresholdNetwork\n const initTx = await thresholdNetwork.initialize(TASK_MANAGER_ADDRESS, await acl.getAddress());\n await initTx.wait();\n\n // Check if MockThresholdNetwork exists\n const exists = await thresholdNetwork.exists();\n if (!exists) {\n throw new Error('MockThresholdNetwork does not exist');\n }\n\n return thresholdNetwork;\n};\n\n// Logging\n\nlet verbosity: LogMocksDeploy = 'v';\n\n/**\n * Emit a green ✓ line at `minVerbosity` or above.\n * - `minVerbosity = 'v'` → prints for both 'v' and 'vv'\n * - `minVerbosity = 'vv'` → prints only for 'vv'\n */\nconst log = (minVerbosity: 'v' | 'vv', message: string, indent = 1) => {\n if (verbosity === '') return;\n if (minVerbosity === 'vv' && verbosity !== 'vv') return;\n console.log(chalk.green(`${' '.repeat(indent)}✓ ${message}`));\n};\n\nconst logEmpty = (minVerbosity: 'v' | 'vv' = 'v') => {\n if (verbosity === '') return;\n if (minVerbosity === 'vv' && verbosity !== 'vv') return;\n console.log('');\n};\n\nconst logWarning = (message: string, indent = 1) => {\n if (verbosity === '') return;\n console.log(chalk.bold(chalk.yellow(`${' '.repeat(indent)}⚠ NOTE:`)), message);\n};\n\nconst logDeployment = (contractName: string, address: string) => {\n if (verbosity !== 'vv') return;\n const paddedName = `${contractName} deployed`.padEnd(36);\n console.log(chalk.green(` ✓ ${paddedName} ${chalk.bold(address)}`));\n};\n","import { TASK_MANAGER_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS } from '@cofhe/sdk';\nimport { expect } from 'chai';\nimport { Contract, ethers } from 'ethers';\nimport { type HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';\nimport type { MockArtifact } from '@cofhe/mock-contracts';\nimport type { HardhatRuntimeEnvironment } from 'hardhat/types';\n\n// Deployment utils\n\n/// Deploys a mock contract from a pre-built artifact from the mock-contracts package.\n/// ABI and bytecode are sourced from Hardhat's artifact registry (populated during compilation)\n/// so that Hardhat can decode reverts and trace calls against these contracts.\n/// If the mock contract should be deployed to a fixed address, `hardhat_setCode` is used.\n/// Otherwise, ethers.js deploys it to a normal address.\nexport const deployMockContractFromArtifact = async (hre: HardhatRuntimeEnvironment, artifact: MockArtifact) => {\n const hardhatArtifact = await hre.artifacts.readArtifact(artifact.contractName);\n\n if (artifact.isFixed) {\n await hre.network.provider.send('hardhat_setCode', [artifact.fixedAddress, hardhatArtifact.deployedBytecode]);\n return hre.ethers.getContractAt(hardhatArtifact.abi, artifact.fixedAddress);\n }\n\n const [signer] = await hre.ethers.getSigners();\n const factory = new hre.ethers.ContractFactory(hardhatArtifact.abi, hardhatArtifact.bytecode, signer);\n const contract = await factory.deploy();\n await contract.waitForDeployment();\n return contract as Contract;\n};\n\nexport const getFixedMockContract = async (hre: HardhatRuntimeEnvironment, artifact: MockArtifact) => {\n if (!artifact.isFixed) {\n throw new Error('Artifact is not fixed');\n }\n const hardhatArtifact = await hre.artifacts.readArtifact(artifact.contractName);\n return hre.ethers.getContractAt(hardhatArtifact.abi, artifact.fixedAddress);\n};\n\n// Testing utils\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 (\n provider: HardhatEthersProvider | ethers.JsonRpcProvider,\n ctHash: bigint | string\n) => {\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(BigInt(ctHash));\n\n return plaintext;\n};\n\nexport const mock_getPlaintextExists = async (\n provider: HardhatEthersProvider | ethers.JsonRpcProvider,\n ctHash: bigint | string\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(BigInt(ctHash));\n\n return plaintextExists;\n};\n\nexport const mock_expectPlaintext = async (\n provider: HardhatEthersProvider | ethers.JsonRpcProvider,\n ctHash: bigint | string,\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 chalk from 'chalk';\nimport { type HardhatRuntimeEnvironment } from 'hardhat/types';\nimport { getFixedMockContract } from './utils';\nimport { MockTaskManagerArtifact } from '@cofhe/mock-contracts';\n\nconst getLoggingEnabled = async (hre: HardhatRuntimeEnvironment): Promise<boolean> => {\n const taskManager = await getFixedMockContract(hre, MockTaskManagerArtifact);\n return taskManager.logOps();\n};\n\nconst setLoggingEnabled = async (hre: HardhatRuntimeEnvironment, enabled: boolean) => {\n const taskManager = await getFixedMockContract(hre, MockTaskManagerArtifact);\n const tx = await taskManager.setLogOps(enabled);\n await tx.wait();\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 try {\n await closure();\n } finally {\n printLogsBlockEnd();\n\n // If logs were disabled, disable them again\n if (!initiallyEnabled) {\n await setLoggingEnabled(hre, false);\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAAA,gBAAkB;AAClB,kBAAiB;AACjB,gBAAe;AACf,kBAAqD;AACrD,oBAAsE;AACtE,wBAA6E;AAC7E,qBAAoC;AACpC,IAAAC,cAKO;AACP,kBAAqD;AACrD,sBAAqC;;;ACfrC,mBAA+C;AAC/C,4BAAO;AASP,eAAsB,sBAAsB,KAAgC,WAAmB,SAAiB,MAAM;AAEpH,QAAM,aACJ,QAAQ,IAAI,sBAAsB;AACpC,MAAI,CAAC,YAAY;AACf,YAAQ,MAAM,wDAAwD;AACtE,WAAO;AAAA,EACT;AAEA,MAAI;AAEF,UAAM,SAAS,IAAI,IAAI,OAAO,OAAO,YAAY,IAAI,OAAO,QAAQ;AAGpE,UAAM,UAAU,MAAM,IAAI,OAAO,SAAS,WAAW,OAAO,OAAO;AACnE,YAAQ,IAAI,0BAA0B,OAAO,OAAO,EAAE;AACtD,YAAQ,IAAI,0BAA0B,IAAI,OAAO,Y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B,KAAK,mDAA4B;AAAA,MACxD,mBAAmB,YACjB,qBAAqB,KAAK,6CAAsB;AAAA,IACpD;AAAA,EACF;AACF,CAAC;","names":["import_chalk","import_sdk","import_types","import_ethers","import_sdk","chalk","import_chalk","import_types","import_mock_contracts","chalk","import_mock_contracts","path","fs","chalk"]}
|
package/dist/index.mjs
CHANGED
|
@@ -85,8 +85,7 @@ import {
|
|
|
85
85
|
MockTaskManagerArtifact,
|
|
86
86
|
MockACLArtifact,
|
|
87
87
|
MockZkVerifierArtifact,
|
|
88
|
-
MockThresholdNetworkArtifact
|
|
89
|
-
TestBedArtifact
|
|
88
|
+
MockThresholdNetworkArtifact
|
|
90
89
|
} from "@cofhe/mock-contracts";
|
|
91
90
|
import {
|
|
92
91
|
TASK_MANAGER_ADDRESS as TASK_MANAGER_ADDRESS2,
|
|
@@ -160,7 +159,6 @@ var mock_expectPlaintext = async (provider, ctHash, expectedValue) => {
|
|
|
160
159
|
|
|
161
160
|
// src/deploy.ts
|
|
162
161
|
var deployMocks = async (hre, options = {
|
|
163
|
-
deployTestBed: true,
|
|
164
162
|
gasWarning: true,
|
|
165
163
|
mocksDeployVerbosity: "v"
|
|
166
164
|
}) => {
|
|
@@ -190,10 +188,6 @@ var deployMocks = async (hre, options = {
|
|
|
190
188
|
logDeployment("MockZkVerifier", await zkVerifier.getAddress());
|
|
191
189
|
const thresholdNetwork = await deployMockThresholdNetwork(hre, acl);
|
|
192
190
|
logDeployment("MockThresholdNetwork", await thresholdNetwork.getAddress());
|
|
193
|
-
if (options.deployTestBed) {
|
|
194
|
-
const testBed = await deployTestBedContract(hre);
|
|
195
|
-
logDeployment("TestBed", await testBed.getAddress());
|
|
196
|
-
}
|
|
197
191
|
log("v", chalk.bold("cofhe-hardhat-plugin :: mocks deployed"), 0);
|
|
198
192
|
if (options.gasWarning) {
|
|
199
193
|
logEmpty("v");
|
|
@@ -269,9 +263,6 @@ var deployMockThresholdNetwork = async (hre, acl) => {
|
|
|
269
263
|
}
|
|
270
264
|
return thresholdNetwork;
|
|
271
265
|
};
|
|
272
|
-
var deployTestBedContract = async (hre) => {
|
|
273
|
-
return deployMockContractFromArtifact(hre, TestBedArtifact);
|
|
274
|
-
};
|
|
275
266
|
var verbosity = "v";
|
|
276
267
|
var log = (minVerbosity, message, indent = 1) => {
|
|
277
268
|
if (verbosity === "")
|
|
@@ -353,8 +344,7 @@ import { hardhat } from "@cofhe/sdk/chains";
|
|
|
353
344
|
import {
|
|
354
345
|
MockThresholdNetworkArtifact as MockThresholdNetworkArtifact2,
|
|
355
346
|
MockTaskManagerArtifact as MockTaskManagerArtifact3,
|
|
356
|
-
MockZkVerifierArtifact as MockZkVerifierArtifact2
|
|
357
|
-
TestBedArtifact as TestBedArtifact2
|
|
347
|
+
MockZkVerifierArtifact as MockZkVerifierArtifact2
|
|
358
348
|
} from "@cofhe/mock-contracts";
|
|
359
349
|
var MOCK_STUBS_DIR_NAME = "cofhe-stubs";
|
|
360
350
|
var MOCK_STUBS_FILE_NAME = "CofheMocksImports.sol";
|
|
@@ -458,13 +448,14 @@ task(TASK_COFHE_USE_FAUCET, "Fund an account from the funder").addOptionalParam(
|
|
|
458
448
|
console.info(chalk3.red(`failed to get funds from localcofhe for ${address}: ${e}`));
|
|
459
449
|
}
|
|
460
450
|
});
|
|
461
|
-
task(TASK_COFHE_MOCKS_DEPLOY, "Deploys the mock contracts on the Hardhat network").
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
}
|
|
451
|
+
task(TASK_COFHE_MOCKS_DEPLOY, "Deploys the mock contracts on the Hardhat network").setAction(
|
|
452
|
+
async ({}, hre) => {
|
|
453
|
+
await deployMocks(hre, {
|
|
454
|
+
gasWarning: hre.config.cofhe.gasWarning ?? true,
|
|
455
|
+
mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
);
|
|
468
459
|
task(TASK_TEST, "Deploy mock contracts on hardhat").setAction(async ({}, hre, runSuper) => {
|
|
469
460
|
const skipAutoDeploy = (() => {
|
|
470
461
|
const raw = process.env.COFHE_SKIP_MOCKS_DEPLOY ?? "";
|
|
@@ -473,7 +464,6 @@ task(TASK_TEST, "Deploy mock contracts on hardhat").setAction(async ({}, hre, ru
|
|
|
473
464
|
})();
|
|
474
465
|
if (!skipAutoDeploy) {
|
|
475
466
|
await deployMocks(hre, {
|
|
476
|
-
deployTestBed: true,
|
|
477
467
|
gasWarning: hre.config.cofhe.gasWarning ?? true,
|
|
478
468
|
mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity
|
|
479
469
|
});
|
|
@@ -488,7 +478,6 @@ task(TASK_NODE, "Deploy mock contracts on hardhat").setAction(async ({}, hre, ru
|
|
|
488
478
|
})();
|
|
489
479
|
if (!skipAutoDeploy) {
|
|
490
480
|
await deployMocks(hre, {
|
|
491
|
-
deployTestBed: true,
|
|
492
481
|
gasWarning: hre.config.cofhe.gasWarning ?? true,
|
|
493
482
|
mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity
|
|
494
483
|
});
|
|
@@ -574,8 +563,7 @@ extendEnvironment((hre) => {
|
|
|
574
563
|
return hre.ethers.getContractAt(aclArtifact.abi, aclAddress);
|
|
575
564
|
},
|
|
576
565
|
getMockThresholdNetwork: async () => getFixedMockContract(hre, MockThresholdNetworkArtifact2),
|
|
577
|
-
getMockZkVerifier: async () => getFixedMockContract(hre, MockZkVerifierArtifact2)
|
|
578
|
-
getTestBed: async () => getFixedMockContract(hre, TestBedArtifact2)
|
|
566
|
+
getMockZkVerifier: async () => getFixedMockContract(hre, MockZkVerifierArtifact2)
|
|
579
567
|
}
|
|
580
568
|
};
|
|
581
569
|
});
|
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/utils.ts","../src/logging.ts"],"sourcesContent":["/* eslint-disable no-empty-pattern */\n/* eslint-disable turbo/no-undeclared-env-vars */\nimport chalk from 'chalk';\nimport path from 'path';\nimport fs from 'fs';\nimport { type PublicClient, type WalletClient } from 'viem';\nimport { extendConfig, extendEnvironment, task, subtask, types } from 'hardhat/config';\nimport { TASK_TEST, TASK_NODE, TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from 'hardhat/builtin-tasks/task-names';\nimport { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';\nimport {\n type CofheClient,\n type CofheConfig,\n type CofheInputConfig,\n MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,\n} from '@cofhe/sdk';\nimport { createCofheClient, createCofheConfig } 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, type LogMocksDeploy } from './deploy.js';\nimport { mock_setLoggingEnabled, mock_withLogs } from './logging.js';\nimport { getFixedMockContract, mock_expectPlaintext } from './utils.js';\nimport { mock_getPlaintext } from './utils.js';\nimport { hardhat } from '@cofhe/sdk/chains';\nimport {\n MockThresholdNetworkArtifact,\n MockTaskManagerArtifact,\n MockZkVerifierArtifact,\n TestBedArtifact,\n type MockACL,\n type MockTaskManager,\n type MockThresholdNetwork,\n type MockZkVerifier,\n type TestBed,\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 cofhe?: {\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 * Controls deploy-mocks console output.\n * - `''` — silent, no output\n * - `'v'` — single summary line (default)\n * - `'vv'` — full per-contract deployment logs\n */\n mocksDeployVerbosity?: LogMocksDeploy;\n };\n }\n\n interface HardhatConfig {\n cofhe: {\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 mocksDeployVerbosity: LogMocksDeploy;\n };\n }\n}\n\nconst MOCK_STUBS_DIR_NAME = 'cofhe-stubs';\nconst MOCK_STUBS_FILE_NAME = 'CofheMocksImports.sol';\n\n/**\n * Returns the absolute paths of every .sol file shipped inside the\n * @cofhe/mock-contracts/contracts directory.\n */\nfunction getMockContractsSolFiles(): string[] {\n let contractsDir: string;\n try {\n const pkgJson = require.resolve('@cofhe/mock-contracts/package.json');\n contractsDir = path.join(path.dirname(pkgJson), 'contracts');\n } catch {\n contractsDir = path.join(process.cwd(), 'node_modules', '@cofhe', 'mock-contracts', 'contracts');\n }\n\n if (!fs.existsSync(contractsDir)) {\n return [];\n }\n\n return fs\n .readdirSync(contractsDir)\n .filter((f) => f.endsWith('.sol'))\n .map((f) => path.join(contractsDir, f));\n}\n\n/**\n * Generates a stub Solidity file that imports every contract from\n * @cofhe/mock-contracts/contracts. Writing it to the Hardhat cache directory\n * (which is inside the project root) means:\n * - localPathToSourceName() accepts it (no HH1007)\n * - Hardhat resolves the npm-style \"@cofhe/mock-contracts/...\" imports\n * the same way it resolves any other node_modules dependency\n * - All mock contract artifacts end up in hre.artifacts, giving Hardhat\n * full ABI knowledge so it can decode reverts and traces\n */\nfunction generateMockContractsStubContent(): string {\n const imports = getMockContractsSolFiles()\n .map((f) => `import \"@cofhe/mock-contracts/contracts/${path.basename(f)}\";`)\n .join('\\n');\n\n return [\n '// SPDX-License-Identifier: UNLICENSED',\n '// Auto-generated by @cofhe/hardhat-plugin — do not edit.',\n '// Importing mock contracts here causes Hardhat to compile them and register',\n '// their artifacts, enabling proper revert decoding during tests.',\n 'pragma solidity >=0.8.25 <0.9.0;',\n '',\n imports,\n '',\n ].join('\\n');\n}\n\nsubtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(async (taskArgs: { sourcePath?: string }, hre, runSuper) => {\n const existing: string[] = await runSuper(taskArgs);\n\n // Write the stub inside the Hardhat cache dir so that it lives within the\n // project root — a requirement of localPathToSourceName (HH1007).\n const stubDir = path.join(hre.config.paths.cache, MOCK_STUBS_DIR_NAME);\n const stubPath = path.join(stubDir, MOCK_STUBS_FILE_NAME);\n fs.mkdirSync(stubDir, { recursive: true });\n fs.writeFileSync(stubPath, generateMockContractsStubContent(), 'utf8');\n\n return [...new Set([...existing, stubPath])];\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.cofhe = {\n logMocks: userConfig.cofhe?.logMocks ?? false,\n gasWarning: userConfig.cofhe?.gasWarning ?? false,\n mocksDeployVerbosity: (userConfig.cofhe?.mocksDeployVerbosity ?? 'v') as LogMocksDeploy,\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 .setAction(async ({ deployTestBed }: DeployMocksArgs, hre) => {\n await deployMocks(hre, {\n deployTestBed: deployTestBed ?? true,\n gasWarning: hre.config.cofhe.gasWarning ?? true,\n mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity,\n });\n });\n\n// Hardhat plugin auto-deploys mocks for every hardhat test run by overriding TASK_TEST and calling deployMocks(...) before runSuper()\ntask(TASK_TEST, 'Deploy mock contracts on hardhat').setAction(async ({}, hre, runSuper) => {\n const skipAutoDeploy = (() => {\n const raw = process.env.COFHE_SKIP_MOCKS_DEPLOY ?? '';\n const normalized = raw.trim().toLowerCase();\n return normalized === '1' || normalized === 'true' || normalized === 'yes';\n })();\n\n if (!skipAutoDeploy) {\n await deployMocks(hre, {\n deployTestBed: true,\n gasWarning: hre.config.cofhe.gasWarning ?? true,\n mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity,\n });\n }\n return runSuper();\n});\n\ntask(TASK_NODE, 'Deploy mock contracts on hardhat').setAction(async ({}, hre, runSuper) => {\n const skipAutoDeploy = (() => {\n const raw = process.env.COFHE_SKIP_MOCKS_DEPLOY ?? '';\n const normalized = raw.trim().toLowerCase();\n return normalized === '1' || normalized === 'true' || normalized === 'yes';\n })();\n\n if (!skipAutoDeploy) {\n await deployMocks(hre, {\n deployTestBed: true,\n gasWarning: hre.config.cofhe.gasWarning ?? true,\n mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity,\n });\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 './consts.js';\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 cofhe: {\n /**\n * Create a CoFHE configuration for use with hre.cofhe.createClient(...)\n * @param {CofheInputConfig} config - The CoFHE input configuration\n * @returns {CofheConfig} The CoFHE configuration\n */\n createConfig: (config: CofheInputConfig) => Promise<CofheConfig>;\n /**\n * Create a CoFHE client instance\n * @param {CofheConfig} config - The CoFHE configuration (use createCofheConfig to create with Node.js defaults)\n * @returns {Promise<CofheClient>} The CoFHE client instance\n */\n createClient: (config: CofheConfig) => CofheClient;\n /**\n * Create viem clients from a Hardhat ethers signer, to be used with `cofheClient.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 client with a Hardhat ethers signer\n * @param {CofheClient} client - The CoFHE client to connect\n * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use\n * @returns {Promise<void>}\n */\n connectWithHardhatSigner: (client: CofheClient, 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 createCofheClient and connectWithHardhatSigner.\n * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use (optional - defaults to first signer)\n * @returns {Promise<CofheClient>} The CoFHE client instance\n */\n createClientWithBatteries: (signer?: HardhatEthersSigner) => Promise<CofheClient>;\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.cofhe.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 | string} ctHash - The ciphertext hash to look up\n * @returns {Promise<bigint>} The plaintext value\n */\n getPlaintext: (ctHash: bigint | string) => Promise<bigint>;\n\n /**\n * **[MOCKS ONLY]**\n *\n * Assert that a ciphertext hash represents an expected plaintext value\n * @param {bigint | string} ctHash - The ciphertext hash to check\n * @param {bigint} expectedValue - The expected plaintext value\n */\n expectPlaintext: (ctHash: bigint | string, expectedValue: bigint) => Promise<void>;\n\n /**\n * Get the MockTaskManager contract (typed via typechain)\n * @returns {Promise<MockTaskManager>} The MockTaskManager contract\n */\n getMockTaskManager: () => Promise<MockTaskManager>;\n\n /**\n * Get the MockACL contract (typed via typechain)\n * @returns {Promise<MockACL>} The MockACL contract\n */\n getMockACL: () => Promise<MockACL>;\n\n /**\n * Get the MockThresholdNetwork contract (typed via typechain)\n * @returns {Promise<MockThresholdNetwork>} The MockThresholdNetwork contract\n */\n getMockThresholdNetwork: () => Promise<MockThresholdNetwork>;\n\n /**\n * Get the MockZkVerifier contract (typed via typechain)\n * @returns {Promise<MockZkVerifier>} The MockZkVerifier contract\n */\n getMockZkVerifier: () => Promise<MockZkVerifier>;\n\n /**\n * Get the TestBed contract (typed via typechain)\n * @returns {Promise<TestBed>} The TestBed contract\n */\n getTestBed: () => Promise<TestBed>;\n };\n };\n }\n}\n\n/**\n * Builds the mocks config for the hardhat plugin.\n * Defaults `encryptDelay` to `0` so tests run without artificial wait times,\n * unless the user has explicitly provided a value.\n */\nexport function buildHardhatPluginMocksConfig(\n mocksConfig: CofheInputConfig['mocks']\n): NonNullable<CofheInputConfig['mocks']> {\n return {\n ...mocksConfig,\n encryptDelay: mocksConfig?.encryptDelay ?? 0,\n };\n}\n\nextendEnvironment((hre) => {\n hre.cofhe = {\n createConfig: async (config: CofheInputConfig) => {\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 // Set encryptDelay to 0 on hardhat to avoid waiting for delays during tests\n const configWithZkvWalletClient = {\n environment: 'hardhat' as const,\n ...config,\n mocks: buildHardhatPluginMocksConfig(config.mocks),\n _internal: {\n ...config._internal,\n zkvWalletClient,\n },\n };\n\n return createCofheConfig(configWithZkvWalletClient);\n },\n createClient: (config: CofheConfig) => {\n return createCofheClient(config);\n },\n hardhatSignerAdapter: async (signer: HardhatEthersSigner) => {\n return HardhatSignerAdapter(signer);\n },\n connectWithHardhatSigner: async (client: CofheClient, signer: HardhatEthersSigner) => {\n const { publicClient, walletClient } = await HardhatSignerAdapter(signer);\n return client.connect(publicClient, walletClient);\n },\n createClientWithBatteries: 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.cofhe.createConfig({\n environment: 'hardhat',\n supportedChains: [hardhat],\n });\n\n // Create client\n const client = hre.cofhe.createClient(config);\n\n // Connect client\n await hre.cofhe.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, { mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity, ...options });\n },\n getPlaintext: async (ctHash: bigint | string) => {\n const [signer] = await hre.ethers.getSigners();\n return mock_getPlaintext(signer.provider, ctHash);\n },\n expectPlaintext: async (ctHash: bigint | string, expectedValue: bigint) => {\n const [signer] = await hre.ethers.getSigners();\n return mock_expectPlaintext(signer.provider, ctHash, expectedValue);\n },\n getMockTaskManager: async () =>\n getFixedMockContract(hre, MockTaskManagerArtifact) as unknown as Promise<MockTaskManager>,\n getMockACL: async () => {\n const taskManager = await getFixedMockContract(hre, MockTaskManagerArtifact);\n const aclAddress = await taskManager.acl();\n const aclArtifact = await hre.artifacts.readArtifact('MockACL');\n return hre.ethers.getContractAt(aclArtifact.abi, aclAddress) as unknown as MockACL;\n },\n getMockThresholdNetwork: async () =>\n getFixedMockContract(hre, MockThresholdNetworkArtifact) as unknown as Promise<MockThresholdNetwork>,\n getMockZkVerifier: async () =>\n getFixedMockContract(hre, MockZkVerifierArtifact) as unknown as Promise<MockZkVerifier>,\n getTestBed: async () => getFixedMockContract(hre, TestBedArtifact) as unknown as Promise<TestBed>,\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","import { type HardhatRuntimeEnvironment } from 'hardhat/types';\nimport chalk from 'chalk';\nimport { Contract, Wallet } from 'ethers';\n\nimport {\n MockTaskManagerArtifact,\n MockACLArtifact,\n MockZkVerifierArtifact,\n MockThresholdNetworkArtifact,\n TestBedArtifact,\n} from '@cofhe/mock-contracts';\n\nimport {\n TASK_MANAGER_ADDRESS,\n MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,\n MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY,\n MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY,\n} from '@cofhe/sdk';\nimport { deployMockContractFromArtifact } from './utils';\n\n// Deployment\n\n/**\n * Controls deploy-mocks console output.\n * - `''` — silent, no output\n * - `'v'` — single summary line (default)\n * - `'vv'` — full per-contract deployment logs\n */\nexport type LogMocksDeploy = '' | 'v' | 'vv';\n\nexport type DeployMocksArgs = {\n deployTestBed?: boolean;\n gasWarning?: boolean;\n mocksDeployVerbosity?: LogMocksDeploy;\n};\n\nexport const deployMocks = async (\n hre: HardhatRuntimeEnvironment,\n options: DeployMocksArgs = {\n deployTestBed: true,\n gasWarning: true,\n mocksDeployVerbosity: 'v',\n }\n) => {\n verbosity = options.mocksDeployVerbosity ?? 'v';\n\n // Check if network is Hardhat, if not log skip message and return\n const isHardhat = await getIsHardhat(hre);\n if (!isHardhat) {\n log('v', `cofhe-hardhat-plugin - deploy mocks - skipped on non-hardhat network ${hre.network.name}`, 0);\n return;\n }\n\n // Compile mock contracts before deploying so that hre.artifacts.readArtifact()\n // resolves correctly and Hardhat can decode reverts against these contracts.\n // The subtask override in index.ts adds the mock-contracts source files to the\n // compilation pipeline, so they are compiled alongside the project's own contracts.\n // Calling compile here is safe: Hardhat caches results, so a second compile\n // triggered by TASK_TEST's runSuper() will be a fast no-op.\n await hre.run('compile', { quiet: true });\n\n log('vv', chalk.bold('cofhe-hardhat-plugin :: deploy mocks'), 0);\n\n // Deploy mock contracts\n const taskManager = await deployMockTaskManager(hre);\n logDeployment('MockTaskManager', await taskManager.getAddress());\n\n const acl = await deployMockACL(hre);\n logDeployment('MockACL', await acl.getAddress());\n\n await linkTaskManagerAndACL(taskManager, acl);\n log('vv', 'ACL address set in TaskManager', 2);\n\n await setVerifierSigner(taskManager);\n log('vv', 'Verifier signer set', 2);\n\n await setDecryptResultSigner(taskManager);\n log('vv', 'Decrypt result signer set', 2);\n\n await fundZkVerifierSigner(hre);\n log('vv', `ZkVerifier signer (${MOCKS_ZK_VERIFIER_SIGNER_ADDRESS}) funded`, 1);\n\n const zkVerifierSignerBalance = await getZkVerifierSignerBalance(hre);\n log('vv', `ETH balance: ${zkVerifierSignerBalance.toString()}`, 2);\n\n const zkVerifier = await deployMockZkVerifier(hre);\n logDeployment('MockZkVerifier', await zkVerifier.getAddress());\n\n const thresholdNetwork = await deployMockThresholdNetwork(hre, acl);\n logDeployment('MockThresholdNetwork', await thresholdNetwork.getAddress());\n\n if (options.deployTestBed) {\n const testBed = await deployTestBedContract(hre);\n logDeployment('TestBed', await testBed.getAddress());\n }\n\n log('v', chalk.bold('cofhe-hardhat-plugin :: mocks deployed'), 0);\n\n if (options.gasWarning) {\n logEmpty('v');\n logWarning(\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.gasWarning: false' in your hardhat config)\",\n 0\n );\n }\n\n logEmpty('v');\n};\n\n// Network\n\nconst getIsHardhat = async (hre: HardhatRuntimeEnvironment) => {\n return hre.network.name === 'hardhat';\n};\n\nconst deployMockTaskManager = async (hre: HardhatRuntimeEnvironment) => {\n const [signer] = await hre.ethers.getSigners();\n\n // Deploy MockTaskManager\n const taskManager = await deployMockContractFromArtifact(hre, MockTaskManagerArtifact);\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 deployMockContractFromArtifact(hre, MockACLArtifact);\n\n // Check if ACL exists\n const exists = await acl.exists();\n if (!exists) {\n throw new Error('MockACL does not exist');\n }\n\n return acl;\n};\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\nconst getZkVerifierSignerBalance = async (hre: HardhatRuntimeEnvironment) => {\n return hre.ethers.provider.getBalance(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);\n};\n\nconst linkTaskManagerAndACL = async (taskManager: Contract, acl: Contract) => {\n const aclAddress = await acl.getAddress();\n const linkAclTx = await taskManager.setACLContract(aclAddress);\n await linkAclTx.wait();\n};\n\nconst setVerifierSigner = async (taskManager: Contract) => {\n const signer = new Wallet(MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY);\n const setSignerTx = await taskManager.setVerifierSigner(signer.address);\n await setSignerTx.wait();\n};\n\nconst setDecryptResultSigner = async (taskManager: Contract) => {\n const signer = new Wallet(MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY);\n const setSignerTx = await taskManager.setDecryptResultSigner(signer.address);\n await setSignerTx.wait();\n};\n\nconst deployMockZkVerifier = async (hre: HardhatRuntimeEnvironment) => {\n const zkVerifier = await deployMockContractFromArtifact(hre, MockZkVerifierArtifact);\n\n const zkVerifierExists = await zkVerifier.exists();\n if (!zkVerifierExists) {\n throw new Error('MockZkVerifier does not exist');\n }\n\n return zkVerifier;\n};\n\nconst deployMockThresholdNetwork = async (hre: HardhatRuntimeEnvironment, acl: Contract) => {\n const thresholdNetwork = await deployMockContractFromArtifact(hre, MockThresholdNetworkArtifact);\n\n // Initialize MockThresholdNetwork\n const initTx = await thresholdNetwork.initialize(TASK_MANAGER_ADDRESS, await acl.getAddress());\n await initTx.wait();\n\n // Check if MockThresholdNetwork exists\n const exists = await thresholdNetwork.exists();\n if (!exists) {\n throw new Error('MockThresholdNetwork does not exist');\n }\n\n return thresholdNetwork;\n};\n\nconst deployTestBedContract = async (hre: HardhatRuntimeEnvironment) => {\n return deployMockContractFromArtifact(hre, TestBedArtifact);\n};\n\n// Logging\n\nlet verbosity: LogMocksDeploy = 'v';\n\n/**\n * Emit a green ✓ line at `minVerbosity` or above.\n * - `minVerbosity = 'v'` → prints for both 'v' and 'vv'\n * - `minVerbosity = 'vv'` → prints only for 'vv'\n */\nconst log = (minVerbosity: 'v' | 'vv', message: string, indent = 1) => {\n if (verbosity === '') return;\n if (minVerbosity === 'vv' && verbosity !== 'vv') return;\n console.log(chalk.green(`${' '.repeat(indent)}✓ ${message}`));\n};\n\nconst logEmpty = (minVerbosity: 'v' | 'vv' = 'v') => {\n if (verbosity === '') return;\n if (minVerbosity === 'vv' && verbosity !== 'vv') return;\n console.log('');\n};\n\nconst logWarning = (message: string, indent = 1) => {\n if (verbosity === '') return;\n console.log(chalk.bold(chalk.yellow(`${' '.repeat(indent)}⚠ NOTE:`)), message);\n};\n\nconst logDeployment = (contractName: string, address: string) => {\n if (verbosity !== 'vv') return;\n const paddedName = `${contractName} deployed`.padEnd(36);\n console.log(chalk.green(` ✓ ${paddedName} ${chalk.bold(address)}`));\n};\n","import { TASK_MANAGER_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS } from '@cofhe/sdk';\nimport { expect } from 'chai';\nimport { Contract, ethers } from 'ethers';\nimport { type HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';\nimport type { MockArtifact } from '@cofhe/mock-contracts';\nimport type { HardhatRuntimeEnvironment } from 'hardhat/types';\n\n// Deployment utils\n\n/// Deploys a mock contract from a pre-built artifact from the mock-contracts package.\n/// ABI and bytecode are sourced from Hardhat's artifact registry (populated during compilation)\n/// so that Hardhat can decode reverts and trace calls against these contracts.\n/// If the mock contract should be deployed to a fixed address, `hardhat_setCode` is used.\n/// Otherwise, ethers.js deploys it to a normal address.\nexport const deployMockContractFromArtifact = async (hre: HardhatRuntimeEnvironment, artifact: MockArtifact) => {\n const hardhatArtifact = await hre.artifacts.readArtifact(artifact.contractName);\n\n if (artifact.isFixed) {\n await hre.network.provider.send('hardhat_setCode', [artifact.fixedAddress, hardhatArtifact.deployedBytecode]);\n return hre.ethers.getContractAt(hardhatArtifact.abi, artifact.fixedAddress);\n }\n\n const [signer] = await hre.ethers.getSigners();\n const factory = new hre.ethers.ContractFactory(hardhatArtifact.abi, hardhatArtifact.bytecode, signer);\n const contract = await factory.deploy();\n await contract.waitForDeployment();\n return contract as Contract;\n};\n\nexport const getFixedMockContract = async (hre: HardhatRuntimeEnvironment, artifact: MockArtifact) => {\n if (!artifact.isFixed) {\n throw new Error('Artifact is not fixed');\n }\n const hardhatArtifact = await hre.artifacts.readArtifact(artifact.contractName);\n return hre.ethers.getContractAt(hardhatArtifact.abi, artifact.fixedAddress);\n};\n\n// Testing utils\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 (\n provider: HardhatEthersProvider | ethers.JsonRpcProvider,\n ctHash: bigint | string\n) => {\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(BigInt(ctHash));\n\n return plaintext;\n};\n\nexport const mock_getPlaintextExists = async (\n provider: HardhatEthersProvider | ethers.JsonRpcProvider,\n ctHash: bigint | string\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(BigInt(ctHash));\n\n return plaintextExists;\n};\n\nexport const mock_expectPlaintext = async (\n provider: HardhatEthersProvider | ethers.JsonRpcProvider,\n ctHash: bigint | string,\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 chalk from 'chalk';\nimport { type HardhatRuntimeEnvironment } from 'hardhat/types';\nimport { getFixedMockContract } from './utils';\nimport { MockTaskManagerArtifact } from '@cofhe/mock-contracts';\n\nconst getLoggingEnabled = async (hre: HardhatRuntimeEnvironment): Promise<boolean> => {\n const taskManager = await getFixedMockContract(hre, MockTaskManagerArtifact);\n return taskManager.logOps();\n};\n\nconst setLoggingEnabled = async (hre: HardhatRuntimeEnvironment, enabled: boolean) => {\n const taskManager = await getFixedMockContract(hre, MockTaskManagerArtifact);\n const tx = await taskManager.setLogOps(enabled);\n await tx.wait();\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 try {\n await closure();\n } finally {\n printLogsBlockEnd();\n\n // If logs were disabled, disable them again\n if (!initiallyEnabled) {\n await setLoggingEnabled(hre, false);\n }\n }\n};\n"],"mappings":";;;;;;;;;AAEA,OAAOA,YAAW;AAClB,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,OAAqD;AACrD,SAAS,cAAc,mBAAmB,MAAM,SAAS,aAAa;AACtE,SAAS,WAAW,WAAW,8CAA8C;AAC7E,OAAoC;AACpC;AAAA,EAIE,oCAAAC;AAAA,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,KAAK,KAAK;AAAA,MAC1C;AAAA,MACA,aAAa,OAAO,UAA2B,CAAC,MAAM;AACpD,eAAO,YAAY,KAAK,EAAE,sBAAsB,IAAI,OAAO,MAAM,sBAAsB,GAAG,QAAQ,CAAC;AAAA,MACrG;AAAA,MACA,cAAc,OAAO,WAA4B;AAC/C,cAAM,CAAC,MAAM,IAAI,MAAM,IAAI,OAAO,WAAW;AAC7C,eAAO,kBAAkB,OAAO,UAAU,MAAM;AAAA,MAClD;AAAA,MACA,iBAAiB,OAAO,QAAyB,kBAA0B;AACzE,cAAM,CAAC,MAAM,IAAI,MAAM,IAAI,OAAO,WAAW;AAC7C,eAAO,qBAAqB,OAAO,UAAU,QAAQ,aAAa;AAAA,MACpE;AAAA,MACA,oBAAoB,YAClB,qBAAqB,KAAKC,wBAAuB;AAAA,MACnD,YAAY,YAAY;AACtB,cAAM,cAAc,MAAM,qBAAqB,KAAKA,wBAAuB;AAC3E,cAAM,aAAa,MAAM,YAAY,IAAI;AACzC,cAAM,cAAc,MAAM,IAAI,UAAU,aAAa,SAAS;AAC9D,eAAO,IAAI,OAAO,cAAc,YAAY,KAAK,UAAU;AAAA,MAC7D;AAAA,MACA,yBAAyB,YACvB,qBAAqB,KAAKC,6BAA4B;AAAA,MACxD,mBAAmB,YACjB,qBAAqB,KAAKC,uBAAsB;AAAA,MAClD,YAAY,YAAY,qBAAqB,KAAKC,gBAAe;AAAA,IACnE;AAAA,EACF;AACF,CAAC;","names":["chalk","MOCKS_ZK_VERIFIER_SIGNER_ADDRESS","TASK_MANAGER_ADDRESS","TASK_MANAGER_ADDRESS","chalk","MockTaskManagerArtifact","chalk","MockThresholdNetworkArtifact","MockTaskManagerArtifact","MockZkVerifierArtifact","TestBedArtifact","chalk","MOCKS_ZK_VERIFIER_SIGNER_ADDRESS","MockTaskManagerArtifact","MockThresholdNetworkArtifact","MockZkVerifierArtifact","TestBedArtifact"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/fund.ts","../src/consts.ts","../src/deploy.ts","../src/utils.ts","../src/logging.ts"],"sourcesContent":["/* eslint-disable no-empty-pattern */\n/* eslint-disable turbo/no-undeclared-env-vars */\nimport chalk from 'chalk';\nimport path from 'path';\nimport fs from 'fs';\nimport { type PublicClient, type WalletClient } from 'viem';\nimport { extendConfig, extendEnvironment, task, subtask, types } from 'hardhat/config';\nimport { TASK_TEST, TASK_NODE, TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from 'hardhat/builtin-tasks/task-names';\nimport { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';\nimport {\n type CofheClient,\n type CofheConfig,\n type CofheInputConfig,\n MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,\n} from '@cofhe/sdk';\nimport { createCofheClient, createCofheConfig } 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, type LogMocksDeploy } from './deploy.js';\nimport { mock_setLoggingEnabled, mock_withLogs } from './logging.js';\nimport { getFixedMockContract, mock_expectPlaintext } from './utils.js';\nimport { mock_getPlaintext } from './utils.js';\nimport { hardhat } from '@cofhe/sdk/chains';\nimport {\n MockThresholdNetworkArtifact,\n MockTaskManagerArtifact,\n MockZkVerifierArtifact,\n type MockACL,\n type MockTaskManager,\n type MockThresholdNetwork,\n type MockZkVerifier,\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 cofhe?: {\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 * Controls deploy-mocks console output.\n * - `''` — silent, no output\n * - `'v'` — single summary line (default)\n * - `'vv'` — full per-contract deployment logs\n */\n mocksDeployVerbosity?: LogMocksDeploy;\n };\n }\n\n interface HardhatConfig {\n cofhe: {\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 mocksDeployVerbosity: LogMocksDeploy;\n };\n }\n}\n\nconst MOCK_STUBS_DIR_NAME = 'cofhe-stubs';\nconst MOCK_STUBS_FILE_NAME = 'CofheMocksImports.sol';\n\n/**\n * Returns the absolute paths of every .sol file shipped inside the\n * @cofhe/mock-contracts/contracts directory.\n */\nfunction getMockContractsSolFiles(): string[] {\n let contractsDir: string;\n try {\n const pkgJson = require.resolve('@cofhe/mock-contracts/package.json');\n contractsDir = path.join(path.dirname(pkgJson), 'contracts');\n } catch {\n contractsDir = path.join(process.cwd(), 'node_modules', '@cofhe', 'mock-contracts', 'contracts');\n }\n\n if (!fs.existsSync(contractsDir)) {\n return [];\n }\n\n return fs\n .readdirSync(contractsDir)\n .filter((f) => f.endsWith('.sol'))\n .map((f) => path.join(contractsDir, f));\n}\n\n/**\n * Generates a stub Solidity file that imports every contract from\n * @cofhe/mock-contracts/contracts. Writing it to the Hardhat cache directory\n * (which is inside the project root) means:\n * - localPathToSourceName() accepts it (no HH1007)\n * - Hardhat resolves the npm-style \"@cofhe/mock-contracts/...\" imports\n * the same way it resolves any other node_modules dependency\n * - All mock contract artifacts end up in hre.artifacts, giving Hardhat\n * full ABI knowledge so it can decode reverts and traces\n */\nfunction generateMockContractsStubContent(): string {\n const imports = getMockContractsSolFiles()\n .map((f) => `import \"@cofhe/mock-contracts/contracts/${path.basename(f)}\";`)\n .join('\\n');\n\n return [\n '// SPDX-License-Identifier: UNLICENSED',\n '// Auto-generated by @cofhe/hardhat-plugin — do not edit.',\n '// Importing mock contracts here causes Hardhat to compile them and register',\n '// their artifacts, enabling proper revert decoding during tests.',\n 'pragma solidity >=0.8.25 <0.9.0;',\n '',\n imports,\n '',\n ].join('\\n');\n}\n\nsubtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(async (taskArgs: { sourcePath?: string }, hre, runSuper) => {\n const existing: string[] = await runSuper(taskArgs);\n\n // Write the stub inside the Hardhat cache dir so that it lives within the\n // project root — a requirement of localPathToSourceName (HH1007).\n const stubDir = path.join(hre.config.paths.cache, MOCK_STUBS_DIR_NAME);\n const stubPath = path.join(stubDir, MOCK_STUBS_FILE_NAME);\n fs.mkdirSync(stubDir, { recursive: true });\n fs.writeFileSync(stubPath, generateMockContractsStubContent(), 'utf8');\n\n return [...new Set([...existing, stubPath])];\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.cofhe = {\n logMocks: userConfig.cofhe?.logMocks ?? false,\n gasWarning: userConfig.cofhe?.gasWarning ?? false,\n mocksDeployVerbosity: (userConfig.cofhe?.mocksDeployVerbosity ?? 'v') as LogMocksDeploy,\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').setAction(\n async ({}: DeployMocksArgs, hre) => {\n await deployMocks(hre, {\n gasWarning: hre.config.cofhe.gasWarning ?? true,\n mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity,\n });\n }\n);\n\n// Hardhat plugin auto-deploys mocks for every hardhat test run by overriding TASK_TEST and calling deployMocks(...) before runSuper()\ntask(TASK_TEST, 'Deploy mock contracts on hardhat').setAction(async ({}, hre, runSuper) => {\n const skipAutoDeploy = (() => {\n const raw = process.env.COFHE_SKIP_MOCKS_DEPLOY ?? '';\n const normalized = raw.trim().toLowerCase();\n return normalized === '1' || normalized === 'true' || normalized === 'yes';\n })();\n\n if (!skipAutoDeploy) {\n await deployMocks(hre, {\n gasWarning: hre.config.cofhe.gasWarning ?? true,\n mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity,\n });\n }\n return runSuper();\n});\n\ntask(TASK_NODE, 'Deploy mock contracts on hardhat').setAction(async ({}, hre, runSuper) => {\n const skipAutoDeploy = (() => {\n const raw = process.env.COFHE_SKIP_MOCKS_DEPLOY ?? '';\n const normalized = raw.trim().toLowerCase();\n return normalized === '1' || normalized === 'true' || normalized === 'yes';\n })();\n\n if (!skipAutoDeploy) {\n await deployMocks(hre, {\n gasWarning: hre.config.cofhe.gasWarning ?? true,\n mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity,\n });\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 './consts.js';\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 cofhe: {\n /**\n * Create a CoFHE configuration for use with hre.cofhe.createClient(...)\n * @param {CofheInputConfig} config - The CoFHE input configuration\n * @returns {CofheConfig} The CoFHE configuration\n */\n createConfig: (config: CofheInputConfig) => Promise<CofheConfig>;\n /**\n * Create a CoFHE client instance\n * @param {CofheConfig} config - The CoFHE configuration (use createCofheConfig to create with Node.js defaults)\n * @returns {Promise<CofheClient>} The CoFHE client instance\n */\n createClient: (config: CofheConfig) => CofheClient;\n /**\n * Create viem clients from a Hardhat ethers signer, to be used with `cofheClient.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 client with a Hardhat ethers signer\n * @param {CofheClient} client - The CoFHE client to connect\n * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use\n * @returns {Promise<void>}\n */\n connectWithHardhatSigner: (client: CofheClient, 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 createCofheClient and connectWithHardhatSigner.\n * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use (optional - defaults to first signer)\n * @returns {Promise<CofheClient>} The CoFHE client instance\n */\n createClientWithBatteries: (signer?: HardhatEthersSigner) => Promise<CofheClient>;\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.cofhe.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.\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 | string} ctHash - The ciphertext hash to look up\n * @returns {Promise<bigint>} The plaintext value\n */\n getPlaintext: (ctHash: bigint | string) => Promise<bigint>;\n\n /**\n * **[MOCKS ONLY]**\n *\n * Assert that a ciphertext hash represents an expected plaintext value\n * @param {bigint | string} ctHash - The ciphertext hash to check\n * @param {bigint} expectedValue - The expected plaintext value\n */\n expectPlaintext: (ctHash: bigint | string, expectedValue: bigint) => Promise<void>;\n\n /**\n * Get the MockTaskManager contract (typed via typechain)\n * @returns {Promise<MockTaskManager>} The MockTaskManager contract\n */\n getMockTaskManager: () => Promise<MockTaskManager>;\n\n /**\n * Get the MockACL contract (typed via typechain)\n * @returns {Promise<MockACL>} The MockACL contract\n */\n getMockACL: () => Promise<MockACL>;\n\n /**\n * Get the MockThresholdNetwork contract (typed via typechain)\n * @returns {Promise<MockThresholdNetwork>} The MockThresholdNetwork contract\n */\n getMockThresholdNetwork: () => Promise<MockThresholdNetwork>;\n\n /**\n * Get the MockZkVerifier contract (typed via typechain)\n * @returns {Promise<MockZkVerifier>} The MockZkVerifier contract\n */\n getMockZkVerifier: () => Promise<MockZkVerifier>;\n };\n };\n }\n}\n\n/**\n * Builds the mocks config for the hardhat plugin.\n * Defaults `encryptDelay` to `0` so tests run without artificial wait times,\n * unless the user has explicitly provided a value.\n */\nexport function buildHardhatPluginMocksConfig(\n mocksConfig: CofheInputConfig['mocks']\n): NonNullable<CofheInputConfig['mocks']> {\n return {\n ...mocksConfig,\n encryptDelay: mocksConfig?.encryptDelay ?? 0,\n };\n}\n\nextendEnvironment((hre) => {\n hre.cofhe = {\n createConfig: async (config: CofheInputConfig) => {\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 // Set encryptDelay to 0 on hardhat to avoid waiting for delays during tests\n const configWithZkvWalletClient = {\n environment: 'hardhat' as const,\n ...config,\n mocks: buildHardhatPluginMocksConfig(config.mocks),\n _internal: {\n ...config._internal,\n zkvWalletClient,\n },\n };\n\n return createCofheConfig(configWithZkvWalletClient);\n },\n createClient: (config: CofheConfig) => {\n return createCofheClient(config);\n },\n hardhatSignerAdapter: async (signer: HardhatEthersSigner) => {\n return HardhatSignerAdapter(signer);\n },\n connectWithHardhatSigner: async (client: CofheClient, signer: HardhatEthersSigner) => {\n const { publicClient, walletClient } = await HardhatSignerAdapter(signer);\n return client.connect(publicClient, walletClient);\n },\n createClientWithBatteries: 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.cofhe.createConfig({\n environment: 'hardhat',\n supportedChains: [hardhat],\n });\n\n // Create client\n const client = hre.cofhe.createClient(config);\n\n // Connect client\n await hre.cofhe.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, { mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity, ...options });\n },\n getPlaintext: async (ctHash: bigint | string) => {\n const [signer] = await hre.ethers.getSigners();\n return mock_getPlaintext(signer.provider, ctHash);\n },\n expectPlaintext: async (ctHash: bigint | string, expectedValue: bigint) => {\n const [signer] = await hre.ethers.getSigners();\n return mock_expectPlaintext(signer.provider, ctHash, expectedValue);\n },\n getMockTaskManager: async () =>\n getFixedMockContract(hre, MockTaskManagerArtifact) as unknown as Promise<MockTaskManager>,\n getMockACL: async () => {\n const taskManager = await getFixedMockContract(hre, MockTaskManagerArtifact);\n const aclAddress = await taskManager.acl();\n const aclArtifact = await hre.artifacts.readArtifact('MockACL');\n return hre.ethers.getContractAt(aclArtifact.abi, aclAddress) as unknown as MockACL;\n },\n getMockThresholdNetwork: async () =>\n getFixedMockContract(hre, MockThresholdNetworkArtifact) as unknown as Promise<MockThresholdNetwork>,\n getMockZkVerifier: async () =>\n getFixedMockContract(hre, MockZkVerifierArtifact) as unknown as Promise<MockZkVerifier>,\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","import { type HardhatRuntimeEnvironment } from 'hardhat/types';\nimport chalk from 'chalk';\nimport { Contract, Wallet } from 'ethers';\n\nimport {\n MockTaskManagerArtifact,\n MockACLArtifact,\n MockZkVerifierArtifact,\n MockThresholdNetworkArtifact,\n} from '@cofhe/mock-contracts';\n\nimport {\n TASK_MANAGER_ADDRESS,\n MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,\n MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY,\n MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY,\n} from '@cofhe/sdk';\nimport { deployMockContractFromArtifact } from './utils';\n\n// Deployment\n\n/**\n * Controls deploy-mocks console output.\n * - `''` — silent, no output\n * - `'v'` — single summary line (default)\n * - `'vv'` — full per-contract deployment logs\n */\nexport type LogMocksDeploy = '' | 'v' | 'vv';\n\nexport type DeployMocksArgs = {\n gasWarning?: boolean;\n mocksDeployVerbosity?: LogMocksDeploy;\n};\n\nexport const deployMocks = async (\n hre: HardhatRuntimeEnvironment,\n options: DeployMocksArgs = {\n gasWarning: true,\n mocksDeployVerbosity: 'v',\n }\n) => {\n verbosity = options.mocksDeployVerbosity ?? 'v';\n\n // Check if network is Hardhat, if not log skip message and return\n const isHardhat = await getIsHardhat(hre);\n if (!isHardhat) {\n log('v', `cofhe-hardhat-plugin - deploy mocks - skipped on non-hardhat network ${hre.network.name}`, 0);\n return;\n }\n\n // Compile mock contracts before deploying so that hre.artifacts.readArtifact()\n // resolves correctly and Hardhat can decode reverts against these contracts.\n // The subtask override in index.ts adds the mock-contracts source files to the\n // compilation pipeline, so they are compiled alongside the project's own contracts.\n // Calling compile here is safe: Hardhat caches results, so a second compile\n // triggered by TASK_TEST's runSuper() will be a fast no-op.\n await hre.run('compile', { quiet: true });\n\n log('vv', chalk.bold('cofhe-hardhat-plugin :: deploy mocks'), 0);\n\n // Deploy mock contracts\n const taskManager = await deployMockTaskManager(hre);\n logDeployment('MockTaskManager', await taskManager.getAddress());\n\n const acl = await deployMockACL(hre);\n logDeployment('MockACL', await acl.getAddress());\n\n await linkTaskManagerAndACL(taskManager, acl);\n log('vv', 'ACL address set in TaskManager', 2);\n\n await setVerifierSigner(taskManager);\n log('vv', 'Verifier signer set', 2);\n\n await setDecryptResultSigner(taskManager);\n log('vv', 'Decrypt result signer set', 2);\n\n await fundZkVerifierSigner(hre);\n log('vv', `ZkVerifier signer (${MOCKS_ZK_VERIFIER_SIGNER_ADDRESS}) funded`, 1);\n\n const zkVerifierSignerBalance = await getZkVerifierSignerBalance(hre);\n log('vv', `ETH balance: ${zkVerifierSignerBalance.toString()}`, 2);\n\n const zkVerifier = await deployMockZkVerifier(hre);\n logDeployment('MockZkVerifier', await zkVerifier.getAddress());\n\n const thresholdNetwork = await deployMockThresholdNetwork(hre, acl);\n logDeployment('MockThresholdNetwork', await thresholdNetwork.getAddress());\n\n log('v', chalk.bold('cofhe-hardhat-plugin :: mocks deployed'), 0);\n\n if (options.gasWarning) {\n logEmpty('v');\n logWarning(\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.gasWarning: false' in your hardhat config)\",\n 0\n );\n }\n\n logEmpty('v');\n};\n\n// Network\n\nconst getIsHardhat = async (hre: HardhatRuntimeEnvironment) => {\n return hre.network.name === 'hardhat';\n};\n\nconst deployMockTaskManager = async (hre: HardhatRuntimeEnvironment) => {\n const [signer] = await hre.ethers.getSigners();\n\n // Deploy MockTaskManager\n const taskManager = await deployMockContractFromArtifact(hre, MockTaskManagerArtifact);\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 deployMockContractFromArtifact(hre, MockACLArtifact);\n\n // Check if ACL exists\n const exists = await acl.exists();\n if (!exists) {\n throw new Error('MockACL does not exist');\n }\n\n return acl;\n};\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\nconst getZkVerifierSignerBalance = async (hre: HardhatRuntimeEnvironment) => {\n return hre.ethers.provider.getBalance(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);\n};\n\nconst linkTaskManagerAndACL = async (taskManager: Contract, acl: Contract) => {\n const aclAddress = await acl.getAddress();\n const linkAclTx = await taskManager.setACLContract(aclAddress);\n await linkAclTx.wait();\n};\n\nconst setVerifierSigner = async (taskManager: Contract) => {\n const signer = new Wallet(MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY);\n const setSignerTx = await taskManager.setVerifierSigner(signer.address);\n await setSignerTx.wait();\n};\n\nconst setDecryptResultSigner = async (taskManager: Contract) => {\n const signer = new Wallet(MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY);\n const setSignerTx = await taskManager.setDecryptResultSigner(signer.address);\n await setSignerTx.wait();\n};\n\nconst deployMockZkVerifier = async (hre: HardhatRuntimeEnvironment) => {\n const zkVerifier = await deployMockContractFromArtifact(hre, MockZkVerifierArtifact);\n\n const zkVerifierExists = await zkVerifier.exists();\n if (!zkVerifierExists) {\n throw new Error('MockZkVerifier does not exist');\n }\n\n return zkVerifier;\n};\n\nconst deployMockThresholdNetwork = async (hre: HardhatRuntimeEnvironment, acl: Contract) => {\n const thresholdNetwork = await deployMockContractFromArtifact(hre, MockThresholdNetworkArtifact);\n\n // Initialize MockThresholdNetwork\n const initTx = await thresholdNetwork.initialize(TASK_MANAGER_ADDRESS, await acl.getAddress());\n await initTx.wait();\n\n // Check if MockThresholdNetwork exists\n const exists = await thresholdNetwork.exists();\n if (!exists) {\n throw new Error('MockThresholdNetwork does not exist');\n }\n\n return thresholdNetwork;\n};\n\n// Logging\n\nlet verbosity: LogMocksDeploy = 'v';\n\n/**\n * Emit a green ✓ line at `minVerbosity` or above.\n * - `minVerbosity = 'v'` → prints for both 'v' and 'vv'\n * - `minVerbosity = 'vv'` → prints only for 'vv'\n */\nconst log = (minVerbosity: 'v' | 'vv', message: string, indent = 1) => {\n if (verbosity === '') return;\n if (minVerbosity === 'vv' && verbosity !== 'vv') return;\n console.log(chalk.green(`${' '.repeat(indent)}✓ ${message}`));\n};\n\nconst logEmpty = (minVerbosity: 'v' | 'vv' = 'v') => {\n if (verbosity === '') return;\n if (minVerbosity === 'vv' && verbosity !== 'vv') return;\n console.log('');\n};\n\nconst logWarning = (message: string, indent = 1) => {\n if (verbosity === '') return;\n console.log(chalk.bold(chalk.yellow(`${' '.repeat(indent)}⚠ NOTE:`)), message);\n};\n\nconst logDeployment = (contractName: string, address: string) => {\n if (verbosity !== 'vv') return;\n const paddedName = `${contractName} deployed`.padEnd(36);\n console.log(chalk.green(` ✓ ${paddedName} ${chalk.bold(address)}`));\n};\n","import { TASK_MANAGER_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS } from '@cofhe/sdk';\nimport { expect } from 'chai';\nimport { Contract, ethers } from 'ethers';\nimport { type HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';\nimport type { MockArtifact } from '@cofhe/mock-contracts';\nimport type { HardhatRuntimeEnvironment } from 'hardhat/types';\n\n// Deployment utils\n\n/// Deploys a mock contract from a pre-built artifact from the mock-contracts package.\n/// ABI and bytecode are sourced from Hardhat's artifact registry (populated during compilation)\n/// so that Hardhat can decode reverts and trace calls against these contracts.\n/// If the mock contract should be deployed to a fixed address, `hardhat_setCode` is used.\n/// Otherwise, ethers.js deploys it to a normal address.\nexport const deployMockContractFromArtifact = async (hre: HardhatRuntimeEnvironment, artifact: MockArtifact) => {\n const hardhatArtifact = await hre.artifacts.readArtifact(artifact.contractName);\n\n if (artifact.isFixed) {\n await hre.network.provider.send('hardhat_setCode', [artifact.fixedAddress, hardhatArtifact.deployedBytecode]);\n return hre.ethers.getContractAt(hardhatArtifact.abi, artifact.fixedAddress);\n }\n\n const [signer] = await hre.ethers.getSigners();\n const factory = new hre.ethers.ContractFactory(hardhatArtifact.abi, hardhatArtifact.bytecode, signer);\n const contract = await factory.deploy();\n await contract.waitForDeployment();\n return contract as Contract;\n};\n\nexport const getFixedMockContract = async (hre: HardhatRuntimeEnvironment, artifact: MockArtifact) => {\n if (!artifact.isFixed) {\n throw new Error('Artifact is not fixed');\n }\n const hardhatArtifact = await hre.artifacts.readArtifact(artifact.contractName);\n return hre.ethers.getContractAt(hardhatArtifact.abi, artifact.fixedAddress);\n};\n\n// Testing utils\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 (\n provider: HardhatEthersProvider | ethers.JsonRpcProvider,\n ctHash: bigint | string\n) => {\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(BigInt(ctHash));\n\n return plaintext;\n};\n\nexport const mock_getPlaintextExists = async (\n provider: HardhatEthersProvider | ethers.JsonRpcProvider,\n ctHash: bigint | string\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(BigInt(ctHash));\n\n return plaintextExists;\n};\n\nexport const mock_expectPlaintext = async (\n provider: HardhatEthersProvider | ethers.JsonRpcProvider,\n ctHash: bigint | string,\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 chalk from 'chalk';\nimport { type HardhatRuntimeEnvironment } from 'hardhat/types';\nimport { getFixedMockContract } from './utils';\nimport { MockTaskManagerArtifact } from '@cofhe/mock-contracts';\n\nconst getLoggingEnabled = async (hre: HardhatRuntimeEnvironment): Promise<boolean> => {\n const taskManager = await getFixedMockContract(hre, MockTaskManagerArtifact);\n return taskManager.logOps();\n};\n\nconst setLoggingEnabled = async (hre: HardhatRuntimeEnvironment, enabled: boolean) => {\n const taskManager = await getFixedMockContract(hre, MockTaskManagerArtifact);\n const tx = await taskManager.setLogOps(enabled);\n await tx.wait();\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 try {\n await closure();\n } finally {\n printLogsBlockEnd();\n\n // If logs were disabled, disable them again\n if (!initiallyEnabled) {\n await setLoggingEnabled(hre, false);\n }\n }\n};\n"],"mappings":";;;;;;;;;AAEA,OAAOA,YAAW;AAClB,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,OAAqD;AACrD,SAAS,cAAc,mBAAmB,MAAM,SAAS,aAAa;AACtE,SAAS,WAAW,WAAW,8CAA8C;AAC7E,OAAoC;AACpC;AAAA,EAIE,oCAAAC;AAAA,OACK;AACP,SAAS,mBAAmB,yBAAyB;AACrD,SAAS,4BAA4B;;;ACfrC,OAA+C;AAC/C,OAAO;AASP,eAAsB,sBAAsB,KAAgC,WAAmB,SAAiB,MAAM;AAEpH,QAAM,aACJ,QAAQ,IAAI,sBAAsB;AACpC,MAAI,CAAC,YAAY;AACf,YAAQ,MAAM,wDAAwD;AACtE,WAAO;AAAA,EACT;AAEA,MAAI;AAEF,UAAM,SAAS,IAAI,IAAI,OAAO,OAAO,YAAY,IAAI,OAAO,QAAQ;AAGpE,UAAM,UAAU,MAAM,IAAI,OAAO,SAAS,WAAW,OAAO,OAAO;AACnE,YAAQ,IAAI,0BAA0B,OAAO,OAA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AAAA,MACxD,mBAAmB,YACjB,qBAAqB,KAAKC,uBAAsB;AAAA,IACpD;AAAA,EACF;AACF,CAAC;","names":["chalk","MOCKS_ZK_VERIFIER_SIGNER_ADDRESS","TASK_MANAGER_ADDRESS","TASK_MANAGER_ADDRESS","chalk","MockTaskManagerArtifact","chalk","MockThresholdNetworkArtifact","MockTaskManagerArtifact","MockZkVerifierArtifact","chalk","MOCKS_ZK_VERIFIER_SIGNER_ADDRESS","MockTaskManagerArtifact","MockThresholdNetworkArtifact","MockZkVerifierArtifact"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cofhe/hardhat-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"fast-glob": "3.3.2",
|
|
22
22
|
"viem": "2.38.6",
|
|
23
23
|
"chai": "4.5.0",
|
|
24
|
-
"@cofhe/sdk": "0.
|
|
25
|
-
"@cofhe/mock-contracts": "0.
|
|
24
|
+
"@cofhe/sdk": "0.6.0",
|
|
25
|
+
"@cofhe/mock-contracts": "0.6.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@nomicfoundation/hardhat-ethers": "3.1.0",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"hardhat": "^2.0.0",
|
|
47
47
|
"@nomicfoundation/hardhat-ethers": "^3.0.0",
|
|
48
48
|
"ethers": "^5.0.0 || ^6.0.0",
|
|
49
|
-
"@fhenixprotocol/cofhe-contracts": ">=0.1.
|
|
49
|
+
"@fhenixprotocol/cofhe-contracts": ">=0.1.4",
|
|
50
50
|
"@openzeppelin/contracts": "^5.0.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependenciesMeta": {
|
package/src/deploy.ts
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
MockACLArtifact,
|
|
8
8
|
MockZkVerifierArtifact,
|
|
9
9
|
MockThresholdNetworkArtifact,
|
|
10
|
-
TestBedArtifact,
|
|
11
10
|
} from '@cofhe/mock-contracts';
|
|
12
11
|
|
|
13
12
|
import {
|
|
@@ -29,7 +28,6 @@ import { deployMockContractFromArtifact } from './utils';
|
|
|
29
28
|
export type LogMocksDeploy = '' | 'v' | 'vv';
|
|
30
29
|
|
|
31
30
|
export type DeployMocksArgs = {
|
|
32
|
-
deployTestBed?: boolean;
|
|
33
31
|
gasWarning?: boolean;
|
|
34
32
|
mocksDeployVerbosity?: LogMocksDeploy;
|
|
35
33
|
};
|
|
@@ -37,7 +35,6 @@ export type DeployMocksArgs = {
|
|
|
37
35
|
export const deployMocks = async (
|
|
38
36
|
hre: HardhatRuntimeEnvironment,
|
|
39
37
|
options: DeployMocksArgs = {
|
|
40
|
-
deployTestBed: true,
|
|
41
38
|
gasWarning: true,
|
|
42
39
|
mocksDeployVerbosity: 'v',
|
|
43
40
|
}
|
|
@@ -89,11 +86,6 @@ export const deployMocks = async (
|
|
|
89
86
|
const thresholdNetwork = await deployMockThresholdNetwork(hre, acl);
|
|
90
87
|
logDeployment('MockThresholdNetwork', await thresholdNetwork.getAddress());
|
|
91
88
|
|
|
92
|
-
if (options.deployTestBed) {
|
|
93
|
-
const testBed = await deployTestBedContract(hre);
|
|
94
|
-
logDeployment('TestBed', await testBed.getAddress());
|
|
95
|
-
}
|
|
96
|
-
|
|
97
89
|
log('v', chalk.bold('cofhe-hardhat-plugin :: mocks deployed'), 0);
|
|
98
90
|
|
|
99
91
|
if (options.gasWarning) {
|
|
@@ -202,10 +194,6 @@ const deployMockThresholdNetwork = async (hre: HardhatRuntimeEnvironment, acl: C
|
|
|
202
194
|
return thresholdNetwork;
|
|
203
195
|
};
|
|
204
196
|
|
|
205
|
-
const deployTestBedContract = async (hre: HardhatRuntimeEnvironment) => {
|
|
206
|
-
return deployMockContractFromArtifact(hre, TestBedArtifact);
|
|
207
|
-
};
|
|
208
|
-
|
|
209
197
|
// Logging
|
|
210
198
|
|
|
211
199
|
let verbosity: LogMocksDeploy = 'v';
|
package/src/index.ts
CHANGED
|
@@ -27,12 +27,10 @@ import {
|
|
|
27
27
|
MockThresholdNetworkArtifact,
|
|
28
28
|
MockTaskManagerArtifact,
|
|
29
29
|
MockZkVerifierArtifact,
|
|
30
|
-
TestBedArtifact,
|
|
31
30
|
type MockACL,
|
|
32
31
|
type MockTaskManager,
|
|
33
32
|
type MockThresholdNetwork,
|
|
34
33
|
type MockZkVerifier,
|
|
35
|
-
type TestBed,
|
|
36
34
|
} from '@cofhe/mock-contracts';
|
|
37
35
|
|
|
38
36
|
/**
|
|
@@ -222,15 +220,14 @@ task(TASK_COFHE_USE_FAUCET, 'Fund an account from the funder')
|
|
|
222
220
|
|
|
223
221
|
// DEPLOY TASKS
|
|
224
222
|
|
|
225
|
-
task(TASK_COFHE_MOCKS_DEPLOY, 'Deploys the mock contracts on the Hardhat network')
|
|
226
|
-
|
|
227
|
-
.setAction(async ({ deployTestBed }: DeployMocksArgs, hre) => {
|
|
223
|
+
task(TASK_COFHE_MOCKS_DEPLOY, 'Deploys the mock contracts on the Hardhat network').setAction(
|
|
224
|
+
async ({}: DeployMocksArgs, hre) => {
|
|
228
225
|
await deployMocks(hre, {
|
|
229
|
-
deployTestBed: deployTestBed ?? true,
|
|
230
226
|
gasWarning: hre.config.cofhe.gasWarning ?? true,
|
|
231
227
|
mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity,
|
|
232
228
|
});
|
|
233
|
-
}
|
|
229
|
+
}
|
|
230
|
+
);
|
|
234
231
|
|
|
235
232
|
// Hardhat plugin auto-deploys mocks for every hardhat test run by overriding TASK_TEST and calling deployMocks(...) before runSuper()
|
|
236
233
|
task(TASK_TEST, 'Deploy mock contracts on hardhat').setAction(async ({}, hre, runSuper) => {
|
|
@@ -242,7 +239,6 @@ task(TASK_TEST, 'Deploy mock contracts on hardhat').setAction(async ({}, hre, ru
|
|
|
242
239
|
|
|
243
240
|
if (!skipAutoDeploy) {
|
|
244
241
|
await deployMocks(hre, {
|
|
245
|
-
deployTestBed: true,
|
|
246
242
|
gasWarning: hre.config.cofhe.gasWarning ?? true,
|
|
247
243
|
mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity,
|
|
248
244
|
});
|
|
@@ -259,7 +255,6 @@ task(TASK_NODE, 'Deploy mock contracts on hardhat').setAction(async ({}, hre, ru
|
|
|
259
255
|
|
|
260
256
|
if (!skipAutoDeploy) {
|
|
261
257
|
await deployMocks(hre, {
|
|
262
|
-
deployTestBed: true,
|
|
263
258
|
gasWarning: hre.config.cofhe.gasWarning ?? true,
|
|
264
259
|
mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity,
|
|
265
260
|
});
|
|
@@ -375,7 +370,7 @@ declare module 'hardhat/types/runtime' {
|
|
|
375
370
|
/**
|
|
376
371
|
* **[MOCKS ONLY]**
|
|
377
372
|
*
|
|
378
|
-
* Deploy the cofhe mock contracts
|
|
373
|
+
* Deploy the cofhe mock contracts.
|
|
379
374
|
* @param {DeployMocksArgs} options - Deployment options
|
|
380
375
|
*/
|
|
381
376
|
deployMocks: (options?: DeployMocksArgs) => Promise<void>;
|
|
@@ -421,12 +416,6 @@ declare module 'hardhat/types/runtime' {
|
|
|
421
416
|
* @returns {Promise<MockZkVerifier>} The MockZkVerifier contract
|
|
422
417
|
*/
|
|
423
418
|
getMockZkVerifier: () => Promise<MockZkVerifier>;
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Get the TestBed contract (typed via typechain)
|
|
427
|
-
* @returns {Promise<TestBed>} The TestBed contract
|
|
428
|
-
*/
|
|
429
|
-
getTestBed: () => Promise<TestBed>;
|
|
430
419
|
};
|
|
431
420
|
};
|
|
432
421
|
}
|
|
@@ -537,7 +526,6 @@ extendEnvironment((hre) => {
|
|
|
537
526
|
getFixedMockContract(hre, MockThresholdNetworkArtifact) as unknown as Promise<MockThresholdNetwork>,
|
|
538
527
|
getMockZkVerifier: async () =>
|
|
539
528
|
getFixedMockContract(hre, MockZkVerifierArtifact) as unknown as Promise<MockZkVerifier>,
|
|
540
|
-
getTestBed: async () => getFixedMockContract(hre, TestBedArtifact) as unknown as Promise<TestBed>,
|
|
541
529
|
},
|
|
542
530
|
};
|
|
543
531
|
});
|