forked from kamescg/delegatable-sol
-
Notifications
You must be signed in to change notification settings - Fork 14
/
hardhat.network.ts
132 lines (118 loc) · 3.87 KB
/
hardhat.network.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
import { HardhatUserConfig } from "hardhat/config";
import { HardhatNetworkAccountUserConfig } from "hardhat/types";
// Accounts
const TESTNET_PK_DEPLOYER = process.env.TESTNET_PK_DEPLOYER || "";
const MAINNET_PK_DEPLOYER = process.env.MAINNET_PK_DEPLOYER || "";
// Json RPC Endpoints
const ARCHIVE_NODE_RPC_URL = process.env.ARCHIVE_NODE_RPC_URL;
const ETHEREUM_MAINNET_RPC_URL = process.env.ETHEREUM_MAINNET_RPC_URL;
const ETHEREUM_GOERLI_RPC_URL = process.env.ETHEREUM_GOERLI_RPC_URL;
const POLYGON_MAINNET_RPC_URL = process.env.POLYGON_MAINNET_RPC_URL;
const POLYGON_TESTNET_RPC_URL = process.env.POLYGON_TESTNET_RPC_URL;
const OPTIMISM_MAINNET_RPC_URL = process.env.OPTIMISM_MAINNET_RPC_URL;
const OPTIMISM_TESTNET_RPC_URL = process.env.OPTIMISM_TESTNET_RPC_URL;
// Forking
const FORK_ENABLED = process.env.FORK_ENABLED;
const FORK_BLOCK_NUMBER = process.env.FORK_BLOCK_NUMBER;
const MNEMONIC = "test test test test test test test test test test test junk";
/* ===================================================================================== */
/* Local */
/* ===================================================================================== */
const networks: HardhatUserConfig["networks"] = {
coverage: {
url: "http://127.0.0.1:8555",
blockGasLimit: 200000000,
allowUnlimitedContractSize: true,
},
localhost: {
chainId: 1,
url: "http://127.0.0.1:8545",
},
};
/* ===================================================================================== */
/* Fork */
/* ===================================================================================== */
if (ARCHIVE_NODE_RPC_URL && FORK_ENABLED) {
networks.hardhat = {
chainId: 1,
hardfork: "istanbul",
accounts: { mnemonic: MNEMONIC },
forking: {
url: ARCHIVE_NODE_RPC_URL,
blockNumber: Number(FORK_BLOCK_NUMBER || "0"),
},
};
} else {
networks.hardhat = {
allowUnlimitedContractSize: true,
accounts: { mnemonic: MNEMONIC },
};
}
/* ===================================================================================== */
/* External */
/* ===================================================================================== */
if (MAINNET_PK_DEPLOYER && ETHEREUM_MAINNET_RPC_URL) {
networks.mainnet = {
url: ETHEREUM_MAINNET_RPC_URL,
chainId: 1,
accounts: [
MAINNET_PK_DEPLOYER as unknown as HardhatNetworkAccountUserConfig,
],
};
}
if (TESTNET_PK_DEPLOYER && ETHEREUM_GOERLI_RPC_URL) {
networks.goerli = {
url: ETHEREUM_GOERLI_RPC_URL,
chainId: 5,
accounts: [
TESTNET_PK_DEPLOYER as unknown as HardhatNetworkAccountUserConfig,
],
};
}
/**
* Optimism
* @mainnet: 10
* @testnet: 42
*/
if (MAINNET_PK_DEPLOYER && OPTIMISM_MAINNET_RPC_URL) {
networks.optimism = {
url: OPTIMISM_MAINNET_RPC_URL,
chainId: 10,
accounts: [
MAINNET_PK_DEPLOYER as unknown as HardhatNetworkAccountUserConfig,
],
};
}
if (TESTNET_PK_DEPLOYER && OPTIMISM_TESTNET_RPC_URL) {
networks.optimismTestnet = {
url: OPTIMISM_TESTNET_RPC_URL,
chainId: 42,
accounts: [
TESTNET_PK_DEPLOYER as unknown as HardhatNetworkAccountUserConfig,
],
};
}
/**
* Polygon
* @mainnet: 137
* @testnet: 80001
*/
if (MAINNET_PK_DEPLOYER && POLYGON_MAINNET_RPC_URL) {
networks.polygon = {
url: POLYGON_MAINNET_RPC_URL,
chainId: 137,
accounts: [
MAINNET_PK_DEPLOYER as unknown as HardhatNetworkAccountUserConfig,
],
};
}
if (TESTNET_PK_DEPLOYER && POLYGON_TESTNET_RPC_URL) {
networks.polygonTestnet = {
url: POLYGON_TESTNET_RPC_URL,
chainId: 80001,
accounts: [
TESTNET_PK_DEPLOYER as unknown as HardhatNetworkAccountUserConfig,
],
};
}
export default networks;