From 177667a75aaf460fbc27d0743236ae1ebc3197f5 Mon Sep 17 00:00:00 2001 From: albertov19 Date: Fri, 29 Mar 2024 15:17:13 +0100 Subject: [PATCH] added support ofr inline and legacy --- package-lock.json | 4 ++-- src/tools/fast-execute-chopstick-proposal.ts | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9f24d5f..d798659 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "moonbeam-tools", - "version": "0.0.47", + "version": "0.0.49", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "moonbeam-tools", - "version": "0.0.47", + "version": "0.0.49", "license": "GPL-3.0", "dependencies": { "@moonbeam-network/api-augment": "^0.2302.0", diff --git a/src/tools/fast-execute-chopstick-proposal.ts b/src/tools/fast-execute-chopstick-proposal.ts index 3d5d7ed..f66f026 100644 --- a/src/tools/fast-execute-chopstick-proposal.ts +++ b/src/tools/fast-execute-chopstick-proposal.ts @@ -7,6 +7,8 @@ const debug = require("debug")("fast-executor"); import { ALITH_PRIVATE_KEY, getApiFor, NETWORK_YARGS_OPTIONS } from ".."; import { ApiPromise, Keyring } from "@polkadot/api"; +import { blake2AsHex } from "@polkadot/util-crypto"; + const argv = yargs(process.argv.slice(2)) .usage("Usage: $0") .version("1.0.0") @@ -139,7 +141,13 @@ const main = async () => { const ongoingData = referendumInfo.asOngoing; const ongoingJson = ongoingData.toJSON(); - const callHash = ongoingData.proposal.asLookup.toHex(); + // Support Lookup, Inline or Legacy + const callHash = ongoingData.proposal.isLookup + ? ongoingData.proposal.asLookup.toHex() + : ongoingData.proposal.isInline + ? blake2AsHex(ongoingData.proposal.asInline.toHex()) + : ongoingData.proposal.asLegacy.toHex(); + const proposalBlockTarget = (await api.rpc.chain.getHeader()).number.toNumber(); const fastProposalData = { ongoing: { @@ -207,7 +215,13 @@ const main = async () => { (await api.rpc.chain.getHeader()).number.toNumber() + 2 )}` ); - await moveScheduledCallTo(api, 1, (call) => call.isLookup && call.asLookup.toHex() == callHash); + await moveScheduledCallTo(api, 1, (call) => + call.isLookup + ? call.asLookup.toHex() == callHash + : call.isInline + ? blake2AsHex(call.asInline.toHex()) == callHash + : call.asLegacy.toHex() == callHash + ); console.log( `${chalk.yellow("Fast forward")} ${chalk.green(1)} to #${chalk.green(