@cofhe/hardhat-plugin 0.0.0-beta-20251027110729

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,43 @@
1
+ # @cofhe/hardhat-plugin Changelog
2
+
3
+ ## 0.0.0-beta-20251027110729
4
+
5
+ ### Patch Changes
6
+
7
+ - a1d1323: Add repository info to package.json of public packages to fix npm publish provenance issue.
8
+ - d232d11: Ensure publish includes correct src and dist files
9
+ - Updated dependencies [a1d1323]
10
+ - Updated dependencies [d232d11]
11
+ - @cofhe/mock-contracts@0.0.0-beta-20251027110729
12
+ - @cofhe/sdk@0.0.0-beta-20251027110729
13
+
14
+ ## 0.1.0
15
+
16
+ ### Minor Changes
17
+
18
+ - 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.
19
+ - 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.
20
+ - 58e93a8: Migrate cofhe-mock-contracts and cofhe-hardhat-plugin into @cofhe/sdk.
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [cba73fd]
25
+ - Updated dependencies [87fc8a0]
26
+ - Updated dependencies [8d41cf2]
27
+ - Updated dependencies [738b9f5]
28
+ - Updated dependencies [a83facb]
29
+ - Updated dependencies [9a7c98e]
30
+ - Updated dependencies [58e93a8]
31
+ - Updated dependencies [fdf26d4]
32
+ - Updated dependencies [f5b8e25]
33
+ - Updated dependencies [3b135a8]
34
+ - Updated dependencies [5b7c43b]
35
+ - Updated dependencies [4bc8182]
36
+ - @cofhe/sdk@0.1.0
37
+ - @cofhe/mock-contracts@0.1.0
38
+
39
+ This changelog is maintained by Changesets and will be populated on each release.
40
+
41
+ - Do not edit this file by hand.
42
+ - Upcoming changes can be previewed with `pnpm changeset status --verbose`.
43
+ - Entries are generated when the Changesets "Version Packages" PR is created/merged.
package/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # CoFHE Hardhat Plugin
2
+
3
+ A Hardhat plugin for Fully Homomorphic Encryption (FHE) development with CoFHE.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install cofhe-hardhat-plugin
9
+ # or
10
+ yarn add cofhe-hardhat-plugin
11
+ # or
12
+ pnpm add cofhe-hardhat-plugin
13
+ ```
14
+
15
+ ## Configuration
16
+
17
+ Add the plugin to your Hardhat config:
18
+
19
+ ```javascript
20
+ // hardhat.config.js or hardhat.config.ts
21
+ require("cofhe-hardhat-plugin");
22
+ // or if using TypeScript
23
+ import "cofhe-hardhat-plugin";
24
+
25
+ module.exports = {
26
+ // ... other config
27
+ cofhe: {
28
+ logMocks: true, // Optional: Set to true to log mock operations
29
+ },
30
+ // Network configuration is automatically added by the plugin
31
+ };
32
+ ```
33
+
34
+ The plugin automatically adds network configurations for:
35
+
36
+ - Hardhat network with deployed mock contracts
37
+ - Ethereum Sepolia testnet
38
+ - Arbitrum Sepolia testnet
39
+
40
+ ## Features
41
+
42
+ ### Mock Contracts
43
+
44
+ This plugin uses [cofhe-mock-contracts](https://github.com/FhenixProtocol/cofhe-mock-contracts) to provide on-chain simulations of the CoFHE system. These mock contracts enable development and testing without requiring the actual off-chain FHE computation engine.
45
+
46
+ The mock contracts include:
47
+
48
+ - MockTaskManager: Manages FHE operations and stores plaintext values
49
+ - MockQueryDecrypter: Handles decryption requests
50
+ - MockZkVerifier: Simulates verification of encrypted inputs
51
+ - ACL: Handles access control
52
+
53
+ Key differences from the real CoFHE system:
54
+
55
+ - Operations are performed on-chain instead of off-chain
56
+ - Plaintext values are stored on-chain for testing and verification
57
+ - Decryption operations are simulated with mock delays
58
+ - Operations are logged using hardhat/console.sol
59
+
60
+ ### Mock Contracts Deployment
61
+
62
+ Mock contracts are automatically deployed when using the Hardhat network:
63
+
64
+ - Running tests: `npx hardhat test`
65
+ - Starting a local node: `npx hardhat node`
66
+
67
+ You can also manually deploy mock contracts:
68
+
69
+ ```bash
70
+ npx hardhat deploy-mocks [--deploy-test-bed true|false] [--log-mocks true|false]
71
+ ```
72
+
73
+ Options:
74
+
75
+ - `--deploy-test-bed`: Deploy the TestBed contract (default: true)
76
+ - `--log-mocks`: Log mock operations (default: true)
77
+
78
+ ### Utility Functions
79
+
80
+ The plugin exports several utility functions for working with mock contracts:
81
+
82
+ #### Mock Utilities
83
+
84
+ ```typescript
85
+ // Get plaintext value from a ciphertext hash
86
+ import { mock_getPlaintext } from "cofhe-hardhat-plugin";
87
+ const plaintext = await mock_getPlaintext(provider, ctHash);
88
+
89
+ // Check if a plaintext exists for a ciphertext hash
90
+ import { mock_getPlaintextExists } from "cofhe-hardhat-plugin";
91
+ const exists = await mock_getPlaintextExists(provider, ctHash);
92
+
93
+ // Test assertion for plaintext values
94
+ import { mock_expectPlaintext } from "cofhe-hardhat-plugin";
95
+ await mock_expectPlaintext(provider, ctHash, expectedValue);
96
+ ```
97
+
98
+ #### Network Utilities
99
+
100
+ ```typescript
101
+ // Get the CoFHE environment based on network name
102
+ import { getCofheEnvironmentFromNetwork } from "cofhe-hardhat-plugin";
103
+ const environment = getCofheEnvironmentFromNetwork(networkName);
104
+
105
+ // Check if a CoFHE environment is permitted for a given network
106
+ import { isPermittedCofheEnvironment } from "cofhe-hardhat-plugin";
107
+ const isPermitted = isPermittedCofheEnvironment(hre, environmentName);
108
+
109
+ // Initialize CoFHEjs with a Hardhat signer
110
+ import { cofhejs_initializeWithHardhatSigner } from "cofhe-hardhat-plugin";
111
+ await cofhejs_initializeWithHardhatSigner(signer, options);
112
+ ```
113
+
114
+ ## Usage in Tests
115
+
116
+ The plugin automatically deploys mock contracts when running tests:
117
+
118
+ ```typescript
119
+ import { expect } from "chai";
120
+ import { mock_expectPlaintext } from "cofhe-hardhat-plugin";
121
+
122
+ describe("My FHE Contract", function() {
123
+ it("should store encrypted value correctly", async function() {
124
+ const [signer] = await ethers.getSigners();
125
+ const myContract = await ethers.deployContract("MyFHEContract");
126
+
127
+ // Interact with your contract
128
+ const tx = await myContract.storeEncrypted(123);
129
+ await tx.wait();
130
+
131
+ // Get the ciphertext hash from event logs
132
+ const ctHash = /* extract from logs */;
133
+
134
+ // Verify plaintext value (only works on hardhat network)
135
+ await mock_expectPlaintext(signer.provider, ctHash, 123n);
136
+ });
137
+ });
138
+ ```
139
+
140
+ ## License
141
+
142
+ MIT
@@ -0,0 +1,192 @@
1
+ import { PublicClient, WalletClient } from 'viem';
2
+ import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';
3
+ import { Result, CofhesdkInputConfig, CofhesdkConfig, CofhesdkClient } from '@cofhe/sdk';
4
+ import { HardhatRuntimeEnvironment } from 'hardhat/types';
5
+ export { MockACLArtifact, MockQueryDecrypterArtifact, MockTaskManagerArtifact, MockZkVerifierArtifact, TestBedArtifact } from '@cofhe/mock-contracts';
6
+ import * as ethers from 'ethers';
7
+ import { ethers as ethers$1 } from 'ethers';
8
+ import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';
9
+
10
+ type DeployMocksArgs = {
11
+ deployTestBed?: boolean;
12
+ gasWarning?: boolean;
13
+ silent?: boolean;
14
+ };
15
+ declare const deployMocks: (hre: HardhatRuntimeEnvironment, options?: DeployMocksArgs) => Promise<void>;
16
+
17
+ declare const mock_getPlaintext: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint) => Promise<any>;
18
+ declare const mock_getPlaintextExists: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint) => Promise<any>;
19
+ declare const mock_expectPlaintext: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint, expectedValue: bigint) => Promise<void>;
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
+ /**
27
+ * Sends funds to the specified address
28
+ * @param hre Hardhat Runtime Environment
29
+ * @param toAddress Address to send funds to
30
+ * @param amount Amount to send in ETH (default: 10)
31
+ * @returns Transaction receipt or null if failed
32
+ */
33
+ declare function localcofheFundAccount(hre: HardhatRuntimeEnvironment, toAddress: string, amount?: string): Promise<ethers.TransactionReceipt | null>;
34
+ /**
35
+ * Checks a wallet's balance and funds it if below 1 ETH
36
+ * @param hre Hardhat Runtime Environment
37
+ * @param walletAddress Address of the wallet to check and potentially fund
38
+ * @returns Promise that resolves when the funding operation completes (if needed)
39
+ */
40
+ declare function localcofheFundWalletIfNeeded(hre: HardhatRuntimeEnvironment, walletAddress: string): Promise<void>;
41
+
42
+ declare const mock_setLoggingEnabled: (hre: HardhatRuntimeEnvironment, enabled: boolean, closureName?: string) => Promise<void>;
43
+ declare const mock_withLogs: (hre: HardhatRuntimeEnvironment, closureName: string, closure: () => Promise<void>) => Promise<void>;
44
+
45
+ /**
46
+ * Configuration interface for the CoFHE Hardhat plugin.
47
+ * Allows users to configure mock logging and gas warning settings.
48
+ */
49
+ declare module 'hardhat/types/config' {
50
+ interface HardhatUserConfig {
51
+ cofhesdk?: {
52
+ /** Whether to log mock operations (default: true) */
53
+ logMocks?: boolean;
54
+ /** Whether to show gas usage warnings for mock operations (default: true) */
55
+ gasWarning?: boolean;
56
+ };
57
+ }
58
+ interface HardhatConfig {
59
+ cofhesdk: {
60
+ /** Whether to log mock operations (default: true) */
61
+ logMocks: boolean;
62
+ /** Whether to show gas usage warnings for mock operations (default: true) */
63
+ gasWarning: boolean;
64
+ };
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Runtime environment extensions for the CoFHE Hardhat plugin.
70
+ * Provides access to CoFHE initialization, environment checks, and mock utilities.
71
+ */
72
+ declare module 'hardhat/types/runtime' {
73
+ interface HardhatRuntimeEnvironment {
74
+ cofhesdk: {
75
+ /**
76
+ * Create a CoFHE SDK configuration for use with cofhesdk.createCofhesdkClient(...)
77
+ * @param {CofhesdkInputConfig} config - The CoFHE SDK input configuration
78
+ * @returns {CofhesdkConfig} The CoFHE SDK configuration
79
+ */
80
+ createCofhesdkConfig: (config: CofhesdkInputConfig) => Promise<CofhesdkConfig>;
81
+ /**
82
+ * Create a CoFHE SDK client instance
83
+ * @param {CofhesdkConfig} config - The CoFHE SDK configuration (use createCofhesdkConfig to create with Node.js defaults)
84
+ * @returns {Promise<CofhesdkClient>} The CoFHE SDK client instance
85
+ */
86
+ createCofhesdkClient: (config: CofhesdkConfig) => CofhesdkClient;
87
+ /**
88
+ * Create viem clients from a Hardhat ethers signer, to be used with `cofhesdkClient.connect(...)`
89
+ * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use
90
+ * @returns {Promise<{ publicClient: PublicClient; walletClient: WalletClient }>} The viem clients
91
+ */
92
+ hardhatSignerAdapter: (signer: HardhatEthersSigner) => Promise<{
93
+ publicClient: PublicClient;
94
+ walletClient: WalletClient;
95
+ }>;
96
+ /**
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)
112
+ */
113
+ expectResultValue: <T>(result: Result<T> | Promise<Result<T>>, value: T) => Promise<T>;
114
+ /**
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)
119
+ */
120
+ expectResultPartialValue: <T>(result: Result<T> | Promise<Result<T>>, partial: Partial<T>) => Promise<T>;
121
+ mocks: {
122
+ /**
123
+ * **[MOCKS ONLY]**
124
+ *
125
+ * Execute a block of code with cofhe mock contracts logging enabled.
126
+ *
127
+ * _(If logging only a function, we recommend passing the function name as the closureName (ex "counter.increment()"))_
128
+ *
129
+ * Example usage:
130
+ *
131
+ * ```ts
132
+ * await hre.cofhesdk.mocks.withLogs("counter.increment()", async () => {
133
+ * await counter.increment();
134
+ * });
135
+ * ```
136
+ *
137
+ * Expected output:
138
+ * ```
139
+ * ┌──────────────────┬──────────────────────────────────────────────────
140
+ * │ [COFHE-MOCKS] │ "counter.increment()" logs:
141
+ * ├──────────────────┴──────────────────────────────────────────────────
142
+ * ├ FHE.add | euint32(4473..3424)[0] + euint32(1157..3648)[1] => euint32(1106..1872)[1]
143
+ * ├ FHE.allowThis | euint32(1106..1872)[1] -> 0x663f..6602
144
+ * ├ FHE.allow | euint32(1106..1872)[1] -> 0x3c44..93bc
145
+ * └─────────────────────────────────────────────────────────────────────
146
+ * ```
147
+ * @param {string} closureName - Name of the code block to log within
148
+ * @param {() => Promise<void>} closure - The async function to execute
149
+ */
150
+ withLogs: (closureName: string, closure: () => Promise<void>) => Promise<void>;
151
+ /**
152
+ * **[MOCKS ONLY]**
153
+ *
154
+ * Enable logging from cofhe mock contracts
155
+ * @param {string} closureName - Optional name of the code block to enable logging for
156
+ */
157
+ enableLogs: (closureName?: string) => Promise<void>;
158
+ /**
159
+ * **[MOCKS ONLY]**
160
+ *
161
+ * Disable logging from cofhe mock contracts
162
+ */
163
+ disableLogs: () => Promise<void>;
164
+ /**
165
+ * **[MOCKS ONLY]**
166
+ *
167
+ * Deploy the cofhe mock contracts (normally this is done automatically)
168
+ * @param {DeployMocksArgs} options - Deployment options
169
+ */
170
+ deployMocks: (options: DeployMocksArgs) => Promise<void>;
171
+ /**
172
+ * **[MOCKS ONLY]**
173
+ *
174
+ * Get the plaintext value for a ciphertext hash
175
+ * @param {bigint} ctHash - The ciphertext hash to look up
176
+ * @returns {Promise<bigint>} The plaintext value
177
+ */
178
+ getPlaintext: (ctHash: bigint) => Promise<bigint>;
179
+ /**
180
+ * **[MOCKS ONLY]**
181
+ *
182
+ * Assert that a ciphertext hash represents an expected plaintext value
183
+ * @param {bigint} ctHash - The ciphertext hash to check
184
+ * @param {bigint} expectedValue - The expected plaintext value
185
+ */
186
+ expectPlaintext: (ctHash: bigint, expectedValue: bigint) => Promise<void>;
187
+ };
188
+ };
189
+ }
190
+ }
191
+
192
+ export { type DeployMocksArgs, deployMocks, expectResultError, expectResultPartialValue, expectResultSuccess, expectResultValue, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs };
@@ -0,0 +1,192 @@
1
+ import { PublicClient, WalletClient } from 'viem';
2
+ import { HardhatEthersSigner } from '@nomicfoundation/hardhat-ethers/signers';
3
+ import { Result, CofhesdkInputConfig, CofhesdkConfig, CofhesdkClient } from '@cofhe/sdk';
4
+ import { HardhatRuntimeEnvironment } from 'hardhat/types';
5
+ export { MockACLArtifact, MockQueryDecrypterArtifact, MockTaskManagerArtifact, MockZkVerifierArtifact, TestBedArtifact } from '@cofhe/mock-contracts';
6
+ import * as ethers from 'ethers';
7
+ import { ethers as ethers$1 } from 'ethers';
8
+ import { HardhatEthersProvider } from '@nomicfoundation/hardhat-ethers/internal/hardhat-ethers-provider';
9
+
10
+ type DeployMocksArgs = {
11
+ deployTestBed?: boolean;
12
+ gasWarning?: boolean;
13
+ silent?: boolean;
14
+ };
15
+ declare const deployMocks: (hre: HardhatRuntimeEnvironment, options?: DeployMocksArgs) => Promise<void>;
16
+
17
+ declare const mock_getPlaintext: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint) => Promise<any>;
18
+ declare const mock_getPlaintextExists: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint) => Promise<any>;
19
+ declare const mock_expectPlaintext: (provider: HardhatEthersProvider | ethers$1.JsonRpcProvider, ctHash: bigint, expectedValue: bigint) => Promise<void>;
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
+ /**
27
+ * Sends funds to the specified address
28
+ * @param hre Hardhat Runtime Environment
29
+ * @param toAddress Address to send funds to
30
+ * @param amount Amount to send in ETH (default: 10)
31
+ * @returns Transaction receipt or null if failed
32
+ */
33
+ declare function localcofheFundAccount(hre: HardhatRuntimeEnvironment, toAddress: string, amount?: string): Promise<ethers.TransactionReceipt | null>;
34
+ /**
35
+ * Checks a wallet's balance and funds it if below 1 ETH
36
+ * @param hre Hardhat Runtime Environment
37
+ * @param walletAddress Address of the wallet to check and potentially fund
38
+ * @returns Promise that resolves when the funding operation completes (if needed)
39
+ */
40
+ declare function localcofheFundWalletIfNeeded(hre: HardhatRuntimeEnvironment, walletAddress: string): Promise<void>;
41
+
42
+ declare const mock_setLoggingEnabled: (hre: HardhatRuntimeEnvironment, enabled: boolean, closureName?: string) => Promise<void>;
43
+ declare const mock_withLogs: (hre: HardhatRuntimeEnvironment, closureName: string, closure: () => Promise<void>) => Promise<void>;
44
+
45
+ /**
46
+ * Configuration interface for the CoFHE Hardhat plugin.
47
+ * Allows users to configure mock logging and gas warning settings.
48
+ */
49
+ declare module 'hardhat/types/config' {
50
+ interface HardhatUserConfig {
51
+ cofhesdk?: {
52
+ /** Whether to log mock operations (default: true) */
53
+ logMocks?: boolean;
54
+ /** Whether to show gas usage warnings for mock operations (default: true) */
55
+ gasWarning?: boolean;
56
+ };
57
+ }
58
+ interface HardhatConfig {
59
+ cofhesdk: {
60
+ /** Whether to log mock operations (default: true) */
61
+ logMocks: boolean;
62
+ /** Whether to show gas usage warnings for mock operations (default: true) */
63
+ gasWarning: boolean;
64
+ };
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Runtime environment extensions for the CoFHE Hardhat plugin.
70
+ * Provides access to CoFHE initialization, environment checks, and mock utilities.
71
+ */
72
+ declare module 'hardhat/types/runtime' {
73
+ interface HardhatRuntimeEnvironment {
74
+ cofhesdk: {
75
+ /**
76
+ * Create a CoFHE SDK configuration for use with cofhesdk.createCofhesdkClient(...)
77
+ * @param {CofhesdkInputConfig} config - The CoFHE SDK input configuration
78
+ * @returns {CofhesdkConfig} The CoFHE SDK configuration
79
+ */
80
+ createCofhesdkConfig: (config: CofhesdkInputConfig) => Promise<CofhesdkConfig>;
81
+ /**
82
+ * Create a CoFHE SDK client instance
83
+ * @param {CofhesdkConfig} config - The CoFHE SDK configuration (use createCofhesdkConfig to create with Node.js defaults)
84
+ * @returns {Promise<CofhesdkClient>} The CoFHE SDK client instance
85
+ */
86
+ createCofhesdkClient: (config: CofhesdkConfig) => CofhesdkClient;
87
+ /**
88
+ * Create viem clients from a Hardhat ethers signer, to be used with `cofhesdkClient.connect(...)`
89
+ * @param {HardhatEthersSigner} signer - The Hardhat ethers signer to use
90
+ * @returns {Promise<{ publicClient: PublicClient; walletClient: WalletClient }>} The viem clients
91
+ */
92
+ hardhatSignerAdapter: (signer: HardhatEthersSigner) => Promise<{
93
+ publicClient: PublicClient;
94
+ walletClient: WalletClient;
95
+ }>;
96
+ /**
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)
112
+ */
113
+ expectResultValue: <T>(result: Result<T> | Promise<Result<T>>, value: T) => Promise<T>;
114
+ /**
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)
119
+ */
120
+ expectResultPartialValue: <T>(result: Result<T> | Promise<Result<T>>, partial: Partial<T>) => Promise<T>;
121
+ mocks: {
122
+ /**
123
+ * **[MOCKS ONLY]**
124
+ *
125
+ * Execute a block of code with cofhe mock contracts logging enabled.
126
+ *
127
+ * _(If logging only a function, we recommend passing the function name as the closureName (ex "counter.increment()"))_
128
+ *
129
+ * Example usage:
130
+ *
131
+ * ```ts
132
+ * await hre.cofhesdk.mocks.withLogs("counter.increment()", async () => {
133
+ * await counter.increment();
134
+ * });
135
+ * ```
136
+ *
137
+ * Expected output:
138
+ * ```
139
+ * ┌──────────────────┬──────────────────────────────────────────────────
140
+ * │ [COFHE-MOCKS] │ "counter.increment()" logs:
141
+ * ├──────────────────┴──────────────────────────────────────────────────
142
+ * ├ FHE.add | euint32(4473..3424)[0] + euint32(1157..3648)[1] => euint32(1106..1872)[1]
143
+ * ├ FHE.allowThis | euint32(1106..1872)[1] -> 0x663f..6602
144
+ * ├ FHE.allow | euint32(1106..1872)[1] -> 0x3c44..93bc
145
+ * └─────────────────────────────────────────────────────────────────────
146
+ * ```
147
+ * @param {string} closureName - Name of the code block to log within
148
+ * @param {() => Promise<void>} closure - The async function to execute
149
+ */
150
+ withLogs: (closureName: string, closure: () => Promise<void>) => Promise<void>;
151
+ /**
152
+ * **[MOCKS ONLY]**
153
+ *
154
+ * Enable logging from cofhe mock contracts
155
+ * @param {string} closureName - Optional name of the code block to enable logging for
156
+ */
157
+ enableLogs: (closureName?: string) => Promise<void>;
158
+ /**
159
+ * **[MOCKS ONLY]**
160
+ *
161
+ * Disable logging from cofhe mock contracts
162
+ */
163
+ disableLogs: () => Promise<void>;
164
+ /**
165
+ * **[MOCKS ONLY]**
166
+ *
167
+ * Deploy the cofhe mock contracts (normally this is done automatically)
168
+ * @param {DeployMocksArgs} options - Deployment options
169
+ */
170
+ deployMocks: (options: DeployMocksArgs) => Promise<void>;
171
+ /**
172
+ * **[MOCKS ONLY]**
173
+ *
174
+ * Get the plaintext value for a ciphertext hash
175
+ * @param {bigint} ctHash - The ciphertext hash to look up
176
+ * @returns {Promise<bigint>} The plaintext value
177
+ */
178
+ getPlaintext: (ctHash: bigint) => Promise<bigint>;
179
+ /**
180
+ * **[MOCKS ONLY]**
181
+ *
182
+ * Assert that a ciphertext hash represents an expected plaintext value
183
+ * @param {bigint} ctHash - The ciphertext hash to check
184
+ * @param {bigint} expectedValue - The expected plaintext value
185
+ */
186
+ expectPlaintext: (ctHash: bigint, expectedValue: bigint) => Promise<void>;
187
+ };
188
+ };
189
+ }
190
+ }
191
+
192
+ export { type DeployMocksArgs, deployMocks, expectResultError, expectResultPartialValue, expectResultSuccess, expectResultValue, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_getPlaintextExists, mock_setLoggingEnabled, mock_withLogs };