forked from allo-protocol/allo-contracts
-
Notifications
You must be signed in to change notification settings - Fork 3
/
era.hardhat.config.ts
168 lines (152 loc) · 3.73 KB
/
era.hardhat.config.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
168
import * as dotenv from "dotenv";
import "@matterlabs/hardhat-zksync-deploy";
import "@matterlabs/hardhat-zksync-solc";
import "@matterlabs/hardhat-zksync-upgradable";
import "@matterlabs/hardhat-zksync-verify";
import "@typechain/hardhat";
import { HardhatUserConfig, subtask } from "hardhat/config";
import { NetworkUserConfig } from "hardhat/types";
import "solidity-coverage";
const { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } = require("hardhat/builtin-tasks/task-names");
const path = require("path");
dotenv.config();
const chainIds = {
// testnet
"zksync-testnet": 280,
// mainnet
"zksync-mainnet": 324,
};
let deployPrivateKey = process.env.DEPLOYER_PRIVATE_KEY as string;
if (!deployPrivateKey) {
deployPrivateKey =
"0x0000000000000000000000000000000000000000000000000000000000000001";
}
const infuraIdKey = process.env.INFURA_ID as string;
/**
* Generates hardhat network configuration the test networks.
* @param network
* @param url (optional)
* @returns {NetworkUserConfig}
*/
function createTestnetConfig(
network: keyof typeof chainIds,
url?: string
): NetworkUserConfig {
if (!url) {
url = `https://${network}.infura.io/v3/${infuraIdKey}`;
}
return {
accounts: [deployPrivateKey],
chainId: chainIds[network],
allowUnlimitedContractSize: true,
url,
};
}
/**
* Generates hardhat network configuration the mainnet networks.
* @param network
* @param url (optional)
* @returns {NetworkUserConfig}
*/
function createMainnetConfig(
network: keyof typeof chainIds,
url?: string
): NetworkUserConfig {
if (!url) {
url = `https://${network}.infura.io/v3/${infuraIdKey}`;
}
return {
accounts: [deployPrivateKey],
chainId: chainIds[network],
url,
};
}
const abiExporter = [
{
path: "./abis/pretty",
flat: true,
clear: true,
format: "fullName",
},
{
path: "./abis/ugly",
flat: true,
clear: true,
},
];
subtask(
TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS,
async (_, { config }, runSuper) => {
const paths = await runSuper();
return paths
.filter(solidityFilePath => {
const relativePath = path.relative(config.paths.sources, solidityFilePath)
return !relativePath.includes("Safe.sol");
})
}
);
const config: HardhatUserConfig = {
solidity: {
version: "0.8.17",
settings: {
optimizer: {
enabled: true,
runs: 400,
},
},
},
networks: {
// Main Networks
"zksync-mainnet": {
...createMainnetConfig(
"zksync-mainnet",
"https://zksync2-mainnet.zksync.io"
),
zksync: true,
ethNetwork: "mainnet",
verifyURL:
"https://zksync2-mainnet-explorer.zksync.io/contract_verification",
},
// Test Networks
"zksync-testnet": {
...createTestnetConfig(
"zksync-testnet",
"https://zksync2-testnet.zksync.dev"
),
zksync: true,
ethNetwork: "goerli",
verifyURL:
"https://zksync2-testnet-explorer.zksync.dev/contract_verification",
},
},
defaultNetwork: "zksync-testnet",
gasReporter: {
enabled: process.env.REPORT_GAS !== undefined,
currency: "USD",
},
etherscan: {
apiKey: {
// @ts-ignore
mainnet: process.env.ETHERSCAN_API_KEY,
// @ts-ignore
goerli: process.env.ETHERSCAN_API_KEY,
// @ts-ignore
optimisticEthereum: process.env.OPTIMISTIC_ETHERSCAN_API_KEY,
// @ts-ignore
ftmTestnet: process.env.FTMSCAN_API_KEY,
// @ts-ignore
opera: process.env.FTMSCAN_API_KEY,
},
},
zksolc: {
version: "1.3.13",
compilerSource: "binary",
settings: {
isSystem: true,
},
},
contractsToIgnore: [
"contracts/payoutStrategy/DirectPayoutStrategy/**/*.sol"
]
};
export default config;