@cofhe/hardhat-plugin 0.2.1 → 0.3.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 +30 -0
- package/README.md +7 -1
- package/dist/index.d.mts +30 -24
- package/dist/index.d.ts +30 -24
- package/dist/index.js +54 -31
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/deploy.ts +12 -12
- package/src/index.ts +83 -50
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @cofhe/hardhat-plugin Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 35024b6: Remove `sdk` from function names and exported types. Rename:
|
|
8
|
+
|
|
9
|
+
- `createCofhesdkConfig` -> `createCofheConfig`
|
|
10
|
+
- `createCofhesdkClient` -> `createCofheClient`
|
|
11
|
+
- `hre.cofhesdk.*` -> `hre.cofhe.*`
|
|
12
|
+
- `hre.cofhesdk.createCofheConfig()` → `hre.cofhe.createConfig()`
|
|
13
|
+
- `hre.cofhesdk.createCofheClient()` → `hre.cofhe.createClient()`
|
|
14
|
+
- `hre.cofhesdk.createBatteriesIncludedCofheClient()` → `hre.cofhe.createClientWithBatteries()`
|
|
15
|
+
|
|
16
|
+
- 29c2401: implement decrypt-with-proof flows and related tests:
|
|
17
|
+
|
|
18
|
+
- Implement production `decryptForTx` backed by Threshold Network `POST /decrypt`, with explicit permit vs global-allowance selection.
|
|
19
|
+
- Rename mocks “Query Decrypter” -> “Threshold Network” and update SDK constants/contracts/artifacts accordingly.
|
|
20
|
+
- Extend mock contracts + hardhat plugin to publish & verify decryption results on-chain, and add end-to-end integration tests.
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- 5467d77: Adds `config.mocks.encryptDelay: number | [number, number, number, number, number]` to allow configurable mock encryption delay. Defaults to 0 delay on hardhat to keep tests quick.
|
|
25
|
+
- Updated dependencies [35024b6]
|
|
26
|
+
- Updated dependencies [5467d77]
|
|
27
|
+
- Updated dependencies [73b1502]
|
|
28
|
+
- Updated dependencies [29c2401]
|
|
29
|
+
- Updated dependencies [650ea48]
|
|
30
|
+
- @cofhe/mock-contracts@0.3.0
|
|
31
|
+
- @cofhe/sdk@0.3.0
|
|
32
|
+
|
|
3
33
|
## 0.2.1
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ This plugin uses [cofhe-mock-contracts](https://github.com/FhenixProtocol/cofhe-
|
|
|
46
46
|
The mock contracts include:
|
|
47
47
|
|
|
48
48
|
- MockTaskManager: Manages FHE operations and stores plaintext values
|
|
49
|
-
-
|
|
49
|
+
- MockThresholdNetwork: Handles decryption requests
|
|
50
50
|
- MockZkVerifier: Simulates verification of encrypted inputs
|
|
51
51
|
- ACL: Handles access control
|
|
52
52
|
|
|
@@ -64,6 +64,12 @@ Mock contracts are automatically deployed when using the Hardhat network:
|
|
|
64
64
|
- Running tests: `npx hardhat test`
|
|
65
65
|
- Starting a local node: `npx hardhat node`
|
|
66
66
|
|
|
67
|
+
To disable this automatic deployment (for example, when your tests only use external RPCs and don't need the in-process Hardhat network), set:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
COFHE_SKIP_MOCKS_DEPLOY=1
|
|
71
|
+
```
|
|
72
|
+
|
|
67
73
|
You can also manually deploy mock contracts:
|
|
68
74
|
|
|
69
75
|
```bash
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PublicClient, WalletClient } from 'viem';
|
|
2
2
|
import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';
|
|
3
|
-
import {
|
|
3
|
+
import { CofheInputConfig, CofheConfig, CofheClient } from '@cofhe/sdk';
|
|
4
4
|
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
|
5
5
|
import * as ethers from 'ethers';
|
|
6
6
|
import { Contract, ethers as ethers$1 } from 'ethers';
|
|
@@ -49,7 +49,7 @@ declare const mock_withLogs: (hre: HardhatRuntimeEnvironment, closureName: strin
|
|
|
49
49
|
*/
|
|
50
50
|
declare module 'hardhat/types/config' {
|
|
51
51
|
interface HardhatUserConfig {
|
|
52
|
-
|
|
52
|
+
cofhe?: {
|
|
53
53
|
/** Whether to log mock operations (default: true) */
|
|
54
54
|
logMocks?: boolean;
|
|
55
55
|
/** Whether to show gas usage warnings for mock operations (default: true) */
|
|
@@ -57,7 +57,7 @@ declare module 'hardhat/types/config' {
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
interface HardhatConfig {
|
|
60
|
-
|
|
60
|
+
cofhe: {
|
|
61
61
|
/** Whether to log mock operations (default: true) */
|
|
62
62
|
logMocks: boolean;
|
|
63
63
|
/** Whether to show gas usage warnings for mock operations (default: true) */
|
|
@@ -72,21 +72,21 @@ declare module 'hardhat/types/config' {
|
|
|
72
72
|
*/
|
|
73
73
|
declare module 'hardhat/types/runtime' {
|
|
74
74
|
interface HardhatRuntimeEnvironment {
|
|
75
|
-
|
|
75
|
+
cofhe: {
|
|
76
76
|
/**
|
|
77
|
-
* Create a CoFHE
|
|
78
|
-
* @param {
|
|
79
|
-
* @returns {
|
|
77
|
+
* Create a CoFHE configuration for use with hre.cofhe.createClient(...)
|
|
78
|
+
* @param {CofheInputConfig} config - The CoFHE input configuration
|
|
79
|
+
* @returns {CofheConfig} The CoFHE configuration
|
|
80
80
|
*/
|
|
81
|
-
|
|
81
|
+
createConfig: (config: CofheInputConfig) => Promise<CofheConfig>;
|
|
82
82
|
/**
|
|
83
|
-
* Create a CoFHE
|
|
84
|
-
* @param {
|
|
85
|
-
* @returns {Promise<
|
|
83
|
+
* Create a CoFHE client instance
|
|
84
|
+
* @param {CofheConfig} config - The CoFHE configuration (use createCofheConfig to create with Node.js defaults)
|
|
85
|
+
* @returns {Promise<CofheClient>} The CoFHE client instance
|
|
86
86
|
*/
|
|
87
|
-
|
|
87
|
+
createClient: (config: CofheConfig) => CofheClient;
|
|
88
88
|
/**
|
|
89
|
-
* Create viem clients from a Hardhat ethers signer, to be used with `
|
|
89
|
+
* Create viem clients from a Hardhat ethers signer, to be used with `cofheClient.connect(...)`
|
|
90
90
|
* @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use
|
|
91
91
|
* @returns {Promise<{ publicClient: PublicClient; walletClient: WalletClient }>} The viem clients
|
|
92
92
|
*/
|
|
@@ -95,20 +95,20 @@ declare module 'hardhat/types/runtime' {
|
|
|
95
95
|
walletClient: WalletClient;
|
|
96
96
|
}>;
|
|
97
97
|
/**
|
|
98
|
-
* Connect a CoFHE
|
|
99
|
-
* @param {
|
|
98
|
+
* Connect a CoFHE client with a Hardhat ethers signer
|
|
99
|
+
* @param {CofheClient} client - The CoFHE client to connect
|
|
100
100
|
* @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use
|
|
101
101
|
* @returns {Promise<void>}
|
|
102
102
|
*/
|
|
103
|
-
connectWithHardhatSigner: (client:
|
|
103
|
+
connectWithHardhatSigner: (client: CofheClient, signer: HardhatEthersSigner) => Promise<void>;
|
|
104
104
|
/**
|
|
105
105
|
* Create and connect to a batteries included client.
|
|
106
106
|
* Also generates a self-usage a permit for the signer.
|
|
107
|
-
* If customization is needed, use
|
|
107
|
+
* If customization is needed, use createCofheClient and connectWithHardhatSigner.
|
|
108
108
|
* @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use (optional - defaults to first signer)
|
|
109
|
-
* @returns {Promise<
|
|
109
|
+
* @returns {Promise<CofheClient>} The CoFHE client instance
|
|
110
110
|
*/
|
|
111
|
-
|
|
111
|
+
createClientWithBatteries: (signer?: HardhatEthersSigner) => Promise<CofheClient>;
|
|
112
112
|
mocks: {
|
|
113
113
|
/**
|
|
114
114
|
* **[MOCKS ONLY]**
|
|
@@ -120,7 +120,7 @@ declare module 'hardhat/types/runtime' {
|
|
|
120
120
|
* Example usage:
|
|
121
121
|
*
|
|
122
122
|
* ```ts
|
|
123
|
-
* await hre.
|
|
123
|
+
* await hre.cofhe.mocks.withLogs("counter.increment()", async () => {
|
|
124
124
|
* await counter.increment();
|
|
125
125
|
* });
|
|
126
126
|
* ```
|
|
@@ -186,10 +186,10 @@ declare module 'hardhat/types/runtime' {
|
|
|
186
186
|
*/
|
|
187
187
|
getMockACL: () => Promise<Contract>;
|
|
188
188
|
/**
|
|
189
|
-
* Get the
|
|
190
|
-
* @returns {Promise<Contract>} The
|
|
189
|
+
* Get the MockThresholdNetwork contract
|
|
190
|
+
* @returns {Promise<Contract>} The MockThresholdNetwork contract
|
|
191
191
|
*/
|
|
192
|
-
|
|
192
|
+
getMockThresholdNetwork: () => Promise<Contract>;
|
|
193
193
|
/**
|
|
194
194
|
* Get the MockZkVerifier contract
|
|
195
195
|
* @returns {Promise<Contract>} The MockZkVerifier contract
|
|
@@ -204,5 +204,11 @@ declare module 'hardhat/types/runtime' {
|
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Builds the mocks config for the hardhat plugin.
|
|
209
|
+
* Defaults `encryptDelay` to `0` so tests run without artificial wait times,
|
|
210
|
+
* unless the user has explicitly provided a value.
|
|
211
|
+
*/
|
|
212
|
+
declare function buildHardhatPluginMocksConfig(mocksConfig: CofheInputConfig['mocks']): NonNullable<CofheInputConfig['mocks']>;
|
|
207
213
|
|
|
208
|
-
export { type DeployMocksArgs, TASK_COFHE_MOCKS_DEPLOY, TASK_COFHE_MOCKS_SET_LOG_OPS, TASK_COFHE_USE_FAUCET, deployMockContractFromArtifact, deployMocks, getFixedMockContract, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PublicClient, WalletClient } from 'viem';
|
|
2
2
|
import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';
|
|
3
|
-
import {
|
|
3
|
+
import { CofheInputConfig, CofheConfig, CofheClient } from '@cofhe/sdk';
|
|
4
4
|
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
|
5
5
|
import * as ethers from 'ethers';
|
|
6
6
|
import { Contract, ethers as ethers$1 } from 'ethers';
|
|
@@ -49,7 +49,7 @@ declare const mock_withLogs: (hre: HardhatRuntimeEnvironment, closureName: strin
|
|
|
49
49
|
*/
|
|
50
50
|
declare module 'hardhat/types/config' {
|
|
51
51
|
interface HardhatUserConfig {
|
|
52
|
-
|
|
52
|
+
cofhe?: {
|
|
53
53
|
/** Whether to log mock operations (default: true) */
|
|
54
54
|
logMocks?: boolean;
|
|
55
55
|
/** Whether to show gas usage warnings for mock operations (default: true) */
|
|
@@ -57,7 +57,7 @@ declare module 'hardhat/types/config' {
|
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
interface HardhatConfig {
|
|
60
|
-
|
|
60
|
+
cofhe: {
|
|
61
61
|
/** Whether to log mock operations (default: true) */
|
|
62
62
|
logMocks: boolean;
|
|
63
63
|
/** Whether to show gas usage warnings for mock operations (default: true) */
|
|
@@ -72,21 +72,21 @@ declare module 'hardhat/types/config' {
|
|
|
72
72
|
*/
|
|
73
73
|
declare module 'hardhat/types/runtime' {
|
|
74
74
|
interface HardhatRuntimeEnvironment {
|
|
75
|
-
|
|
75
|
+
cofhe: {
|
|
76
76
|
/**
|
|
77
|
-
* Create a CoFHE
|
|
78
|
-
* @param {
|
|
79
|
-
* @returns {
|
|
77
|
+
* Create a CoFHE configuration for use with hre.cofhe.createClient(...)
|
|
78
|
+
* @param {CofheInputConfig} config - The CoFHE input configuration
|
|
79
|
+
* @returns {CofheConfig} The CoFHE configuration
|
|
80
80
|
*/
|
|
81
|
-
|
|
81
|
+
createConfig: (config: CofheInputConfig) => Promise<CofheConfig>;
|
|
82
82
|
/**
|
|
83
|
-
* Create a CoFHE
|
|
84
|
-
* @param {
|
|
85
|
-
* @returns {Promise<
|
|
83
|
+
* Create a CoFHE client instance
|
|
84
|
+
* @param {CofheConfig} config - The CoFHE configuration (use createCofheConfig to create with Node.js defaults)
|
|
85
|
+
* @returns {Promise<CofheClient>} The CoFHE client instance
|
|
86
86
|
*/
|
|
87
|
-
|
|
87
|
+
createClient: (config: CofheConfig) => CofheClient;
|
|
88
88
|
/**
|
|
89
|
-
* Create viem clients from a Hardhat ethers signer, to be used with `
|
|
89
|
+
* Create viem clients from a Hardhat ethers signer, to be used with `cofheClient.connect(...)`
|
|
90
90
|
* @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use
|
|
91
91
|
* @returns {Promise<{ publicClient: PublicClient; walletClient: WalletClient }>} The viem clients
|
|
92
92
|
*/
|
|
@@ -95,20 +95,20 @@ declare module 'hardhat/types/runtime' {
|
|
|
95
95
|
walletClient: WalletClient;
|
|
96
96
|
}>;
|
|
97
97
|
/**
|
|
98
|
-
* Connect a CoFHE
|
|
99
|
-
* @param {
|
|
98
|
+
* Connect a CoFHE client with a Hardhat ethers signer
|
|
99
|
+
* @param {CofheClient} client - The CoFHE client to connect
|
|
100
100
|
* @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use
|
|
101
101
|
* @returns {Promise<void>}
|
|
102
102
|
*/
|
|
103
|
-
connectWithHardhatSigner: (client:
|
|
103
|
+
connectWithHardhatSigner: (client: CofheClient, signer: HardhatEthersSigner) => Promise<void>;
|
|
104
104
|
/**
|
|
105
105
|
* Create and connect to a batteries included client.
|
|
106
106
|
* Also generates a self-usage a permit for the signer.
|
|
107
|
-
* If customization is needed, use
|
|
107
|
+
* If customization is needed, use createCofheClient and connectWithHardhatSigner.
|
|
108
108
|
* @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use (optional - defaults to first signer)
|
|
109
|
-
* @returns {Promise<
|
|
109
|
+
* @returns {Promise<CofheClient>} The CoFHE client instance
|
|
110
110
|
*/
|
|
111
|
-
|
|
111
|
+
createClientWithBatteries: (signer?: HardhatEthersSigner) => Promise<CofheClient>;
|
|
112
112
|
mocks: {
|
|
113
113
|
/**
|
|
114
114
|
* **[MOCKS ONLY]**
|
|
@@ -120,7 +120,7 @@ declare module 'hardhat/types/runtime' {
|
|
|
120
120
|
* Example usage:
|
|
121
121
|
*
|
|
122
122
|
* ```ts
|
|
123
|
-
* await hre.
|
|
123
|
+
* await hre.cofhe.mocks.withLogs("counter.increment()", async () => {
|
|
124
124
|
* await counter.increment();
|
|
125
125
|
* });
|
|
126
126
|
* ```
|
|
@@ -186,10 +186,10 @@ declare module 'hardhat/types/runtime' {
|
|
|
186
186
|
*/
|
|
187
187
|
getMockACL: () => Promise<Contract>;
|
|
188
188
|
/**
|
|
189
|
-
* Get the
|
|
190
|
-
* @returns {Promise<Contract>} The
|
|
189
|
+
* Get the MockThresholdNetwork contract
|
|
190
|
+
* @returns {Promise<Contract>} The MockThresholdNetwork contract
|
|
191
191
|
*/
|
|
192
|
-
|
|
192
|
+
getMockThresholdNetwork: () => Promise<Contract>;
|
|
193
193
|
/**
|
|
194
194
|
* Get the MockZkVerifier contract
|
|
195
195
|
* @returns {Promise<Contract>} The MockZkVerifier contract
|
|
@@ -204,5 +204,11 @@ declare module 'hardhat/types/runtime' {
|
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Builds the mocks config for the hardhat plugin.
|
|
209
|
+
* Defaults `encryptDelay` to `0` so tests run without artificial wait times,
|
|
210
|
+
* unless the user has explicitly provided a value.
|
|
211
|
+
*/
|
|
212
|
+
declare function buildHardhatPluginMocksConfig(mocksConfig: CofheInputConfig['mocks']): NonNullable<CofheInputConfig['mocks']>;
|
|
207
213
|
|
|
208
|
-
export { type DeployMocksArgs, TASK_COFHE_MOCKS_DEPLOY, TASK_COFHE_MOCKS_SET_LOG_OPS, TASK_COFHE_USE_FAUCET, deployMockContractFromArtifact, deployMocks, getFixedMockContract, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(src_exports, {
|
|
|
33
33
|
TASK_COFHE_MOCKS_DEPLOY: () => TASK_COFHE_MOCKS_DEPLOY,
|
|
34
34
|
TASK_COFHE_MOCKS_SET_LOG_OPS: () => TASK_COFHE_MOCKS_SET_LOG_OPS,
|
|
35
35
|
TASK_COFHE_USE_FAUCET: () => TASK_COFHE_USE_FAUCET,
|
|
36
|
+
buildHardhatPluginMocksConfig: () => buildHardhatPluginMocksConfig,
|
|
36
37
|
deployMockContractFromArtifact: () => deployMockContractFromArtifact,
|
|
37
38
|
deployMocks: () => deployMocks,
|
|
38
39
|
getFixedMockContract: () => getFixedMockContract,
|
|
@@ -208,8 +209,8 @@ var deployMocks = async (hre, options = {
|
|
|
208
209
|
logSuccess(`ETH balance: ${zkVerifierSignerBalance.toString()}`, 2);
|
|
209
210
|
const zkVerifier = await deployMockZkVerifier(hre);
|
|
210
211
|
logDeployment("MockZkVerifier", await zkVerifier.getAddress());
|
|
211
|
-
const
|
|
212
|
-
logDeployment("
|
|
212
|
+
const thresholdNetwork = await deployMockThresholdNetwork(hre, acl);
|
|
213
|
+
logDeployment("MockThresholdNetwork", await thresholdNetwork.getAddress());
|
|
213
214
|
if (options.deployTestBed) {
|
|
214
215
|
logSuccess("TestBed deployment enabled", 2);
|
|
215
216
|
const testBed = await deployTestBedContract(hre);
|
|
@@ -271,15 +272,15 @@ var deployMockZkVerifier = async (hre) => {
|
|
|
271
272
|
}
|
|
272
273
|
return zkVerifier;
|
|
273
274
|
};
|
|
274
|
-
var
|
|
275
|
-
const
|
|
276
|
-
const initTx = await
|
|
275
|
+
var deployMockThresholdNetwork = async (hre, acl) => {
|
|
276
|
+
const thresholdNetwork = await deployMockContractFromArtifact(hre, import_mock_contracts.MockThresholdNetworkArtifact);
|
|
277
|
+
const initTx = await thresholdNetwork.initialize(import_sdk2.TASK_MANAGER_ADDRESS, await acl.getAddress());
|
|
277
278
|
await initTx.wait();
|
|
278
|
-
const
|
|
279
|
-
if (!
|
|
280
|
-
throw new Error("
|
|
279
|
+
const exists = await thresholdNetwork.exists();
|
|
280
|
+
if (!exists) {
|
|
281
|
+
throw new Error("MockThresholdNetwork does not exist");
|
|
281
282
|
}
|
|
282
|
-
return
|
|
283
|
+
return thresholdNetwork;
|
|
283
284
|
};
|
|
284
285
|
var deployTestBedContract = async (hre) => {
|
|
285
286
|
return deployMockContractFromArtifact(hre, import_mock_contracts.TestBedArtifact);
|
|
@@ -398,9 +399,9 @@ var import_mock_contracts3 = require("@cofhe/mock-contracts");
|
|
|
398
399
|
httpHeaders: {}
|
|
399
400
|
};
|
|
400
401
|
}
|
|
401
|
-
config.
|
|
402
|
-
logMocks: userConfig.
|
|
403
|
-
gasWarning: userConfig.
|
|
402
|
+
config.cofhe = {
|
|
403
|
+
logMocks: userConfig.cofhe?.logMocks ?? true,
|
|
404
|
+
gasWarning: userConfig.cofhe?.gasWarning ?? true
|
|
404
405
|
};
|
|
405
406
|
});
|
|
406
407
|
(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) => {
|
|
@@ -424,44 +425,65 @@ var import_mock_contracts3 = require("@cofhe/mock-contracts");
|
|
|
424
425
|
(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).addOptionalParam("silent", "Whether to suppress output", false, import_config.types.boolean).setAction(async ({ deployTestBed, silent }, hre) => {
|
|
425
426
|
await deployMocks(hre, {
|
|
426
427
|
deployTestBed: deployTestBed ?? true,
|
|
427
|
-
gasWarning: hre.config.
|
|
428
|
+
gasWarning: hre.config.cofhe.gasWarning ?? true,
|
|
428
429
|
silent: silent ?? false
|
|
429
430
|
});
|
|
430
431
|
});
|
|
431
432
|
(0, import_config.task)(import_task_names.TASK_TEST, "Deploy mock contracts on hardhat").setAction(async ({}, hre, runSuper) => {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
433
|
+
const skipAutoDeploy = (() => {
|
|
434
|
+
const raw = process.env.COFHE_SKIP_MOCKS_DEPLOY ?? "";
|
|
435
|
+
const normalized = raw.trim().toLowerCase();
|
|
436
|
+
return normalized === "1" || normalized === "true" || normalized === "yes";
|
|
437
|
+
})();
|
|
438
|
+
if (!skipAutoDeploy) {
|
|
439
|
+
await deployMocks(hre, {
|
|
440
|
+
deployTestBed: true,
|
|
441
|
+
gasWarning: hre.config.cofhe.gasWarning ?? true
|
|
442
|
+
});
|
|
443
|
+
}
|
|
436
444
|
return runSuper();
|
|
437
445
|
});
|
|
438
446
|
(0, import_config.task)(import_task_names.TASK_NODE, "Deploy mock contracts on hardhat").setAction(async ({}, hre, runSuper) => {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
447
|
+
const skipAutoDeploy = (() => {
|
|
448
|
+
const raw = process.env.COFHE_SKIP_MOCKS_DEPLOY ?? "";
|
|
449
|
+
const normalized = raw.trim().toLowerCase();
|
|
450
|
+
return normalized === "1" || normalized === "true" || normalized === "yes";
|
|
451
|
+
})();
|
|
452
|
+
if (!skipAutoDeploy) {
|
|
453
|
+
await deployMocks(hre, {
|
|
454
|
+
deployTestBed: true,
|
|
455
|
+
gasWarning: hre.config.cofhe.gasWarning ?? true
|
|
456
|
+
});
|
|
457
|
+
}
|
|
443
458
|
return runSuper();
|
|
444
459
|
});
|
|
445
460
|
(0, import_config.task)(TASK_COFHE_MOCKS_SET_LOG_OPS, "Set logging for the Mock CoFHE contracts").addParam("enable", "Whether to enable logging", false, import_config.types.boolean).setAction(async ({ enable }, hre) => {
|
|
446
461
|
await mock_setLoggingEnabled(hre, enable);
|
|
447
462
|
});
|
|
463
|
+
function buildHardhatPluginMocksConfig(mocksConfig) {
|
|
464
|
+
return {
|
|
465
|
+
...mocksConfig,
|
|
466
|
+
encryptDelay: mocksConfig?.encryptDelay ?? 0
|
|
467
|
+
};
|
|
468
|
+
}
|
|
448
469
|
(0, import_config.extendEnvironment)((hre) => {
|
|
449
|
-
hre.
|
|
450
|
-
|
|
470
|
+
hre.cofhe = {
|
|
471
|
+
createConfig: async (config) => {
|
|
451
472
|
const zkvHhSigner = await hre.ethers.getImpersonatedSigner(import_sdk3.MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);
|
|
452
473
|
const { walletClient: zkvWalletClient } = await (0, import_adapters.HardhatSignerAdapter)(zkvHhSigner);
|
|
453
474
|
const configWithZkvWalletClient = {
|
|
454
475
|
environment: "hardhat",
|
|
455
476
|
...config,
|
|
477
|
+
mocks: buildHardhatPluginMocksConfig(config.mocks),
|
|
456
478
|
_internal: {
|
|
457
479
|
...config._internal,
|
|
458
480
|
zkvWalletClient
|
|
459
481
|
}
|
|
460
482
|
};
|
|
461
|
-
return (0, import_node.
|
|
483
|
+
return (0, import_node.createCofheConfig)(configWithZkvWalletClient);
|
|
462
484
|
},
|
|
463
|
-
|
|
464
|
-
return (0, import_node.
|
|
485
|
+
createClient: (config) => {
|
|
486
|
+
return (0, import_node.createCofheClient)(config);
|
|
465
487
|
},
|
|
466
488
|
hardhatSignerAdapter: async (signer) => {
|
|
467
489
|
return (0, import_adapters.HardhatSignerAdapter)(signer);
|
|
@@ -470,16 +492,16 @@ var import_mock_contracts3 = require("@cofhe/mock-contracts");
|
|
|
470
492
|
const { publicClient, walletClient } = await (0, import_adapters.HardhatSignerAdapter)(signer);
|
|
471
493
|
return client.connect(publicClient, walletClient);
|
|
472
494
|
},
|
|
473
|
-
|
|
495
|
+
createClientWithBatteries: async (signer) => {
|
|
474
496
|
if (!signer) {
|
|
475
497
|
[signer] = await hre.ethers.getSigners();
|
|
476
498
|
}
|
|
477
|
-
const config = await hre.
|
|
499
|
+
const config = await hre.cofhe.createConfig({
|
|
478
500
|
environment: "hardhat",
|
|
479
501
|
supportedChains: [import_chains.hardhat]
|
|
480
502
|
});
|
|
481
|
-
const client = hre.
|
|
482
|
-
await hre.
|
|
503
|
+
const client = hre.cofhe.createClient(config);
|
|
504
|
+
await hre.cofhe.connectWithHardhatSigner(client, signer);
|
|
483
505
|
await client.permits.createSelf({
|
|
484
506
|
issuer: signer.address
|
|
485
507
|
});
|
|
@@ -512,7 +534,7 @@ var import_mock_contracts3 = require("@cofhe/mock-contracts");
|
|
|
512
534
|
const aclAddress = await taskManager.acl();
|
|
513
535
|
return hre.ethers.getContractAt(import_mock_contracts3.MockACLArtifact.abi, aclAddress);
|
|
514
536
|
},
|
|
515
|
-
|
|
537
|
+
getMockThresholdNetwork: async () => getFixedMockContract(hre, import_mock_contracts3.MockThresholdNetworkArtifact),
|
|
516
538
|
getMockZkVerifier: async () => getFixedMockContract(hre, import_mock_contracts3.MockZkVerifierArtifact),
|
|
517
539
|
getTestBed: async () => getFixedMockContract(hre, import_mock_contracts3.TestBedArtifact)
|
|
518
540
|
}
|
|
@@ -523,6 +545,7 @@ var import_mock_contracts3 = require("@cofhe/mock-contracts");
|
|
|
523
545
|
TASK_COFHE_MOCKS_DEPLOY,
|
|
524
546
|
TASK_COFHE_MOCKS_SET_LOG_OPS,
|
|
525
547
|
TASK_COFHE_USE_FAUCET,
|
|
548
|
+
buildHardhatPluginMocksConfig,
|
|
526
549
|
deployMockContractFromArtifact,
|
|
527
550
|
deployMocks,
|
|
528
551
|
getFixedMockContract,
|