Skip to content

Commit b6c661a

Browse files
committed
refactor(contract_manager): support batch set fee proposal
1 parent 083a098 commit b6c661a

File tree

2 files changed

+70
-21
lines changed

2 files changed

+70
-21
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
- name: aurora
2+
fee: 3
3+
exponent: 12
4+
- name: avalanche
5+
fee: 25
6+
exponent: 13
7+
- name: conflux_espace
8+
fee: 1
9+
exponent: 17
10+
- name: cronos
11+
fee: 6
12+
exponent: 16
13+
- name: meter
14+
fee: 2
15+
exponent: 16
16+
- name: ronin
17+
fee: 1
18+
exponent: 15
19+
- name: sei_evm_mainnet
20+
fee: 1
21+
exponent: 16
22+
- name: shimmer
23+
fee: 1
24+
exponent: 18
Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,66 @@
11
import yargs from "yargs";
22
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";
56

67
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>")
89
.options({
9-
chain: {
10+
config: {
1011
type: "string",
1112
demandOption: true,
12-
desc: "Chain for which to generate the Set Fee payload",
13+
desc: "Path to the config file",
1314
},
14-
fee: {
15-
type: "number",
15+
"ops-key-path": {
16+
type: "string",
1617
demandOption: true,
17-
desc: "The new fee to set",
18+
desc: "Path to the ops key file",
1819
},
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",
2324
},
2425
});
2526

2627
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];
2855

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.`);
3258
}
3359

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());
3964
}
4065

4166
main();

0 commit comments

Comments
 (0)