@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/CHANGELOG.md CHANGED
@@ -1,5 +1,43 @@
1
1
  # @cofhe/hardhat-plugin Changelog
2
2
 
3
+ ## 0.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 0000d5e: Mock contracts deployed to alternate fixed addresses to avoid collision with hardhat pre-compiles.
8
+ - Updated dependencies [409bfdf]
9
+ - Updated dependencies [ac47e2f]
10
+ - Updated dependencies [0000d5e]
11
+ - Updated dependencies [8af1b70]
12
+ - @cofhe/sdk@0.2.1
13
+ - @cofhe/mock-contracts@0.2.1
14
+
15
+ ## 0.2.0
16
+
17
+ ### Minor Changes
18
+
19
+ - 8fda09a: Removes `Promise<boolean>` return type from `client.connect(...)`, instead throws an error if the connection fails.
20
+ - e0caeca: Adds `environment: 'node' | 'web' | 'hardhat' | 'react'` option to config. Exposed via `client.config.enviroment`. Automatically populated appropriately within the various `createCofhesdkConfig` functions.
21
+
22
+ ### Patch Changes
23
+
24
+ - 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:
25
+
26
+ - `hre.cofhesdk.connectWithHardhatSigner(client, signer)` - Connect to client with hardhat ethers signer.
27
+ - `hre.cofhesdk.createBatteriesIncludedCofhesdkClient()` - Creates a batteries included client with signer connected.
28
+ - `hre.cofhesdk.mocks.getMockTaskManager()` - Gets deployed Mock Taskmanager
29
+ - `hre.cofhesdk.mocks.getMockACL()` - Gets deployed Mock ACL
30
+
31
+ - Updated dependencies [8fda09a]
32
+ - Updated dependencies [e121108]
33
+ - Updated dependencies [4057a76]
34
+ - Updated dependencies [dba2759]
35
+ - Updated dependencies [e0caeca]
36
+ - Updated dependencies [7c861af]
37
+ - Updated dependencies [2a9d6c5]
38
+ - @cofhe/mock-contracts@0.2.0
39
+ - @cofhe/sdk@0.2.0
40
+
3
41
  ## 0.1.1
4
42
 
5
43
  ### Patch Changes
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,11 +1,11 @@
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 { Contract, ethers as ethers$1 } from 'ethers';
8
7
  import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';
8
+ import { MockArtifact } from '@cofhe/mock-contracts';
9
9
 
10
10
  type DeployMocksArgs = {
11
11
  deployTestBed?: boolean;
@@ -14,15 +14,16 @@ type DeployMocksArgs = {
14
14
  };
15
15
  declare const deployMocks: (hre: HardhatRuntimeEnvironment, options?: DeployMocksArgs) => Promise<void>;
16
16
 
17
+ declare const TASK_COFHE_USE_FAUCET = "task:cofhe:usefaucet";
18
+ declare const TASK_COFHE_MOCKS_SET_LOG_OPS = "task:cofhe-mocks:setlogops";
19
+ declare const TASK_COFHE_MOCKS_DEPLOY = "task:cofhe-mocks:deploy";
20
+
21
+ declare const deployMockContractFromArtifact: (hre: HardhatRuntimeEnvironment, artifact: MockArtifact) => Promise<Contract>;
22
+ declare const getFixedMockContract: (hre: HardhatRuntimeEnvironment, artifact: MockArtifact) => Promise<Contract>;
17
23
  declare const mock_getPlaintext: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint) => Promise<any>;
18
24
  declare const mock_getPlaintextExists: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint) => Promise<any>;
19
25
  declare const mock_expectPlaintext: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint, expectedValue: bigint) => Promise<void>;
20
26
 
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
27
  /**
27
28
  * Sends funds to the specified address
28
29
  * @param hre Hardhat Runtime Environment
@@ -94,30 +95,20 @@ declare module 'hardhat/types/runtime' {
94
95
  walletClient: WalletClient;
95
96
  }>;
96
97
  /**
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)
98
+ * Connect a CoFHE SDK client with a Hardhat ethers signer
99
+ * @param {CofhesdkClient} client - The CoFHE SDK client to connect
100
+ * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use
101
+ * @returns {Promise<void>}
112
102
  */
113
- expectResultValue: <T>(result: Result<T> | Promise<Result<T>>, value: T) => Promise<T>;
103
+ connectWithHardhatSigner: (client: CofhesdkClient, signer: HardhatEthersSigner) => Promise<void>;
114
104
  /**
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)
105
+ * Create and connect to a batteries included client.
106
+ * Also generates a self-usage a permit for the signer.
107
+ * If customization is needed, use createCofhesdkClient and connectWithHardhatSigner.
108
+ * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use (optional - defaults to first signer)
109
+ * @returns {Promise<CofhesdkClient>} The CoFHE SDK client instance
119
110
  */
