-
Notifications
You must be signed in to change notification settings - Fork 54
/
helper-hardhat-config.ts
64 lines (57 loc) · 2.32 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
// @ts-ignore
import { HardhatNetworkForkingUserConfig, HardhatUserConfig } from "hardhat/types";
import { eEthereumNetwork, iParamsPerNetwork } from "./helpers/types";
require("dotenv").config();
const INFURA_KEY = process.env.INFURA_KEY || "";
const ALCHEMY_KEY = process.env.ALCHEMY_KEY || "";
const TENDERLY_FORK_ID = process.env.TENDERLY_FORK_ID || "";
const FORK = process.env.FORK || "";
const FORK_BLOCK_NUMBER = process.env.FORK_BLOCK_NUMBER ? parseInt(process.env.FORK_BLOCK_NUMBER) : 0;
const GWEI = 1000 * 1000 * 1000;
export const buildForkConfig = (): HardhatNetworkForkingUserConfig | undefined => {
let forkMode;
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.sepolia]: ALCHEMY_KEY
? `https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_KEY}`
: `https://sepolia.infura.io/v3/${INFURA_KEY}`,
[eEthereumNetwork.goerli]: ALCHEMY_KEY
? `https://eth-goerli.g.alchemy.com/v2/${ALCHEMY_KEY}`
: `https://goerli.infura.io/v3/${INFURA_KEY}`,
[eEthereumNetwork.rinkeby]: ALCHEMY_KEY
? `https://eth-rinkeby.g.alchemy.com/v2/${ALCHEMY_KEY}`
: `https://rinkeby.infura.io/v3/${INFURA_KEY}`,
[eEthereumNetwork.main]: ALCHEMY_KEY
? `https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}`
: `https://mainnet.infura.io/v3/${INFURA_KEY}`,
[eEthereumNetwork.coverage]: "http://localhost:8555",
[eEthereumNetwork.hardhat]: "http://localhost:8545",
[eEthereumNetwork.localhost]: "http://localhost:8545",
};
export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
[eEthereumNetwork.sepolia]: 15 * GWEI,
[eEthereumNetwork.goerli]: 65 * GWEI,
[eEthereumNetwork.rinkeby]: 65 * GWEI,
[eEthereumNetwork.main]: 15 * GWEI,
[eEthereumNetwork.coverage]: 65 * GWEI,
[eEthereumNetwork.hardhat]: 65 * GWEI,
[eEthereumNetwork.localhost]: 65 * GWEI,
};
export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = {
[eEthereumNetwork.main]: 13623705,
[eEthereumNetwork.rinkeby]: 0,
[eEthereumNetwork.goerli]: 0,
[eEthereumNetwork.sepolia]: 0,
[eEthereumNetwork.coverage]: 0,
[eEthereumNetwork.hardhat]: 0,
[eEthereumNetwork.localhost]: 0,
};