Skip to content

Commit d553f19

Browse files
authored
[contract_manager] Add a script to list wormhole contracts (#1659)
* script to list wormhole contracts * minor * minor
1 parent 21cda36 commit d553f19

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import yargs from "yargs";
2+
import { hideBin } from "yargs/helpers";
3+
import { DefaultStore, EvmWormholeContract } from "../src";
4+
5+
const parser = yargs(hideBin(process.argv))
6+
.usage("Usage: $0")
7+
.options({
8+
testnet: {
9+
type: "boolean",
10+
default: false,
11+
desc: "Fetch testnet contracts instead of mainnet",
12+
},
13+
});
14+
15+
async function main() {
16+
const argv = await parser.argv;
17+
const entries = [];
18+
for (const contract of Object.values(DefaultStore.wormhole_contracts)) {
19+
if (
20+
contract instanceof EvmWormholeContract &&
21+
contract.getChain().isMainnet() !== argv.testnet
22+
) {
23+
try {
24+
const index = await contract.getCurrentGuardianSetIndex();
25+
const chainId = await contract.getChainId();
26+
entries.push({
27+
chain: contract.getChain().getId(),
28+
contract: contract.address,
29+
guardianSetIndex: index,
30+
chainId: chainId,
31+
});
32+
console.log(`Fetched contract for ${contract.getId()}`);
33+
} catch (e) {
34+
console.error(`Error fetching contract for ${contract.getId()}`, e);
35+
}
36+
}
37+
}
38+
console.table(entries);
39+
}
40+
41+
main();

0 commit comments

Comments
 (0)