forked from AbdelStark/token-vesting-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.config.js
119 lines (109 loc) · 2.69 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
require("@nomiclabs/hardhat-waffle");
require("@nomiclabs/hardhat-solhint");
require("@nomiclabs/hardhat-etherscan");
require("hardhat-abi-exporter");
require("hardhat-docgen");
require("hardhat-tracer");
require("hardhat-gas-reporter");
require("solidity-coverage");
require("hardhat-preprocessor");
const fs = require("fs");
const etherscanApiKey = getEtherscanApiKey();
function getRemappings() {
return fs
.readFileSync("remappings.txt", "utf8")
.split("\n")
.filter(Boolean)
.map((line) => line.trim().split("="));
}
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
solidity: {
version: "0.8.19",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
paths: {
sources: "./src", // Use ./src rather than ./contracts as Hardhat expects
cache: "./cache_hardhat", // Use a different cache for Hardhat than Foundry
},
// This fully resolves paths for imports in the ./lib directory for Hardhat
preprocess: {
eachLine: (hre) => ({
transform: (line) => {
if (line.match(/^\s*import /i)) {
getRemappings().forEach(([find, replace]) => {
if (line.match(find)) {
line = line.replace(find, replace);
}
});
}
return line;
},
}),
},
networks: {
mainnet: mainnetNetworkConfig(),
goerli: goerliNetworkConfig(),
},
abiExporter: {
path: "./build/abi",
clear: true,
flat: true,
spacing: 2,
},
docgen: {
path: "./docs",
clear: true,
runOnCompile: true,
},
gasReporter: {
currency: "USD",
},
etherscan: {
apiKey: `${etherscanApiKey}`,
},
};
function mainnetNetworkConfig() {
let url = "https://mainnet.infura.io/v3/";
let accountPrivateKey =
"0x0000000000000000000000000000000000000000000000000000000000000000";
if (process.env.MAINNET_ENDPOINT) {
url = `${process.env.MAINNET_ENDPOINT}`;
}
if (process.env.MAINNET_PRIVATE_KEY) {
accountPrivateKey = `${process.env.MAINNET_PRIVATE_KEY}`;
}
return {
url: url,
accounts: [accountPrivateKey],
};
}
function goerliNetworkConfig() {
let url = "https://goerli.infura.io/v3/";
let accountPrivateKey =
"0x0000000000000000000000000000000000000000000000000000000000000000";
if (process.env.GOERLI_ENDPOINT) {
url = `${process.env.GOERLI_ENDPOINT}`;
}
if (process.env.GOERLI_PRIVATE_KEY) {
accountPrivateKey = `${process.env.GOERLI_PRIVATE_KEY}`;
}
return {
url: url,
accounts: [accountPrivateKey],
};
}
function getEtherscanApiKey() {
let apiKey = "";
if (process.env.ETHERSCAN_API_KEY) {
apiKey = `${process.env.ETHERSCAN_API_KEY}`;
}
return apiKey;
}