-
Notifications
You must be signed in to change notification settings - Fork 39
/
helper-hardhat-config.ts
180 lines (174 loc) · 6.21 KB
/
helper-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
import {HardhatNetworkForkingUserConfig} from "hardhat/types";
import {eEthereumNetwork, iParamsPerNetwork} from "./helpers/types";
import dotenv from "dotenv";
import {
ALCHEMY_KEY,
ARBITRUM_GOERLI_CHAINID,
ARBITRUM_ONE_CHAINID,
FORK,
FORK_BLOCK_NUMBER,
FORK_CHAINID,
GOERLI_CHAINID,
SEPOLIA_CHAINID,
HARDHAT_CHAINID,
INFURA_KEY,
L1_RPC_URL,
L2_RPC_URL,
LINEA_CHAINID,
LINEA_GOERLI_CHAINID,
MAINNET_CHAINID,
MOONBASE_CHAINID,
MOONBEAM_CHAINID,
PARALLEL_CHAINID,
POLYGON_CHAINID,
POLYGON_MUMBAI_CHAINID,
POLYGON_ZKEVM_CHAINID,
POLYGON_ZKEVM_GOERLI_CHAINID,
RPC_URL,
TENDERLY_FORK_ID,
ZKSYNC_CHAINID,
ZKSYNC_GOERLI_CHAINID,
ARBITRUM_SEPOLIA_CHAINID,
PARALLEL_DEV_CHAINID,
NEON_CHAINID,
} from "./helpers/hardhat-constants";
dotenv.config();
// const GWEI = 1000 * 1000 * 1000;
export const buildForkConfig = ():
| HardhatNetworkForkingUserConfig
| undefined => {
let forkMode: HardhatNetworkForkingUserConfig | undefined;
if (FORK) {
forkMode = {
url: NETWORKS_RPC_URL[FORK],
};
if (FORK_BLOCK_NUMBER || BLOCK_TO_FORK[FORK]) {
forkMode.blockNumber = FORK_BLOCK_NUMBER || BLOCK_TO_FORK[FORK];
}
}
return forkMode;
};
export const NETWORKS_RPC_URL: iParamsPerNetwork<string> = {
[eEthereumNetwork.goerli]:
L1_RPC_URL ||
RPC_URL ||
(ALCHEMY_KEY
? `https://eth-goerli.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://goerli.infura.io/v3/${INFURA_KEY}`),
[eEthereumNetwork.sepolia]:
L1_RPC_URL ||
RPC_URL ||
(ALCHEMY_KEY
? `https://eth-sepolia.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://sepolia.infura.io/v3/${INFURA_KEY}`),
[eEthereumNetwork.mainnet]:
L1_RPC_URL ||
RPC_URL ||
(ALCHEMY_KEY
? `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://mainnet.infura.io/v3/${INFURA_KEY}`),
[eEthereumNetwork.hardhat]: RPC_URL || "http://localhost:8545",
[eEthereumNetwork.anvil]: RPC_URL || "http://localhost:8545",
[eEthereumNetwork.ganache]: RPC_URL || "http://localhost:8545",
[eEthereumNetwork.tenderlyMain]:
RPC_URL || `https://rpc.tenderly.co/fork/${TENDERLY_FORK_ID}`,
[eEthereumNetwork.parallel]: RPC_URL || "https://rpc.parallel.fi",
[eEthereumNetwork.moonbeam]: "https://rpc.api.moonbeam.network",
[eEthereumNetwork.moonbase]: "https://rpc.testnet.moonbeam.network",
[eEthereumNetwork.arbitrum]:
L2_RPC_URL ||
RPC_URL ||
`https://arb-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}`,
[eEthereumNetwork.arbitrumGoerli]:
L2_RPC_URL ||
RPC_URL ||
`https://arb-goerli.g.alchemy.com/v2/${ALCHEMY_KEY}`,
[eEthereumNetwork.arbitrumSepolia]:
L2_RPC_URL ||
RPC_URL ||
`https://arb-sepolia.g.alchemy.com/v2/${ALCHEMY_KEY}`,
[eEthereumNetwork.parallelDev]:
L2_RPC_URL ||
RPC_URL ||
`https://rpc-surprised-harlequin-bonobo-fvcy2k9oqh.t.conduit.xyz`,
[eEthereumNetwork.polygon]:
RPC_URL || `https://polygon-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}`,
[eEthereumNetwork.polygonMumbai]:
RPC_URL || `https://polygon-mumbai.g.alchemy.com/v2/${ALCHEMY_KEY}`,
[eEthereumNetwork.polygonZkevm]:
L2_RPC_URL ||
RPC_URL ||
`https://polygonzkevm-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}`,
[eEthereumNetwork.polygonZkevmGoerli]:
L2_RPC_URL ||
RPC_URL ||
`https://polygonzkevm-testnet.g.alchemy.com/v2/${ALCHEMY_KEY}`,
[eEthereumNetwork.zksync]:
L2_RPC_URL || RPC_URL || `https://mainnet.era.zksync.io`,
[eEthereumNetwork.zksyncGoerli]:
L2_RPC_URL || RPC_URL || `https://testnet.era.zksync.dev`,
[eEthereumNetwork.linea]:
L2_RPC_URL ||
RPC_URL ||
(INFURA_KEY
? `https://linea-mainnet.infura.io/v3/${INFURA_KEY}`
: "https://rpc.linea.build"),
[eEthereumNetwork.lineaGoerli]:
L2_RPC_URL ||
RPC_URL ||
(INFURA_KEY
? `https://linea-goerli.infura.io/v3/${INFURA_KEY}`
: `https://rpc.goerli.linea.build`),
[eEthereumNetwork.neon]:
RPC_URL || `https://neon-proxy-mainnet.solana.p2p.org`,
};
export const CHAINS_ID: iParamsPerNetwork<number | undefined> = {
[eEthereumNetwork.mainnet]: MAINNET_CHAINID,
[eEthereumNetwork.goerli]: GOERLI_CHAINID,
[eEthereumNetwork.sepolia]: SEPOLIA_CHAINID,
[eEthereumNetwork.hardhat]: FORK ? FORK_CHAINID : HARDHAT_CHAINID,
[eEthereumNetwork.anvil]: HARDHAT_CHAINID,
[eEthereumNetwork.ganache]: undefined,
[eEthereumNetwork.parallel]: PARALLEL_CHAINID,
[eEthereumNetwork.tenderlyMain]: undefined,
[eEthereumNetwork.moonbeam]: MOONBEAM_CHAINID,
[eEthereumNetwork.moonbase]: MOONBASE_CHAINID,
[eEthereumNetwork.arbitrum]: ARBITRUM_ONE_CHAINID,
[eEthereumNetwork.arbitrumGoerli]: ARBITRUM_GOERLI_CHAINID,
[eEthereumNetwork.arbitrumSepolia]: ARBITRUM_SEPOLIA_CHAINID,
[eEthereumNetwork.parallelDev]: PARALLEL_DEV_CHAINID,
[eEthereumNetwork.polygon]: POLYGON_CHAINID,
[eEthereumNetwork.polygonMumbai]: POLYGON_MUMBAI_CHAINID,
[eEthereumNetwork.polygonZkevm]: POLYGON_ZKEVM_CHAINID,
[eEthereumNetwork.polygonZkevmGoerli]: POLYGON_ZKEVM_GOERLI_CHAINID,
[eEthereumNetwork.zksync]: ZKSYNC_CHAINID,
[eEthereumNetwork.zksyncGoerli]: ZKSYNC_GOERLI_CHAINID,
[eEthereumNetwork.linea]: LINEA_CHAINID,
[eEthereumNetwork.lineaGoerli]: LINEA_GOERLI_CHAINID,
[eEthereumNetwork.neon]: NEON_CHAINID,
};
export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = {
[eEthereumNetwork.mainnet]: undefined,
[eEthereumNetwork.goerli]: undefined,
[eEthereumNetwork.sepolia]: undefined,
[eEthereumNetwork.hardhat]: undefined,
[eEthereumNetwork.anvil]: undefined,
[eEthereumNetwork.ganache]: undefined,
[eEthereumNetwork.parallel]: undefined,
[eEthereumNetwork.tenderlyMain]: undefined,
[eEthereumNetwork.moonbeam]: undefined,
[eEthereumNetwork.moonbase]: undefined,
[eEthereumNetwork.arbitrum]: undefined,
[eEthereumNetwork.arbitrumGoerli]: undefined,
[eEthereumNetwork.arbitrumSepolia]: undefined,
[eEthereumNetwork.parallelDev]: undefined,
[eEthereumNetwork.polygon]: undefined,
[eEthereumNetwork.polygonMumbai]: undefined,
[eEthereumNetwork.polygonZkevm]: undefined,
[eEthereumNetwork.polygonZkevmGoerli]: undefined,
[eEthereumNetwork.zksync]: undefined,
[eEthereumNetwork.zksyncGoerli]: undefined,
[eEthereumNetwork.linea]: undefined,
[eEthereumNetwork.lineaGoerli]: undefined,
[eEthereumNetwork.neon]: undefined,
};