-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathhardhat.config.js
366 lines (352 loc) · 12.2 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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
const { task } = require("hardhat/config");
const { extendEnvironment } = require("hardhat/config");
require("@nomiclabs/hardhat-ganache");
require("@nomiclabs/hardhat-truffle5");
require("@nomiclabs/hardhat-ethers");
require("hardhat-deploy-ethers");
require("@nomiclabs/hardhat-web3");
require("hardhat-contract-sizer"); //yarn run hardhat size-contracts
require("solidity-coverage"); // $ npx hardhat coverage
require("hardhat-log-remover");
require("hardhat-abi-exporter");
require("hardhat-deploy");
require("@nomicfoundation/hardhat-chai-matchers");
require("@nomicfoundation/hardhat-foundry");
require("./hardhat/tasks");
require("dotenv").config();
require("@secrez/cryptoenv").parse();
const mnemonic = { mnemonic: "test test test test test test test test test test test junk" };
const testnetPKs = [
process.env.TESTNET_DEPLOYER_PRIVATE_KEY ?? "",
process.env.TESTNET_SIGNER_PRIVATE_KEY ?? "",
process.env.TESTNET_SIGNER_PRIVATE_KEY_2 ?? "",
].filter((item, i, arr) => item !== "" && arr.indexOf(item) === i);
const testnetAccounts = testnetPKs.length > 0 ? testnetPKs : mnemonic;
const mainnetPKs = [
process.env.MAINNET_DEPLOYER_PRIVATE_KEY ?? "",
process.env.PROPOSAL_CREATOR_PRIVATE_KEY ?? "",
process.env.TESTNET_DEPLOYER_PRIVATE_KEY ?? "", //mainnet signer2
].filter((item, i, arr) => item !== "" && arr.indexOf(item) === i);
const mainnetAccounts = mainnetPKs.length > 0 ? mainnetPKs : mnemonic;
/*
* Test hardhat forking with patched hardhat
*
* If you get this error:
* InvalidResponseError: Invalid JSON-RPC response's result.
* Errors: Invalid value null supplied to : RpcBlockWithTransactions | null/transactions: RpcTransaction Array/2:
* RpcTransaction/v: QUANTITY, Invalid value null supplied to : RpcBlockWithTransactions | null/transactions:
* RpcTransaction Array/2: RpcTransaction/r: QUANTITY, Invalid value null supplied to :
* RpcBlockWithTransactions | null/transactions: RpcTransaction Array/2: RpcTransaction/s: QUANTITY
*
* Then the forking doesn't work correctly (ie. hardhat was not properly patched)
*/
task("check-fork-patch", "Check Hardhat Fork Patch by Rainer").setAction(async (taskArgs, hre) => {
await hre.network.provider.request({
method: "hardhat_reset",
params: [
{
forking: {
jsonRpcUrl: "https://mainnet-dev.sovryn.app/rpc",
blockNumber: 4272658,
},
},
],
});
//const xusd = await IERC20.at("0xb5999795BE0EbB5bAb23144AA5FD6A02D080299F");
const xusd = await hre.ethers.getContractAt(
"ERC20",
"0xb5999795BE0EbB5bAb23144AA5FD6A02D080299F"
);
const totalSupply = await xusd.totalSupply();
if (totalSupply.toString() === "12346114443582774719512874")
console.log("Hardhat mainnet forking works properly!");
else console.log("Hardhat mainnet forking does NOT work properly!");
});
/*task("accounts", "Prints accounts", async (_, { web3 }) => {
console.log();
console.log(await web3.eth.getAccounts());
});*/
// You need to export an object to set up your config
// Go to https://hardhat.org/config/ to learn more
/**
* @type import('hardhat/config').HardhatUserConfig
*/
/**/
module.exports = {
solidity: {
compilers: [
{
version: "0.5.17",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
outputSelection: {
"*": {
"*": ["storageLayout"],
},
},
},
},
{
version: "0.8.13",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
outputSelection: {
"*": {
"*": ["storageLayout"],
},
},
},
},
{
version: "0.8.17",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
outputSelection: {
"*": {
"*": ["storageLayout"],
},
},
},
},
],
},
abiExporter: {
clear: true,
runOnCompile: true,
flat: false,
spacing: 4,
},
contractSizer: {
alphaSort: false,
runOnCompile: false,
disambiguatePaths: false,
},
namedAccounts: {
deployer: {
default: 0,
},
signer: {
default: 1,
rskSovrynMainnet: 0,
},
signer2: {
default: 2,
},
voter: {
default: 1,
rskForkedMainnet: 0,
rskMainnet: 0,
},
proposer2: {
default: 1,
},
},
networks: {
hardhat: {
chainId: 31337,
allowUnlimitedContractSize: true,
accounts: { mnemonic: "test test test test test test test test test test test junk" },
initialBaseFeePerGas: 0,
saveDeployments: false,
//blockGasLimit: 6800000,
//gasPrice: 66000010,
//timeout: 1000000,
},
localhost: {
timeout: 100000,
},
rskForkedTestnet: {
chainId: 31337,
url: "http://127.0.0.1:8545/",
gasPrice: 66000010,
blockGasLimit: 6800000,
accounts: testnetAccounts,
live: true,
tags: ["testnet", "forked"],
timeout: 100000,
},
rskForkedTestnetFlashback: {
chainId: 31337,
accounts: testnetAccounts,
url: "http://127.0.0.1:8545/",
gasPrice: 66000010,
blockGasLimit: 6800000,
live: true,
tags: ["testnet", "forked"],
timeout: 100000,
},
rskForkedMainnetFlashback: {
chainId: 31337,
accounts: mainnetAccounts,
url: "http://127.0.0.1:8545",
blockGasLimit: 6800000,
live: true,
tags: ["mainnet", "forked"],
timeout: 100000,
},
rskForkedMainnet: {
chainId: 31337,
accounts: mainnetAccounts,
url: "http://127.0.0.1:8545",
blockGasLimit: 6800000,
gasPrice: 66000010,
live: true,
tags: ["mainnet", "forked"],
timeout: 1000000,
},
/*localhost: {
url: "http://127.0.0.1:8545/",
allowUnlimitedContractSize: true,
initialBaseFeePerGas: 0,
},*/
rskTestnet: {
url: "https://public-node.testnet.rsk.co/",
accounts: testnetAccounts,
chainId: 31,
confirmations: 4,
gasMultiplier: 1.25,
tags: ["testnet"],
//timeout: 20000, // increase if needed; 20000 is the default value
//allowUnlimitedContractSize, //EIP170 contrtact size restriction temporal testnet workaround
},
rskMainnet: {
url: "https://public-node.rsk.co/",
chainId: 30,
accounts: mainnetAccounts,
tags: ["mainnet"],
//timeout: 20000, // increase if needed; 20000 is the default value
timeout: 100000,
},
rskSovrynTestnet: {
chainId: 31,
url: "https://testnet.sovryn.app/rpc",
accounts: testnetAccounts,
gasPrice: 66000010,
blockGasLimit: 6800000,
confirmations: 4,
gasMultiplier: 1.25,
tags: ["testnet"],
//timeout: 20000, // increase if needed; 20000 is the default value
//allowUnlimitedContractSize, //EIP170 contrtact size restriction temporal testnet workaround
},
rskSovrynMainnet: {
chainId: 30,
url: "https://mainnet-dev.sovryn.app/rpc",
accounts: mainnetAccounts,
gasPrice: 66000010,
blockGasLimit: 6800000,
tags: ["mainnet"],
timeout: 100000,
//timeout: 20000, // increase if needed; 20000 is the default value
},
ethMainnet: {
chainId: 1,
url: `https://mainnet.infura.io/v3/${process.env.INFURA_KEY}`,
accounts: mainnetAccounts,
},
bobTestnet: {
url: "https://bob-sepolia.rpc.gobob.xyz/",
chainId: 808813,
accounts: testnetAccounts,
//gasPrice: 50000000,
tags: ["testnet"],
},
bobMainnet: {
url: "https://rpc.gobob.xyz/",
chainId: 60808,
accounts: testnetAccounts,
//gasPrice: 50000000,
tags: ["mainnet"],
},
bobForkedTestnet: {
chainId: 31337,
accounts: mainnetAccounts,
url: "http://127.0.0.1:8545",
blockGasLimit: 6800000,
gasPrice: 50000000,
live: true,
tags: ["mainnet", "forked"],
timeout: 1000000,
},
bobForkedTestnet: {
chainId: 31337,
accounts: testnetAccounts,
url: "http://127.0.0.1:8545",
gasPrice: 50000000,
live: true,
tags: ["testnet", "forked"],
timeout: 100000,
},
},
paths: {
sources: "./contracts",
tests: "./tests",
deploy: "./deployment/deploy",
deployments: "./deployment/deployments",
},
external: {
contracts: [
{
artifacts: "external/artifacts",
// deploy: "node_modules/@cartesi/arbitration/export/deploy",
},
//{
//artifacts: "node_modules/someotherpackage/artifacts",
//},
],
deployments: {
rskSovrynTestnet: ["external/deployments/rskTestnet"],
rskTestnet: [
"external/deployments/rskTestnet",
"deployment/deployments/rskSovrynTestnet",
],
rskForkedTestnet: [
"external/deployments/rskTestnet",
"external/deployments/rskForkedTestnet",
"deployment/deployments/rskSovrynTestnet",
],
rskForkedTestnetFlashback: ["external/deployments/rskForkedTestnetFlashback"],
rskForkedMainnetFlashback: ["external/deployments/rskForkedMainnetFlashback"],
rskSovrynMainnet: ["external/deployments/rskMainnet"],
rskMainnet: [
"external/deployments/rskMainnet",
"deployment/deployments/rskSovrynMainnet",
],
rskForkedMainnet: [
"external/deployments/rskMainnet",
"deployment/deployments/rskSovrynMainnet",
"external/deployments/rskForkedMainnet",
],
bobTestnet: ["external/deployments/bobTestnet"],
bobForkedTestnet: [
"external/deployments/bobTestnet",
"deployment/deployments/bobTestnet",
],
bobMainnet: ["external/deployments/bobMainnet"],
bobForkedMainnet: [
"external/deployments/bobMainnet",
"deployment/deployments/bobMainnet",
],
ethMainnet: ["external/deployments/ethMainnet", "deployment/deployments/ethMainnet"],
},
},
typechain: {
outDir: "types",
target: "ethers-v5",
alwaysGenerateOverloads: false, // should overloads with full signatures like deposit(uint256) be generated always, even if there are no overloads?
externalArtifacts: ["external/artifacts"], // optional array of glob patterns with external artifacts to process (for example external libs from node_modules)
// externalArtifacts: ["external/artifacts/*.json"], // optional array of glob patterns with external artifacts to process (for example external libs from node_modules)
},
mocha: {
timeout: 800000,
},
};