@cofhe/hardhat-3-plugin 0.0.0-alpha-20260409113701
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 +11 -0
- package/README.md +270 -0
- package/dist/chunk-5FCSZD6A.js +223 -0
- package/dist/chunk-IVRNGFNF.js +64 -0
- package/dist/chunk-Z2FAJP4Y.js +42 -0
- package/dist/config-YK3LB5IH.js +64 -0
- package/dist/hre-YCSQIPJL.js +143 -0
- package/dist/index.d.ts +140 -0
- package/dist/index.js +52 -0
- package/dist/set-log-ops-GVEQWMZP.js +15 -0
- package/dist/use-faucet-O732FNWJ.js +33 -0
- package/package.json +54 -0
- package/src/config.ts +64 -0
- package/src/consts.ts +2 -0
- package/src/deploy.ts +250 -0
- package/src/fund.ts +62 -0
- package/src/hooks/config.ts +13 -0
- package/src/hooks/hre.ts +172 -0
- package/src/index.ts +41 -0
- package/src/logging.ts +84 -0
- package/src/tasks/set-log-ops.ts +17 -0
- package/src/tasks/use-faucet.ts +39 -0
- package/src/type-extensions.ts +107 -0
- package/src/utils.ts +79 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import {
|
|
2
|
+
deployMocks,
|
|
3
|
+
mock_expectPlaintext,
|
|
4
|
+
mock_getPlaintext
|
|
5
|
+
} from "./chunk-5FCSZD6A.js";
|
|
6
|
+
import {
|
|
7
|
+
mock_setLoggingEnabled,
|
|
8
|
+
mock_withLogs
|
|
9
|
+
} from "./chunk-IVRNGFNF.js";
|
|
10
|
+
|
|
11
|
+
// src/hooks/hre.ts
|
|
12
|
+
import { createPublicClient, createWalletClient, custom } from "viem";
|
|
13
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
14
|
+
import {
|
|
15
|
+
MockTaskManagerArtifact,
|
|
16
|
+
MockACLArtifact,
|
|
17
|
+
MockZkVerifierArtifact,
|
|
18
|
+
MockThresholdNetworkArtifact,
|
|
19
|
+
TestBedArtifact
|
|
20
|
+
} from "@cofhe/mock-contracts";
|
|
21
|
+
import { MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY } from "@cofhe/sdk";
|
|
22
|
+
import { createCofheConfig, createCofheClient } from "@cofhe/sdk/node";
|
|
23
|
+
import { hardhat as hardhatChain } from "@cofhe/sdk/chains";
|
|
24
|
+
function createCofheConnection(publicClient, walletClient, transport) {
|
|
25
|
+
return {
|
|
26
|
+
async createConfig(config = {}) {
|
|
27
|
+
const zkvAccount = privateKeyToAccount(MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY);
|
|
28
|
+
const zkvWalletClient = createWalletClient({ account: zkvAccount, transport });
|
|
29
|
+
return createCofheConfig({
|
|
30
|
+
environment: "hardhat",
|
|
31
|
+
supportedChains: [hardhatChain],
|
|
32
|
+
...config,
|
|
33
|
+
mocks: {
|
|
34
|
+
encryptDelay: 0,
|
|
35
|
+
...config.mocks
|
|
36
|
+
},
|
|
37
|
+
_internal: {
|
|
38
|
+
...config._internal,
|
|
39
|
+
zkvWalletClient
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
createClient(config) {
|
|
44
|
+
return createCofheClient(config);
|
|
45
|
+
},
|
|
46
|
+
async createClientWithBatteries(signerWalletClient) {
|
|
47
|
+
let signerClient;
|
|
48
|
+
let address;
|
|
49
|
+
if (signerWalletClient) {
|
|
50
|
+
const [addr] = await signerWalletClient.getAddresses();
|
|
51
|
+
if (!addr) throw new Error("createClientWithBatteries: provided walletClient has no accounts");
|
|
52
|
+
signerClient = signerWalletClient;
|
|
53
|
+
address = addr;
|
|
54
|
+
} else {
|
|
55
|
+
const [addr] = await walletClient.getAddresses();
|
|
56
|
+
if (!addr) throw new Error("createClientWithBatteries: no accounts available on this connection");
|
|
57
|
+
address = addr;
|
|
58
|
+
signerClient = createWalletClient({ account: address, transport });
|
|
59
|
+
}
|
|
60
|
+
const config = await this.createConfig();
|
|
61
|
+
const client = this.createClient(config);
|
|
62
|
+
await client.connect(publicClient, signerClient);
|
|
63
|
+
await client.permits.createSelf({ issuer: address });
|
|
64
|
+
return client;
|
|
65
|
+
},
|
|
66
|
+
mocks: {
|
|
67
|
+
async deployMocks(options) {
|
|
68
|
+
await deployMocks({ publicClient, walletClient }, options);
|
|
69
|
+
},
|
|
70
|
+
async withLogs(closureName, closure) {
|
|
71
|
+
await mock_withLogs(publicClient, walletClient, closureName, closure);
|
|
72
|
+
},
|
|
73
|
+
async enableLogs(closureName) {
|
|
74
|
+
await mock_setLoggingEnabled(publicClient, walletClient, true, closureName);
|
|
75
|
+
},
|
|
76
|
+
async disableLogs() {
|
|
77
|
+
await mock_setLoggingEnabled(publicClient, walletClient, false);
|
|
78
|
+
},
|
|
79
|
+
async getPlaintext(ctHash) {
|
|
80
|
+
const value = await mock_getPlaintext(publicClient, ctHash);
|
|
81
|
+
if (value === void 0) throw new Error("getPlaintext: not on mock network");
|
|
82
|
+
return value;
|
|
83
|
+
},
|
|
84
|
+
async expectPlaintext(ctHash, expectedValue) {
|
|
85
|
+
await mock_expectPlaintext(publicClient, ctHash, expectedValue);
|
|
86
|
+
},
|
|
87
|
+
MockTaskManager: {
|
|
88
|
+
address: MockTaskManagerArtifact.fixedAddress,
|
|
89
|
+
abi: MockTaskManagerArtifact.abi
|
|
90
|
+
},
|
|
91
|
+
async MockACL() {
|
|
92
|
+
const address = await publicClient.readContract({
|
|
93
|
+
address: MockTaskManagerArtifact.fixedAddress,
|
|
94
|
+
abi: [
|
|
95
|
+
{ name: "acl", type: "function", inputs: [], outputs: [{ type: "address" }], stateMutability: "view" }
|
|
96
|
+
],
|
|
97
|
+
functionName: "acl"
|
|
98
|
+
});
|
|
99
|
+
return { address, abi: MockACLArtifact.abi };
|
|
100
|
+
},
|
|
101
|
+
MockZkVerifier: {
|
|
102
|
+
address: MockZkVerifierArtifact.fixedAddress,
|
|
103
|
+
abi: MockZkVerifierArtifact.abi
|
|
104
|
+
},
|
|
105
|
+
MockThresholdNetwork: {
|
|
106
|
+
address: MockThresholdNetworkArtifact.fixedAddress,
|
|
107
|
+
abi: MockThresholdNetworkArtifact.abi
|
|
108
|
+
},
|
|
109
|
+
TestBed: {
|
|
110
|
+
address: TestBedArtifact.fixedAddress,
|
|
111
|
+
abi: TestBedArtifact.abi
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
var hreHooks = {
|
|
117
|
+
async created(_context, hre) {
|
|
118
|
+
const networkHandlers = {
|
|
119
|
+
async newConnection(context, next) {
|
|
120
|
+
const conn = await next(context);
|
|
121
|
+
const transport = custom(conn.provider);
|
|
122
|
+
const publicClient = createPublicClient({ transport });
|
|
123
|
+
const walletClient = createWalletClient({ transport });
|
|
124
|
+
const connTransport = custom({ request: (args) => walletClient.request(args) });
|
|
125
|
+
await deployMocks(
|
|
126
|
+
{ publicClient, walletClient },
|
|
127
|
+
{
|
|
128
|
+
deployTestBed: true,
|
|
129
|
+
gasWarning: hre.config.cofhe.gasWarning,
|
|
130
|
+
mocksDeployVerbosity: hre.config.cofhe.mocksDeployVerbosity
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
conn.cofhe = createCofheConnection(publicClient, walletClient, connTransport);
|
|
134
|
+
return conn;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
hre.hooks.registerHandlers("network", networkHandlers);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
var hre_default = async () => hreHooks;
|
|
141
|
+
export {
|
|
142
|
+
hre_default as default
|
|
143
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { HardhatPlugin } from 'hardhat/types/plugins';
|
|
2
|
+
import { PublicClient, WalletClient } from 'viem';
|
|
3
|
+
import { CofheInputConfig, CofheConfig, CofheClient } from '@cofhe/sdk';
|
|
4
|
+
import { MockTaskManagerArtifact, MockACLArtifact, MockZkVerifierArtifact, MockThresholdNetworkArtifact, TestBedArtifact } from '@cofhe/mock-contracts';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Controls deploy-mocks console output.
|
|
8
|
+
* - `''` — silent, no output
|
|
9
|
+
* - `'v'` — single summary line (default)
|
|
10
|
+
* - `'vv'` — full per-contract deployment logs
|
|
11
|
+
*/
|
|
12
|
+
type LogMocksDeploy = '' | 'v' | 'vv';
|
|
13
|
+
type DeployMocksArgs = {
|
|
14
|
+
deployTestBed?: boolean;
|
|
15
|
+
gasWarning?: boolean;
|
|
16
|
+
mocksDeployVerbosity?: LogMocksDeploy;
|
|
17
|
+
};
|
|
18
|
+
type DeployContext = {
|
|
19
|
+
publicClient: PublicClient;
|
|
20
|
+
walletClient: WalletClient;
|
|
21
|
+
};
|
|
22
|
+
declare function deployMocks(ctx: DeployContext, options?: DeployMocksArgs): Promise<void>;
|
|
23
|
+
|
|
24
|
+
interface CofheConnection {
|
|
25
|
+
/**
|
|
26
|
+
* Create a CoFHE configuration. Defaults to hardhat environment;
|
|
27
|
+
* pass overrides as needed.
|
|
28
|
+
*/
|
|
29
|
+
createConfig(config?: Partial<CofheInputConfig>): Promise<CofheConfig>;
|
|
30
|
+
/** Create a CoFHE client instance from a config. */
|
|
31
|
+
createClient(config: CofheConfig): CofheClient;
|
|
32
|
+
/**
|
|
33
|
+
* Create and connect a batteries-included CoFHE client.
|
|
34
|
+
* If a WalletClient is provided it is used as the signer; otherwise the
|
|
35
|
+
* first account from the connection is used automatically.
|
|
36
|
+
*/
|
|
37
|
+
createClientWithBatteries(walletClient?: WalletClient): Promise<CofheClient>;
|
|
38
|
+
mocks: {
|
|
39
|
+
/** Deploy (or re-deploy) the mock contracts. */
|
|
40
|
+
deployMocks(options?: DeployMocksArgs): Promise<void>;
|
|
41
|
+
/** Execute a block with CoFHE mock logging enabled. */
|
|
42
|
+
withLogs(closureName: string, closure: () => Promise<void>): Promise<void>;
|
|
43
|
+
/** Enable logging from CoFHE mock contracts. */
|
|
44
|
+
enableLogs(closureName?: string): Promise<void>;
|
|
45
|
+
/** Disable logging from CoFHE mock contracts. */
|
|
46
|
+
disableLogs(): Promise<void>;
|
|
47
|
+
/** Get the plaintext value stored for a ciphertext hash. */
|
|
48
|
+
getPlaintext(ctHash: bigint | string): Promise<bigint>;
|
|
49
|
+
/** Assert that a ciphertext hash represents the expected plaintext value. */
|
|
50
|
+
expectPlaintext(ctHash: bigint | string, expectedValue: bigint): Promise<void>;
|
|
51
|
+
/** MockTaskManager contract descriptor — spread into readContract / writeContract */
|
|
52
|
+
MockTaskManager: {
|
|
53
|
+
address: `0x${string}`;
|
|
54
|
+
abi: typeof MockTaskManagerArtifact.abi;
|
|
55
|
+
};
|
|
56
|
+
/** Resolves the MockACL descriptor from the TaskManager on-chain. */
|
|
57
|
+
MockACL(): Promise<{
|
|
58
|
+
address: `0x${string}`;
|
|
59
|
+
abi: typeof MockACLArtifact.abi;
|
|
60
|
+
}>;
|
|
61
|
+
/** MockZkVerifier contract descriptor */
|
|
62
|
+
MockZkVerifier: {
|
|
63
|
+
address: `0x${string}`;
|
|
64
|
+
abi: typeof MockZkVerifierArtifact.abi;
|
|
65
|
+
};
|
|
66
|
+
/** MockThresholdNetwork contract descriptor */
|
|
67
|
+
MockThresholdNetwork: {
|
|
68
|
+
address: `0x${string}`;
|
|
69
|
+
abi: typeof MockThresholdNetworkArtifact.abi;
|
|
70
|
+
};
|
|
71
|
+
/** TestBed contract descriptor */
|
|
72
|
+
TestBed: {
|
|
73
|
+
address: `0x${string}`;
|
|
74
|
+
abi: typeof TestBedArtifact.abi;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
declare module 'hardhat/types/config' {
|
|
79
|
+
interface HardhatUserConfig {
|
|
80
|
+
cofhe?: {
|
|
81
|
+
/** Whether to log mock FHE operations (default: true) */
|
|
82
|
+
logMocks?: boolean;
|
|
83
|
+
/** Whether to show gas usage warnings for mock operations (default: true) */
|
|
84
|
+
gasWarning?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Controls deploy-mocks console output.
|
|
87
|
+
* - `''` — silent, no output
|
|
88
|
+
* - `'v'` — single summary line (default)
|
|
89
|
+
* - `'vv'` — full per-contract deployment logs
|
|
90
|
+
*/
|
|
91
|
+
mocksDeployVerbosity?: LogMocksDeploy;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
interface HardhatConfig {
|
|
95
|
+
cofhe: {
|
|
96
|
+
logMocks: boolean;
|
|
97
|
+
gasWarning: boolean;
|
|
98
|
+
mocksDeployVerbosity: LogMocksDeploy;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
declare module 'hardhat/types/network' {
|
|
103
|
+
interface NetworkConnection {
|
|
104
|
+
/**
|
|
105
|
+
* CoFHE mock environment — ready to use immediately after network.connect().
|
|
106
|
+
* Mock contracts are deployed automatically on every connect().
|
|
107
|
+
*/
|
|
108
|
+
cofhe: CofheConnection;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
declare const TASK_COFHE_USE_FAUCET = "cofhe:faucet";
|
|
113
|
+
declare const TASK_COFHE_SET_LOG_OPS = "cofhe:set-log-ops";
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Sends ETH to `toAddress` on the localcofhe network using the funder wallet.
|
|
117
|
+
* The funder private key can be overridden via the FUNDER_PRIVATE_KEY environment variable.
|
|
118
|
+
*/
|
|
119
|
+
declare function localcofheFundAccount(publicClient: PublicClient, walletClient: WalletClient, toAddress: `0x${string}`, amount?: string): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Checks a wallet's balance and funds it if below 1 ETH.
|
|
122
|
+
*/
|
|
123
|
+
declare function localcofheFundWalletIfNeeded(publicClient: PublicClient, walletClient: WalletClient, walletAddress: `0x${string}`): Promise<void>;
|
|
124
|
+
|
|
125
|
+
declare function mock_setLoggingEnabled(publicClient: PublicClient, walletClient: WalletClient, enabled: boolean, closureName?: string): Promise<void>;
|
|
126
|
+
declare function mock_withLogs(publicClient: PublicClient, walletClient: WalletClient, closureName: string, closure: () => Promise<void>): Promise<void>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Reads the plaintext value stored for a ciphertext hash from MockTaskManager.
|
|
130
|
+
* Returns undefined when not running on a mock network.
|
|
131
|
+
*/
|
|
132
|
+
declare function mock_getPlaintext(publicClient: PublicClient, ctHash: bigint | string): Promise<bigint | undefined>;
|
|
133
|
+
/**
|
|
134
|
+
* Asserts that a ciphertext hash maps to the expected plaintext value.
|
|
135
|
+
*/
|
|
136
|
+
declare function mock_expectPlaintext(publicClient: PublicClient, ctHash: bigint | string, expectedValue: bigint): Promise<void>;
|
|
137
|
+
|
|
138
|
+
declare const plugin: HardhatPlugin;
|
|
139
|
+
|
|
140
|
+
export { type DeployContext, type DeployMocksArgs, type LogMocksDeploy, TASK_COFHE_SET_LOG_OPS, TASK_COFHE_USE_FAUCET, plugin as default, deployMocks, localcofheFundAccount, localcofheFundWalletIfNeeded, mock_expectPlaintext, mock_getPlaintext, mock_setLoggingEnabled, mock_withLogs };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import {
|
|
2
|
+
deployMocks,
|
|
3
|
+
mock_expectPlaintext,
|
|
4
|
+
mock_getPlaintext
|
|
5
|
+
} from "./chunk-5FCSZD6A.js";
|
|
6
|
+
import {
|
|
7
|
+
localcofheFundAccount,
|
|
8
|
+
localcofheFundWalletIfNeeded
|
|
9
|
+
} from "./chunk-Z2FAJP4Y.js";
|
|
10
|
+
import {
|
|
11
|
+
mock_setLoggingEnabled,
|
|
12
|
+
mock_withLogs
|
|
13
|
+
} from "./chunk-IVRNGFNF.js";
|
|
14
|
+
|
|
15
|
+
// src/index.ts
|
|
16
|
+
import { task } from "hardhat/config";
|
|
17
|
+
import { ArgumentType } from "hardhat/types/arguments";
|
|
18
|
+
|
|
19
|
+
// src/consts.ts
|
|
20
|
+
var TASK_COFHE_USE_FAUCET = "cofhe:faucet";
|
|
21
|
+
var TASK_COFHE_SET_LOG_OPS = "cofhe:set-log-ops";
|
|
22
|
+
|
|
23
|
+
// src/index.ts
|
|
24
|
+
var plugin = {
|
|
25
|
+
id: "@cofhe/hardhat-3-plugin",
|
|
26
|
+
hookHandlers: {
|
|
27
|
+
config: async () => import("./config-YK3LB5IH.js"),
|
|
28
|
+
hre: async () => import("./hre-YCSQIPJL.js")
|
|
29
|
+
},
|
|
30
|
+
tasks: [
|
|
31
|
+
task(TASK_COFHE_USE_FAUCET, "Fund an account via the localcofhe faucet").addOption({
|
|
32
|
+
name: "address",
|
|
33
|
+
description: "Address to fund",
|
|
34
|
+
type: ArgumentType.STRING_WITHOUT_DEFAULT,
|
|
35
|
+
defaultValue: void 0
|
|
36
|
+
}).setAction(async () => import("./use-faucet-O732FNWJ.js")).build(),
|
|
37
|
+
task(TASK_COFHE_SET_LOG_OPS, "Enable or disable CoFHE mock contract logging").addFlag({ name: "enable", description: "Whether to enable logging" }).setAction(async () => import("./set-log-ops-GVEQWMZP.js")).build()
|
|
38
|
+
]
|
|
39
|
+
};
|
|
40
|
+
var index_default = plugin;
|
|
41
|
+
export {
|
|
42
|
+
TASK_COFHE_SET_LOG_OPS,
|
|
43
|
+
TASK_COFHE_USE_FAUCET,
|
|
44
|
+
index_default as default,
|
|
45
|
+
deployMocks,
|
|
46
|
+
localcofheFundAccount,
|
|
47
|
+
localcofheFundWalletIfNeeded,
|
|
48
|
+
mock_expectPlaintext,
|
|
49
|
+
mock_getPlaintext,
|
|
50
|
+
mock_setLoggingEnabled,
|
|
51
|
+
mock_withLogs
|
|
52
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mock_setLoggingEnabled
|
|
3
|
+
} from "./chunk-IVRNGFNF.js";
|
|
4
|
+
|
|
5
|
+
// src/tasks/set-log-ops.ts
|
|
6
|
+
import { createPublicClient, createWalletClient, custom } from "viem";
|
|
7
|
+
var action = async ({ enable }, hre) => {
|
|
8
|
+
const connection = await hre.network.connect();
|
|
9
|
+
const transport = custom(connection.provider);
|
|
10
|
+
await mock_setLoggingEnabled(createPublicClient({ transport }), createWalletClient({ transport }), enable);
|
|
11
|
+
};
|
|
12
|
+
var set_log_ops_default = action;
|
|
13
|
+
export {
|
|
14
|
+
set_log_ops_default as default
|
|
15
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
localcofheFundAccount
|
|
3
|
+
} from "./chunk-Z2FAJP4Y.js";
|
|
4
|
+
|
|
5
|
+
// src/tasks/use-faucet.ts
|
|
6
|
+
import { createPublicClient, createWalletClient, custom } from "viem";
|
|
7
|
+
import chalk from "chalk";
|
|
8
|
+
var action = async ({ address }, hre) => {
|
|
9
|
+
const connection = await hre.network.connect();
|
|
10
|
+
if (connection.networkName !== "localcofhe") {
|
|
11
|
+
console.info(chalk.yellow("Programmatic faucet only supported for localcofhe"));
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (!address) {
|
|
15
|
+
console.info(chalk.red("Failed to get address to fund"));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
console.info(chalk.green(`Getting funds from faucet for ${address}`));
|
|
19
|
+
const transport = custom(connection.provider);
|
|
20
|
+
try {
|
|
21
|
+
await localcofheFundAccount(
|
|
22
|
+
createPublicClient({ transport }),
|
|
23
|
+
createWalletClient({ transport }),
|
|
24
|
+
address
|
|
25
|
+
);
|
|
26
|
+
} catch (e) {
|
|
27
|
+
console.info(chalk.red(`Failed to get funds from localcofhe for ${address}: ${e}`));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var use_faucet_default = action;
|
|
31
|
+
export {
|
|
32
|
+
use_faucet_default as default
|
|
33
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cofhe/hardhat-3-plugin",
|
|
3
|
+
"version": "0.0.0-alpha-20260409113701",
|
|
4
|
+
"description": "Hardhat 3 plugin for CoFHE — deploys mock contracts and wires up the hre.cofhe interface",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/FhenixProtocol/cofhesdk.git",
|
|
20
|
+
"directory": "packages/hardhat-3-plugin"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist/**",
|
|
24
|
+
"src/**",
|
|
25
|
+
"CHANGELOG.md",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"chalk": "^4.1.2",
|
|
30
|
+
"viem": "^2.38.6",
|
|
31
|
+
"@cofhe/mock-contracts": "0.0.0-alpha-20260409113701",
|
|
32
|
+
"@cofhe/sdk": "0.0.0-alpha-20260409113701"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^20.0.0",
|
|
36
|
+
"hardhat": "^3.1.12",
|
|
37
|
+
"tsup": "^8.0.2",
|
|
38
|
+
"typescript": "5.5.4",
|
|
39
|
+
"@cofhe/tsconfig": "0.1.2"
|
|
40
|
+
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"hardhat": "^3.0.0"
|
|
43
|
+
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public",
|
|
46
|
+
"registry": "https://registry.npmjs.org/"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "tsup src/index.ts --format esm --dts",
|
|
50
|
+
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
51
|
+
"check:types": "tsc --noEmit",
|
|
52
|
+
"clean": "rm -rf dist node_modules .tsbuildinfo"
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { HardhatUserConfig, HardhatConfig } from 'hardhat/types/config';
|
|
2
|
+
import type { LogMocksDeploy } from './deploy.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Extends the resolved config with plugin defaults and network presets.
|
|
6
|
+
* Mirrors the logic from the v2 plugin's extendConfig callback.
|
|
7
|
+
*/
|
|
8
|
+
export function resolvePluginConfig(userConfig: HardhatUserConfig, resolvedConfig: HardhatConfig): void {
|
|
9
|
+
// Inject localcofhe network preset if the user hasn't defined it
|
|
10
|
+
if (!userConfig.networks?.['localcofhe']) {
|
|
11
|
+
(resolvedConfig.networks as Record<string, unknown>)['localcofhe'] = {
|
|
12
|
+
type: 'http',
|
|
13
|
+
url: 'http://127.0.0.1:42069',
|
|
14
|
+
gas: 'auto',
|
|
15
|
+
gasMultiplier: 1.2,
|
|
16
|
+
gasPrice: 'auto',
|
|
17
|
+
timeout: 10_000,
|
|
18
|
+
httpHeaders: {},
|
|
19
|
+
accounts: [
|
|
20
|
+
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
|
|
21
|
+
'0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d',
|
|
22
|
+
'0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a',
|
|
23
|
+
'0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6',
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Inject eth-sepolia preset if the user hasn't defined it
|
|
29
|
+
if (!userConfig.networks?.['eth-sepolia']) {
|
|
30
|
+
(resolvedConfig.networks as Record<string, unknown>)['eth-sepolia'] = {
|
|
31
|
+
type: 'http',
|
|
32
|
+
url: process.env['SEPOLIA_RPC_URL'] ?? 'https://ethereum-sepolia.publicnode.com',
|
|
33
|
+
accounts: process.env['PRIVATE_KEY'] ? [process.env['PRIVATE_KEY']] : [],
|
|
34
|
+
chainId: 11155111,
|
|
35
|
+
gas: 'auto',
|
|
36
|
+
gasMultiplier: 1.2,
|
|
37
|
+
gasPrice: 'auto',
|
|
38
|
+
timeout: 60_000,
|
|
39
|
+
httpHeaders: {},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Inject arb-sepolia preset if the user hasn't defined it
|
|
44
|
+
if (!userConfig.networks?.['arb-sepolia']) {
|
|
45
|
+
(resolvedConfig.networks as Record<string, unknown>)['arb-sepolia'] = {
|
|
46
|
+
type: 'http',
|
|
47
|
+
url: process.env['ARBITRUM_SEPOLIA_RPC_URL'] ?? 'https://sepolia-rollup.arbitrum.io/rpc',
|
|
48
|
+
accounts: process.env['PRIVATE_KEY'] ? [process.env['PRIVATE_KEY']] : [],
|
|
49
|
+
chainId: 421614,
|
|
50
|
+
gas: 'auto',
|
|
51
|
+
gasMultiplier: 1.2,
|
|
52
|
+
gasPrice: 'auto',
|
|
53
|
+
timeout: 60_000,
|
|
54
|
+
httpHeaders: {},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Resolve cofhe plugin config
|
|
59
|
+
resolvedConfig.cofhe = {
|
|
60
|
+
logMocks: userConfig.cofhe?.logMocks ?? false,
|
|
61
|
+
gasWarning: userConfig.cofhe?.gasWarning ?? false,
|
|
62
|
+
mocksDeployVerbosity: (userConfig.cofhe?.mocksDeployVerbosity ?? 'v') as LogMocksDeploy,
|
|
63
|
+
};
|
|
64
|
+
}
|
package/src/consts.ts
ADDED