@cofhe/hardhat-plugin 0.1.0 → 0.2.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 ADDED
@@ -0,0 +1,71 @@
1
+ # @cofhe/hardhat-plugin Changelog
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8fda09a: Removes `Promise<boolean>` return type from `client.connect(...)`, instead throws an error if the connection fails.
8
+ - e0caeca: Adds `environment: 'node' | 'web' | 'hardhat' | 'react'` option to config. Exposed via `client.config.enviroment`. Automatically populated appropriately within the various `createCofhesdkConfig` functions.
9
+
10
+ ### Patch Changes
11
+
12
+ - e121108: Fix ACL permission invalid issue. MockACL needs real deployment since etching doesn't call the constructor, so the EIP712 is uninitialized. Also adds additional utility functions to hardhat-plugin:
13
+
14
+ - `hre.cofhesdk.connectWithHardhatSigner(client, signer)` - Connect to client with hardhat ethers signer.
15
+ - `hre.cofhesdk.createBatteriesIncludedCofhesdkClient()` - Creates a batteries included client with signer connected.
16
+ - `hre.cofhesdk.mocks.getMockTaskManager()` - Gets deployed Mock Taskmanager
17
+ - `hre.cofhesdk.mocks.getMockACL()` - Gets deployed Mock ACL
18
+
19
+ - Updated dependencies [8fda09a]
20
+ - Updated dependencies [e121108]
21
+ - Updated dependencies [4057a76]
22
+ - Updated dependencies [dba2759]
23
+ - Updated dependencies [e0caeca]
24
+ - Updated dependencies [7c861af]
25
+ - Updated dependencies [2a9d6c5]
26
+ - @cofhe/mock-contracts@0.2.0
27
+ - @cofhe/sdk@0.2.0
28
+
29
+ ## 0.1.1
30
+
31
+ ### Patch Changes
32
+
33
+ - a1d1323: Add repository info to package.json of public packages to fix npm publish provenance issue.
34
+ - d232d11: Ensure publish includes correct src and dist files
35
+ - b6521fb: Update publish workflow to create versioning PR upon merge with changeset.
36
+ - Updated dependencies [a1d1323]
37
+ - Updated dependencies [d232d11]
38
+ - Updated dependencies [b6521fb]
39
+ - @cofhe/mock-contracts@0.1.1
40
+ - @cofhe/sdk@0.1.1
41
+
42
+ ## 0.1.0
43
+
44
+ ### Minor Changes
45
+
46
+ - 8d41cf2: Combine existing packages into more reasonable defaults. New package layout is @cofhe/sdk (includes all the core logic for configuring and creating a @cofhe/sdk client, encrypting values, and decrypting handles), mock-contracts, hardhat-plugin, and react.
47
+ - a83facb: Prepare for initial release. Rename scope from `@cofhesdk` to `@cofhe` and rename `cofhesdk` package to `@cofhe/sdk`. Create `publish.yml` to publish `beta` packages on merged PR, and `latest` on changeset PR.
48
+ - 58e93a8: Migrate cofhe-mock-contracts and cofhe-hardhat-plugin into @cofhe/sdk.
49
+
50
+ ### Patch Changes
51
+
52
+ - Updated dependencies [cba73fd]
53
+ - Updated dependencies [87fc8a0]
54
+ - Updated dependencies [8d41cf2]
55
+ - Updated dependencies [738b9f5]
56
+ - Updated dependencies [a83facb]
57
+ - Updated dependencies [9a7c98e]
58
+ - Updated dependencies [58e93a8]
59
+ - Updated dependencies [fdf26d4]
60
+ - Updated dependencies [f5b8e25]
61
+ - Updated dependencies [3b135a8]
62
+ - Updated dependencies [5b7c43b]
63
+ - Updated dependencies [4bc8182]
64
+ - @cofhe/sdk@0.1.0
65
+ - @cofhe/mock-contracts@0.1.0
66
+
67
+ This changelog is maintained by Changesets and will be populated on each release.
68
+
69
+ - Do not edit this file by hand.
70
+ - Upcoming changes can be previewed with `pnpm changeset status --verbose`.
71
+ - Entries are generated when the Changesets "Version Packages" PR is created/merged.
package/README.md CHANGED
@@ -18,9 +18,9 @@ Add the plugin to your Hardhat config:
18
18
 
