-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhardhat.config.ts
100 lines (92 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
import "@typechain/hardhat";
import "@nomicfoundation/hardhat-toolbox";
import { config as dotenvConfig } from "dotenv";
import type { HardhatUserConfig } from "hardhat/config";
import type {
HardhatNetworkAccountUserConfig,
NetworkUserConfig,
} from "hardhat/types";
import path, { resolve } from "path";
import fs from "fs";
import { eEthereumNetwork } from "./script/types";
import {
ARBITRUM_ETHERSCAN_KEY,
ARBITRUM_SEPOLIA_ETHERSCAN_KEY,
BROWSER_URLS,
CHAIN_ID,
ETHERSCAN_APIS,
ETHERSCAN_KEY,
NETWORKS_RPC_URL,
SEPOLIA_ETHERSCAN_KEY,
} from "./hardhat-constants";
const dotenvConfigPath: string = process.env.DOTENV_CONFIG_PATH || "./.env";
dotenvConfig({ path: resolve(__dirname, dotenvConfigPath) });
const tasksPath = path.join(__dirname, "task");
fs.readdirSync(tasksPath)
.filter((pth) => pth.includes(".ts"))
.forEach((task) => {
require(`${tasksPath}/${task}`);
});
// Ensure that we have all the environment variables we need.
if (!process.env.SIGNER_KEY) throw new Error("No private key found");
const privateKey: HardhatNetworkAccountUserConfig = process.env
.SIGNER_KEY as unknown as HardhatNetworkAccountUserConfig;
function getChainConfig(network: eEthereumNetwork): NetworkUserConfig {
return {
accounts: [`0x${privateKey}`],
chainId: CHAIN_ID[network],
url: NETWORKS_RPC_URL[network],
};
}
const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
etherscan: {
apiKey: {
localhost: ETHERSCAN_KEY,
mainnet: ETHERSCAN_KEY,
sepolia: ETHERSCAN_KEY,
arbitrum: ARBITRUM_ETHERSCAN_KEY,
arbitrumSepolia: ARBITRUM_SEPOLIA_ETHERSCAN_KEY,
},
customChains: [
eEthereumNetwork.mainnet,
eEthereumNetwork.sepolia,
eEthereumNetwork.arbitrum,
eEthereumNetwork.arbitrumSepolia,
].map((network) => ({
network,
chainId: CHAIN_ID[network]!,
urls: {
apiURL: ETHERSCAN_APIS[network],
browserURL: BROWSER_URLS[network],
},
})),
},
networks: {
[eEthereumNetwork.hardhat]: {
chainId: CHAIN_ID[eEthereumNetwork.hardhat],
},
[eEthereumNetwork.mainnet]: getChainConfig(eEthereumNetwork.mainnet),
[eEthereumNetwork.sepolia]: getChainConfig(eEthereumNetwork.sepolia),
[eEthereumNetwork.arbitrum]: getChainConfig(eEthereumNetwork.arbitrum),
[eEthereumNetwork.arbitrumSepolia]: getChainConfig(
eEthereumNetwork.arbitrumSepolia
),
},
paths: {
sources: "./contracts",
cache: "./cache_hardhat",
artifacts: "./artifacts",
tests: "./test",
},
solidity: {
version: "0.8.20",
settings: {
optimizer: {
enabled: true,
runs: 999999,
},
},
},
};
export default config;