120
- expectResultPartialValue: <T>(result: Result<T> | Promise<Result<T>>, partial: Partial<T>) => Promise<T>;
111
+ createBatteriesIncludedCofhesdkClient: (signer?: HardhatEthersSigner) => Promise<CofhesdkClient>;
121
112
  mocks: {
122
113
  /**
123
114
  * **[MOCKS ONLY]**
@@ -184,9 +175,34 @@ declare module 'hardhat/types/runtime' {
184
175
  * @param {bigint} expectedValue - The expected plaintext value
185
176
  */
186
177
  expectPlaintext: (ctHash: bigint, expectedValue: bigint) => Promise<void>;
178
+ /**
179
+ * Get the MockTaskManager contract
180
+ * @returns {Promise<Contract>} The MockTaskManager contract
181
+ */
182
+ getMockTaskManager: () => Promise<Contract>;
183
+ /**
184
+ * Get the MockACL contract
185
+ * @returns {Promise<Contract>} The MockACL contract
186
+ */
187
+ getMockACL: () => Promise<Contract>;
188
+ /**
189
+ * Get the MockQueryDecrypter contract
190
+ * @returns {Promise<Contract>} The MockQueryDecrypter contract
191
+ */
192
+ getMockQueryDecrypter: () => Promise<Contract>;
193
+ /**
194
+ * Get the MockZkVerifier contract
195
+ * @returns {Promise<Contract>} The MockZkVerifier contract
196
+ */
197
+ getMockZkVerifier: () => Promise<Contract>;
198
+ /**
199
+ * Get the TestBed contract
200
+ * @returns {Promise<Contract>} The TestBed contract
201
+ */
202
+ getTestBed: () => Promise<Contract>;
187
203
  };
188
204
  };
189
205
  }
190
206
  }
191
207
 
192
- export { type DeployMocksArgs, deployMocks, expectResultError, expectResultPartialValue, expectResultSuccess, expectResultValue, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs };
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 };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
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 { Contract, ethers as ethers$1 } from 'ethers';
8
7
  import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';
8
+ import { MockArtifact } from '@cofhe/mock-contracts';
9
9
 
10
10
  type DeployMocksArgs = {
11
11
  deployTestBed?: boolean;
@@ -14,15 +14,16 @@ type DeployMocksArgs = {
14
14
  };
15
15
  declare const deployMocks: (hre: HardhatRuntimeEnvironment, options?: DeployMocksArgs) => Promise<void>;
16
16
 
17
+ declare const TASK_COFHE_USE_FAUCET = "task:cofhe:usefaucet";
18
+ declare const TASK_COFHE_MOCKS_SET_LOG_OPS = "task:cofhe-mocks:setlogops";
19
+ declare const TASK_COFHE_MOCKS_DEPLOY = "task:cofhe-mocks:deploy";
20
+
21
+ declare const deployMockContractFromArtifact: (hre: HardhatRuntimeEnvironment, artifact: MockArtifact) => Promise<Contract>;
22
+ declare const getFixedMockContract: (hre: HardhatRuntimeEnvironment, artifact: MockArtifact) => Promise<Contract>;
17
23
  declare const mock_getPlaintext: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint) => Promise<any>;
18
24
  declare const mock_getPlaintextExists: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint) => Promise<any>;
19
25
  declare const mock_expectPlaintext: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint, expectedValue: bigint) => Promise<void>;
20
26
 
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
27
  /**
27
28
  * Sends funds to the specified address
28
29
  * @param hre Hardhat Runtime Environment
@@ -94,30 +95,20 @@ declare module 'hardhat/types/runtime' {
94
95
  walletClient: WalletClient;
95
96
  }>;
96
97
  /**
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)
98
+ * Connect a CoFHE SDK client with a Hardhat ethers signer
99
+ * @param {CofhesdkClient} client - The CoFHE SDK client to connect
100
+ * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use
101
+ * @returns {Promise<void>}
112
102
  */
113
- expectResultValue: <T>(result: Result<T> | Promise<Result<T>>, value: T) => Promise<T>;
103
+ connectWithHardhatSigner: (client: CofhesdkClient, signer: HardhatEthersSigner) => Promise<void>;
114
104
  /**
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)
105
+ * Create and connect to a batteries included client.
106
+ * Also generates a self-usage a permit for the signer.
107
+ * If customization is needed, use createCofhesdkClient and connectWithHardhatSigner.
108
+ * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use (optional - defaults to first signer)
109
+ * @returns {Promise<CofhesdkClient>} The CoFHE SDK client instance
119
110
  */
120
- expectResultPartialValue: <T>(result: Result<T> | Promise<Result<T>>, partial: Partial<T>) => Promise<T>;
111
+ createBatteriesIncludedCofhesdkClient: (signer?: HardhatEthersSigner) => Promise<CofhesdkClient>;
121
112
  mocks: {
122
113
  /**
123
114
  * **[MOCKS ONLY]**
@@ -184,9 +175,34 @@ declare module 'hardhat/types/runtime' {
184
175
  * @param {bigint} expectedValue - The expected plaintext value
185
176
  */
186
177
  expectPlaintext: (ctHash: bigint, expectedValue: bigint) => Promise<void>;
178
+ /**
179
+ * Get the MockTaskManager contract
180
+ * @returns {Promise<Contract>} The MockTaskManager contract
181
+ */
182
+ getMockTaskManager: () => Promise<Contract>;
183
+ /**
184
+ * Get the MockACL contract
185
+ * @returns {Promise<Contract>} The MockACL contract
186
+ */
187
+ getMockACL: () => Promise<Contract>;
188
+ /**
189
+ * Get the MockQueryDecrypter contract
190
+ * @returns {Promise<Contract>} The MockQueryDecrypter contract
191
+ */
192
+ getMockQueryDecrypter: () => Promise<Contract>;
193
+ /**
194
+ * Get the MockZkVerifier contract
195
+ * @returns {Promise<Contract>} The MockZkVerifier contract
196
+ */
197
+ getMockZkVerifier: () => Promise<Contract>;
198
+ /**
199
+ * Get the TestBed contract
200
+ * @returns {Promise<Contract>} The TestBed contract
201
+ */
202
+ getTestBed: () => Promise<Contract>;
187
203
  };
188
204
  };
189
205
  }
190
206
  }
191
207
 
192
- export { type DeployMocksArgs, deployMocks, expectResultError, expectResultPartialValue, expectResultSuccess, expectResultValue, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs };
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 };