-
Notifications
You must be signed in to change notification settings - Fork 14
/
hardhat.config.ts
250 lines (244 loc) · 8.81 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
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
import '@nomicfoundation/hardhat-toolbox';
import '@nomiclabs/hardhat-truffle5';
import * as fs from 'fs';
import 'hardhat-dependency-compiler';
import 'hardhat-deploy';
import { HardhatUserConfig, task } from 'hardhat/config';
import {
HARDHAT_NETWORK_MNEMONIC,
defaultHardhatNetworkParams,
defaultLocalhostNetworkParams,
} from 'hardhat/internal/core/config/default-config';
import 'solidity-docgen';
import chainConfig from './config/config.json';
const isNativeChainType = chainConfig.chains.default.asset == 'Native';
const isLocalFork = process.env.LOCAL_FORK == 'true';
const bellecourBlockscoutUrl =
process.env.BLOCKSCOUT_VERSION == 'v5'
? 'https://blockscout.bellecour.iex.ec'
: 'https://blockscout-v6.bellecour.iex.ec'; // Use Blockscout v6 by default
const settings = {
optimizer: {
enabled: true,
runs: 200,
},
outputSelection: { '*': { '*': ['storageLayout'] } },
};
const v8Settings = {
...settings,
/**
* Enable Intermediate Representation (IR) to reduce `Stack too deep` occurrences
* at compile time (e.g.: too many local variables in `matchOrdersBoost`).
* https://hardhat.org/hardhat-runner/docs/reference/solidity-support#support-for-ir-based-codegen
*/
viaIR: true,
optimizer: {
...settings.optimizer,
details: {
yul: true,
yulDetails: {
optimizerSteps: 'u',
},
},
},
/**
* @dev The 0.8.20 compiler switches the default target EVM version to Shanghai.
* At this time, the iExec Bellecour blockchain does not support new OPCODES
* brought by the Shanghai fork, hence the target must be lowered.
*/
evmVersion: 'berlin',
};
/**
* @dev Native mode. As close as possible to the iExec Bellecour blockchain.
* @note Any fresh version of Hardhat uses for its default
* hardhat network a configuration from a recent Ethereum
* fork. EIPs brought by such recent fork are not necessarily
* supported by the iExec Bellecour blockchain.
*/
const bellecourNetworkConfig = {
hardfork: 'berlin', // No EIP-1559 before London fork
gasPrice: 0,
blockGasLimit: 6_700_000,
};
const config: HardhatUserConfig = {
solidity: {
compilers: [
{ version: '0.8.21', settings: v8Settings }, // PoCo Boost (and ENS contracts >=0.8.4)
{ version: '0.6.12', settings }, // PoCo contracts
{ version: '0.4.11', settings }, // RLC contracts
],
},
networks: {
hardhat: {
accounts: {
mnemonic: process.env.MNEMONIC || HARDHAT_NETWORK_MNEMONIC,
},
...((isNativeChainType || isLocalFork) && bellecourNetworkConfig),
...(isLocalFork && {
forking: {
url: 'https://bellecour.iex.ec',
},
chainId: 134,
}),
},
'external-hardhat': {
...defaultHardhatNetworkParams,
...defaultLocalhostNetworkParams,
accounts: {
mnemonic: process.env.MNEMONIC || HARDHAT_NETWORK_MNEMONIC,
},
...((isNativeChainType || isLocalFork) && bellecourNetworkConfig),
...(isLocalFork && {
accounts: 'remote', // Override defaults accounts for impersonation
chainId: 134,
}),
},
'dev-native': {
chainId: 65535,
url: process.env.DEV_NODE || 'http://localhost:8545',
accounts: {
mnemonic: process.env.MNEMONIC || '',
},
gasPrice: 0, // Get closer to Bellecour network
},
'dev-token': {
chainId: 65535,
url: process.env.DEV_NODE || 'http://localhost:8545',
accounts: {
mnemonic: process.env.MNEMONIC || '',
},
// When deploying on a blockchain with EIP-1559 enabled and
// force-sealing disabled, deployment gets stuck if gasPrice is
// not manually set. Other approaches might be considered here.
gasPrice: 8_000_000_000, // 8 Gwei
},
// live networks
mainnet: {
chainId: 1,
url: process.env.MAINNET_NODE || '',
accounts: {
mnemonic: process.env.PROD_MNEMONIC || '',
},
},
goerli: {
chainId: 5,
url: process.env.GOERLI_NODE || '',
accounts: {
mnemonic: process.env.MNEMONIC || '',
},
},
viviani: {
chainId: 133,
url: 'https://viviani.iex.ec',
accounts: {
mnemonic: process.env.MNEMONIC || '',
},
gasPrice: 0,
gas: 6700000,
},
bellecour: {
chainId: 134,
url: 'https://bellecour.iex.ec',
accounts: [
process.env.PROD_PRIVATE_KEY ||
'0x0000000000000000000000000000000000000000000000000000000000000000',
],
hardfork: 'berlin', // No EIP-1559 before London fork
gasPrice: 0,
gas: 6700000,
verify: {
etherscan: {
apiUrl: bellecourBlockscoutUrl,
apiKey: '<>',
},
},
},
},
etherscan: {
apiKey: {
mainnet: process.env.ETHERSCAN_API_KEY || '',
viviani: 'nothing', // a non-empty string is needed by the plugin.
bellecour: 'nothing', // a non-empty string is needed by the plugin.
},
customChains: [
{
network: 'viviani',
chainId: 133,
urls: {
apiURL: 'https://blockscout.viviani.iex.ec/api',
browserURL: 'https://blockscout.viviani.iex.ec/',
},
},
{
network: 'bellecour',
chainId: 134,
urls: {
apiURL: `${bellecourBlockscoutUrl}/api`,
browserURL: bellecourBlockscoutUrl,
},
},
],
},
typechain: {
outDir: 'typechain',
},
dependencyCompiler: {
paths: [
'rlc-faucet-contract/contracts/RLC.sol',
'@iexec/solidity/contracts/ERC1538/ERC1538Modules/ERC1538Update.sol',
'@iexec/solidity/contracts/ERC1538/ERC1538Modules/ERC1538Query.sol',
'@iexec/solidity/contracts/ERC1538/ERC1538Proxy/ERC1538Proxy.sol',
// ENS
'@ensdomains/ens-contracts/contracts/registry/ENSRegistry.sol',
'@ensdomains/ens-contracts/contracts/registry/FIFSRegistrar.sol',
'@ensdomains/ens-contracts/contracts/registry/ReverseRegistrar.sol',
'@ensdomains/ens-contracts/contracts/resolvers/PublicResolver.sol',
// Used as mock or fake in UTs
'@openzeppelin/contracts-v5/interfaces/IERC1271.sol',
// Used in deployment
'@amxx/factory/contracts/v6/GenericFactory.sol',
],
keep: true, // Slither requires compiled dependencies
},
docgen: {
outputDir: 'docs/solidity',
templates: 'docs/solidity/templates',
exclude: [
'external',
'modules/delegates/IexecAccessorsABILegacyDelegate.sol', // not relevant
'modules/delegates/IexecEscrowTokenSwapDelegate.sol', // not relevant
'modules/delegates/SignatureVerifier.sol', // contains only internal/private
'modules/delegates/SignatureVerifier.v8.sol',
'modules/interfaces', // interesting for events but too much doc duplication if enabled
'registries', // ignore them for now
'tools',
'IexecInterfaceNativeABILegacy.sol', // ignore interfaces
'IexecInterfaceTokenABILegacy.sol',
'IexecInterfaceNative.sol',
'IexecInterfaceToken.sol',
'Store.sol', // almost empty
'Store.v8.sol',
],
},
mocha: { timeout: 50000 },
};
/**
* Ignore doc generation of contracts compiled with [email protected] (unsupported by docgen).
*/
task('docgen').setAction(async (taskArgs, hre, runSuper) => {
const ignoredSuffix = '.docgen-ignored';
const ignoredPaths: string[] = [];
for (const path of await hre.artifacts.getBuildInfoPaths()) {
const solcVersion: string = JSON.parse(fs.readFileSync(path, 'utf8')).solcVersion;
if (solcVersion.startsWith('0.4')) {
fs.renameSync(path, path + ignoredSuffix); // mark as docgen ignored
ignoredPaths.push(path);
}
}
await runSuper(taskArgs).finally(() => {
for (const path of ignoredPaths) {
fs.renameSync(path + ignoredSuffix, path); // restore build info as before
}
});
});
export default config;