-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconfig.ts
More file actions
55 lines (47 loc) · 1.74 KB
/
config.ts
File metadata and controls
55 lines (47 loc) · 1.74 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
import { HardhatUserConfig } from "hardhat/config";
import config from "./hardhat.config";
import { HyperlaneConfig, NetworkInfo } from "./types/enrollRouterTypes";
/**
* Hyperlane Configuration
*
* networks: Network information pulled from Hardhat config
* deployments: Contract addresses with optional hook and ISM (Interchain Security Module) addresses
* relationships: One-way messaging channels between networks
* Format: [sourceNetwork, destinationNetwork]
* Example: ["topaz", "sepolia"] means contracts on topaz can message sepolia
*/
function generateNetworkConfig(config: HardhatUserConfig) {
const networks: { [networkName: string]: NetworkInfo } = {};
if (!config.networks) {
throw new Error("Network configuration is required in Hardhat config");
}
for (const [name, network] of Object.entries(config.networks)) {
if (!network) throw new Error("Network Missing");
if (!network.chainId) throw new Error("chainId required");
networks[name] = {
chainId: network.chainId,
gasAmount: "gasAmount" in network ? network.gasAmount : undefined,
};
}
return networks;
}
// Example Data
export const HYPERLANE_CONFIG: HyperlaneConfig = {
networks: generateNetworkConfig(config),
deployments: {
MyCustomHypERC20: {
sepolia: {
address: "0xd117Ee788E6e4BB24f65D744e009219861697D24",
},
},
MyCustomHypERC20Collateral: {
arbsepolia: {
address: "0x0fceE3f0a2d240bDBCb93627097f5491dC83Ed75",
},
},
},
relationships: {
MyCustomHypERC20: [["sepolia", "arbsepolia"]],
MyCustomHypERC20Collateral: [["arbsepolia", "sepolia"]],
},
};