-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.js
162 lines (150 loc) · 5.24 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
160
161
162
const { task, extendEnvironment } = require("hardhat/config");
const { gray, yellow } = require("chalk");
require("@nomiclabs/hardhat-ethers");
require("@openzeppelin/hardhat-upgrades");
require("@nomiclabs/hardhat-truffle5");
require("solidity-coverage");
require("hardhat-gas-reporter");
require("hardhat-contract-sizer");
require("hardhat-abi-exporter");
require("@nomiclabs/hardhat-etherscan");
require("@nomicfoundation/hardhat-chai-matchers");
require("dotenv").config();
const BLOCK_NUMBER = 12514;
const OPTIMIZER_RUNS = 5000000;
const log = (...text) => console.log(gray(...["└─> [DEBUG]"].concat(text)));
extendEnvironment((hre) => {
hre.log = log;
});
function optimizeIfRequired({ hre, taskArguments: { optimizer } }) {
if (optimizer || hre.optimizer) {
// only show message once if re-run
if (hre.optimizer === undefined) {
log(gray("Adding optimizer, runs", yellow(OPTIMIZER_RUNS.toString())));
}
// Use optimizer (slower) but simulates real contract size limits and gas usage
hre.config.solidity.compilers[0].settings.optimizer = {
enabled: true,
runs: OPTIMIZER_RUNS,
};
hre.config.networks.hardhat.allowUnlimitedContractSize = false;
} else {
if (hre.optimizer === undefined) {
log(gray("Optimizer disabled. Unlimited contract sizes allowed."));
}
hre.config.solidity.compilers[0].settings.optimizer = { enabled: false };
hre.config.networks.hardhat.allowUnlimitedContractSize = true;
}
// flag here so that if invoked via "hardhat test" the argument will persist to the compile stage
hre.optimizer = !!optimizer;
}
task("compile")
.addFlag("optimizer", "Compile with the optimizer")
.setAction(async (taskArguments, hre, runSuper) => {
optimizeIfRequired({ hre, taskArguments });
await runSuper(taskArguments);
});
task("coverage").setAction(async (taskArguments, hre, runSuper) => {
log(gray("Mainnet fork with block number", yellow(BLOCK_NUMBER.toString())));
await runSuper(taskArguments);
});
task("verify")
.addFlag("optimizer", "Compile with the optimizer")
.setAction(async (taskArguments, hre, runSuper) => {
optimizeIfRequired({ hre, taskArguments });
await runSuper(taskArguments);
});
module.exports = {
solidity: {
version: "0.8.20",
},
etherscan: {
apiKey: "no-api-key-needed",
customChains: [
{
network: "luksoTestnet",
chainId: 4201,
urls: {
apiURL: "https://api.explorer.execution.testnet.lukso.network/api",
browserURL: "https://explorer.execution.testnet.lukso.network/",
},
},
{
network: "luksoMainnet",
chainId: 42,
urls: {
apiURL: "https://api.explorer.execution.mainnet.lukso.network/api",
browserURL: "https://explorer.execution.mainnet.lukso.network/",
},
},
],
},
networks: {
hardhat: {
accounts: {
accountsBalance: "1000000000000000000000000",
},
},
local: {
url: "http://127.0.0.1:8545/",
},
luksoTestnet: {
url: `https://rpc.testnet.lukso.network`, // Replace this with the RPC URL for your custom network
chainId: 4201, // The chain ID of the custom network (replace with the correct value)
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : undefined,
// You can also set other network-specific configurations, such as gas and block gas limit
},
luksoMainnet: {
url: `https://rpc.mainnet.lukso.network`, // Replace this with the RPC URL for your custom network
chainId: 42, // The chain ID of the custom network (replace with the correct value)
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : undefined,
// You can also set other network-specific configurations, such as gas and block gas limit
},
luksoDevnet: {
url: `https://rpc.devnet.lukso.dev/`, // Replace this with the RPC URL for your custom network
chainId: 7420, // The chain ID of the custom network (replace with the correct value)
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : undefined,
// You can also set other network-specific configurations, such as gas and block gas limit
},
sepolia: {
url: "https://rpc2.sepolia.org/ ", // Replace this with the RPC URL for your custom network
chainId: 11155111, // The chain ID of the custom network (replace with the correct value)
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : undefined,
// You can also set other network-specific configurations, such as gas and block gas limit
},
},
throwOnTransactionFailures: true,
gasReporter: {
enabled: false,
showTimeSpent: true,
currency: "USD",
maxMethodDiff: 25, // CI will fail if gas usage is > than this %
gasPrice: 75,
excludeContracts: ["mocks/"],
},
abiExporter: {
path: "./abi",
only: [
"AccessControl",
"Oracles",
"IDepositContract",
"Pool",
"PoolEscrow",
"PoolValidators",
"Rewards",
"StakedLyxToken",
"StakeWiseToken",
"VestingEscrow",
"VestingEscrowFactory",
"MerkleDrop",
"MerkleDistributor",
"ContractChecker",
"Roles",
],
clear: true,
flat: true,
},
mocha: {
timeout: 1000000,
},
};