19
19
  ```javascript
20
20
  // hardhat.config.js or hardhat.config.ts
21
- require("cofhe-hardhat-plugin");
21
+ require('cofhe-hardhat-plugin');
22
22
  // or if using TypeScript
23
- import "cofhe-hardhat-plugin";
23
+ import 'cofhe-hardhat-plugin';
24
24
 
25
25
  module.exports = {
26
26
  // ... other config
@@ -83,15 +83,15 @@ The plugin exports several utility functions for working with mock contracts:
83
83
 
84
84
  ```typescript
85
85
  // Get plaintext value from a ciphertext hash
86
- import { mock_getPlaintext } from "cofhe-hardhat-plugin";
86
+ import { mock_getPlaintext } from 'cofhe-hardhat-plugin';
87
87
  const plaintext = await mock_getPlaintext(provider, ctHash);
88
88
 
89
89
  // Check if a plaintext exists for a ciphertext hash
90
- import { mock_getPlaintextExists } from "cofhe-hardhat-plugin";
90
+ import { mock_getPlaintextExists } from 'cofhe-hardhat-plugin';
91
91
  const exists = await mock_getPlaintextExists(provider, ctHash);
92
92
 
93
93
  // Test assertion for plaintext values
94
- import { mock_expectPlaintext } from "cofhe-hardhat-plugin";
94
+ import { mock_expectPlaintext } from 'cofhe-hardhat-plugin';
95
95
  await mock_expectPlaintext(provider, ctHash, expectedValue);
96
96
  ```
97
97
 
@@ -99,15 +99,15 @@ await mock_expectPlaintext(provider, ctHash, expectedValue);
99
99
 
100
100
  ```typescript
101
101
  // Get the CoFHE environment based on network name
102
- import { getCofheEnvironmentFromNetwork } from "cofhe-hardhat-plugin";
102
+ import { getCofheEnvironmentFromNetwork } from 'cofhe-hardhat-plugin';
103
103
  const environment = getCofheEnvironmentFromNetwork(networkName);
104
104
 
105
105
  // Check if a CoFHE environment is permitted for a given network
106
- import { isPermittedCofheEnvironment } from "cofhe-hardhat-plugin";
106
+ import { isPermittedCofheEnvironment } from 'cofhe-hardhat-plugin';
107
107
  const isPermitted = isPermittedCofheEnvironment(hre, environmentName);
108
108
 
109
109
  // Initialize CoFHEjs with a Hardhat signer
110
- import { cofhejs_initializeWithHardhatSigner } from "cofhe-hardhat-plugin";
110
+ import { cofhejs_initializeWithHardhatSigner } from 'cofhe-hardhat-plugin';
111
111
  await cofhejs_initializeWithHardhatSigner(signer, options);
