@cofhe/hardhat-plugin 0.4.0 → 0.5.1
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 +54 -0
- package/dist/index.d.mts +17 -2
- package/dist/index.d.ts +17 -2
- package/dist/index.js +92 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +102 -49
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -22
- package/src/deploy.ts +47 -36
- package/src/index.ts +89 -11
- package/src/logging.ts +8 -5
- package/src/utils.ts +13 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,59 @@
|
|
|
1
1
|
# @cofhe/hardhat-plugin Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [342fd0f]
|
|
8
|
+
- @cofhe/sdk@0.5.1
|
|
9
|
+
- @cofhe/mock-contracts@0.5.1
|
|
10
|
+
|
|
11
|
+
## 0.5.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- f78beb7: Add `@cofhe/hardhat-3-plugin` and `@cofhe/foundry-plugin` packages.
|
|
16
|
+
|
|
17
|
+
**`@cofhe/hardhat-3-plugin`** — Hardhat 3 plugin with the same mock contract deployment, `network.cofhe` API, logging, and faucet task as the v2 plugin, adapted to the Hardhat 3 plugin/hook model.
|
|
18
|
+
|
|
19
|
+
**`@cofhe/foundry-plugin`** — Foundry test utilities: `CofheTest` base contract (`deployMocks`, `expectPlaintext`, `getPlaintext`) and `CofheClient` SDK mock (`connect`, `createInE*`, `decryptForTx`, `decryptForView`, permits). Usable as a git submodule or npm package, with `remappings.txt` for Hardhat 3 Solidity test compatibility.
|
|
20
|
+
|
|
21
|
+
**`mocksDeployVerbosity` config option** added to both Hardhat plugins:
|
|
22
|
+
|
|
23
|
+
- `''` — silent
|
|
24
|
+
- `'v'` — single summary line (new default)
|
|
25
|
+
- `'vv'` — full per-contract deployment logs (previous default behavior)
|
|
26
|
+
|
|
27
|
+
- 50bb3e4: Decode custom errors from deployed mock contracts by name instead of raw hex selectors.
|
|
28
|
+
|
|
29
|
+
**`@cofhe/mock-contracts`**
|
|
30
|
+
|
|
31
|
+
- Replaced transient storage (`tstore`/`tload`) in `MockACL.sol` with block-number-based storage, removing the EVM `cancun` requirement and lowering the Solidity pragma to `>=0.8.19`.
|
|
32
|
+
- Removed `bytecode` and `deployedBytecode` fields from published artifacts — they are now sourced at runtime from Hardhat's own compilation output.
|
|
33
|
+
|
|
34
|
+
**`@cofhe/hardhat-plugin`**
|
|
35
|
+
|
|
36
|
+
- Overrides `TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS` to inject a stub file that imports all mock contracts, so Hardhat compiles them and registers their artifacts. This lets the Hardhat network decode mock contract custom errors by name (e.g. `PermissionInvalid_Expired`) rather than raw hex.
|
|
37
|
+
- Deployment bytecode is now fetched from `hre.artifacts.readArtifact()` instead of the pre-built artifact bundle.
|
|
38
|
+
|
|
39
|
+
**`@cofhe/hardhat-3-plugin`**
|
|
40
|
+
|
|
41
|
+
- Calls `hre.solidity.build()` during the `hre.created` hook to compile mock contracts once at startup, enabling the EDR to decode their custom errors by name.
|
|
42
|
+
- `deployFixed` and `deployVariable` now source bytecode from `hre.artifacts.readArtifact()`, ensuring the deployed bytecode matches Hardhat's build info — which is required for error decoding on variable-address contracts like `MockACL`.
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- a685cd4: **Breaking change: upgraded to tfhe v1.5.3.**
|
|
47
|
+
Previous cofhesdk versions will no longer function.
|
|
48
|
+
- Updated dependencies [6c4084f]
|
|
49
|
+
- Updated dependencies [50bb3e4]
|
|
50
|
+
- Updated dependencies [788a6e2]
|
|
51
|
+
- Updated dependencies [9a06012]
|
|
52
|
+
- Updated dependencies [503536a]
|
|
53
|
+
- Updated dependencies [a685cd4]
|
|
54
|
+
- @cofhe/sdk@0.5.0
|
|
55
|
+
- @cofhe/mock-contracts@0.5.0
|
|
56
|
+
|
|
3
57
|
## 0.4.0
|
|
4
58
|
|
|
5
59
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -7,10 +7,17 @@ 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';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Controls deploy-mocks console output.
|
|
12
|
+
* - `''` — silent, no output
|
|
13
|
+
* - `'v'` — single summary line (default)
|
|
14
|
+
* - `'vv'` — full per-contract deployment logs
|
|
15
|
+
*/
|
|
16
|
+
type LogMocksDeploy = '' | 'v' | 'vv';
|
|
10
17
|
type DeployMocksArgs = {
|
|
11
18
|
deployTestBed?: boolean;
|
|
12
19
|
gasWarning?: boolean;
|
|
13
|
-
|
|
20
|
+
mocksDeployVerbosity?: LogMocksDeploy;
|
|
14
21
|
};
|
|
15
22
|
declare const deployMocks: (hre: HardhatRuntimeEnvironment, options?: DeployMocksArgs) => Promise<void>;
|
|
16
23
|
|
|
@@ -54,6 +61,13 @@ declare module 'hardhat/types/config' {
|
|
|
54
61
|
logMocks?: boolean;
|
|
55
62
|
/** Whether to show gas usage warnings for mock operations (default: true) */
|
|
56
63
|
gasWarning?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Controls deploy-mocks console output.
|
|
66
|
+
* - `''` — silent, no output
|
|
67
|
+
* - `'v'` — single summary line (default)
|
|
68
|
+
* - `'vv'` — full per-contract deployment logs
|
|
69
|
+
*/
|
|
70
|
+
mocksDeployVerbosity?: LogMocksDeploy;
|
|
57
71
|
};
|
|
58
72
|
}
|
|
59
73
|
interface HardhatConfig {
|
|
@@ -62,6 +76,7 @@ declare module 'hardhat/types/config' {
|
|
|
62
76
|
logMocks: boolean;
|
|
63
77
|
/** Whether to show gas usage warnings for mock operations (default: true) */
|
|
64
78
|
gasWarning: boolean;
|
|
79
|
+
mocksDeployVerbosity: LogMocksDeploy;
|
|
65
80
|
};
|
|
66
81
|
}
|
|
67
82
|
}
|
|
@@ -211,4 +226,4 @@ declare module 'hardhat/types/runtime' {
|
|
|
211
226
|
*/
|
|
212
227
|
declare function buildHardhatPluginMocksConfig(mocksConfig: CofheInputConfig['mocks']): NonNullable<CofheInputConfig['mocks']>;
|
|
213
228
|
|
|
214
|
-
export { type DeployMocksArgs, TASK_COFHE_MOCKS_DEPLOY, TASK_COFHE_MOCKS_SET_LOG_OPS, TASK_COFHE_USE_FAUCET, buildHardhatPluginMocksConfig, deployMockContractFromArtifact, deployMocks, getFixedMockContract, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs };
|
|
229
|
+
export { type DeployMocksArgs, type LogMocksDeploy, TASK_COFHE_MOCKS_DEPLOY, TASK_COFHE_MOCKS_SET_LOG_OPS, TASK_COFHE_USE_FAUCET, buildHardhatPluginMocksConfig, deployMockContractFromArtifact, deployMocks, getFixedMockContract, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,10 +7,17 @@ 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';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Controls deploy-mocks console output.
|
|
12
|
+
* - `''` — silent, no output
|
|
13
|
+
* - `'v'` — single summary line (default)
|
|
14
|
+
* - `'vv'` — full per-contract deployment logs
|
|
15
|
+
*/
|
|
16
|
+
type LogMocksDeploy = '' | 'v' | 'vv';
|
|
10
17
|
type DeployMocksArgs = {
|
|
11
18
|
deployTestBed?: boolean;
|
|
12
19
|
gasWarning?: boolean;
|
|
13
|
-
|
|
20
|
+
mocksDeployVerbosity?: LogMocksDeploy;
|
|
14
21
|
};
|
|
15
22
|
declare const deployMocks: (hre: HardhatRuntimeEnvironment, options?: DeployMocksArgs) => Promise<void>;
|
|
16
23
|
|
|
@@ -54,6 +61,13 @@ declare module 'hardhat/types/config' {
|
|
|
54
61
|
logMocks?: boolean;
|
|
55
62
|
/** Whether to show gas usage warnings for mock operations (default: true) */
|
|
56
63
|
gasWarning?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Controls deploy-mocks console output.
|
|
66
|
+
* - `''` — silent, no output
|
|
67
|
+
* - `'v'` — single summary line (default)
|
|
68
|
+
* - `'vv'` — full per-contract deployment logs
|
|
69
|
+
*/
|
|
70
|
+
mocksDeployVerbosity?: LogMocksDeploy;
|
|
57
71
|
};
|
|
58
72
|
}
|
|
59
73
|
interface HardhatConfig {
|
|
@@ -62,6 +76,7 @@ declare module 'hardhat/types/config' {
|
|
|
62
76
|
logMocks: boolean;
|
|
63
77
|
/** Whether to show gas usage warnings for mock operations (default: true) */
|
|
64
78
|
gasWarning: boolean;
|
|
79
|
+
mocksDeployVerbosity: LogMocksDeploy;
|
|
65
80
|
};
|
|
66
81
|
}
|
|
67
82
|
}
|
|
@@ -211,4 +226,4 @@ declare module 'hardhat/types/runtime' {
|
|
|
211
226
|
*/
|
|
212
227
|
declare function buildHardhatPluginMocksConfig(mocksConfig: CofheInputConfig['mocks']): NonNullable<CofheInputConfig['mocks']>;
|
|
213
228
|
|
|
214
|
-
export { type DeployMocksArgs, TASK_COFHE_MOCKS_DEPLOY, TASK_COFHE_MOCKS_SET_LOG_OPS, TASK_COFHE_USE_FAUCET, buildHardhatPluginMocksConfig, deployMockContractFromArtifact, deployMocks, getFixedMockContract, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs };
|
|
229
|
+
export { type DeployMocksArgs, type LogMocksDeploy, TASK_COFHE_MOCKS_DEPLOY, TASK_COFHE_MOCKS_SET_LOG_OPS, TASK_COFHE_USE_FAUCET, buildHardhatPluginMocksConfig, deployMockContractFromArtifact, deployMocks, getFixedMockContract, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs };
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,8 @@ __export(src_exports, {
|
|
|
47
47
|
});
|
|
48
48
|
module.exports = __toCommonJS(src_exports);
|
|
49
49
|
var import_chalk3 = __toESM(require("chalk"));
|
|
50
|
+
var import_path = __toESM(require("path"));
|
|
51
|
+
var import_fs = __toESM(require("fs"));
|
|
50
52
|
var import_viem = require("viem");
|
|
51
53
|
var import_config = require("hardhat/config");
|
|
52
54
|
var import_task_names = require("hardhat/builtin-tasks/task-names");
|
|
@@ -125,15 +127,14 @@ var import_chai = require("chai");
|
|
|
125
127
|
var import_ethers = require("ethers");
|
|
126
128
|
var import_hardhat_ethers_provider = require("@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider");
|
|
127
129
|
var deployMockContractFromArtifact = async (hre, artifact) => {
|
|
130
|
+
const hardhatArtifact = await hre.artifacts.readArtifact(artifact.contractName);
|
|
128
131
|
if (artifact.isFixed) {
|
|
129
|
-
await hre.network.provider.send("hardhat_setCode", [artifact.fixedAddress,
|
|
130
|
-
return
|
|
132
|
+
await hre.network.provider.send("hardhat_setCode", [artifact.fixedAddress, hardhatArtifact.deployedBytecode]);
|
|
133
|
+
return hre.ethers.getContractAt(hardhatArtifact.abi, artifact.fixedAddress);
|
|
131
134
|
}
|
|
132
135
|
const [signer] = await hre.ethers.getSigners();
|
|
133
|
-
const factory = new hre.ethers.ContractFactory(
|
|
134
|
-
const contract = await factory.deploy(
|
|
135
|
-
/* constructor args */
|
|
136
|
-
);
|
|
136
|
+
const factory = new hre.ethers.ContractFactory(hardhatArtifact.abi, hardhatArtifact.bytecode, signer);
|
|
137
|
+
const contract = await factory.deploy();
|
|
137
138
|
await contract.waitForDeployment();
|
|
138
139
|
return contract;
|
|
139
140
|
};
|
|
@@ -141,7 +142,8 @@ var getFixedMockContract = async (hre, artifact) => {
|
|
|
141
142
|
if (!artifact.isFixed) {
|
|
142
143
|
throw new Error("Artifact is not fixed");
|
|
143
144
|
}
|
|
144
|
-
|
|
145
|
+
const hardhatArtifact = await hre.artifacts.readArtifact(artifact.contractName);
|
|
146
|
+
return hre.ethers.getContractAt(hardhatArtifact.abi, artifact.fixedAddress);
|
|
145
147
|
};
|
|
146
148
|
var mock_checkIsTestnet = async (fnName, provider) => {
|
|
147
149
|
const bytecode = await provider.getCode(import_sdk.MOCKS_ZK_VERIFIER_ADDRESS);
|
|
@@ -186,50 +188,47 @@ var mock_expectPlaintext = async (provider, ctHash, expectedValue) => {
|
|
|
186
188
|
var deployMocks = async (hre, options = {
|
|
187
189
|
deployTestBed: true,
|
|
188
190
|
gasWarning: true,
|
|
189
|
-
|
|
191
|
+
mocksDeployVerbosity: "v"
|
|
190
192
|
}) => {
|
|
193
|
+
verbosity = options.mocksDeployVerbosity ?? "v";
|
|
191
194
|
const isHardhat = await getIsHardhat(hre);
|
|
192
195
|
if (!isHardhat) {
|
|
193
|
-
|
|
196
|
+
log("v", `cofhe-hardhat-plugin - deploy mocks - skipped on non-hardhat network ${hre.network.name}`, 0);
|
|
194
197
|
return;
|
|
195
198
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
logSuccess(import_chalk.default.bold("cofhe-hardhat-plugin :: deploy mocks"), 0);
|
|
199
|
-
logEmpty();
|
|
199
|
+
await hre.run("compile", { quiet: true });
|
|
200
|
+
log("vv", import_chalk.default.bold("cofhe-hardhat-plugin :: deploy mocks"), 0);
|
|
200
201
|
const taskManager = await deployMockTaskManager(hre);
|
|
201
202
|
logDeployment("MockTaskManager", await taskManager.getAddress());
|
|
202
203
|
const acl = await deployMockACL(hre);
|
|
203
204
|
logDeployment("MockACL", await acl.getAddress());
|
|
204
205
|
await linkTaskManagerAndACL(taskManager, acl);
|
|
205
|
-
|
|
206
|
+
log("vv", "ACL address set in TaskManager", 2);
|
|
206
207
|
await setVerifierSigner(taskManager);
|
|
207
|
-
|
|
208
|
+
log("vv", "Verifier signer set", 2);
|
|
208
209
|
await setDecryptResultSigner(taskManager);
|
|
209
|
-
|
|
210
|
+
log("vv", "Decrypt result signer set", 2);
|
|
210
211
|
await fundZkVerifierSigner(hre);
|
|
211
|
-
|
|
212
|
+
log("vv", `ZkVerifier signer (${import_sdk2.MOCKS_ZK_VERIFIER_SIGNER_ADDRESS}) funded`, 1);
|
|
212
213
|
const zkVerifierSignerBalance = await getZkVerifierSignerBalance(hre);
|
|
213
|
-
|
|
214
|
+
log("vv", `ETH balance: ${zkVerifierSignerBalance.toString()}`, 2);
|
|
214
215
|
const zkVerifier = await deployMockZkVerifier(hre);
|
|
215
216
|
logDeployment("MockZkVerifier", await zkVerifier.getAddress());
|
|
216
217
|
const thresholdNetwork = await deployMockThresholdNetwork(hre, acl);
|
|
217
218
|
logDeployment("MockThresholdNetwork", await thresholdNetwork.getAddress());
|
|
218
219
|
if (options.deployTestBed) {
|
|
219
|
-
logSuccess("TestBed deployment enabled", 2);
|
|
220
220
|
const testBed = await deployTestBedContract(hre);
|
|
221
221
|
logDeployment("TestBed", await testBed.getAddress());
|
|
222
222
|
}
|
|
223
|
-
|
|
224
|
-
logSuccess(import_chalk.default.bold("cofhe-hardhat-plugin :: mocks deployed successfully"), 0);
|
|
223
|
+
log("v", import_chalk.default.bold("cofhe-hardhat-plugin :: mocks deployed"), 0);
|
|
225
224
|
if (options.gasWarning) {
|
|
226
|
-
logEmpty();
|
|
225
|
+
logEmpty("v");
|
|
227
226
|
logWarning(
|
|
228
|
-
"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 '
|
|
227
|
+
"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)",
|
|
229
228
|
0
|
|
230
229
|
);
|
|
231
230
|
}
|
|
232
|
-
logEmpty();
|
|
231
|
+
logEmpty("v");
|
|
233
232
|
};
|
|
234
233
|
var getIsHardhat = async (hre) => {
|
|
235
234
|
return hre.network.name === "hardhat";
|
|
@@ -299,27 +298,31 @@ var deployMockThresholdNetwork = async (hre, acl) => {
|
|
|
299
298
|
var deployTestBedContract = async (hre) => {
|
|
300
299
|
return deployMockContractFromArtifact(hre, import_mock_contracts.TestBedArtifact);
|
|
301
300
|
};
|
|
302
|
-
var
|
|
303
|
-
var
|
|
304
|
-
if (
|
|
301
|
+
var verbosity = "v";
|
|
302
|
+
var log = (minVerbosity, message, indent = 1) => {
|
|
303
|
+
if (verbosity === "")
|
|
305
304
|
return;
|
|
306
|
-
|
|
307
|
-
};
|
|
308
|
-
var logSuccess = (message, indent = 1) => {
|
|
309
|
-
if (isSilent)
|
|
305
|
+
if (minVerbosity === "vv" && verbosity !== "vv")
|
|
310
306
|
return;
|
|
311
307
|
console.log(import_chalk.default.green(`${" ".repeat(indent)}\u2713 ${message}`));
|
|
312
308
|
};
|
|
309
|
+
var logEmpty = (minVerbosity = "v") => {
|
|
310
|
+
if (verbosity === "")
|
|
311
|
+
return;
|
|
312
|
+
if (minVerbosity === "vv" && verbosity !== "vv")
|
|
313
|
+
return;
|
|
314
|
+
console.log("");
|
|
315
|
+
};
|
|
313
316
|
var logWarning = (message, indent = 1) => {
|
|
314
|
-
if (
|
|
317
|
+
if (verbosity === "")
|
|
315
318
|
return;
|
|
316
319
|
console.log(import_chalk.default.bold(import_chalk.default.yellow(`${" ".repeat(indent)}\u26A0 NOTE:`)), message);
|
|
317
320
|
};
|
|
318
321
|
var logDeployment = (contractName, address) => {
|
|
319
|
-
if (
|
|
322
|
+
if (verbosity !== "vv")
|
|
320
323
|
return;
|
|
321
324
|
const paddedName = `${contractName} deployed`.padEnd(36);
|
|
322
|
-
|
|
325
|
+
console.log(import_chalk.default.green(` \u2713 ${paddedName} ${import_chalk.default.bold(address)}`));
|
|
323
326
|
};
|
|
324
327
|
|
|
325
328
|
// src/logging.ts
|
|
@@ -361,16 +364,55 @@ var mock_withLogs = async (hre, closureName, closure) => {
|
|
|
361
364
|
const initiallyEnabled = await getLoggingEnabled(hre);
|
|
362
365
|
await setLoggingEnabled(hre, true);
|
|
363
366
|
printLogsEnabledMessage(`"${import_chalk2.default.bold(closureName)}" logs:`);
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
367
|
+
try {
|
|
368
|
+
await closure();
|
|
369
|
+
} finally {
|
|
370
|
+
printLogsBlockEnd();
|
|
371
|
+
if (!initiallyEnabled) {
|
|
372
|
+
await setLoggingEnabled(hre, false);
|
|
373
|
+
}
|
|
368
374
|
}
|
|
369
375
|
};
|
|
370
376
|
|
|
371
377
|
// src/index.ts
|
|
372
378
|
var import_chains = require("@cofhe/sdk/chains");
|
|
373
379
|
var import_mock_contracts3 = require("@cofhe/mock-contracts");
|
|
380
|
+
var MOCK_STUBS_DIR_NAME = "cofhe-stubs";
|
|
381
|
+
var MOCK_STUBS_FILE_NAME = "CofheMocksImports.sol";
|
|
382
|
+
function getMockContractsSolFiles() {
|
|
383
|
+
let contractsDir;
|
|
384
|
+
try {
|
|
385
|
+
const pkgJson = require.resolve("@cofhe/mock-contracts/package.json");
|
|
386
|
+
contractsDir = import_path.default.join(import_path.default.dirname(pkgJson), "contracts");
|
|
387
|
+
} catch {
|
|
388
|
+
contractsDir = import_path.default.join(process.cwd(), "node_modules", "@cofhe", "mock-contracts", "contracts");
|
|
389
|
+
}
|
|
390
|
+
if (!import_fs.default.existsSync(contractsDir)) {
|
|
391
|
+
return [];
|
|
392
|
+
}
|
|
393
|
+
return import_fs.default.readdirSync(contractsDir).filter((f) => f.endsWith(".sol")).map((f) => import_path.default.join(contractsDir, f));
|
|
394
|
+
}
|
|
395
|
+
function generateMockContractsStubContent() {
|
|
396
|
+
const imports = getMockContractsSolFiles().map((f) => `import "@cofhe/mock-contracts/contracts/${import_path.default.basename(f)}";`).join("\n");
|
|
397
|
+
return [
|
|
398
|
+
"// SPDX-License-Identifier: UNLICENSED",
|
|
399
|
+
"// Auto-generated by @cofhe/hardhat-plugin \u2014 do not edit.",
|
|
400
|
+
"// Importing mock contracts here causes Hardhat to compile them and register",
|
|
401
|
+
"// their artifacts, enabling proper revert decoding during tests.",
|
|
402
|
+
"pragma solidity >=0.8.25 <0.9.0;",
|
|
403
|
+
"",
|
|
404
|
+
imports,
|
|
405
|
+
""
|
|
406
|
+
].join("\n");
|
|
407
|
+
}
|
|
408
|
+
(0, import_config.subtask)(import_task_names.TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(async (taskArgs, hre, runSuper) => {
|
|
409
|
+
const existing = await runSuper(taskArgs);
|
|
410
|
+
const stubDir = import_path.default.join(hre.config.paths.cache, MOCK_STUBS_DIR_NAME);
|
|
411
|
+
const stubPath = import_path.default.join(stubDir, MOCK_STUBS_FILE_NAME);
|
|
412
|
+
import_fs.default.mkdirSync(stubDir, { recursive: true });
|
|
413
|
+
import_fs.default.writeFileSync(stubPath, generateMockContractsStubContent(), "utf8");
|
|
414
|
+
return [.../* @__PURE__ */ new Set([...existing, stubPath])];
|
|
415
|
+
});
|
|
374
416
|
(0, import_config.extendConfig)((config, userConfig) => {
|
|
375
417
|
if (userConfig.networks && userConfig.networks.localcofhe) {
|
|
376
418
|
return;
|
|
@@ -414,8 +456,9 @@ var import_mock_contracts3 = require("@cofhe/mock-contracts");
|
|
|
414
456
|
};
|
|
415
457
|
}
|
|
416
458
|
config.cofhe = {
|
|
417
|
-
logMocks: userConfig.cofhe?.logMocks ??
|
|
418
|
-
gasWarning: userConfig.cofhe?.gasWarning ??
|
|
459
|
+
logMocks: userConfig.cofhe?.logMocks ?? false,
|
|
460
|
+
gasWarning: userConfig.cofhe?.gasWarning ?? false,
|
|
461
|
+
mocksDeployVerbosity: userConfig.cofhe?.mocksDeployVerbosity ?? "v"
|
|
419
462
|
};
|
|
420
463
|
});
|
|
421
464
|
(0, import_config.task)(TASK_COFHE_USE_FAUCET, "Fund an account from the funder").addOptionalParam("address", "Address to fund", void 0, import_config.types.string).setAction(async ({ address }, hre) => {
|
|
@@ -436,11 +479,11 @@ var import_mock_contracts3 = require("@cofhe/mock-contracts");
|
|
|
436
479
|
console.info(import_chalk3.default.red(`failed to get funds from localcofhe for ${address}: ${e}`));
|
|
437
480
|
}
|
|
438
481
|
});
|
|
439
|
-
(0, import_config.task)(TASK_COFHE_MOCKS_DEPLOY, "Deploys the mock contracts on the Hardhat network").addOptionalParam("deployTestBed", "Whether to deploy the test bed", true, import_config.types.boolean).
|
|
482
|
+
(0, import_config.task)(TASK_COFHE_MOCKS_DEPLOY, "Deploys the mock contracts on the Hardhat network").addOptionalParam("deployTestBed", "Whether to deploy the test bed", true, import_config.types.boolean).setAction(async ({ deployTestBed }, hre) => {
|
|
440
483
|
await deployMocks(hre, {
|
|
441
484
|
deployTestBed: deployTestBed ?? true,
|
|
442
485
|
gasWarning: hre.config.cofhe.gasWarning ?? true,
|
|
443
|
-
|
|
486
|
+
mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity
|
|
444
487
|
});
|
|
445
488
|
});
|
|
446
489
|
(0, import_config.task)(import_task_names.TASK_TEST, "Deploy mock contracts on hardhat").setAction(async ({}, hre, runSuper) => {
|
|
@@ -452,7 +495,8 @@ var import_mock_contracts3 = require("@cofhe/mock-contracts");
|
|
|
452
495
|
if (!skipAutoDeploy) {
|
|
453
496
|
await deployMocks(hre, {
|
|
454
497
|
deployTestBed: true,
|
|
455
|
-
gasWarning: hre.config.cofhe.gasWarning ?? true
|
|
498
|
+
gasWarning: hre.config.cofhe.gasWarning ?? true,
|
|
499
|
+
mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity
|
|
456
500
|
});
|
|
457
501
|
}
|
|
458
502
|
return runSuper();
|
|
@@ -466,7 +510,8 @@ var import_mock_contracts3 = require("@cofhe/mock-contracts");
|
|
|
466
510
|
if (!skipAutoDeploy) {
|
|
467
511
|
await deployMocks(hre, {
|
|
468
512
|
deployTestBed: true,
|
|
469
|
-
gasWarning: hre.config.cofhe.gasWarning ?? true
|
|
513
|
+
gasWarning: hre.config.cofhe.gasWarning ?? true,
|
|
514
|
+
mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity
|
|
470
515
|
});
|
|
471
516
|
}
|
|
472
517
|
return runSuper();
|
|
@@ -532,7 +577,7 @@ function buildHardhatPluginMocksConfig(mocksConfig) {
|
|
|
532
577
|
return mock_setLoggingEnabled(hre, false);
|
|
533
578
|
},
|
|
534
579
|
deployMocks: async (options = {}) => {
|
|
535
|
-
return deployMocks(hre, options);
|
|
580
|
+
return deployMocks(hre, { mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity, ...options });
|
|
536
581
|
},
|
|
537
582
|
getPlaintext: async (ctHash) => {
|
|
538
583
|
const [signer] = await hre.ethers.getSigners();
|
|
@@ -546,7 +591,8 @@ function buildHardhatPluginMocksConfig(mocksConfig) {
|
|
|
546
591
|
getMockACL: async () => {
|
|
547
592
|
const taskManager = await getFixedMockContract(hre, import_mock_contracts3.MockTaskManagerArtifact);
|
|
548
593
|
const aclAddress = await taskManager.acl();
|
|
549
|
-
|
|
594
|
+
const aclArtifact = await hre.artifacts.readArtifact("MockACL");
|
|
595
|
+
return hre.ethers.getContractAt(aclArtifact.abi, aclAddress);
|
|
550
596
|
},
|
|
551
597
|
getMockThresholdNetwork: async () => getFixedMockContract(hre, import_mock_contracts3.MockThresholdNetworkArtifact),
|
|
552
598
|
getMockZkVerifier: async () => getFixedMockContract(hre, import_mock_contracts3.MockZkVerifierArtifact),
|