-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhardhat.config.ts
More file actions
121 lines (110 loc) · 2.86 KB
/
hardhat.config.ts
File metadata and controls
121 lines (110 loc) · 2.86 KB
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
import '@nomiclabs/hardhat-etherscan';
import '@nomiclabs/hardhat-waffle';
import '@typechain/hardhat';
import * as dotenv from 'dotenv';
import 'hardhat-abi-exporter';
import 'hardhat-contract-sizer';
import 'hardhat-gas-reporter';
import 'hardhat-storage-layout';
import { HardhatUserConfig } from 'hardhat/config';
import 'solidity-coverage';
import {
FORK_URLS,
NETWORKS_DEFAULT_GAS,
NETWORKS_RPC_URL,
} from './helpers/hardhat';
import {
EChainID,
EEthereumNetwork,
ENetwork,
EPolygonNetwork,
} from './helpers/typings';
import './scripts/accounts';
dotenv.config({ path: '.env' });
const COVERAGE_CHAINID = 1337;
const BUIDLEREVM_CHAINID = 31337;
const HARDFORK = 'arrowGlacier';
const MNEMONIC_PATH = "m/44'/60'/0'/0";
const MNEMONIC = process.env.MNEMONIC || '';
const DEFAULT_BLOCK_GAS_LIMIT = 7_000_000;
const DEFAULT_GAS_MUL = 2;
const FORK_NETWORK = process.env.FORK;
const getCommonNetworkConfig = (
networkName: ENetwork,
networkId: EChainID,
) => ({
url: NETWORKS_RPC_URL[networkName] ?? '',
hardfork: HARDFORK,
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
gas: DEFAULT_BLOCK_GAS_LIMIT,
gasMultiplier: DEFAULT_GAS_MUL,
gasPrice: NETWORKS_DEFAULT_GAS[networkName],
chainId: networkId,
accounts: {
mnemonic: MNEMONIC,
path: MNEMONIC_PATH,
initialIndex: 0,
count: 20,
},
});
const getForkConfig = (name: ENetwork) => ({
url: FORK_URLS[name] ?? '',
accounts: {
mnemonic: MNEMONIC,
path: MNEMONIC_PATH,
},
});
const mainnetFork = () => {
if (!FORK_NETWORK) {
return undefined;
}
const url =
FORK_URLS[FORK_NETWORK as ENetwork] ||
NETWORKS_RPC_URL[FORK_NETWORK as ENetwork];
if (!url) {
throw new Error(`Unknown network to fork: ${FORK_NETWORK}`);
}
return { url };
};
const config: HardhatUserConfig = {
solidity: '0.8.15',
typechain: {
outDir: './types',
target: 'ethers-v5',
},
networks: {
hardhat: {
hardfork: HARDFORK,
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
gas: DEFAULT_BLOCK_GAS_LIMIT,
chainId: BUIDLEREVM_CHAINID,
gasPrice: 8_000_000_000,
throwOnTransactionFailures: true,
throwOnCallFailures: true,
forking: mainnetFork(),
},
coverage: {
url: 'http://localhost:8555',
chainId: COVERAGE_CHAINID,
},
goerli: getCommonNetworkConfig(EEthereumNetwork.GOERLI, EChainID.GOERLI),
matic: getCommonNetworkConfig(EPolygonNetwork.MATIC, EChainID.MATIC),
mumbai: getCommonNetworkConfig(EPolygonNetwork.MUMBAI, EChainID.MUMBAI),
matic_fork: getForkConfig(EPolygonNetwork.MATIC),
mumbai_fork: getForkConfig(EPolygonNetwork.MUMBAI),
},
abiExporter: {
path: './abi',
clear: true,
flat: true,
spacing: 2,
},
gasReporter: {
enabled: process.env.REPORT_GAS !== undefined,
currency: 'USD',
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
},
};
export default config;