112
112
  ```
113
113
 
package/dist/index.d.mts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { PublicClient, WalletClient } from 'viem';
2
2
  import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';
3
- import { Result, CofhesdkInputConfig, CofhesdkConfig, CofhesdkClient } from '@cofhe/sdk';
3
+ import { CofhesdkInputConfig, CofhesdkConfig, CofhesdkClient } from '@cofhe/sdk';
4
4
  import { HardhatRuntimeEnvironment } from 'hardhat/types';
5
- export { MockACLArtifact, MockQueryDecrypterArtifact, MockTaskManagerArtifact, MockZkVerifierArtifact, TestBedArtifact } from '@cofhe/mock-contracts';
6
5
  import * as ethers from 'ethers';
7
- import { ethers as ethers$1 } from 'ethers';
6
+ import { ethers as ethers$1, Contract } from 'ethers';
7
+ export { MockACLArtifact, MockQueryDecrypterArtifact, MockTaskManagerArtifact, MockZkVerifierArtifact, TestBedArtifact } from '@cofhe/mock-contracts';
8
8
  import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';
9
9
 
10
10
  type DeployMocksArgs = {
@@ -18,11 +18,6 @@ declare const mock_getPlaintext: (provider: HardhatEthersProvider | ethers$1.Jso
18
18
  declare const mock_getPlaintextExists: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint) => Promise<any>;
19
19
  declare const mock_expectPlaintext: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint, expectedValue: bigint) => Promise<void>;
20
20
 
21
- declare const expectResultError: <T>(result: Result<T>, errorPartial: string) => void;
22
- declare const expectResultSuccess: <T>(result: Result<T>) => T;
23
- declare const expectResultValue: <T>(result: Result<T>, value: T) => T;
24
- declare const expectResultPartialValue: <T>(result: Result<T>, partial: Partial<T>) => T;
25
-
26
21
  /**
27
22
  * Sends funds to the specified address
28
23
  * @param hre Hardhat Runtime Environment
@@ -94,30 +89,20 @@ declare module 'hardhat/types/runtime' {
94
89
  walletClient: WalletClient;
95
90
  }>;
96
91
  /**
97
- * Assert that a Result type returned from a function is successful and return its value (result.success === true)
98
- * @param {Result<T>} result - The Result to check
99
- * @returns {T} The inner data of the Result (non null)
100
- */
101
- expectResultSuccess: <T>(result: Result<T> | Promise<Result<T>>) => Promise<T>;
102
- /**
103
- * Assert that a Result type contains an error matching the partial string (result.success === false && result.error.includes(errorPartial))
104
- * @param {Result<T>} result - The Result to check
105
- * @param {string} errorPartial - The partial error string to match
106
- */
107
- expectResultError: <T>(result: Result<T> | Promise<Result<T>>, errorPartial: string) => Promise<void>;
108
- /**
109
- * Assert that a Result type contains a specific value (result.success === true && result.data === value)
110
- * @param {Result<T>} result - The Result to check
111
- * @param {T} value - The inner data of the Result (non null)
92
+ * Connect a CoFHE SDK client with a Hardhat ethers signer
93
+ * @param {CofhesdkClient} client - The CoFHE SDK client to connect
94
+ * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use
95
+ * @returns {Promise<void>}
112
96
  */
113
- expectResultValue: <T>(result: Result<T> | Promise<Result<T>>, value: T) => Promise<T>;
97
+ connectWithHardhatSigner: (client: CofhesdkClient, signer: HardhatEthersSigner) => Promise<void>;
114
98
  /**
115
- * Assert that a Result type contains a value matching the partial object (result.success === true && result.data.includes(partial))
116
- * @param {Result<T>} result - The Result to check
117
- * @param {Partial<T>} partial - The partial object to match against
118
- * @returns {T} The inner data of the Result (non null)
99
+ * Create and connect to a batteries included client.
100
+ * Also generates a self-usage a permit for the signer.
101
+ * If customization is needed, use createCofhesdkClient and connectWithHardhatSigner.
102
+ * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use (optional - defaults to first signer)
103
+ * @returns {Promise<CofhesdkClient>} The CoFHE SDK client instance
119
104
  */
120
- expectResultPartialValue: <T>(result: Result<T> | Promise<Result<T>>, partial: Partial<T>) => Promise<T>;
105
+ createBatteriesIncludedCofhesdkClient: (signer?: HardhatEthersSigner) => Promise<CofhesdkClient>;
121
106
  mocks: {
122
107
  /**
123
108
  * **[MOCKS ONLY]**
@@ -184,9 +169,34 @@ declare module 'hardhat/types/runtime' {
184
169
  * @param {bigint} expectedValue - The expected plaintext value
185
170
  */
186
171
  expectPlaintext: (ctHash: bigint, expectedValue: bigint) => Promise<void>;
172
+ /**
173
+ * Get the MockTaskManager contract
174
+ * @returns {Promise<Contract>} The MockTaskManager contract
175
+ */
176
+ getMockTaskManager: () => Promise<Contract>;
177
+ /**
178
+ * Get the MockACL contract
179
+ * @returns {Promise<Contract>} The MockACL contract
180
+ */
181
+ getMockACL: () => Promise<Contract>;
182
+ /**
183
+ * Get the MockQueryDecrypter contract
184
+ * @returns {Promise<Contract>} The MockQueryDecrypter contract
185
+ */
186
+ getMockQueryDecrypter: () => Promise<Contract>;
187
+ /**
188
+ * Get the MockZkVerifier contract
189
+ * @returns {Promise<Contract>} The MockZkVerifier contract
190
+ */
191
+ getMockZkVerifier: () => Promise<Contract>;
192
+ /**
193
+ * Get the TestBed contract
194
+ * @returns {Promise<Contract>} The TestBed contract
195
+ */
196
+ getTestBed: () => Promise<Contract>;
187
197
  };
188
198
  };
189
199
  }
190
200
  }
191
201
 
192
- export { type DeployMocksArgs, deployMocks, expectResultError, expectResultPartialValue, expectResultSuccess, expectResultValue, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs };
202
+ export { type DeployMocksArgs, deployMocks, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { PublicClient, WalletClient } from 'viem';
2
2
  import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';
3
- import { Result, CofhesdkInputConfig, CofhesdkConfig, CofhesdkClient } from '@cofhe/sdk';
3
+ import { CofhesdkInputConfig, CofhesdkConfig, CofhesdkClient } from '@cofhe/sdk';
4
4
  import { HardhatRuntimeEnvironment } from 'hardhat/types';
5
- export { MockACLArtifact, MockQueryDecrypterArtifact, MockTaskManagerArtifact, MockZkVerifierArtifact, TestBedArtifact } from '@cofhe/mock-contracts';
6
5
  import * as ethers from 'ethers';
7
- import { ethers as ethers$1 } from 'ethers';
6
+ import { ethers as ethers$1, Contract } from 'ethers';
7
+ export { MockACLArtifact, MockQueryDecrypterArtifact, MockTaskManagerArtifact, MockZkVerifierArtifact, TestBedArtifact } from '@cofhe/mock-contracts';
8
8
  import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';
9
9
 
10
10
  type DeployMocksArgs = {
@@ -18,11 +18,6 @@ declare const mock_getPlaintext: (provider: HardhatEthersProvider | ethers$1.Jso
18
18
  declare const mock_getPlaintextExists: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint) => Promise<any>;
19
19
  declare const mock_expectPlaintext: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint, expectedValue: bigint) => Promise<void>;
20
20
 
21
- declare const expectResultError: <T>(result: Result<T>, errorPartial: string) => void;
22
- declare const expectResultSuccess: <T>(result: Result<T>) => T;
23
- declare const expectResultValue: <T>(result: Result<T>, value: T) => T;
24
- declare const expectResultPartialValue: <T>(result: Result<T>, partial: Partial<T>) => T;
25
-
26
21
  /**
27
22
  * Sends funds to the specified address
28
23
  * @param hre Hardhat Runtime Environment
@@ -94,30 +89,20 @@ declare module 'hardhat/types/runtime' {
94
89
  walletClient: WalletClient;
95
90
  }>;
96
91
  /**
97
- * Assert that a Result type returned from a function is successful and return its value (result.success === true)
98
- * @param {Result<T>} result - The Result to check
99
- * @returns {T} The inner data of the Result (non null)
100
- */
101
- expectResultSuccess: <T>(result: Result<T> | Promise<Result<T>>) => Promise<T>;
102
- /**
103
- * Assert that a Result type contains an error matching the partial string (result.success === false && result.error.includes(errorPartial))
104
- * @param {Result<T>} result - The Result to check
105
- * @param {string} errorPartial - The partial error string to match
106
- */
107
- expectResultError: <T>(result: Result<T> | Promise<Result<T>>, errorPartial: string) => Promise<void>;
108
- /**
109
- * Assert that a Result type contains a specific value (result.success === true && result.data === value)
110
- * @param {Result<T>} result - The Result to check
111
- * @param {T} value - The inner data of the Result (non null)
92
+ * Connect a CoFHE SDK client with a Hardhat ethers signer
93
+ * @param {CofhesdkClient} client - The CoFHE SDK client to connect
94
+ * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use
95
+ * @returns {Promise<void>}
112
96
  */
113
- expectResultValue: <T>(result: Result<T> | Promise<Result<T>>, value: T) => Promise<T>;
97
+ connectWithHardhatSigner: (client: CofhesdkClient, signer: HardhatEthersSigner) => Promise<void>;
114
98
  /**
115
- * Assert that a Result type contains a value matching the partial object (result.success === true && result.data.includes(partial))
116
- * @param {Result<T>} result - The Result to check
117
- * @param {Partial<T>} partial - The partial object to match against
118
- * @returns {T} The inner data of the Result (non null)
99
+ * Create and connect to a batteries included client.
100
+ * Also generates a self-usage a permit for the signer.
101
+ * If customization is needed, use createCofhesdkClient and connectWithHardhatSigner.
102
+ * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use (optional - defaults to first signer)
103
+ * @returns {Promise<CofhesdkClient>} The CoFHE SDK client instance
119
104
  */
120
- expectResultPartialValue: <T>(result: Result<T> | Promise<Result<T>>, partial: Partial<T>) => Promise<T>;
105
+ createBatteriesIncludedCofhesdkClient: (signer?: HardhatEthersSigner) => Promise<CofhesdkClient>;
121
106
  mocks: {
122
107
  /**
123
108
  * **[MOCKS ONLY]**
@@ -184,9 +169,34 @@ declare module 'hardhat/types/runtime' {
184
169
  * @param {bigint} expectedValue - The expected plaintext value
185
170
  */
186
171
  expectPlaintext: (ctHash: bigint, expectedValue: bigint) => Promise<void>;
172
+ /**
173
+ * Get the MockTaskManager contract
174
+ * @returns {Promise<Contract>} The MockTaskManager contract
175
+ */
176
+ getMockTaskManager: () => Promise<Contract>;
177
+ /**
178
+ * Get the MockACL contract
179
+ * @returns {Promise<Contract>} The MockACL contract
180
+ */
181
+ getMockACL: () => Promise<Contract>;
182
+ /**
183
+ * Get the MockQueryDecrypter contract
184
+ * @returns {Promise<Contract>} The MockQueryDecrypter contract
185
+ */
186
+ getMockQueryDecrypter: () => Promise<Contract>;
187
+ /**
188
+ * Get the MockZkVerifier contract
189
+ * @returns {Promise<Contract>} The MockZkVerifier contract
190
+ */
191
+ getMockZkVerifier: () => Promise<Contract>;
192
+ /**
193
+ * Get the TestBed contract
194
+ * @returns {Promise<Contract>} The TestBed contract
195
+ */
196
+ getTestBed: () => Promise<Contract>;
187
197
  };
188
198
  };
189
199
  }
190
200
  }
191
201
 
192
- export { type DeployMocksArgs, deployMocks, expectResultError, expectResultPartialValue, expectResultSuccess, expectResultValue, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs };
202
+ export { type DeployMocksArgs, deployMocks, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs };
package/dist/index.js CHANGED
@@ -30,16 +30,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // src/index.ts
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
- MockACLArtifact: () => import_mock_contracts3.MockACLArtifact,
34
- MockQueryDecrypterArtifact: () => import_mock_contracts3.MockQueryDecrypterArtifact,
35
- MockTaskManagerArtifact: () => import_mock_contracts3.MockTaskManagerArtifact,
36
- MockZkVerifierArtifact: () => import_mock_contracts3.MockZkVerifierArtifact,
37
- TestBedArtifact: () => import_mock_contracts3.TestBedArtifact,
33
+ MockACLArtifact: () => import_mock_contracts4.MockACLArtifact,
34
+ MockQueryDecrypterArtifact: () => import_mock_contracts4.MockQueryDecrypterArtifact,
35
+ MockTaskManagerArtifact: () => import_mock_contracts4.MockTaskManagerArtifact,
36
+ MockZkVerifierArtifact: () => import_mock_contracts4.MockZkVerifierArtifact,
37
+ TestBedArtifact: () => import_mock_contracts4.TestBedArtifact,
38
38
  deployMocks: () => deployMocks,
39
- expectResultError: () => expectResultError,
40
- expectResultPartialValue: () => expectResultPartialValue,
41
- expectResultSuccess: () => expectResultSuccess,
42
- expectResultValue: () => expectResultValue,
43
39
  localcofheFundAccount: () => localcofheFundAccount,
44
40
  localcofheFundWalletIfNeeded: () => localcofheFundWalletIfNeeded,
45
41
  mock_expectPlaintext: () => mock_expectPlaintext,
@@ -115,17 +111,16 @@ var TASK_COFHE_USE_FAUCET = "task:cofhe:usefaucet";
115
111
  var TASK_COFHE_MOCKS_SET_LOG_OPS = "task:cofhe-mocks:setlogops";
116
112
  var TASK_COFHE_MOCKS_DEPLOY = "task:cofhe-mocks:deploy";
117
113
  var TASK_MANAGER_ADDRESS = "0xeA30c4B8b44078Bbf8a6ef5b9f1eC1626C7848D9";
118
- var MOCKS_ACL_ADDRESS = "0x0000000000000000000000000000000000000400";
119
114
  var MOCKS_ZK_VERIFIER_ADDRESS = "0x0000000000000000000000000000000000000100";
120
115
  var MOCKS_QUERY_DECRYPTER_ADDRESS = "0x0000000000000000000000000000000000000200";
121
116
  var TEST_BED_ADDRESS = "0x0000000000000000000000000000000000000300";
122
- var MOCKS_ZK_VERIFIER_SIGNER_ADDRESS = "0x6E12D8C87503D4287c294f2Fdef96ACd9DFf6bd2";
123
117
 
124
118
  // src/deploy.ts
125
119
  var import_types2 = require("hardhat/types");
126
120
  var import_chalk = __toESM(require("chalk"));
127
121
  var import_ethers = require("ethers");
128
122
  var import_mock_contracts = require("@cofhe/mock-contracts");
123
+ var import_sdk = require("@cofhe/sdk");
129
124
  var deployMockTaskManager = async (hre) => {
130
125
  const [signer] = await hre.ethers.getSigners();
131
126
  await hardhatSetCode(hre, TASK_MANAGER_ADDRESS, import_mock_contracts.MockTaskManagerArtifact.deployedBytecode);
@@ -139,8 +134,7 @@ var deployMockTaskManager = async (hre) => {
139
134
  return taskManager;
140
135
  };
141
136
  var deployMockACL = async (hre) => {
142
- await hardhatSetCode(hre, MOCKS_ACL_ADDRESS, import_mock_contracts.MockACLArtifact.deployedBytecode);
143
- const acl = await hre.ethers.getContractAt(import_mock_contracts.MockACLArtifact.abi, MOCKS_ACL_ADDRESS);
137
+ const acl = await ethersDeployContract(hre, import_mock_contracts.MockACLArtifact.abi, import_mock_contracts.MockACLArtifact.bytecode);
144
138
  const exists = await acl.exists();
145
139
  if (!exists) {
146
140
  logError("MockACL does not exist", 2);
@@ -177,7 +171,7 @@ var deployTestBedContract = async (hre) => {
177
171
  return testBed;
178
172
  };
179
173
  var fundZkVerifierSigner = async (hre) => {
180
- const zkVerifierSigner = await hre.ethers.getSigner(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);
174
+ const zkVerifierSigner = await hre.ethers.getSigner(import_sdk.MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);
181
175
  await hre.network.provider.send("hardhat_setBalance", [
182
176
  zkVerifierSigner.address,
183
177
  "0x" + hre.ethers.parseEther("10").toString(16)
@@ -218,8 +212,6 @@ var deployMocks = async (hre, options = {
218
212
  logEmptyIfNoisy();
219
213
  logSuccessIfNoisy(import_chalk.default.bold("cofhe-hardhat-plugin :: deploy mocks"), 0);
220
214
  logEmptyIfNoisy();
221
- logEmptyIfNoisy();
222
- logSuccessIfNoisy("Mock contracts compiled", 1);
223
215
  const taskManager = await deployMockTaskManager(hre);
224
216
  logDeploymentIfNoisy("MockTaskManager", await taskManager.getAddress());
225
217
  const acl = await deployMockACL(hre);
@@ -227,8 +219,8 @@ var deployMocks = async (hre, options = {
227
219
  await setTaskManagerACL(taskManager, acl);
228
220
  logSuccessIfNoisy("ACL address set in TaskManager", 2);
229
221
  await fundZkVerifierSigner(hre);
230
- logSuccessIfNoisy(`ZkVerifier signer (${MOCKS_ZK_VERIFIER_SIGNER_ADDRESS}) funded`, 1);
231
- const zkVerifierSignerBalance = await hre.ethers.provider.getBalance(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);
222
+ logSuccessIfNoisy(`ZkVerifier signer (${import_sdk.MOCKS_ZK_VERIFIER_SIGNER_ADDRESS}) funded`, 1);
223
+ const zkVerifierSignerBalance = await hre.ethers.provider.getBalance(import_sdk.MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);
232
224
  logSuccessIfNoisy(`ETH balance: ${zkVerifierSignerBalance.toString()}`, 2);
233
225
  const zkVerifier = await deployMockZkVerifier(hre);
234
226
  logDeploymentIfNoisy("MockZkVerifier", await zkVerifier.getAddress());
@@ -253,6 +245,15 @@ var deployMocks = async (hre, options = {
253
245
  var hardhatSetCode = async (hre, address, bytecode) => {
254
246
  await hre.network.provider.send("hardhat_setCode", [address, bytecode]);
255
247
  };
248
+ var ethersDeployContract = async (hre, abi, bytecode) => {
249
+ const [signer] = await hre.ethers.getSigners();
250
+ const factory = new hre.ethers.ContractFactory(abi, bytecode, signer);
251
+ const contract = await factory.deploy(
252
+ /* constructor args */
253
+ );
254
+ await contract.waitForDeployment();
255
+ return contract;
256
+ };
256
257
  var checkNetworkAndSkip = async (hre) => {
257
258
  const network = hre.network.name;
258
259
  const isHardhat = network === "hardhat";
@@ -369,30 +370,10 @@ var mock_expectPlaintext = async (provider, ctHash, expectedValue) => {
369
370
  (0, import_chai.expect)(plaintext).equal(expectedValue, "Plaintext value is incorrect");
370
371
  };
371
372
 
372
- // src/expectResultUtils.ts
373
- var import_sdk = require("@cofhe/sdk");
374
- var import_chai2 = require("chai");
375
- var expectResultError = (result, errorPartial) => {
376
- (0, import_chai2.expect)(result.success).to.eq(false, "Result should be an error");
377
- (0, import_chai2.expect)(result.error).to.include(errorPartial, `Error should contain error partial: ${errorPartial}`);
378
- };
379
- var expectResultSuccess = (result) => {
380
- (0, import_chai2.expect)(result.success).to.eq(true, "Result should be a success");
381
- return result.data;
382
- };
383
- var expectResultValue = (result, value) => {
384
- (0, import_chai2.expect)(result.success).to.eq(true, "Result should be a success");
385
- (0, import_chai2.expect)(result.data).to.eq(value, `Result should have the expected value ${value}`);
386
- return result.data;
387
- };
388
- var expectResultPartialValue = (result, partial) => {
389
- (0, import_chai2.expect)(result.success).to.eq(true, "Result should be a success");
390
- (0, import_chai2.expect)(result.data).to.include(partial, `Result should have the expected partial ${partial}`);
391
- return result.data;
392
- };
393
-
394
373
  // src/index.ts
395
374
  var import_mock_contracts3 = require("@cofhe/mock-contracts");
375
+ var import_chains = require("@cofhe/sdk/chains");
376
+ var import_mock_contracts4 = require("@cofhe/mock-contracts");
396
377
  (0, import_config.extendConfig)((config, userConfig) => {
397
378
  if (userConfig.networks && userConfig.networks.localcofhe) {
398
379
  return;
@@ -485,9 +466,10 @@ var import_mock_contracts3 = require("@cofhe/mock-contracts");
485
466
  (0, import_config.extendEnvironment)((hre) => {
486
467
  hre.cofhesdk = {
487
468
  createCofhesdkConfig: async (config) => {
488
- const zkvHhSigner = await hre.ethers.getImpersonatedSigner(MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);
469
+ const zkvHhSigner = await hre.ethers.getImpersonatedSigner(import_sdk2.MOCKS_ZK_VERIFIER_SIGNER_ADDRESS);
489
470
  const { walletClient: zkvWalletClient } = await (0, import_adapters.HardhatSignerAdapter)(zkvHhSigner);
490
471
  const configWithZkvWalletClient = {
472
+ environment: "hardhat",
491
473
  ...config,
492
474
  _internal: {
493
475
  ...config._internal,
@@ -502,21 +484,24 @@ var import_mock_contracts3 = require("@cofhe/mock-contracts");
502
484
  hardhatSignerAdapter: async (signer) => {
503
485
  return (0, import_adapters.HardhatSignerAdapter)(signer);
504
486
  },
505
- expectResultSuccess: async (result) => {
506
- const awaitedResult = await result;
507
- return expectResultSuccess(awaitedResult);
508
- },
509
- expectResultError: async (result, errorPartial) => {
510
- const awaitedResult = await result;
511
- return expectResultError(awaitedResult, errorPartial);
512
- },
513
- expectResultValue: async (result, value) => {
514
- const awaitedResult = await result;
515
- return expectResultValue(awaitedResult, value);
487
+ connectWithHardhatSigner: async (client, signer) => {
488
+ const { publicClient, walletClient } = await (0, import_adapters.HardhatSignerAdapter)(signer);
489
+ return client.connect(publicClient, walletClient);
516
490
  },
517
- expectResultPartialValue: async (result, partial) => {
518
- const awaitedResult = await result;
519
- return expectResultPartialValue(awaitedResult, partial);
491
+ createBatteriesIncludedCofhesdkClient: async (signer) => {
492
+ if (!signer) {
493
+ [signer] = await hre.ethers.getSigners();
494
+ }
495
+ const config = await hre.cofhesdk.createCofhesdkConfig({
496
+ environment: "hardhat",
497
+ supportedChains: [import_chains.hardhat]
498
+ });
499
+ const client = hre.cofhesdk.createCofhesdkClient(config);
500
+ await hre.cofhesdk.connectWithHardhatSigner(client, signer);
501
+ await client.permits.createSelf({
502
+ issuer: signer.address
503
+ });
504
+ return client;
520
505
  },
521
506
  mocks: {
522
507
  withLogs: async (closureName, closure) => {
@@ -538,6 +523,23 @@ var import_mock_contracts3 = require("@cofhe/mock-contracts");
538
523
  expectPlaintext: async (ctHash, expectedValue) => {
539
524
  const [signer] = await hre.ethers.getSigners();
540
525
  return mock_expectPlaintext(signer.provider, ctHash, expectedValue);
526
+ },
527
+ getMockTaskManager: async () => {
528
+ return await hre.ethers.getContractAt(import_mock_contracts3.MockTaskManagerArtifact.abi, import_mock_contracts3.MockTaskManagerArtifact.fixedAddress);
529
+ },
530
+ getMockACL: async () => {
531
+ const tm = await hre.ethers.getContractAt(import_mock_contracts3.MockTaskManagerArtifact.abi, import_mock_contracts3.MockTaskManagerArtifact.fixedAddress);
532
+ const aclAddress = await tm.acl();
533
+ return await hre.ethers.getContractAt(import_mock_contracts3.MockACLArtifact.abi, aclAddress);
534
+ },
535
+ getMockQueryDecrypter: async () => {
536
+ return await hre.ethers.getContractAt(import_mock_contracts3.MockQueryDecrypterArtifact.abi, import_mock_contracts3.MockQueryDecrypterArtifact.fixedAddress);
537
+ },
538
+ getMockZkVerifier: async () => {
539
+ return await hre.ethers.getContractAt(import_mock_contracts3.MockZkVerifierArtifact.abi, import_mock_contracts3.MockZkVerifierArtifact.fixedAddress);
540
+ },
541
+ getTestBed: async () => {
542
+ return await hre.ethers.getContractAt(import_mock_contracts3.TestBedArtifact.abi, import_mock_contracts3.TestBedArtifact.fixedAddress);
541
543
  }
542
544
  }
543
545
  };
@@ -550,10 +552,6 @@ var import_mock_contracts3 = require("@cofhe/mock-contracts");
550
552
  MockZkVerifierArtifact,
551
553
  TestBedArtifact,
552
554
  deployMocks,
553
- expectResultError,
554
- expectResultPartialValue,
555
- expectResultSuccess,
556
- expectResultValue,
557
555
  localcofheFundAccount,
558
556
  localcofheFundWalletIfNeeded,
559
557
  mock_expectPlaintext,