@cofhe/hardhat-3-plugin 0.5.2 → 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 +16 -0
- package/README.md +37 -32
- package/dist/{chunk-WZRVFS4U.js → chunk-AAZRPK26.js} +4 -10
- package/dist/{hre-44O4XM4I.js → hre-PG4EAJES.js} +3 -6
- package/dist/index.d.ts +3 -9
- package/dist/index.js +2 -2
- package/package.json +3 -3
- package/src/deploy.ts +2 -12
- package/src/hooks/hre.ts +0 -3
- package/src/type-extensions.ts +2 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @cofhe/hardhat-3-plugin
|
|
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
|
+
|
|
3
19
|
## 0.5.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @cofhe/hardhat-3-plugin
|
|
2
2
|
|
|
3
|
-
A [Hardhat 3](https://hardhat.org) plugin for [CoFHE](https://docs.fhenix.io) development. It deploys the CoFHE mock contracts to an in-process Hardhat network on every `network.connect()` call and exposes a `cofhe` namespace on the connection object — ready to use immediately, no boilerplate required.
|
|
3
|
+
A [Hardhat 3](https://hardhat.org) plugin for [CoFHE](https://docs.fhenix.io) development. It deploys the core CoFHE mock contracts to an in-process Hardhat network on every `network.connect()` call and exposes a `cofhe` namespace on the connection object — ready to use immediately, no boilerplate required.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- Automatically deploys
|
|
7
|
+
- Automatically deploys the core CoFHE mock contracts (`MockTaskManager`, `MockACL`, `MockZkVerifier`, `MockThresholdNetwork`) on every `network.connect()`
|
|
8
8
|
- Exposes `conn.cofhe` on the Hardhat 3 connection object (compatible with `@nomicfoundation/hardhat-viem`'s `conn.viem`)
|
|
9
9
|
- Provides a batteries-included `cofhe.createClientWithBatteries()` for quick SDK client setup
|
|
10
10
|
- Mock-specific helpers: plaintext inspection, logging control, and Viem contract descriptors for every mock
|
|
@@ -57,7 +57,7 @@ export default defineConfig({
|
|
|
57
57
|
|
|
58
58
|
Every call to `network.connect()` automatically:
|
|
59
59
|
|
|
60
|
-
1. Deploys
|
|
60
|
+
1. Deploys the core CoFHE mock contracts to the fresh in-process EVM
|
|
61
61
|
2. Attaches a `cofhe` namespace to the returned connection object
|
|
62
62
|
|
|
63
63
|
Because `network.connect()` is awaitable at the top level of an `async describe`, you can set everything up without lifecycle hooks:
|
|
@@ -131,25 +131,21 @@ const client = await cofhe.createClientWithBatteries(walletClient);
|
|
|
131
131
|
|
|
132
132
|
#### Contract descriptors
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
The core mock contracts are exposed as an `{ address, abi }` object that can be spread directly into Viem's `readContract` / `writeContract`:
|
|
135
135
|
|
|
136
136
|
```typescript
|
|
137
|
-
//
|
|
137
|
+
// Core mock contracts are synchronous { address, abi } descriptors:
|
|
138
138
|
cofhe.mocks.MockTaskManager; // { address: `0x...`, abi: [...] }
|
|
139
139
|
cofhe.mocks.MockACL; // { address: `0x...`, abi: [...] }
|
|
140
140
|
cofhe.mocks.MockZkVerifier; // { address: `0x...`, abi: [...] }
|
|
141
141
|
cofhe.mocks.MockThresholdNetwork; // { address: `0x...`, abi: [...] }
|
|
142
|
-
cofhe.mocks.TestBed; // { address: `0x...`, abi: [...] }
|
|
143
142
|
```
|
|
144
143
|
|
|
144
|
+
`SimpleTest` is not injected onto `cofhe.mocks`. If a test needs it, deploy it explicitly and bind it locally using its fixed address and ABI.
|
|
145
|
+
|
|
145
146
|
Example — calling a mock directly with Viem:
|
|
146
147
|
|
|
147
148
|
```typescript
|
|
148
|
-
const value = await publicClient.readContract({
|
|
149
|
-
...cofhe.mocks.TestBed,
|
|
150
|
-
functionName: 'numberHash',
|
|
151
|
-
});
|
|
152
|
-
|
|
153
149
|
await walletClient.writeContract({
|
|
154
150
|
...cofhe.mocks.MockTaskManager,
|
|
155
151
|
functionName: 'setSecurityZones',
|
|
@@ -190,34 +186,34 @@ await cofhe.mocks.withLogs('my test', async () => {
|
|
|
190
186
|
|
|
191
187
|
#### `cofhe.mocks.deployMocks(options?)`
|
|
192
188
|
|
|
193
|
-
Re-deploys
|
|
189
|
+
Re-deploys the core mock contracts. They are deployed automatically on every `network.connect()`.
|
|
194
190
|
|
|
195
191
|
```typescript
|
|
196
|
-
await cofhe.mocks.deployMocks({
|
|
192
|
+
await cofhe.mocks.deployMocks({ gasWarning: false, mocksDeployVerbosity: '' });
|
|
197
193
|
```
|
|
198
194
|
|
|
199
|
-
| Option
|
|
200
|
-
|
|
|
201
|
-
| `
|
|
202
|
-
| `
|
|
203
|
-
| `silent` | `boolean` | `false` | Suppress all deployment output |
|
|
195
|
+
| Option | Type | Default | Description |
|
|
196
|
+
| ---------------------- | ------------------- | --------------- | ------------------------------------ |
|
|
197
|
+
| `gasWarning` | `boolean` | inherits config | Print gas warning after deployment |
|
|
198
|
+
| `mocksDeployVerbosity` | `'' \| 'v' \| 'vv'` | inherits config | Controls deployment output verbosity |
|
|
204
199
|
|
|
205
200
|
---
|
|
206
201
|
|
|
207
202
|
## Mock contracts
|
|
208
203
|
|
|
209
|
-
The plugin deploys these contracts automatically on every `network.connect()`:
|
|
204
|
+
The plugin deploys these core contracts automatically on every `network.connect()`:
|
|
210
205
|
|
|
211
|
-
| Contract | Address | Description
|
|
212
|
-
| ---------------------- | -------------------------------------------- |
|
|
213
|
-
| `MockTaskManager` | `0xeA30c4B8b44078Bbf8a6ef5b9f1eC1626C7848D9` | Coordinates FHE operations and ACL
|
|
214
|
-
| `MockACL` | dynamic | Access Control List — address resolved from TaskManager
|
|
215
|
-
| `MockZkVerifier` | `0x0000000000000000000000000000000000005001` | Verifies ZK proofs for encrypted inputs
|
|
216
|
-
| `MockThresholdNetwork` | `0x0000000000000000000000000000000000005002` | Simulates the threshold decryption network
|
|
217
|
-
| `TestBed` | `0x0000000000000000000000000000000000005003` | Utility contract for storing and retrieving encrypted values in tests |
|
|
206
|
+
| Contract | Address | Description |
|
|
207
|
+
| ---------------------- | -------------------------------------------- | ------------------------------------------------------- |
|
|
208
|
+
| `MockTaskManager` | `0xeA30c4B8b44078Bbf8a6ef5b9f1eC1626C7848D9` | Coordinates FHE operations and ACL |
|
|
209
|
+
| `MockACL` | dynamic | Access Control List — address resolved from TaskManager |
|
|
210
|
+
| `MockZkVerifier` | `0x0000000000000000000000000000000000005001` | Verifies ZK proofs for encrypted inputs |
|
|
211
|
+
| `MockThresholdNetwork` | `0x0000000000000000000000000000000000005002` | Simulates the threshold decryption network |
|
|
218
212
|
|
|
219
213
|
Fixed-address contracts are deployed via `hardhat_setCode`, ensuring they are always at the same address regardless of deployment order. `MockACL` is deployed as a normal contract (so its EIP-712 domain constructor runs correctly) and its address is registered in `MockTaskManager`.
|
|
220
214
|
|
|
215
|
+
If a test needs `SimpleTest`, deploy it directly from its artifact rather than through `cofhe.mocks`.
|
|
216
|
+
|
|
221
217
|
---
|
|
222
218
|
|
|
223
219
|
## Complete test example
|
|
@@ -232,6 +228,15 @@ describe('Encrypted counter', async () => {
|
|
|
232
228
|
const { viem, cofhe } = await network.connect();
|
|
233
229
|
const publicClient = await viem.getPublicClient();
|
|
234
230
|
const [walletClient] = await viem.getWalletClients();
|
|
231
|
+
const simpleTestArtifact = /* your compiled SimpleTest artifact */;
|
|
232
|
+
const deployHash = await walletClient.deployContract({
|
|
233
|
+
abi: simpleTestArtifact.abi,
|
|
234
|
+
bytecode: simpleTestArtifact.bytecode.object as `0x${string}`,
|
|
235
|
+
});
|
|
236
|
+
const deployReceipt = await publicClient.waitForTransactionReceipt({ hash: deployHash });
|
|
237
|
+
if (!deployReceipt.contractAddress) throw new Error('SimpleTest deployment failed');
|
|
238
|
+
|
|
239
|
+
const simpleTest = { address: deployReceipt.contractAddress, abi: simpleTestArtifact.abi } as const;
|
|
235
240
|
|
|
236
241
|
it('encrypts, stores, and decrypts a uint32', async () => {
|
|
237
242
|
const client = await cofhe.createClientWithBatteries(walletClient);
|
|
@@ -239,16 +244,16 @@ describe('Encrypted counter', async () => {
|
|
|
239
244
|
// Encrypt
|
|
240
245
|
const [enc] = await client.encryptInputs([Encryptable.uint32(42n)]).execute();
|
|
241
246
|
|
|
242
|
-
// Store on-chain via
|
|
247
|
+
// Store on-chain via SimpleTest
|
|
243
248
|
await walletClient.writeContract({
|
|
244
|
-
...
|
|
245
|
-
functionName: '
|
|
246
|
-
args: [
|
|
249
|
+
...simpleTest,
|
|
250
|
+
functionName: 'setValue',
|
|
251
|
+
args: [enc],
|
|
247
252
|
});
|
|
248
253
|
|
|
249
254
|
const ctHash = (await publicClient.readContract({
|
|
250
|
-
...
|
|
251
|
-
functionName: '
|
|
255
|
+
...simpleTest,
|
|
256
|
+
functionName: 'getValueHash',
|
|
252
257
|
})) as `0x${string}`;
|
|
253
258
|
|
|
254
259
|
// Decrypt via view (off-chain, instant)
|
|
@@ -2,15 +2,14 @@
|
|
|
2
2
|
import { createTestClient, custom } from "viem";
|
|
3
3
|
import chalk from "chalk";
|
|
4
4
|
import { privateKeyToAccount } from "viem/accounts";
|
|
5
|
-
import { MockTaskManagerArtifact, MockThresholdNetworkArtifact
|
|
5
|
+
import { MockTaskManagerArtifact, MockThresholdNetworkArtifact } from "@cofhe/mock-contracts";
|
|
6
6
|
import {
|
|
7
7
|
TASK_MANAGER_ADDRESS,
|
|
8
8
|
MOCKS_ZK_VERIFIER_ADDRESS,
|
|
9
9
|
MOCKS_ZK_VERIFIER_SIGNER_ADDRESS,
|
|
10
10
|
MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY,
|
|
11
11
|
MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY,
|
|
12
|
-
MOCKS_THRESHOLD_NETWORK_ADDRESS
|
|
13
|
-
TEST_BED_ADDRESS
|
|
12
|
+
MOCKS_THRESHOLD_NETWORK_ADDRESS
|
|
14
13
|
} from "@cofhe/sdk";
|
|
15
14
|
var verbosity = "v";
|
|
16
15
|
async function isLocalHardhatNetwork(publicClient) {
|
|
@@ -22,7 +21,7 @@ async function isLocalHardhatNetwork(publicClient) {
|
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
async function deployMocks(ctx, options = {}) {
|
|
25
|
-
const {
|
|
24
|
+
const { gasWarning = true } = options;
|
|
26
25
|
verbosity = options.mocksDeployVerbosity ?? "v";
|
|
27
26
|
if (!await isLocalHardhatNetwork(ctx.publicClient)) {
|
|
28
27
|
log("v", `cofhe-hardhat-3-plugin - deploy mocks - skipped on non-hardhat network`, 0);
|
|
@@ -103,10 +102,6 @@ async function deployMocks(ctx, options = {}) {
|
|
|
103
102
|
account,
|
|
104
103
|
chain: null
|
|
105
104
|
});
|
|
106
|
-
if (deployTestBed) {
|
|
107
|
-
await deployFixed(ctx.publicClient, "TestBed", TestBedArtifact.fixedAddress, ctx.artifacts);
|
|
108
|
-
logDeployment("TestBed", TestBedArtifact.fixedAddress);
|
|
109
|
-
}
|
|
110
105
|
log("v", chalk.bold("cofhe-hardhat-3-plugin :: mocks deployed"), 0);
|
|
111
106
|
if (gasWarning) {
|
|
112
107
|
logEmpty("v");
|
|
@@ -120,8 +115,7 @@ async function deployMocks(ctx, options = {}) {
|
|
|
120
115
|
MockTaskManager: TASK_MANAGER_ADDRESS,
|
|
121
116
|
MockACL: aclAddress,
|
|
122
117
|
MockZkVerifier: MOCKS_ZK_VERIFIER_ADDRESS,
|
|
123
|
-
MockThresholdNetwork: MOCKS_THRESHOLD_NETWORK_ADDRESS
|
|
124
|
-
TestBed: deployTestBed ? TEST_BED_ADDRESS : void 0
|
|
118
|
+
MockThresholdNetwork: MOCKS_THRESHOLD_NETWORK_ADDRESS
|
|
125
119
|
};
|
|
126
120
|
}
|
|
127
121
|
async function deployFixed(publicClient, contractName, fixedAddress, artifactManager) {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getMockContractsNpmPaths,
|
|
4
4
|
mock_expectPlaintext,
|
|
5
5
|
mock_getPlaintext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AAZRPK26.js";
|
|
7
7
|
import {
|
|
8
8
|
mock_setLoggingEnabled,
|
|
9
9
|
mock_withLogs
|
|
@@ -17,8 +17,7 @@ import {
|
|
|
17
17
|
MockTaskManagerArtifact,
|
|
18
18
|
MockACLArtifact,
|
|
19
19
|
MockZkVerifierArtifact,
|
|
20
|
-
MockThresholdNetworkArtifact
|
|
21
|
-
TestBedArtifact
|
|
20
|
+
MockThresholdNetworkArtifact
|
|
22
21
|
} from "@cofhe/mock-contracts";
|
|
23
22
|
import { MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY } from "@cofhe/sdk";
|
|
24
23
|
import { createCofheConfig, createCofheClient } from "@cofhe/sdk/node";
|
|
@@ -92,8 +91,7 @@ function createCofheConnection(publicClient, walletClient, transport, artifacts,
|
|
|
92
91
|
MockThresholdNetwork: {
|
|
93
92
|
address: deployedMockContracts.MockThresholdNetwork,
|
|
94
93
|
abi: MockThresholdNetworkArtifact.abi
|
|
95
|
-
}
|
|
96
|
-
TestBed: { address: deployedMockContracts.TestBed, abi: TestBedArtifact.abi }
|
|
94
|
+
}
|
|
97
95
|
}
|
|
98
96
|
};
|
|
99
97
|
}
|
|
@@ -134,7 +132,6 @@ var hreHooks = {
|
|
|
134
132
|
const deployedMockContracts = await deployMocks(
|
|
135
133
|
{ publicClient, walletClient, artifacts: hre.artifacts },
|
|
136
134
|
{
|
|
137
|
-
deployTestBed: true,
|
|
138
135
|
gasWarning: hre.config.cofhe.gasWarning,
|
|
139
136
|
mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity
|
|
140
137
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { HardhatPlugin } from 'hardhat/types/plugins';
|
|
|
2
2
|
import { PublicClient, WalletClient } from 'viem';
|
|
3
3
|
import { CofheInputConfig, CofheConfig, CofheClient } from '@cofhe/sdk';
|
|
4
4
|
import { ArtifactManager } from 'hardhat/types/artifacts';
|
|
5
|
-
import { MockTaskManagerArtifact, MockACLArtifact, MockZkVerifierArtifact, MockThresholdNetworkArtifact
|
|
5
|
+
import { MockTaskManagerArtifact, MockACLArtifact, MockZkVerifierArtifact, MockThresholdNetworkArtifact } from '@cofhe/mock-contracts';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Controls deploy-mocks console output.
|
|
@@ -17,10 +17,8 @@ type DeployedMockContracts = {
|
|
|
17
17
|
MockACL: `0x${string}`;
|
|
18
18
|
MockZkVerifier: `0x${string}`;
|
|
19
19
|
MockThresholdNetwork: `0x${string}`;
|
|
20
|
-
TestBed: `0x${string}` | undefined;
|
|
21
20
|
};
|
|
22
21
|
type DeployMocksArgs = {
|
|
23
|
-
deployTestBed?: boolean;
|
|
24
22
|
gasWarning?: boolean;
|
|
25
23
|
mocksDeployVerbosity?: LogMocksDeploy;
|
|
26
24
|
};
|
|
@@ -78,11 +76,6 @@ interface CofheConnection {
|
|
|
78
76
|
address: `0x${string}`;
|
|
79
77
|
abi: typeof MockThresholdNetworkArtifact.abi;
|
|
80
78
|
};
|
|
81
|
-
/** TestBed contract descriptor */
|
|
82
|
-
TestBed: {
|
|
83
|
-
address: `0x${string}`;
|
|
84
|
-
abi: typeof TestBedArtifact.abi;
|
|
85
|
-
};
|
|
86
79
|
};
|
|
87
80
|
}
|
|
88
81
|
declare module 'hardhat/types/config' {
|
|
@@ -113,7 +106,8 @@ declare module 'hardhat/types/network' {
|
|
|
113
106
|
interface NetworkConnection {
|
|
114
107
|
/**
|
|
115
108
|
* CoFHE mock environment — ready to use immediately after network.connect().
|
|
116
|
-
*
|
|
109
|
+
* Core mock contracts are deployed automatically on every connect().
|
|
110
|
+
* Contracts like SimpleTest should be deployed explicitly when a test needs them.
|
|
117
111
|
*/
|
|
118
112
|
cofhe: CofheConnection;
|
|
119
113
|
}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getMockContractsNpmPaths,
|
|
4
4
|
mock_expectPlaintext,
|
|
5
5
|
mock_getPlaintext
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-AAZRPK26.js";
|
|
7
7
|
import {
|
|
8
8
|
localcofheFundAccount,
|
|
9
9
|
localcofheFundWalletIfNeeded
|
|
@@ -26,7 +26,7 @@ var plugin = {
|
|
|
26
26
|
id: "@cofhe/hardhat-3-plugin",
|
|
27
27
|
hookHandlers: {
|
|
28
28
|
config: async () => import("./config-YK3LB5IH.js"),
|
|
29
|
-
hre: async () => import("./hre-
|
|
29
|
+
hre: async () => import("./hre-PG4EAJES.js")
|
|
30
30
|
},
|
|
31
31
|
tasks: [
|
|
32
32
|
task(TASK_COFHE_USE_FAUCET, "Fund an account via the localcofhe faucet").addOption({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cofhe/hardhat-3-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Hardhat 3 plugin for CoFHE — deploys mock contracts and wires up the hre.cofhe interface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"chalk": "4.1.2",
|
|
30
30
|
"viem": "2.38.6",
|
|
31
|
-
"@cofhe/
|
|
32
|
-
"@cofhe/
|
|
31
|
+
"@cofhe/mock-contracts": "0.6.0",
|
|
32
|
+
"@cofhe/sdk": "0.6.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "20.19.15",
|
package/src/deploy.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { createTestClient, custom } from 'viem';
|
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import { privateKeyToAccount } from 'viem/accounts';
|
|
6
6
|
|
|
7
|
-
import { MockTaskManagerArtifact, MockThresholdNetworkArtifact
|
|
7
|
+
import { MockTaskManagerArtifact, MockThresholdNetworkArtifact } from '@cofhe/mock-contracts';
|
|
8
8
|
import {
|
|
9
9
|
TASK_MANAGER_ADDRESS,
|
|
10
10
|
MOCKS_ZK_VERIFIER_ADDRESS,
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY,
|
|
13
13
|
MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY,
|
|
14
14
|
MOCKS_THRESHOLD_NETWORK_ADDRESS,
|
|
15
|
-
TEST_BED_ADDRESS,
|
|
16
15
|
} from '@cofhe/sdk';
|
|
17
16
|
|
|
18
17
|
/**
|
|
@@ -29,11 +28,9 @@ export type DeployedMockContracts = {
|
|
|
29
28
|
MockACL: `0x${string}`;
|
|
30
29
|
MockZkVerifier: `0x${string}`;
|
|
31
30
|
MockThresholdNetwork: `0x${string}`;
|
|
32
|
-
TestBed: `0x${string}` | undefined;
|
|
33
31
|
};
|
|
34
32
|
|
|
35
33
|
export type DeployMocksArgs = {
|
|
36
|
-
deployTestBed?: boolean;
|
|
37
34
|
gasWarning?: boolean;
|
|
38
35
|
mocksDeployVerbosity?: LogMocksDeploy;
|
|
39
36
|
};
|
|
@@ -62,7 +59,7 @@ async function isLocalHardhatNetwork(publicClient: PublicClient): Promise<boolea
|
|
|
62
59
|
}
|
|
63
60
|
|
|
64
61
|
export async function deployMocks(ctx: DeployContext, options: DeployMocksArgs = {}): Promise<DeployedMockContracts> {
|
|
65
|
-
const {
|
|
62
|
+
const { gasWarning = true } = options;
|
|
66
63
|
verbosity = options.mocksDeployVerbosity ?? 'v';
|
|
67
64
|
|
|
68
65
|
if (!(await isLocalHardhatNetwork(ctx.publicClient))) {
|
|
@@ -167,12 +164,6 @@ export async function deployMocks(ctx: DeployContext, options: DeployMocksArgs =
|
|
|
167
164
|
chain: null,
|
|
168
165
|
});
|
|
169
166
|
|
|
170
|
-
// 11. Optionally deploy TestBed
|
|
171
|
-
if (deployTestBed) {
|
|
172
|
-
await deployFixed(ctx.publicClient, 'TestBed', TestBedArtifact.fixedAddress, ctx.artifacts);
|
|
173
|
-
logDeployment('TestBed', TestBedArtifact.fixedAddress);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
167
|
log('v', chalk.bold('cofhe-hardhat-3-plugin :: mocks deployed'), 0);
|
|
177
168
|
|
|
178
169
|
if (gasWarning) {
|
|
@@ -192,7 +183,6 @@ export async function deployMocks(ctx: DeployContext, options: DeployMocksArgs =
|
|
|
192
183
|
MockACL: aclAddress,
|
|
193
184
|
MockZkVerifier: MOCKS_ZK_VERIFIER_ADDRESS,
|
|
194
185
|
MockThresholdNetwork: MOCKS_THRESHOLD_NETWORK_ADDRESS,
|
|
195
|
-
TestBed: deployTestBed ? TEST_BED_ADDRESS : undefined,
|
|
196
186
|
};
|
|
197
187
|
}
|
|
198
188
|
|
package/src/hooks/hre.ts
CHANGED
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
MockACLArtifact,
|
|
12
12
|
MockZkVerifierArtifact,
|
|
13
13
|
MockThresholdNetworkArtifact,
|
|
14
|
-
TestBedArtifact,
|
|
15
14
|
} from '@cofhe/mock-contracts';
|
|
16
15
|
import { MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, type CofheInputConfig } from '@cofhe/sdk';
|
|
17
16
|
import { createCofheConfig, createCofheClient } from '@cofhe/sdk/node';
|
|
@@ -113,7 +112,6 @@ function createCofheConnection(
|
|
|
113
112
|
address: deployedMockContracts.MockThresholdNetwork,
|
|
114
113
|
abi: MockThresholdNetworkArtifact.abi,
|
|
115
114
|
},
|
|
116
|
-
TestBed: { address: deployedMockContracts.TestBed!, abi: TestBedArtifact.abi },
|
|
117
115
|
},
|
|
118
116
|
};
|
|
119
117
|
}
|
|
@@ -173,7 +171,6 @@ const hreHooks: Partial<HardhatRuntimeEnvironmentHooks> = {
|
|
|
173
171
|
const deployedMockContracts = await deployMocks(
|
|
174
172
|
{ publicClient, walletClient, artifacts: hre.artifacts },
|
|
175
173
|
{
|
|
176
|
-
deployTestBed: true,
|
|
177
174
|
gasWarning: hre.config.cofhe.gasWarning,
|
|
178
175
|
mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity,
|
|
179
176
|
}
|
package/src/type-extensions.ts
CHANGED
|
@@ -6,7 +6,6 @@ import type {
|
|
|
6
6
|
MockACLArtifact,
|
|
7
7
|
MockZkVerifierArtifact,
|
|
8
8
|
MockThresholdNetworkArtifact,
|
|
9
|
-
TestBedArtifact,
|
|
10
9
|
} from '@cofhe/mock-contracts';
|
|
11
10
|
|
|
12
11
|
import 'hardhat/types/network';
|
|
@@ -60,9 +59,6 @@ export interface CofheConnection {
|
|
|
60
59
|
|
|
61
60
|
/** MockThresholdNetwork contract descriptor */
|
|
62
61
|
MockThresholdNetwork: { address: `0x${string}`; abi: typeof MockThresholdNetworkArtifact.abi };
|
|
63
|
-
|
|
64
|
-
/** TestBed contract descriptor */
|
|
65
|
-
TestBed: { address: `0x${string}`; abi: typeof TestBedArtifact.abi };
|
|
66
62
|
};
|
|
67
63
|
}
|
|
68
64
|
|
|
@@ -100,7 +96,8 @@ declare module 'hardhat/types/network' {
|
|
|
100
96
|
interface NetworkConnection {
|
|
101
97
|
/**
|
|
102
98
|
* CoFHE mock environment — ready to use immediately after network.connect().
|
|
103
|
-
*
|
|
99
|
+
* Core mock contracts are deployed automatically on every connect().
|
|
100
|
+
* Contracts like SimpleTest should be deployed explicitly when a test needs them.
|
|
104
101
|
*/
|
|
105
102
|
cofhe: CofheConnection;
|
|
106
103
|
}
|