-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhardhat.config.js
139 lines (126 loc) · 3.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
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
/// ENVVAR
// - CI: output gas report to file instead of stdout
// - COVERAGE: enable coverage report
// - ENABLE_GAS_REPORT: enable gas report
// - COMPILE_MODE: production modes enables optimizations (default: development)
// - COMPILE_VERSION: compiler version (default: 0.8.3)
// - COINMARKETCAP: coinmarkercat api key for USD value in gas report
require('dotenv').config({ path: '../.env' });
const Web3 = require('web3');
const getStringValue = (input) => {
return input === undefined ? '' : input;
};
const getArrayValue = (input) => {
return input === undefined ? [] : String(input).split(',')
}
const Config = {
network: getStringValue(process.env.NETWORK_NAME),
networkId: getStringValue(process.env.NETWORK_ID),
proxyUrl: getStringValue(process.env.PROXY_URL),
privateKeys: getArrayValue(process.env.PRIVATE_KEYS)
};
const web3 = new Web3(
new Web3.providers.HttpProvider(Config.proxyUrl, 180000)
);
if (Config.privateKeys.length > 0){
process.env.PRIVATE_KEY = Config.privateKeys[0];
process.env.ADDRESS_FROM = web3.eth.accounts.privateKeyToAccount(Config.privateKeys[0]).address;
process.env.ADDRESS_TO = web3.eth.accounts.privateKeyToAccount(Config.privateKeys[1]).address;
} else {
process.env.PRIVATE_KEY = "";
process.env.ADDRESS_FROM = "";
process.env.ADDRESS_TO = "";
}
const fs = require('fs');
const path = require('path');
const argv = require('yargs/yargs')()
.env('')
.options({
ci: {
type: 'boolean',
default: false
},
coverage: {
type: 'boolean',
default: false
},
gas: {
alias: 'enableGasReport',
type: 'boolean',
default: false
},
mode: {
alias: 'compileMode',
type: 'string',
choices: ['production', 'development'],
default: 'development'
},
compiler: {
alias: 'compileVersion',
type: 'string',
default: '0.8.10'
},
coinmarketcap: {
alias: 'coinmarketcapApiKey',
type: 'string'
}
}).argv;
require('@nomiclabs/hardhat-truffle5');
if (argv.enableGasReport) {
require('hardhat-gas-reporter');
}
for (const f of fs.readdirSync(path.join(__dirname, 'hardhat'))) {
require(path.join(__dirname, 'hardhat', f));
}
const withOptimizations =
argv.enableGasReport || argv.compileMode === 'production';
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: {
version: argv.compiler,
settings: {
optimizer: {
enabled: withOptimizations,
runs: 200
}
}
},
defaultNetwork: 'neonlabs',
networks: {
hardhat: {
blockGasLimit: 10000000,
allowUnlimitedContractSize: !withOptimizations
},
neonlabs: {
url: Config.proxyUrl,
accounts: Config.privateKeys,
from: process.env.ADDRESS_FROM,
to: process.env.ADDRESS_TO,
network_id: parseInt(Config.networkId),
gas: "auto",
gasPrice: "auto",
allowUnlimitedContractSize: !withOptimizations,
timeout: 180000,
isFork: true
}
},
gasReporter: {
currency: 'USD',
outputFile: argv.ci ? 'gas-report.txt' : undefined,
coinmarketcap: argv.coinmarketcap
},
mocha: {
timeout: 1800000,
reporter: 'mocha-multi-reporters',
reporterOption: {
configFile: '../reporterConfig.json'
},
diff: true
}
};
if (argv.coverage) {
require('solidity-coverage');
module.exports.networks.hardhat.initialBaseFeePerGas = 0;
}