-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsync-config.js
141 lines (117 loc) · 3.76 KB
/
sync-config.js
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
import {
MultiProvider,
defaultMultisigIsmConfigs,
hyperlaneEnvironments,
chainMetadata,
} from "@hyperlane-xyz/sdk";
import {
Mailbox__factory,
ValidatorAnnounce__factory,
} from "@hyperlane-xyz/core";
import { markdownTable } from "markdown-table";
const homepages = {
dsrv: "https://www.dsrvlabs.com/",
abacus: "https://www.hyperlane.xyz/crew",
everstake: "https://everstake.one/",
"zee prime": "https://zeeprime.capital/",
staked: "https://staked.us/",
zkv: "https://zkvalidator.com/",
};
// TODO: add to storage modality
export const multisigConfigNames = {
celo: {
names: ["abacus", "dsrv", "everstake", "zee prime", "staked", "zkv"],
},
ethereum: {
names: ["abacus", "dsrv", "everstake", "zee prime", "staked", "zkv"],
},
avalanche: {
names: ["abacus", "dsrv", "everstake", "zee prime", "staked", "zkv"],
},
polygon: {
names: ["abacus", "dsrv", "everstake", "zee prime", "staked", "zkv"],
},
bsc: {
names: ["abacus", "dsrv", "everstake", "zee prime", "staked", "zkv"],
},
arbitrum: {
names: ["abacus", "dsrv", "everstake", "zee prime", "staked", "ZKV"],
},
optimism: {
names: ["abacus", "dsrv", "everstake", "zee prime", "staked", "ZKV"],
},
moonbeam: {
names: ["abacus", "dsrv", "everstake", "staked"],
},
gnosis: {
names: ["abacus", "dsrv", "everstake", "staked"],
},
};
function capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
console.log(`---
description: Mailbox default security settings
---
# Mailbox default security settings
`);
const multiProvider = new MultiProvider();
const environments = ["mainnet"];
for (const env of environments) {
const addresses = hyperlaneEnvironments[env];
const networks = Object.keys(addresses);
for (const network of networks) {
const config = defaultMultisigIsmConfigs[network];
console.log(`## ${capitalize(network)}\n`);
const contracts = addresses[network];
const provider = multiProvider.getProvider(network);
const validatorAnnounce = ValidatorAnnounce__factory.connect(
contracts.validatorAnnounce,
provider
);
const names = multisigConfigNames[network].names;
const storageLocations =
await validatorAnnounce.getAnnouncedStorageLocations(config.validators);
const storageUrls = storageLocations.map((sl) => {
const [modality, , bucket, region] = sl[0].split("/");
if (!modality.includes("s3")) {
throw new Error("Unknown modality");
}
const url = `https://${bucket}.s3.${region}.amazonaws.com`;
return url;
});
const validatorEntries = [
["Validator", "Address", "Storage Location"],
...config.validators.map((address, i) => {
const name = names[i];
const homepage = homepages[name];
return [`[${name}](${homepage})`, `\`${address}\``, `[View on S3](${storageUrls[i]})`];
}),
];
console.log(`### Validators\n`);
console.log(markdownTable(validatorEntries));
console.log();
let ismEntries = [
["Destination", "Threshold", "Address", "View on Explorer"],
];
for (const remote of networks.filter((n) => n !== network)) {
const remoteProvider = multiProvider.getProvider(remote);
const mailbox = Mailbox__factory.connect(
addresses[remote].mailbox,
remoteProvider
);
const ism = await mailbox.defaultIsm();
const explorer = chainMetadata[remote].blockExplorers[0].url;
const url = new URL(explorer);
ismEntries.push([
capitalize(remote),
`${config.threshold} / ${config.validators.length}`,
`\`${ism}\``,
`[View on ${url.hostname}](${explorer}/address/${ism})`,
]);
}
console.log(`### Multisig ISM\n`);
console.log(markdownTable(ismEntries));
console.log();
}
}