generated from zerosnacks/solidity-template
-
Notifications
You must be signed in to change notification settings - Fork 3
/
hardhat.config.ts
128 lines (120 loc) · 2.67 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
// Vendor
import Joi from "joi";
import "@nomiclabs/hardhat-waffle";
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-etherscan";
import "hardhat-gas-reporter";
import "solidity-coverage";
import "hardhat-contract-sizer";
import { HardhatUserConfig, subtask } from "hardhat/config";
import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from "hardhat/builtin-tasks/task-names";
// Utilities
import { validateEnvConfig } from "./scripts/utilities/validateConfig";
// Validate values from .env file
const {
FORKING,
FORK_BLOCK,
PRIVATE_KEY,
ETH_RPC_URL,
ARBITRUM_RPC_URL,
CMC_API_KEY,
ETHERSCAN_API_KEY,
} = validateEnvConfig(
".env",
Joi.object({
PRIVATE_KEY: Joi.string().default("1".repeat(64)),
FORK_BLOCK: Joi.number(),
FORKING: Joi.boolean(),
ETH_RPC_URL: Joi.string().default(""),
ARBITRUM_RPC_URL: Joi.string().default(""),
CMC_API_KEY: Joi.string(),
ETHERSCAN_API_KEY: Joi.string(),
})
);
// Filter out .t.sol test files and regular Solidity files in the test directory
subtask(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS).setAction(
async (_, __, runSuper) => {
const paths = await runSuper();
return paths.filter(
(p: string) => !p.endsWith(".t.sol") && !p.includes("test")
);
}
);
// Accounts
const accounts = [PRIVATE_KEY];
// Network settings
const settings = {
optimizer: {
enabled: true,
runs: 200,
},
};
const config: HardhatUserConfig & {
contractSizer: {
alphaSort: boolean;
disambiguatePaths: boolean;
runOnCompile: boolean;
};
etherscan: {
apiKey: string;
};
} = {
paths: {
cache: "hh-cache",
sources: "./src",
tests: "./test",
},
contractSizer: {
alphaSort: false,
disambiguatePaths: false,
runOnCompile: true,
},
defaultNetwork: "hardhat",
networks: {
hardhat: {
allowUnlimitedContractSize: false,
chainId: 1337,
forking: {
blockNumber: Number(FORK_BLOCK),
enabled: FORKING === true,
url: ETH_RPC_URL,
},
},
mainnet: {
url: ETH_RPC_URL,
accounts,
},
arbitrum: {
url: ARBITRUM_RPC_URL,
accounts,
},
},
solidity: {
compilers: [
{
version: "0.5.17",
settings,
},
{
version: "0.6.12",
settings,
},
{
version: "0.8.10",
settings,
},
],
},
gasReporter: {
currency: "USD",
gasPrice: 77,
excludeContracts: ["src/test"],
// API key for CoinMarketCap: https://pro.coinmarketcap.com/signup
coinmarketcap: CMC_API_KEY,
},
etherscan: {
// API key for Etherscan: https://etherscan.io/
apiKey: ETHERSCAN_API_KEY,
},
};
export default config;