-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathhelper-hardhat-config.ts
84 lines (78 loc) · 2.8 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
import {HardhatNetworkForkingUserConfig} from "hardhat/types";
import {eEthereumNetwork, iParamsPerNetwork} from "./helpers/types";
import dotenv from "dotenv";
import {
ALCHEMY_KEY,
FORK,
FORK_BLOCK_NUMBER,
FORK_CHAINID,
GOERLI_CHAINID,
HARDHAT_CHAINID,
INFURA_KEY,
MAINNET_CHAINID,
PARALLEL_CHAINID,
RPC_URL,
TENDERLY_FORK_ID,
} 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.kovan]:
RPC_URL || ALCHEMY_KEY
? `https://eth-kovan.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://kovan.infura.io/v3/${INFURA_KEY}`,
[eEthereumNetwork.ropsten]:
RPC_URL || ALCHEMY_KEY
? `https://eth-ropsten.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://ropsten.infura.io/v3/${INFURA_KEY}`,
[eEthereumNetwork.goerli]:
RPC_URL || ALCHEMY_KEY
? `https://eth-goerli.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://goerli.infura.io/v3/${INFURA_KEY}`,
[eEthereumNetwork.mainnet]:
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 || "http://localhost:29933",
};
export const CHAINS_ID: iParamsPerNetwork<number | undefined> = {
[eEthereumNetwork.mainnet]: MAINNET_CHAINID,
[eEthereumNetwork.kovan]: undefined,
[eEthereumNetwork.ropsten]: undefined,
[eEthereumNetwork.goerli]: GOERLI_CHAINID,
[eEthereumNetwork.hardhat]: FORK ? FORK_CHAINID : HARDHAT_CHAINID,
[eEthereumNetwork.anvil]: HARDHAT_CHAINID,
[eEthereumNetwork.ganache]: undefined,
[eEthereumNetwork.parallel]: PARALLEL_CHAINID,
[eEthereumNetwork.tenderlyMain]: undefined,
};
export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = {
[eEthereumNetwork.mainnet]: 16119797,
[eEthereumNetwork.kovan]: undefined,
[eEthereumNetwork.ropsten]: undefined,
[eEthereumNetwork.goerli]: 8127721,
[eEthereumNetwork.hardhat]: undefined,
[eEthereumNetwork.anvil]: undefined,
[eEthereumNetwork.ganache]: undefined,
[eEthereumNetwork.parallel]: undefined,
[eEthereumNetwork.tenderlyMain]: 16119797,
};