Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
- name: aurora
fee: 3
exponent: 12
- name: avalanche
fee: 25
exponent: 13
- name: conflux_espace
fee: 1
exponent: 17
- name: cronos
fee: 6
exponent: 16
- name: meter
fee: 2
exponent: 16
- name: ronin
fee: 1
exponent: 15
- name: sei_evm_mainnet
fee: 1
exponent: 16
- name: shimmer
fee: 1
exponent: 18
67 changes: 46 additions & 21 deletions contract_manager/scripts/generate_governance_set_fee_payload.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,66 @@
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { DefaultStore } from "../src";
import { Chain } from "../src/chains";
import { DefaultStore, loadHotWallet } from "../src";
import { readFileSync } from "fs";
import { parse } from "yaml";

const parser = yargs(hideBin(process.argv))
.usage("Usage: $0 --chain <chain_id> --fee <fee> --exponent <exponent>")
.usage("Usage: $0 --config <path/to/config.yaml>")
.options({
chain: {
config: {
type: "string",
demandOption: true,
desc: "Chain for which to generate the Set Fee payload",
desc: "Path to the config file",
},
fee: {
type: "number",
"ops-key-path": {
type: "string",
demandOption: true,
desc: "The new fee to set",
desc: "Path to the ops key file",
},
exponent: {
type: "number",
demandOption: true,
desc: "The new fee exponent to set",
vault: {
type: "string",
default: "mainnet-beta_FVQyHcooAtThJ83XFrNnv74BcinbRH3bRmfFamAHBfuj",
desc: "Vault ID",
},
});

async function main() {
const { chain, fee, exponent } = await parser.argv;
const {
config,
"ops-key-path": ops_key_path,
vault: vault_id,
} = await parser.argv;

const config_obj = parse(readFileSync(config, "utf8"));

let update_payloads: Buffer[] = [];

Check failure on line 36 in contract_manager/scripts/generate_governance_set_fee_payload.ts

View workflow job for this annotation

GitHub Actions / test

'update_payloads' is never reassigned. Use 'const' instead
for (const chain of config_obj) {
const chain_obj = DefaultStore.chains[chain.name];
if (!chain_obj) {
throw new Error(`Chain with ID '${chain.name}' does not exist.`);
}

const payload = chain_obj.generateGovernanceSetFeePayload(
chain.fee,
chain.exponent
);
update_payloads.push(payload);
console.log(
`Generated payload for chain ${chain.name}:`,
payload.toString("hex")
);
}

const vault = DefaultStore.vaults[vault_id];

const chain_obj = DefaultStore.chains[chain];
if (!chain_obj) {
throw new Error(`Chain with ID '${chain}' does not exist.`);
if (!vault) {
throw new Error(`Vault with ID '${vault_id}' does not exist.`);
}

const payload = chain_obj.generateGovernanceSetFeePayload(fee, exponent);
console.log(
`Generated payload for chain ${chain_obj}:`,
payload.toString("hex")
);
const keypair = await loadHotWallet(ops_key_path);
vault.connect(keypair);
const proposal = await vault.proposeWormholeMessage(update_payloads);
console.log("Proposal address:", proposal.address.toBase58());
}

main();
Loading