-
Notifications
You must be signed in to change notification settings - Fork 15
/
hardhat.config.zksync.ts
167 lines (157 loc) · 4.45 KB
/
hardhat.config.zksync.ts
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
160
161
162
163
164
165
166
167
import "module-alias/register";
import "@matterlabs/hardhat-zksync";
import "@matterlabs/hardhat-zksync-solc";
import "@matterlabs/hardhat-zksync-verify";
import "@nomicfoundation/hardhat-chai-matchers";
import "@nomiclabs/hardhat-ethers";
import * as dotenv from "dotenv";
import "hardhat-dependency-compiler";
import "hardhat-deploy";
import "hardhat-gas-reporter";
import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from "hardhat/builtin-tasks/task-names";
import { subtask } from "hardhat/config";
import { HardhatUserConfig, extendConfig, task } from "hardhat/config";
import { HardhatConfig } from "hardhat/types";
import "solidity-docgen";
dotenv.config();
const DEPLOYER_PRIVATE_KEY = process.env.DEPLOYER_PRIVATE_KEY;
extendConfig((config: HardhatConfig) => {
if (process.env.EXPORT !== "true") {
config.external = {
...config.external,
deployments: {
zksyncsepolia: ["node_modules/@venusprotocol/protocol-reserve/deployments/zksyncsepolia"],
zksyncmainnet: ["node_modules/@venusprotocol/protocol-reserve/deployments/zksyncmainnet"],
},
};
}
});
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
zksolc: {
version: "1.5.3",
},
solidity: {
compilers: [
{
version: "0.8.25",
settings: {
optimizer: {
enabled: true,
details: {
yul: !process.env.CI,
},
},
evmVersion: "paris",
outputSelection: {
"*": {
"*": ["storageLayout"],
},
},
},
},
{
version: "0.6.6",
settings: {
optimizer: {
enabled: true,
details: {
yul: !process.env.CI,
},
},
outputSelection: {
"*": {
"*": ["storageLayout"],
},
},
},
},
{
version: "0.5.16",
settings: {
optimizer: {
enabled: true,
details: {
yul: !process.env.CI,
},
},
outputSelection: {
"*": {
"*": ["storageLayout"],
},
},
},
},
],
},
networks: {
hardhat: {
allowUnlimitedContractSize: true,
loggingEnabled: false,
live: false,
zksync: true,
},
zksyncsepolia: {
url: process.env.ARCHIVE_NODE_zksyncsepolia || "https://sepolia.era.zksync.dev",
ethNetwork: "sepolia",
verifyURL: "https://explorer.sepolia.era.zksync.dev/contract_verification",
accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [],
zksync: true,
live: true,
},
zksyncmainnet: {
url: process.env.ARCHIVE_NODE_zksyncmainnet || "https://mainnet.era.zksync.io",
ethNetwork: "mainnet",
verifyURL: "https://zksync2-mainnet-explorer.zksync.io/contract_verification",
accounts: DEPLOYER_PRIVATE_KEY ? [`0x${DEPLOYER_PRIVATE_KEY}`] : [],
zksync: true,
live: true,
},
},
gasReporter: {
enabled: process.env.REPORT_GAS !== undefined,
currency: "USD",
},
paths: {
tests: "./tests",
cache: "./cache-zk",
artifacts: "./artifacts-zk",
},
docgen: {
outputDir: "./docs",
pages: "files",
templates: "./docgen-templates",
},
// Hardhat deploy
namedAccounts: {
deployer: {
default: 0, // here this will by default take the first account as deployer
acc1: 1,
acc2: 2,
proxyAdmin: 3,
acc3: 4,
},
},
dependencyCompiler: {
paths: [
"hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol",
"hardhat-deploy/solc_0.8/openzeppelin/proxy/transparent/ProxyAdmin.sol",
],
},
};
// Added a subtask to exclude some solidity files from compilation due to limitation in zksync compiler, https://docs.zksync.io/zk-stack/components/compiler/toolchain/solidity#limitations
subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(async (_, __, runSuper) => {
const paths = await runSuper();
// List the files to exclude that are not being deployed on zkSync
const filesToExclude = ["WrappedNative"];
return paths.filter(p => {
return !filesToExclude.some(file => p.includes(file));
});
});
export default config;