-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.js
159 lines (146 loc) · 4.39 KB
/
hardhat.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
require("@nomiclabs/hardhat-waffle");
require("@nomiclabs/hardhat-ethers");
require("dotenv").config();
// Define common settings for reuse
const commonCompilerSettings = {
optimizer: {
enabled: true,
runs: 200,
},
evmVersion: "istanbul",
};
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: {
compilers: [
{
version: "0.8.24", // Uniswap-v4
settings: { ...commonCompilerSettings },
},
{
version: "0.8.20", // Uniswap-v4
settings: { ...commonCompilerSettings },
},
{
version: "0.8.19", // Uniswap-v4
settings: { ...commonCompilerSettings },
},
{
version: "0.8.15", // Uniswap-v4
settings: { ...commonCompilerSettings },
},
{
version: "0.8.10", // Lens
settings: { ...commonCompilerSettings },
},
{
version: "0.8.9", // Lido DAO
settings: { ...commonCompilerSettings },
},
{
version: "0.8.4", // Lido DAO
settings: { ...commonCompilerSettings },
},
{
version: "0.8.0", // Uniswap-v4
settings: { ...commonCompilerSettings },
},
{
version: "0.7.6", // Safe Contracts
settings: { ...commonCompilerSettings },
},
{
version: "0.6.12", // Lido DAO
settings: { ...commonCompilerSettings },
},
{
version: "0.6.11", // Lido DAO
settings: { ...commonCompilerSettings },
},
{
version: "0.4.24", // Lido DAO
settings: { ...commonCompilerSettings },
},
],
ignore: [
"./lib/lido-dao/contracts/0.4.24/**",
"./lib/lido-dao/contracts/0.6.11/**",
"./lib/lido-dao/contracts/0.6.12/**",
"./lib/lido-dao/contracts/0.8.4/**",
],
},
networks: {
polygonZkEvmTestnet: {
url: process.env.POLYGON_ZKEVM_TESTNET_RPC_URL,
accounts: {
mnemonic: process.env.MNEMONIC,
},
chainId: parseInt(process.env.POLYGON_ZKEVM_TESTNET_CHAIN_ID || 1422),
},
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts",
},
external: {
contracts: [
{
artifact:
"./artifacts/contracts/ExternalContract.sol/ExternalContract.json",
address: "0xYourContractAddress",
},
],
},
// rest of your config...
};
// This is a sample Hardhat task. To learn how to create your own go to
// https://hardhat.org/guides/create-task.html
task("accounts", "Prints the list of accounts", async () => {
const accounts = await ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
// This is removed from the global scope of the config file to prevent HH9 errors
// const { ethers } = require("hardhat");
// const { Safe, SafeFactory } = require("@safe-global/safe-core-sdk");
// const { EthersAdapter } = require("@safe-global/safe-ethers-adapters");
const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY;
task("initSafe", "Initializes a Gnosis Safe with given owners and threshold")
.addParam("owners", "The owners of the Safe")
.addParam("threshold", "The threshold for the Safe")
.setAction(async ({ owners, threshold }, { ethers }) => {
const { Safe, SafeFactory } = require("@safe-global/safe-core-sdk");
const { EthersAdapter } = require("@safe-global/safe-ethers-adapters");
const provider = ethers.provider;
const ethAdapter = new EthersAdapter({
ethers,
signer: provider.getSigner(),
});
const safeFactory = new SafeFactory({
ethAdapter,
contractNetworks: {
[1422]: {
multiSendAddress: "0x5a0b54d5dc17e0aadc383d2db43b0a0d3e029c4c",
safeMasterCopyAddress: "0x6851D6fDFAfD08c0295C392436245E5bc78B0185",
safeProxyFactoryAddress: "0x76E2cFc1F5Fa8F6a5b3fC4c8F4788F0116861F9B",
},
},
});
const safeTransaction = await safeFactory.deploySafe({
owners: owners.split(","), // Assuming owners are passed as a comma-separated list
threshold: parseInt(threshold, 10),
});
const safeAddress = await safeTransaction.getAddress();
console.log(`Safe deployed at: ${safeAddress}`);
const safe = await Safe.create({
ethAdapter,
safeAddress,
contractNetworks: safeFactory.contractNetworks, // Reuse the contractNetworks from safeFactory
});
return safe;
});