Skip to content

Commit

Permalink
[contract_manager] Add a script to list wormhole contracts (#1659)
Browse files Browse the repository at this point in the history
* script to list wormhole contracts

* minor

* minor
  • Loading branch information
jayantk authored Jun 6, 2024
1 parent 21cda36 commit d553f19
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions contract_manager/scripts/list_wormhole_contracts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { DefaultStore, EvmWormholeContract } from "../src";

const parser = yargs(hideBin(process.argv))
.usage("Usage: $0")
.options({
testnet: {
type: "boolean",
default: false,
desc: "Fetch testnet contracts instead of mainnet",
},
});

async function main() {
const argv = await parser.argv;
const entries = [];
for (const contract of Object.values(DefaultStore.wormhole_contracts)) {
if (
contract instanceof EvmWormholeContract &&
contract.getChain().isMainnet() !== argv.testnet
) {
try {
const index = await contract.getCurrentGuardianSetIndex();
const chainId = await contract.getChainId();
entries.push({
chain: contract.getChain().getId(),
contract: contract.address,
guardianSetIndex: index,
chainId: chainId,
});
console.log(`Fetched contract for ${contract.getId()}`);
} catch (e) {
console.error(`Error fetching contract for ${contract.getId()}`, e);
}
}
}
console.table(entries);
}

main();

0 comments on commit d553f19

Please sign in to comment.