|
1 | 1 | import yargs from "yargs"; |
2 | 2 | import { hideBin } from "yargs/helpers"; |
3 | | -import { DefaultStore } from "../src"; |
4 | | -import { Chain } from "../src/chains"; |
| 3 | +import { DefaultStore, loadHotWallet } from "../src"; |
| 4 | +import { readFileSync } from "fs"; |
| 5 | +import { parse } from "yaml"; |
5 | 6 |
|
6 | 7 | const parser = yargs(hideBin(process.argv)) |
7 | | - .usage("Usage: $0 --chain <chain_id> --fee <fee> --exponent <exponent>") |
| 8 | + .usage("Usage: $0 --config <path/to/config.yaml>") |
8 | 9 | .options({ |
9 | | - chain: { |
| 10 | + config: { |
10 | 11 | type: "string", |
11 | 12 | demandOption: true, |
12 | | - desc: "Chain for which to generate the Set Fee payload", |
| 13 | + desc: "Path to the config file", |
13 | 14 | }, |
14 | | - fee: { |
15 | | - type: "number", |
| 15 | + "ops-key-path": { |
| 16 | + type: "string", |
16 | 17 | demandOption: true, |
17 | | - desc: "The new fee to set", |
| 18 | + desc: "Path to the ops key file", |
18 | 19 | }, |
19 | | - exponent: { |
20 | | - type: "number", |
21 | | - demandOption: true, |
22 | | - desc: "The new fee exponent to set", |
| 20 | + vault: { |
| 21 | + type: "string", |
| 22 | + default: "mainnet-beta_FVQyHcooAtThJ83XFrNnv74BcinbRH3bRmfFamAHBfuj", |
| 23 | + desc: "Vault ID", |
23 | 24 | }, |
24 | 25 | }); |
25 | 26 |
|
26 | 27 | async function main() { |
27 | | - const { chain, fee, exponent } = await parser.argv; |
| 28 | + const { |
| 29 | + config, |
| 30 | + "ops-key-path": ops_key_path, |
| 31 | + vault: vault_id, |
| 32 | + } = await parser.argv; |
| 33 | + |
| 34 | + const config_obj = parse(readFileSync(config, "utf8")); |
| 35 | + |
| 36 | + let update_payloads: Buffer[] = []; |
| 37 | + for (const chain of config_obj) { |
| 38 | + const chain_obj = DefaultStore.chains[chain.name]; |
| 39 | + if (!chain_obj) { |
| 40 | + throw new Error(`Chain with ID '${chain.name}' does not exist.`); |
| 41 | + } |
| 42 | + |
| 43 | + const payload = chain_obj.generateGovernanceSetFeePayload( |
| 44 | + chain.fee, |
| 45 | + chain.exponent |
| 46 | + ); |
| 47 | + update_payloads.push(payload); |
| 48 | + console.log( |
| 49 | + `Generated payload for chain ${chain.name}:`, |
| 50 | + payload.toString("hex") |
| 51 | + ); |
| 52 | + } |
| 53 | + |
| 54 | + const vault = DefaultStore.vaults[vault_id]; |
28 | 55 |
|
29 | | - const chain_obj = DefaultStore.chains[chain]; |
30 | | - if (!chain_obj) { |
31 | | - throw new Error(`Chain with ID '${chain}' does not exist.`); |
| 56 | + if (!vault) { |
| 57 | + throw new Error(`Vault with ID '${vault_id}' does not exist.`); |
32 | 58 | } |
33 | 59 |
|
34 | | - const payload = chain_obj.generateGovernanceSetFeePayload(fee, exponent); |
35 | | - console.log( |
36 | | - `Generated payload for chain ${chain_obj}:`, |
37 | | - payload.toString("hex") |
38 | | - ); |
| 60 | + const keypair = await loadHotWallet(ops_key_path); |
| 61 | + vault.connect(keypair); |
| 62 | + const proposal = await vault.proposeWormholeMessage(update_payloads); |
| 63 | + console.log("Proposal address:", proposal.address.toBase58()); |
39 | 64 | } |
40 | 65 |
|
41 | 66 | main(); |
0 commit comments