@cofhe/hardhat-plugin 0.1.1 → 0.2.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/dist/index.mjs CHANGED
@@ -4,7 +4,9 @@ import "viem";
4
4
  import { extendConfig, extendEnvironment, task, types } from "hardhat/config";
5
5
  import { TASK_TEST, TASK_NODE } from "hardhat/builtin-tasks/task-names";
6
6
  import "@nomicfoundation/hardhat-ethers/signers";
7
- import "@cofhe/sdk";
7
+ import {
8
+ MOCKS_ZK_VERIFIER_SIGNER_ADDRESS as MOCKS_ZK_VERIFIER_SIGNER_ADDRESS2
9
+ } from "@cofhe/sdk";
8
10
  import { createCofhesdkClient, createCofhesdkConfig } from "@cofhe/sdk/node";
9
11
  import { HardhatSignerAdapter } from "@cofhe/sdk/adapters";
10
12
 
@@ -64,12 +66,6 @@ async function localcofheFundWalletIfNeeded(hre, walletAddress) {
64
66
  var TASK_COFHE_USE_FAUCET = "task:cofhe:usefaucet";
65
67
  var TASK_COFHE_MOCKS_SET_LOG_OPS = "task:cofhe-mocks:setlogops";
66
68
  var TASK_COFHE_MOCKS_DEPLOY = "task:cofhe-mocks:deploy";
67
- var TASK_MANAGER_ADDRESS = "0xeA30c4B8b44078Bbf8a6ef5b9f1eC1626C7848D9";
68
- var MOCKS_ACL_ADDRESS = "0x0000000000000000000000000000000000000400";
69
- var MOCKS_ZK_VERIFIER_ADDRESS = "0x0000000000000000000000000000000000000100";
70
- var MOCKS_QUERY_DECRYPTER_ADDRESS = "0x0000000000000000000000000000000000000200";
71
- var TEST_BED_ADDRESS = "0x0000000000000000000000000000000000000300";
72
- var MOCKS_ZK_VERIFIER_SIGNER_ADDRESS = "0x6E12D8C87503D4287c294f2Fdef96ACd9DFf6bd2";
73
69
 
74
70
  // src/deploy.ts
75
71
  import "hardhat/types";
@@ -82,10 +78,122 @@ import {
82
78
  MockQueryDecrypterArtifact,
83
79
  TestBedArtifact
84
80
  } from "@cofhe/mock-contracts";
81
+ import { TASK_MANAGER_ADDRESS as TASK_MANAGER_ADDRESS2, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS } from "@cofhe/sdk";
82
+
83
+ // src/utils.ts
84
+ import { TASK_MANAGER_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS } from "@cofhe/sdk";
85
+ import { expect } from "chai";
86
+ import { ethers } from "ethers";
87
+ import "@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider";
88
+ var deployMockContractFromArtifact = async (hre, artifact) => {
89
+ if (artifact.isFixed) {
90
+ await hre.network.provider.send("hardhat_setCode", [artifact.fixedAddress, artifact.deployedBytecode]);
91
+ return getFixedMockContract(hre, artifact);
92
+ }
93
+ const [signer] = await hre.ethers.getSigners();
94
+ const factory = new hre.ethers.ContractFactory(artifact.abi, artifact.bytecode, signer);
95
+ const contract = await factory.deploy(
96
+ /* constructor args */
97
+ );
98
+ await contract.waitForDeployment();
99
+ return contract;
100
+ };
101
+ var getFixedMockContract = async (hre, artifact) => {
102
+ if (!artifact.isFixed) {
103
+ throw new Error("Artifact is not fixed");
104
+ }
105
+ return await hre.ethers.getContractAt(artifact.abi, artifact.fixedAddress);
106
+ };
107
+ var mock_checkIsTestnet = async (fnName, provider) => {
108
+ const bytecode = await provider.getCode(MOCKS_ZK_VERIFIER_ADDRESS);
109
+ const isTestnet = bytecode.length === 0;
110
+ if (isTestnet) {
111
+ console.log(`${fnName} - skipped on non-testnet chain`);
112
+ }
113
+ return isTestnet;
114
+ };
115
+ var mock_getPlaintext = async (provider, ctHash) => {
116
+ if (await mock_checkIsTestnet(mock_getPlaintext.name, provider))
117
+ return;
118
+ const taskManager = new ethers.Contract(
119
+ TASK_MANAGER_ADDRESS,
120
+ ["function mockStorage(uint256) view returns (uint256)"],
121
+ provider
122
+ );
123
+ const plaintext = await taskManager.mockStorage(ctHash);
124
+ return plaintext;
125
+ };
126
+ var mock_getPlaintextExists = async (provider, ctHash) => {
127
+ if (await mock_checkIsTestnet(mock_getPlaintextExists.name, provider))
128
+ return;
129
+ const taskManager = new ethers.Contract(
130
+ TASK_MANAGER_ADDRESS,
131
+ ["function inMockStorage(uint256) view returns (bool)"],
132
+ provider
133
+ );
134
+ const plaintextExists = await taskManager.inMockStorage(ctHash);
135
+ return plaintextExists;
136
+ };
137
+ var mock_expectPlaintext = async (provider, ctHash, expectedValue) => {
138
+ if (await mock_checkIsTestnet(mock_expectPlaintext.name, provider))
139
+ return;
140
+ const plaintextExists = await mock_getPlaintextExists(provider, ctHash);
141
+ expect(plaintextExists).equal(true, "Plaintext does not exist");
142
+ const plaintext = await mock_getPlaintext(provider, ctHash);
143
+ expect(plaintext).equal(expectedValue, "Plaintext value is incorrect");
144
+ };
145
+
146
+ // src/deploy.ts
147
+ var deployMocks = async (hre, options = {
148
+ deployTestBed: true,
149
+ gasWarning: true,
150
+ silent: false
151
+ }) => {
152
+ const isHardhat = await getIsHardhat(hre);
153
+ if (!isHardhat) {
154
+ logSuccess(`cofhe-hardhat-plugin - deploy mocks - skipped on non-hardhat network ${hre.network.name}`, 0);
155
+ return;
156
+ }
157
+ isSilent = options.silent ?? false;
158
+ logEmpty();
159
+ logSuccess(chalk.bold("cofhe-hardhat-plugin :: deploy mocks"), 0);
160
+ logEmpty();
161
+ const taskManager = await deployMockTaskManager(hre);
162
+ logDeployment("MockTaskManager", await taskManager.getAddress());
163
+ const acl = await deployMockACL(hre);
164
+ logDeployment("MockACL", await acl.getAddress());
165
+ await linkTaskManagerAndACL(taskManager, acl);
166
+ logSuccess("ACL address set in TaskManager", 2);
167
+ await fundZkVerifierSigner(hre);
168
+ logSuccess(`ZkVerifier signer (${MOCKS_ZK_VERIFIER_SIGNER_ADDRESS}) funded`, 1);
169
+ const zkVerifierSignerBalance = await getZkVerifierSignerBalance(hre);
170
+ logSuccess(`ETH balance: ${zkVerifierSignerBalance.toString()}`, 2);
171
+ const zkVerifier = await deployMockZkVerifier(hre);
172
+ logDeployment("MockZkVerifier", await zkVerifier.getAddress());
173
+ const queryDecrypter = await deployMockQueryDecrypter(hre, acl);
174
+ logDeployment("MockQueryDecrypter", await queryDecrypter.getAddress());
175
+ if (options.deployTestBed) {
176
+ logSuccess("TestBed deployment enabled", 2);
177
+ const testBed = await deployTestBedContract(hre);
178
+ logDeployment("TestBed", await testBed.getAddress());
179
+ }
180
+ logEmpty();
181
+ logSuccess(chalk.bold("cofhe-hardhat-plugin :: mocks deployed successfully"), 0);
182
+ if (options.gasWarning) {
183
+ logEmpty();
184
+ logWarning(
185
+ "When using mocks, FHE operations (eg FHE.add / FHE.mul) report a higher gas price due to additional on-chain mocking logic. Deploy your contracts on a testnet chain to check the true gas costs.\n(Disable this warning by setting '@cofhe/sdk.gasWarning' to false in your hardhat config",
186
+ 0
187
+ );
188
+ }
189
+ logEmpty();
190
+ };
191
+ var getIsHardhat = async (hre) => {
192
+ return hre.network.name === "hardhat";
193
+ };
85
194
  var deployMockTaskManager = async (hre) => {
86
195
  const [signer] = await hre.ethers.getSigners();
87
- await hardhatSetCode(hre, TASK_MANAGER_ADDRESS, MockTaskManagerArtifact.deployedBytecode);
88
- const taskManager = await hre.ethers.getContractAt(MockTaskManagerArtifact.abi, TASK_MANAGER_ADDRESS);
196
+ const taskManager = await deployMockContractFromArtifact(hre, MockTaskManagerArtifact);
89
197
  const initTx = await taskManager.initialize(signer.address);
90
198
  await initTx.wait();
91
199
  const tmExists = await taskManager.exists();
@@ -95,140 +203,68 @@ var deployMockTaskManager = async (hre) => {
95
203
  return taskManager;
96
204
  };
97
205
  var deployMockACL = async (hre) => {
98
- await hardhatSetCode(hre, MOCKS_ACL_ADDRESS, MockACLArtifact.deployedBytecode);
99
- const acl = await hre.ethers.getContractAt(MockACLArtifact.abi, MOCKS_ACL_ADDRESS);
206
+ const acl = await deployMockContractFromArtifact(hre, MockACLArtifact);
100
207
  const exists = await acl.exists();
101
208
  if (!exists) {
102
- logError("MockACL does not exist", 2);
103
209
  throw new Error("MockACL does not exist");
104
210
  }
105
211
  return acl;
106
212
  };
213
+ var fundZkVerifierSigner = async (hre) => {
214
+ const zkVerifierSigner = await hre.ethers.getSigner(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);
215
+ await hre.network.provider.send("hardhat_setBalance", [
216
+ zkVerifierSigner.address,
217
+ "0x" + hre.ethers.parseEther("10").toString(16)
218
+ ]);
219
+ };
220
+ var getZkVerifierSignerBalance = async (hre) => {
221
+ return hre.ethers.provider.getBalance(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);
222
+ };
223
+ var linkTaskManagerAndACL = async (taskManager, acl) => {
224
+ const aclAddress = await acl.getAddress();
225
+ const linkAclTx = await taskManager.setACLContract(aclAddress);
226
+ await linkAclTx.wait();
227
+ };
107
228
  var deployMockZkVerifier = async (hre) => {
108
- await hardhatSetCode(hre, MOCKS_ZK_VERIFIER_ADDRESS, MockZkVerifierArtifact.deployedBytecode);
109
- const zkVerifier = await hre.ethers.getContractAt(MockZkVerifierArtifact.abi, MOCKS_ZK_VERIFIER_ADDRESS);
229
+ const zkVerifier = await deployMockContractFromArtifact(hre, MockZkVerifierArtifact);
110
230
  const zkVerifierExists = await zkVerifier.exists();
111
231
  if (!zkVerifierExists) {
112
- logError("MockZkVerifier does not exist", 2);
113
232
  throw new Error("MockZkVerifier does not exist");
114
233
  }
115
234
  return zkVerifier;
116
235
  };
117
236
  var deployMockQueryDecrypter = async (hre, acl) => {
118
- await hardhatSetCode(hre, MOCKS_QUERY_DECRYPTER_ADDRESS, MockQueryDecrypterArtifact.deployedBytecode);
119
- const queryDecrypter = await hre.ethers.getContractAt(MockQueryDecrypterArtifact.abi, MOCKS_QUERY_DECRYPTER_ADDRESS);
120
- const initTx = await queryDecrypter.initialize(TASK_MANAGER_ADDRESS, await acl.getAddress());
237
+ const queryDecrypter = await deployMockContractFromArtifact(hre, MockQueryDecrypterArtifact);
238
+ const initTx = await queryDecrypter.initialize(TASK_MANAGER_ADDRESS2, await acl.getAddress());
121
239
  await initTx.wait();
122
240
  const queryDecrypterExists = await queryDecrypter.exists();
123
241
  if (!queryDecrypterExists) {
124
- logError("MockQueryDecrypter does not exist", 2);
125
242
  throw new Error("MockQueryDecrypter does not exist");
126
243
  }
127
244
  return queryDecrypter;
128
245
  };
129
246
  var deployTestBedContract = async (hre) => {
130
- await hardhatSetCode(hre, TEST_BED_ADDRESS, TestBedArtifact.deployedBytecode);
131
- const testBed = await hre.ethers.getContractAt(TestBedArtifact.abi, TEST_BED_ADDRESS);
132
- await testBed.waitForDeployment();
133
- return testBed;
134
- };
135
- var fundZkVerifierSigner = async (hre) => {
136
- const zkVerifierSigner = await hre.ethers.getSigner(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);
137
- await hre.network.provider.send("hardhat_setBalance", [
138
- zkVerifierSigner.address,
139
- "0x" + hre.ethers.parseEther("10").toString(16)
140
- ]);
141
- };
142
- var setTaskManagerACL = async (taskManager, acl) => {
143
- const setAclTx = await taskManager.setACLContract(await acl.getAddress());
144
- await setAclTx.wait();
145
- };
146
- var deployMocks = async (hre, options = {
147
- deployTestBed: true,
148
- gasWarning: true,
149
- silent: false
150
- }) => {
151
- const isHardhat = await checkNetworkAndSkip(hre);
152
- if (!isHardhat)
153
- return;
154
- const logEmptyIfNoisy = () => {
155
- if (!options.silent) {
156
- logEmpty();
157
- }
158
- };
159
- const logSuccessIfNoisy = (message, indent = 0) => {
160
- if (!options.silent) {
161
- logSuccess(message, indent);
162
- }
163
- };
164
- const logDeploymentIfNoisy = (contractName, address) => {
165
- if (!options.silent) {
166
- logDeployment(contractName, address);
167
- }
168
- };
169
- const logWarningIfNoisy = (message, indent = 0) => {
170
- if (!options.silent) {
171
- logWarning(message, indent);
172
- }
173
- };
174
- logEmptyIfNoisy();
175
- logSuccessIfNoisy(chalk.bold("cofhe-hardhat-plugin :: deploy mocks"), 0);
176
- logEmptyIfNoisy();
177
- logEmptyIfNoisy();
178
- logSuccessIfNoisy("Mock contracts compiled", 1);
179
- const taskManager = await deployMockTaskManager(hre);
180
- logDeploymentIfNoisy("MockTaskManager", await taskManager.getAddress());
181
- const acl = await deployMockACL(hre);
182
- logDeploymentIfNoisy("MockACL", await acl.getAddress());
183
- await setTaskManagerACL(taskManager, acl);
184
- logSuccessIfNoisy("ACL address set in TaskManager", 2);
185
- await fundZkVerifierSigner(hre);
186
- logSuccessIfNoisy(`ZkVerifier signer (${MOCKS_ZK_VERIFIER_SIGNER_ADDRESS}) funded`, 1);
187
- const zkVerifierSignerBalance = await hre.ethers.provider.getBalance(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);
188
- logSuccessIfNoisy(`ETH balance: ${zkVerifierSignerBalance.toString()}`, 2);
189
- const zkVerifier = await deployMockZkVerifier(hre);
190
- logDeploymentIfNoisy("MockZkVerifier", await zkVerifier.getAddress());
191
- const queryDecrypter = await deployMockQueryDecrypter(hre, acl);
192
- logDeploymentIfNoisy("MockQueryDecrypter", await queryDecrypter.getAddress());
193
- if (options.deployTestBed) {
194
- logSuccessIfNoisy("TestBed deployment enabled", 2);
195
- const testBed = await deployTestBedContract(hre);
196
- logDeploymentIfNoisy("TestBed", await testBed.getAddress());
197
- }
198
- logEmptyIfNoisy();
199
- logSuccessIfNoisy(chalk.bold("cofhe-hardhat-plugin :: mocks deployed successfully"), 0);
200
- if (options.gasWarning) {
201
- logEmptyIfNoisy();
202
- logWarningIfNoisy(
203
- "When using mocks, FHE operations (eg FHE.add / FHE.mul) report a higher gas price due to additional on-chain mocking logic. Deploy your contracts on a testnet chain to check the true gas costs.\n(Disable this warning by setting '@cofhe/sdk.gasWarning' to false in your hardhat config",
204
- 0
205
- );
206
- }
207
- logEmptyIfNoisy();
208
- };
209
- var hardhatSetCode = async (hre, address, bytecode) => {
210
- await hre.network.provider.send("hardhat_setCode", [address, bytecode]);
211
- };
212
- var checkNetworkAndSkip = async (hre) => {
213
- const network = hre.network.name;
214
- const isHardhat = network === "hardhat";
215
- if (!isHardhat)
216
- logSuccess(`cofhe-hardhat-plugin - deploy mocks - skipped on non-hardhat network ${network}`, 0);
217
- return isHardhat;
247
+ return deployMockContractFromArtifact(hre, TestBedArtifact);
218
248
  };
249
+ var isSilent = false;
219
250
  var logEmpty = () => {
251
+ if (isSilent)
252
+ return;
220
253
  console.log("");
221
254
  };
222
255
  var logSuccess = (message, indent = 1) => {
256
+ if (isSilent)
257
+ return;
223
258
  console.log(chalk.green(`${" ".repeat(indent)}\u2713 ${message}`));
224
259
  };
225
260
  var logWarning = (message, indent = 1) => {
261
+ if (isSilent)
262
+ return;
226
263
  console.log(chalk.bold(chalk.yellow(`${" ".repeat(indent)}\u26A0 NOTE:`)), message);
227
264
  };
228
- var logError = (message, indent = 1) => {
229
- console.log(chalk.red(`${" ".repeat(indent)}\u2717 ${message}`));
230
- };
231
265
  var logDeployment = (contractName, address) => {
266
+ if (isSilent)
267
+ return;
232
268
  const paddedName = `${contractName} deployed`.padEnd(36);
233
269
  logSuccess(`${paddedName} ${chalk.bold(address)}`);
234
270
  };
@@ -237,17 +273,14 @@ var logDeployment = (contractName, address) => {
237
273
  import chalk2 from "chalk";
238
274
  import "hardhat/types";
239
275
  import { MockTaskManagerArtifact as MockTaskManagerArtifact2 } from "@cofhe/mock-contracts";
240
- var getDeployedMockTaskManager = async (hre) => {
241
- const taskManager = await hre.ethers.getContractAt(MockTaskManagerArtifact2.abi, TASK_MANAGER_ADDRESS);
242
- return taskManager;
243
- };
244
276
  var getLoggingEnabled = async (hre) => {
245
- const taskManager = await getDeployedMockTaskManager(hre);
246
- return await taskManager.logOps();
277
+ const taskManager = await getFixedMockContract(hre, MockTaskManagerArtifact2);
278
+ return taskManager.logOps();
247
279
  };
248
280
  var setLoggingEnabled = async (hre, enabled) => {
249
- const taskManager = await getDeployedMockTaskManager(hre);
250
- await taskManager.setLogOps(enabled);
281
+ const taskManager = await getFixedMockContract(hre, MockTaskManagerArtifact2);
282
+ const tx = await taskManager.setLogOps(enabled);
283
+ await tx.wait();
251
284
  };
252
285
  var printLogsEnabledMessage = (closureMessage) => {
253
286
  console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
@@ -282,72 +315,8 @@ var mock_withLogs = async (hre, closureName, closure) => {
282
315
  }
283
316
  };
284
317
 
285
- // src/utils.ts
286
- import { expect } from "chai";
287
- import { ethers } from "ethers";
288
- import "@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider";
289
- var mock_checkIsTestnet = async (fnName, provider) => {
290
- const bytecode = await provider.getCode(MOCKS_ZK_VERIFIER_ADDRESS);
291
- const isTestnet = bytecode.length === 0;
292
- if (isTestnet) {
293
- console.log(`${fnName} - skipped on non-testnet chain`);
294
- }
295
- return isTestnet;
296
- };
297
- var mock_getPlaintext = async (provider, ctHash) => {
298
- if (await mock_checkIsTestnet(mock_getPlaintext.name, provider))
299
- return;
300
- const taskManager = new ethers.Contract(
301
- TASK_MANAGER_ADDRESS,
302
- ["function mockStorage(uint256) view returns (uint256)"],
303
- provider
304
- );
305
- const plaintext = await taskManager.mockStorage(ctHash);
306
- return plaintext;
307
- };
308
- var mock_getPlaintextExists = async (provider, ctHash) => {
309
- if (await mock_checkIsTestnet(mock_getPlaintextExists.name, provider))
310
- return;
311
- const taskManager = new ethers.Contract(
312
- TASK_MANAGER_ADDRESS,
313
- ["function inMockStorage(uint256) view returns (bool)"],
314
- provider
315
- );
316
- const plaintextExists = await taskManager.inMockStorage(ctHash);
317
- return plaintextExists;
318
- };
319
- var mock_expectPlaintext = async (provider, ctHash, expectedValue) => {
320
- if (await mock_checkIsTestnet(mock_expectPlaintext.name, provider))
321
- return;
322
- const plaintextExists = await mock_getPlaintextExists(provider, ctHash);
323
- expect(plaintextExists).equal(true, "Plaintext does not exist");
324
- const plaintext = await mock_getPlaintext(provider, ctHash);
325
- expect(plaintext).equal(expectedValue, "Plaintext value is incorrect");
326
- };
327
-
328
- // src/expectResultUtils.ts
329
- import "@cofhe/sdk";
330
- import { expect as expect2 } from "chai";
331
- var expectResultError = (result, errorPartial) => {
332
- expect2(result.success).to.eq(false, "Result should be an error");
333
- expect2(result.error).to.include(errorPartial, `Error should contain error partial: ${errorPartial}`);
334
- };
335
- var expectResultSuccess = (result) => {
336
- expect2(result.success).to.eq(true, "Result should be a success");
337
- return result.data;
338
- };
339
- var expectResultValue = (result, value) => {
340
- expect2(result.success).to.eq(true, "Result should be a success");
341
- expect2(result.data).to.eq(value, `Result should have the expected value ${value}`);
342
- return result.data;
343
- };
344
- var expectResultPartialValue = (result, partial) => {
345
- expect2(result.success).to.eq(true, "Result should be a success");
346
- expect2(result.data).to.include(partial, `Result should have the expected partial ${partial}`);
347
- return result.data;
348
- };
349
-
350
318
  // src/index.ts
319
+ import { hardhat } from "@cofhe/sdk/chains";
351
320
  import {
352
321
  MockACLArtifact as MockACLArtifact2,
353
322
  MockQueryDecrypterArtifact as MockQueryDecrypterArtifact2,
@@ -447,9 +416,10 @@ task(TASK_COFHE_MOCKS_SET_LOG_OPS, "Set logging for the Mock CoFHE contracts").a
447
416
  extendEnvironment((hre) => {
448
417
  hre.cofhesdk = {
449
418
  createCofhesdkConfig: async (config) => {
450
- const zkvHhSigner = await hre.ethers.getImpersonatedSigner(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);
419
+ const zkvHhSigner = await hre.ethers.getImpersonatedSigner(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS2);
451
420
  const { walletClient: zkvWalletClient } = await HardhatSignerAdapter(zkvHhSigner);
452
421
  const configWithZkvWalletClient = {
422
+ environment: "hardhat",
453
423
  ...config,
454
424
  _internal: {
455
425
  ...config._internal,
@@ -464,21 +434,24 @@ extendEnvironment((hre) => {
464
434
  hardhatSignerAdapter: async (signer) => {
465
435
  return HardhatSignerAdapter(signer);
466
436
  },
467
- expectResultSuccess: async (result) => {
468
- const awaitedResult = await result;
469
- return expectResultSuccess(awaitedResult);
470
- },
471
- expectResultError: async (result, errorPartial) => {
472
- const awaitedResult = await result;
473
- return expectResultError(awaitedResult, errorPartial);
437
+ connectWithHardhatSigner: async (client, signer) => {
438
+ const { publicClient, walletClient } = await HardhatSignerAdapter(signer);
439
+ return client.connect(publicClient, walletClient);
474
440
  },
475
- expectResultValue: async (result, value) => {
476
- const awaitedResult = await result;
477
- return expectResultValue(awaitedResult, value);
478
- },
479
- expectResultPartialValue: async (result, partial) => {
480
- const awaitedResult = await result;
481
- return expectResultPartialValue(awaitedResult, partial);
441
+ createBatteriesIncludedCofhesdkClient: async (signer) => {
442
+ if (!signer) {
443
+ [signer] = await hre.ethers.getSigners();
444
+ }
445
+ const config = await hre.cofhesdk.createCofhesdkConfig({
446
+ environment: "hardhat",
447
+ supportedChains: [hardhat]
448
+ });
449
+ const client = hre.cofhesdk.createCofhesdkClient(config);
450
+ await hre.cofhesdk.connectWithHardhatSigner(client, signer);
451
+ await client.permits.createSelf({
452
+ issuer: signer.address
453
+ });
454
+ return client;
482
455
  },
483
456
  mocks: {
484
457
  withLogs: async (closureName, closure) => {
@@ -500,21 +473,26 @@ extendEnvironment((hre) => {
500
473
  expectPlaintext: async (ctHash, expectedValue) => {
501
474
  const [signer] = await hre.ethers.getSigners();
502
475
  return mock_expectPlaintext(signer.provider, ctHash, expectedValue);
503
- }
476
+ },
477
+ getMockTaskManager: async () => getFixedMockContract(hre, MockTaskManagerArtifact3),
478
+ getMockACL: async () => {
479
+ const taskManager = await getFixedMockContract(hre, MockTaskManagerArtifact3);
480
+ const aclAddress = await taskManager.acl();
481
+ return hre.ethers.getContractAt(MockACLArtifact2.abi, aclAddress);
482
+ },
483
+ getMockQueryDecrypter: async () => getFixedMockContract(hre, MockQueryDecrypterArtifact2),
484
+ getMockZkVerifier: async () => getFixedMockContract(hre, MockZkVerifierArtifact2),
485
+ getTestBed: async () => getFixedMockContract(hre, TestBedArtifact2)
504
486
  }
505
487
  };
506
488
  });
507
489
  export {
508
- MockACLArtifact2 as MockACLArtifact,
509
- MockQueryDecrypterArtifact2 as MockQueryDecrypterArtifact,
510
- MockTaskManagerArtifact3 as MockTaskManagerArtifact,
511
- MockZkVerifierArtifact2 as MockZkVerifierArtifact,
512
- TestBedArtifact2 as TestBedArtifact,
490
+ TASK_COFHE_MOCKS_DEPLOY,
491
+ TASK_COFHE_MOCKS_SET_LOG_OPS,
492
+ TASK_COFHE_USE_FAUCET,
493
+ deployMockContractFromArtifact,
513
494
  deployMocks,
514
- expectResultError,
515
- expectResultPartialValue,
516
- expectResultSuccess,
517
- expectResultValue,
495
+ getFixedMockContract,
518
496
  localcofheFundAccount,
519
497
  localcofheFundWalletIfNeeded,
520
498
  mock_expectPlaintext,