-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathhardhat.config.ts
More file actions
155 lines (143 loc) · 3.55 KB
/
hardhat.config.ts
File metadata and controls
155 lines (143 loc) · 3.55 KB
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
import dotenv from "dotenv";
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "@openzeppelin/hardhat-upgrades";
import "hardhat-contract-sizer";
import "./tasks/get-versions";
import "./tasks/btc-best-height";
import "./tasks/hash-quote";
import "./tasks/refund-user-pegout";
import "./tasks/register-pegin";
dotenv.config();
const {
MAINNET_RPC_URL,
TESTNET_RPC_URL,
REGTEST_RPC_URL,
MAINNET_SIGNER_PRIVATE_KEY,
MAINNET_MNEMONIC,
TESTNET_SIGNER_PRIVATE_KEY,
TESTNET_MNEMONIC,
DEV_SIGNER_PRIVATE_KEY,
DEV_MNEMONIC,
} = process.env;
const forkEnabled = shouldEnableFork(process.argv);
const rskMainnetDerivationPath = "m/44'/137'/0'/0/0";
const rskTestnetDerivationPath = "m/44'/37310'/0'/0/0";
const rpcDefaultTimeout = 3 * 60 * 1000; // 3 minutes
const config: HardhatUserConfig = {
networks: {
rskRegtest: {
url: REGTEST_RPC_URL ?? "http://localhost:4444",
chainId: 33,
},
rskDevelopment: {
url: TESTNET_RPC_URL ?? "https://public-node.testnet.rsk.co",
timeout: rpcDefaultTimeout,
chainId: 31,
accounts: getAccounts("development"),
},
rskTestnet: {
url: TESTNET_RPC_URL ?? "https://public-node.testnet.rsk.co",
timeout: rpcDefaultTimeout,
chainId: 31,
accounts: getAccounts("testnet"),
},
rskMainnet: {
url: MAINNET_RPC_URL ?? "https://public-node.rsk.co",
timeout: rpcDefaultTimeout,
chainId: 30,
accounts: getAccounts("mainnet"),
},
...(process.env.FORK_NETWORK_URL && {
tenderly: {
url: process.env.FORK_NETWORK_URL,
chainId: 30,
timeout: rpcDefaultTimeout,
},
}),
hardhat: {
...(forkEnabled
? {
forking: {
url:
process.env.FORK_NETWORK_URL ??
"https://public-node.testnet.rsk.co",
blockNumber: Number(process.env.FORK_NETWORK_BLOCK ?? 6100000),
},
chains: {
31: {
hardforkHistory: {
london: 4000000,
berlin: 60000000,
},
},
},
}
: {}),
},
},
solidity: {
version: "0.8.18",
settings: {
optimizer: {
enabled: true,
runs: 1,
},
},
},
};
export default config;
function getAccounts(network: "mainnet" | "testnet" | "development") {
switch (network) {
case "mainnet":
return getMainnetAccounts();
case "testnet":
return getTestnetAccounts();
case "development":
return getDevAccounts();
default:
return undefined;
}
}
function getMainnetAccounts() {
if (MAINNET_MNEMONIC) {
return {
mnemonic: MAINNET_MNEMONIC,
path: rskMainnetDerivationPath,
};
} else if (MAINNET_SIGNER_PRIVATE_KEY) {
return [MAINNET_SIGNER_PRIVATE_KEY];
} else {
return undefined;
}
}
function getTestnetAccounts() {
if (TESTNET_MNEMONIC) {
return {
mnemonic: TESTNET_MNEMONIC,
path: rskTestnetDerivationPath,
};
} else if (TESTNET_SIGNER_PRIVATE_KEY) {
return [TESTNET_SIGNER_PRIVATE_KEY];
} else {
return undefined;
}
}
function getDevAccounts() {
if (DEV_MNEMONIC) {
return {
mnemonic: DEV_MNEMONIC,
path: rskTestnetDerivationPath,
};
} else if (DEV_SIGNER_PRIVATE_KEY) {
return [DEV_SIGNER_PRIVATE_KEY];
} else {
return undefined;
}
}
function shouldEnableFork(argv: string[]) {
if (argv.includes("e2e/multisig-migration.test.ts")) {
return true;
}
return false;
}