-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathhardhat.config.js
67 lines (58 loc) · 1.41 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
require('dotenv').config();
require("@nomiclabs/hardhat-ethers");
const providersRaw = process.env.WEB3_PROVIDER_URLS_BY_CHAINID;
if (!providersRaw) {
throw new Error('supply "WEB3_PROVIDER_URLS_BY_CHAINID" as a stringified JSON object');
}
let providers;
try {
providers = JSON.parse(providersRaw);
} catch (e) {
throw new Error(`Cannot parse "WEB3_PROVIDER_URLS_BY_CHAINID": ${e.message}`);
}
if (!(typeof providers === 'object' && !Array.isArray(providers))) {
throw new Error('"WEB3_PROVIDER_URLS_BY_CHAINID" must be formatted as {chainId: url, ...}');
}
if (Object.keys(providers).length === 0) {
throw new Error('No providers found in "WEB3_PROVIDER_URLS_BY_CHAINID"');
}
if (typeof providers[1] !== 'string') {
throw new Error('No provider found for mainnet (chainId = 1) in "WEB3_PROVIDER_URLS_BY_CHAINID"');
}
const directNetworks = Object.entries(providers)
.map(([chainId, url]) => [
chainId,
{
url,
}
]).reduce(
(result, [key, value]) => Object.assign({}, result, {[key]: value}),
{}
);
const networks = {
...directNetworks,
hardhat: {
forking: {
url: providers[1],
},
},
};
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: {
version: "0.8.4",
settings: {
optimizer: {
enabled: true,
runs: 200,
}
}
},
networks,
mocha: {
timeout: 99999,
parallel: true,
}
};