-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhardhat.config.ts
96 lines (84 loc) · 2.18 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
import { HardhatUserConfig, subtask } from "hardhat/config";
import "@openzeppelin/hardhat-upgrades";
import "@nomiclabs/hardhat-ethers";
import "@nomiclabs/hardhat-etherscan";
import "@nomicfoundation/hardhat-chai-matchers";
import "@typechain/hardhat";
import "solidity-coverage";
import * as dotenv from "dotenv"
import { utils, Wallet } from "ethers";
import { HardhatNetworkAccountUserConfig } from "hardhat/types/config";
import path from "path";
import { TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS } from "hardhat/builtin-tasks/task-names";
dotenv.config();
function getAccounts() {
const accounts: HardhatNetworkAccountUserConfig[] = [];
const defaultBalance = utils.parseEther("2000000").toString();
const n = 10;
for (let i = 0; i < n; ++i) {
accounts.push({
privateKey: Wallet.createRandom().privateKey,
balance: defaultBalance
})
}
return accounts;
}
function getCustomUrl(url: string | undefined) {
if (url) {
return url;
} else {
return "http://127.0.0.1:8545"
}
}
function getCustomPrivateKey(privateKey: string | undefined) {
if (privateKey) {
return [privateKey];
} else {
return [];
}
}
function getGasPrice(gasPrice: string | undefined) {
if (gasPrice) {
return parseInt(gasPrice, 10);
} else {
return "auto";
}
}
subtask(
TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS,
async (_, { config }, runSuper) => {
const paths = await runSuper() as Array<string>;
return paths
.filter((solidityFilePath: string) => {
const relativePath = path.relative(config.paths.sources, solidityFilePath)
return relativePath !== "test/MarionetteOld.sol";
})
}
);
const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
solidity: {
version: '0.8.11',
settings: {
optimizer:{
enabled: true,
runs: 200
}
}
},
networks: {
hardhat: {
accounts: getAccounts(),
blockGasLimit: 12000000
},
custom: {
url: getCustomUrl(process.env.ENDPOINT),
accounts: getCustomPrivateKey(process.env.PRIVATE_KEY),
gasPrice: getGasPrice(process.env.GASPRICE)
}
},
etherscan: {
apiKey: process.env.ETHERSCAN
}
};
export default config;