-
Notifications
You must be signed in to change notification settings - Fork 2
/
hardhat.config.ts
202 lines (182 loc) · 5.2 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import "@nomicfoundation/hardhat-toolbox";
// import "@typechain/hardhat";
// import "@nomicfoundation/hardhat-ethers";
import "@nomicfoundation/hardhat-chai-matchers";
// import "@nomicfoundation/hardhat-toolbox";
import { HardhatUserConfig, task } from "hardhat/config";
import fs from "fs";
import path from "path";
require("dotenv").config();
const DEFAULT_MNEMONIC =
"test test test test test test test test test test test junk";
const MNEMONIC = process.env.MNEMONIC || DEFAULT_MNEMONIC;
const ETHERSCAN_API_KEY = process.env.ETHERSCAN_API_KEY || "";
const COINMARKETCAP_API_KEY = process.env.COINMARKETCAP_API_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);
}
});
async function makeDirIfNotExists(directory: any) {
await new Promise<void>((resolve) => {
fs.access(directory, function(err) {
if (err && err.code === 'ENOENT') {
fs.mkdirSync(directory, {recursive: true});
}
resolve();
});
})
}
task("solidity-json", "Extract Standard Solidity Input JSON", async (taskArgs, hre) => {
console.log("solidity-json task");
const pathA = await hre.artifacts.getArtifactPaths();
console.log(pathA);
const names = await hre.artifacts.getAllFullyQualifiedNames();
console.dir(names);
const baseDir = "./artifacts/solidity-json";
const handled: any[] = [];
for (const name of names) {
const [fileName] = name.split(':');
// skip, if non-local file
if (!fs.existsSync(path.join("./", fileName))) {
continue;
}
// only one output per file
if (handled.find(x => x === fileName)) {
continue;
}
handled.push(fileName);
const buildInfo = await hre.artifacts.getBuildInfo(name);
const artifactStdJson = JSON.stringify(buildInfo?.input,null, 4);
const fullFileName = path.join(baseDir, fileName + ".json");
const directoryName = path.dirname(fullFileName);
console.log("> Extracting standard Solidity Input JSON for", fileName);
await makeDirIfNotExists(directoryName);
fs.writeFileSync(fullFileName, artifactStdJson);
}
});
const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.7.6",
settings: {
optimizer: {
enabled: true,
runs: 2000,
},
},
},
],
overrides: {
"contracts/converter/TokenConverter.sol": {
version: "0.8.19",
settings: {
optimizer: {
enabled: true,
runs: 2000,
}
}
},
"contracts/dex-core/Autolisting.sol": {
version: "0.7.6",
settings: {
optimizer: {
enabled: true,
runs: 5000,
}
}
},
"contracts/dex-periphery/NonfungiblePositionManager.sol": {
version: "0.7.6",
settings: {
optimizer: {
enabled: true,
runs: 5000,
}
}
},
"contracts/dex-periphery/SwapRouter.sol": {
version: "0.7.6",
settings: {
optimizer: {
enabled: true,
runs: 5000,
}
}
},
}
},
typechain: {
outDir: "typechain-types",
target: "ethers-v6",
},
etherscan: {
apiKey: {
sepolia: ETHERSCAN_API_KEY,
},
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts",
},
gasReporter: {
currency: "USD",
coinmarketcap: COINMARKETCAP_API_KEY,
token: "ETH",
},
networks: {
hardhat: {
allowUnlimitedContractSize: true,
blockGasLimit: 30000000,
accounts: {
mnemonic: DEFAULT_MNEMONIC,
path: "m/44'/60'/0'/0",
initialIndex: 0,
count: 20,
},
chainId: 31337,
},
localhost: {
blockGasLimit: 30000000,
allowUnlimitedContractSize: true,
url: "http://0.0.0.0:8545/",
chainId: 31337,
},
sepolia: {
// url: `https://sepolia.infura.io/v3/${INFURA_API_KEY}`,
// url: "https://rpc2.sepolia.org", // https://sepolia.drpc.org
// url: "https://ethereum-sepolia.rpc.subquery.network/public",
url: "https://eth-sepolia.public.blastapi.io",
chainId: 11155111,
accounts: {
mnemonic: MNEMONIC,
},
},
tbnb: {
// url: "https://bsc-testnet-rpc.publicnode.com",
url: "https://data-seed-prebsc-1-s2.bnbchain.org:8545",
// url: "https://data-seed-prebsc-1-s3.bnbchain.org:8545",
// url: "https://public.stackup.sh/api/v1/node/bsc-testnet", // https://data-seed-prebsc-1-s2.bnbchain.org:8545",
// url: "https://endpoints.omniatech.io/v1/bsc/testnet/public", // NOT work
// url: "https://bsc-testnet.public.blastapi.io",
// url: "https://api.zan.top/node/v1/bsc/testnet/public", // NOT work
// url: "https://bsc-testnet.blockpi.network/v1/rpc/public",
chainId: 97,
accounts: {
mnemonic: MNEMONIC,
},
},
eostest: {
url: "https://api.testnet.evm.eosnetwork.com",
chainId: 15557,
accounts: {
mnemonic: MNEMONIC,
},
},
},
};
export default config;