forked from pooltogether/ERC5164
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hardhat.network.ts
95 lines (85 loc) · 2.15 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
import { HardhatUserConfig } from 'hardhat/config';
import {
MAINNET_CHAIN_ID,
ARBITRUM_CHAIN_ID,
OPTIMISM_CHAIN_ID,
POLYGON_CHAIN_ID,
GOERLI_CHAIN_ID,
} from './Constants';
const mainnetRPCUrl = process.env.MAINNET_RPC_URL;
const arbitrumRPCUrl = process.env.ARBITRUM_RPC_URL;
const optimismRPCUrl = process.env.OPTIMISM_RPC_URL;
const polygonRPCUrl = process.env.OPTIMISM_RPC_URL;
const goerliRPCUrl = process.env.GOERLI_RPC_URL;
const mnemonic = process.env.HDWALLET_MNEMONIC;
const chainId = Number(process.env.CHAIN_ID);
const networks: HardhatUserConfig['networks'] = {
coverage: {
url: 'http://127.0.0.1:8555',
blockGasLimit: 200000000,
allowUnlimitedContractSize: true,
},
localhostMainnet: {
chainId,
url: 'http://127.0.0.1:8545',
allowUnlimitedContractSize: true,
},
localhostArbitrum: {
chainId,
url: 'http://127.0.0.1:8546',
allowUnlimitedContractSize: true,
},
};
if (goerliRPCUrl && mnemonic) {
networks.goerli = {
chainId: GOERLI_CHAIN_ID,
url: goerliRPCUrl,
accounts: {
mnemonic,
},
};
}
if (process.env.FORK_ENABLED && mnemonic) {
const defaultHardhatConfig = {
accounts: {
mnemonic,
},
allowUnlimitedContractSize: true,
};
if (chainId === MAINNET_CHAIN_ID && mainnetRPCUrl) {
networks.hardhat = {
chainId: MAINNET_CHAIN_ID,
forking: {
url: mainnetRPCUrl,
blockNumber: 15684520,
},
...defaultHardhatConfig,
};
} else if (chainId === ARBITRUM_CHAIN_ID && arbitrumRPCUrl) {
networks.hardhat = {
chainId: ARBITRUM_CHAIN_ID,
forking: {
url: arbitrumRPCUrl,
blockNumber: 28574320,
},
...defaultHardhatConfig,
};
} else if (chainId === OPTIMISM_CHAIN_ID && optimismRPCUrl) {
networks.hardhat = {
chainId: OPTIMISM_CHAIN_ID,
forking: {
url: optimismRPCUrl,
},
...defaultHardhatConfig,
};
} else if (chainId === POLYGON_CHAIN_ID && polygonRPCUrl) {
networks.hardhat = {
chainId: POLYGON_CHAIN_ID,
forking: {
url: polygonRPCUrl,
},
...defaultHardhatConfig,
};
}
}
export default networks;