-
Notifications
You must be signed in to change notification settings - Fork 10
/
hardhat.config.ts
193 lines (175 loc) · 4.78 KB
/
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
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
import '@typechain/hardhat';
import '@nomiclabs/hardhat-ethers';
import 'hardhat-deploy';
import 'hardhat-gas-reporter';
import '@nomicfoundation/hardhat-chai-matchers';
import '@solidstate/hardhat-4byte-uploader';
import '@bahuy3103/hardhat-storage-layout';
import '@bahuy3103/hardhat-contract-sizer';
import * as dotenv from 'dotenv';
import { HardhatUserConfig, NetworkUserConfig, SolcUserConfig } from 'hardhat/types';
import './src/tasks/generate-storage-layout';
dotenv.config();
const DEFAULT_MNEMONIC = 'title spike pink garlic hamster sorry few damage silver mushroom clever window';
const {
REPORT_GAS,
DEVNET_PK,
DEVNET_URL,
TESTNET_PK,
TESTNET_URL,
MAINNET_PK,
MAINNET_URL,
GOERLI_URL,
GOERLI_PK,
ETHEREUM_URL,
ETHEREUM_PK,
} = process.env;
if (!DEVNET_PK) {
console.warn('DEVNET_PK is unset. Using DEFAULT_MNEMONIC');
}
if (!TESTNET_PK) {
console.warn('TESTNET_PK is unset. Using DEFAULT_MNEMONIC');
}
if (!MAINNET_PK) {
console.warn('MAINNET_PK is unset. Using DEFAULT_MNEMONIC');
}
if (!GOERLI_PK) {
console.warn('GOERLI_PK is unset. Using DEFAULT_MNEMONIC');
}
if (!ETHEREUM_PK) {
console.warn('ETHEREUM_PK is unset. Using DEFAULT_MNEMONIC');
}
const local: NetworkUserConfig = {
url: 'http://localhost:8545',
accounts: { mnemonic: DEFAULT_MNEMONIC },
};
const devnet: NetworkUserConfig = {
url: DEVNET_URL || 'http://localhost:8545',
accounts: DEVNET_PK ? [DEVNET_PK] : { mnemonic: DEFAULT_MNEMONIC },
companionNetworks: {
mainchain: 'goerli-for-devnet',
},
};
const testnet: NetworkUserConfig = {
chainId: 2021,
url: TESTNET_URL || 'https://saigon-testnet.roninchain.com/rpc',
accounts: TESTNET_PK ? [TESTNET_PK] : { mnemonic: DEFAULT_MNEMONIC },
blockGasLimit: 100000000,
companionNetworks: {
mainchain: 'goerli',
},
};
const mainnet: NetworkUserConfig = {
chainId: 2020,
url: MAINNET_URL || 'https://api.roninchain.com/rpc',
accounts: MAINNET_PK ? [MAINNET_PK] : { mnemonic: DEFAULT_MNEMONIC },
blockGasLimit: 100000000,
companionNetworks: {
mainchain: 'ethereum',
},
};
const goerli: NetworkUserConfig = {
chainId: 5,
url: GOERLI_URL || 'https://gateway.tenderly.co/public/goerli',
accounts: GOERLI_PK ? [GOERLI_PK] : { mnemonic: DEFAULT_MNEMONIC },
blockGasLimit: 100000000,
};
const ethereum: NetworkUserConfig = {
chainId: 1,
url: ETHEREUM_URL || 'https://gateway.tenderly.co/public/mainnet',
accounts: ETHEREUM_PK ? [ETHEREUM_PK] : { mnemonic: DEFAULT_MNEMONIC },
blockGasLimit: 100000000,
};
const compilerConfig: SolcUserConfig = {
version: '0.8.17',
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
};
const config: HardhatUserConfig = {
solidity: {
compilers: [compilerConfig],
overrides: {
'contracts/ronin/validator/RoninValidatorSet.sol': {
version: '0.8.17',
settings: {
optimizer: {
enabled: true,
runs: 10,
},
/// @dev see: https://github.com/Uniswap/v3-core/blob/main/hardhat.config.ts
metadata: {
// do not include the metadata hash, since this is machine dependent
// and we want all generated code to be deterministic
// https://docs.soliditylang.org/en/v0.8.17/metadata.html
bytecodeHash: 'none',
},
},
},
'contracts/ronin/gateway/RoninBridgeManager.sol': {
version: '0.8.17',
settings: {
optimizer: {
enabled: true,
runs: 10,
},
metadata: {
useLiteralContent: true,
},
},
},
},
},
typechain: {
outDir: 'src/types',
},
paths: {
deploy: ['src/deploy', 'src/upgrades', 'src/dashboard'],
tests: 'test/hardhat_test',
},
namedAccounts: {
deployer: 0,
governor: 0,
// governor: '0x00000000000000000000000000000000deadbeef',
// governor: 'privatekey://0x00000000000000000000000000000000deadbeef000000000000000000sample',
// governor: 'trezor://0x0000000000000000000000000000000000000000',
},
networks: {
hardhat: {
hardfork: 'istanbul',
accounts: {
mnemonic: DEFAULT_MNEMONIC,
count: 150,
accountsBalance: '1000000000000000000000000000', // 1B RON
},
allowUnlimitedContractSize: true,
},
local,
'ronin-devnet': devnet,
'ronin-testnet': testnet,
'ronin-mainnet': mainnet,
goerli,
'goerli-for-devnet': goerli,
ethereum,
},
gasReporter: {
enabled: REPORT_GAS ? true : false,
showTimeSpent: true,
},
// etherscan: {
// apiKey: process.env.ETHERSCAN_API_KEY,
// },
mocha: {
timeout: 100000, // 100s
},
contractSizer: {
alphaSort: true,
disambiguatePaths: false,
runOnCompile: true,
outputFile: './logs/contract_code_sizes.log',
},
};
export default config;