|
| 1 | +import yargs from "yargs"; |
| 2 | +import { hideBin } from "yargs/helpers"; |
| 3 | +import { DefaultStore } from "../src/node/utils/store"; |
| 4 | +import { loadHotWallet } from "../src/node/utils/governance"; |
| 5 | + |
| 6 | +const parser = yargs(hideBin(process.argv)) |
| 7 | + .usage("Usage: $0 --config <path/to/config.json>") |
| 8 | + .options({ |
| 9 | + "ops-key-path": { |
| 10 | + type: "string", |
| 11 | + demandOption: true, |
| 12 | + desc: "Path to the ops key file", |
| 13 | + }, |
| 14 | + contract: { |
| 15 | + type: "string", |
| 16 | + demandOption: true, |
| 17 | + desc: "Contract to update the trusted signer on. (e.g mumbai_0xff1a0f4744e8582DF1aE09D5611b887B6a12925C)", |
| 18 | + }, |
| 19 | + "trusted-signer": { |
| 20 | + type: "string", |
| 21 | + demandOption: true, |
| 22 | + desc: "Address of the trusted signer", |
| 23 | + }, |
| 24 | + "expires-at": { |
| 25 | + type: "number", |
| 26 | + demandOption: true, |
| 27 | + desc: "Expiration timestamp for the trusted signer", |
| 28 | + }, |
| 29 | + vault: { |
| 30 | + type: "string", |
| 31 | + default: "mainnet-beta_FVQyHcooAtThJ83XFrNnv74BcinbRH3bRmfFamAHBfuj", |
| 32 | + desc: "Vault ID", |
| 33 | + }, |
| 34 | + }); |
| 35 | + |
| 36 | +async function main() { |
| 37 | + const argv = await parser.argv; |
| 38 | + |
| 39 | + if (argv["expires-at"] < Date.now() / 1000) { |
| 40 | + throw new Error("Expiration timestamp must be in the future"); |
| 41 | + } |
| 42 | + if (argv["trusted-signer"] === "") { |
| 43 | + throw new Error("Trusted signer address cannot be empty"); |
| 44 | + } |
| 45 | + const vault = DefaultStore.vaults[argv.vault]; |
| 46 | + if (!vault) { |
| 47 | + throw new Error(`Vault with ID '${argv.vault}' does not exist.`); |
| 48 | + } |
| 49 | + |
| 50 | + const contract = DefaultStore.lazer_contracts[argv.contract]; |
| 51 | + if (!contract) { |
| 52 | + throw new Error(`Contract with ID '${argv.contract}' does not exist.`); |
| 53 | + } |
| 54 | + const updatePayloads: Buffer[] = []; |
| 55 | + console.log(`Generating payload for contract ${contract.getId()}`); |
| 56 | + const payload = await contract.generateUpdateTrustedSignerPayload( |
| 57 | + argv["trusted-signer"], |
| 58 | + argv["expires-at"], |
| 59 | + ); |
| 60 | + updatePayloads.push(payload); |
| 61 | + |
| 62 | + console.log("Using vault at for proposal", vault.getId()); |
| 63 | + const wallet = await loadHotWallet(argv["ops-key-path"]); |
| 64 | + console.log("Using wallet ", wallet.publicKey.toBase58()); |
| 65 | + await vault.connect(wallet); |
| 66 | + const proposal = await vault.proposeWormholeMessage(updatePayloads); |
| 67 | + console.log("Proposal address", proposal.address.toBase58()); |
| 68 | +} |
| 69 | + |
| 70 | +main(); |
0 commit comments