-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathhardhat.config.ts
169 lines (159 loc) · 4.14 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
import "module-alias/register";
import "@nomicfoundation/hardhat-chai-matchers";
import "@nomicfoundation/hardhat-toolbox";
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-etherscan";
import "@openzeppelin/hardhat-upgrades";
import "@typechain/hardhat";
import { ethers } from "ethers";
import fs from "fs";
import "hardhat-deploy";
import { HardhatUserConfig, task } from "hardhat/config";
import "solidity-coverage";
import "solidity-docgen";
require("hardhat-contract-sizer");
require("dotenv").config();
const BSCSCAN_API_KEY = process.env.BSCSCAN_API_KEY;
const DEPLOYER_PRIVATE_KEY = process.env.DEPLOYER_PRIVATE_KEY;
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
task("run-script", "Runs a hardhard script by name")
.addParam("path", "Path within script/hardhat to script")
.setAction(async (taskArgs: { path: string }) => {
let main;
try {
main = require(`./script/hardhat/${taskArgs.path}`);
} catch (error) {
console.log("Make sure you pass an existing script path. Available scripts:");
fs.readdirSync("./script/hardhat", { withFileTypes: true }).forEach((file: fs.Dirent) => {
// Some directories don't contain files that can be run this way
if (file.isDirectory() && file.name !== "simulations" && file.name !== "utils" && file.name !== "vips") {
console.log(`${file.name}/`);
fs.readdirSync(`./script/hardhat/${file.name}`).forEach((file: string) => {
console.log(` ${file}`);
});
}
});
}
if (main) {
await main()
.then(() => process.exit(0))
.catch((error: Error) => {
console.error(error);
process.exit(1);
});
}
});
const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
solidity: {
compilers: [
{
version: "0.5.16",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
outputSelection: {
"*": {
"*": ["storageLayout"],
},
},
},
},
{
version: "0.8.13",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
outputSelection: {
"*": {
"*": ["storageLayout"],
},
},
},
},
],
},
networks: {
hardhat: isFork(),
bsctestnet: {
url: process.env.BSC_ARCHIVE_NODE_URL || "https://data-seed-prebsc-1-s1.binance.org:8545",
chainId: 97,
accounts: {
mnemonic: process.env.MNEMONIC || "",
},
gasPrice: ethers.utils.parseUnits("10", "gwei").toNumber(),
gasMultiplier: 10,
timeout: 12000000,
},
bscmainnet: {
url: "http://127.0.0.1:1248",
chainId: 56,
live: true,
timeout: 1200000, // 20 minutes
},
},
etherscan: {
apiKey: BSCSCAN_API_KEY,
},
paths: {
sources: "./contracts",
tests: "./tests/hardhat",
cache: "./cache",
artifacts: "./artifacts",
},
mocha: {
timeout: 200000000,
},
typechain: {
outDir: "typechain",
target: "ethers-v5",
},
// Hardhat deploy
namedAccounts: {
deployer: {
default: 0, // here this will by default take the first account as deployer
},
},
external: {
contracts: [
{
artifacts: "node_modules/@venusprotocol/isolated-pools/artifacts",
},
],
},
docgen: {
outputDir: "./docgen-docs",
pages: "files",
templates: "docgen-templates",
},
};
function isFork() {
return process.env.FORK_MAINNET === "true"
? {
allowUnlimitedContractSize: false,
loggingEnabled: false,
forking: {
url: process.env.BSC_ARCHIVE_NODE_URL || "",
blockNumber: 21068448,
},
accounts: {
accountsBalance: "1000000000000000000000",
},
live: false,
}
: {
allowUnlimitedContractSize: true,
loggingEnabled: false,
live: false,
};
}
export default config;