From 23feee19a01225e9537bd72d495b091dc43ceced Mon Sep 17 00:00:00 2001 From: Daniel Shiposha Date: Thu, 19 Oct 2023 18:08:48 +0200 Subject: [PATCH] feat: add propose-fast-track --- tests/package.json | 3 ++- tests/src/proposefasttrack.ts | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 tests/src/proposefasttrack.ts diff --git a/tests/package.json b/tests/package.json index c669f54d63..556a2e6397 100644 --- a/tests/package.json +++ b/tests/package.json @@ -131,7 +131,8 @@ "polkadot-types-from-chain": "ts-node --esm ./node_modules/.bin/polkadot-types-from-chain --endpoint src/interfaces/metadata.json --output src/interfaces/ --package .", "polkadot-types": "echo \"export default {}\" > src/interfaces/lookup.ts && yarn polkadot-types-fetch-metadata && yarn polkadot-types-from-defs && yarn polkadot-types-from-defs && yarn polkadot-types-from-chain", "generateEnv": "ts-node --esm ./src/generateEnv.ts", - "propose-upgrade": "ts-node --esm ./src/proposeupgrade.ts" + "propose-upgrade": "ts-node --esm ./src/proposeupgrade.ts", + "propose-fast-track": "ts-node --esm ./src/proposefasttrack.ts" }, "author": "", "license": "SEE LICENSE IN ../LICENSE", diff --git a/tests/src/proposefasttrack.ts b/tests/src/proposefasttrack.ts new file mode 100644 index 0000000000..50936acd24 --- /dev/null +++ b/tests/src/proposefasttrack.ts @@ -0,0 +1,42 @@ +import {ApiPromise, WsProvider} from '@polkadot/api'; +import {blake2AsHex} from '@polkadot/util-crypto'; + +async function main() { + const networkUrl = process.argv[2]; + + const wsProvider = new WsProvider(networkUrl); + const api = await ApiPromise.create({provider: wsProvider}); + + const externalDemocracyProposal = (await api.query.democracy.nextExternal() as any).unwrap()[0]; + + let proposalHash; + if(externalDemocracyProposal.isInline) { + proposalHash = blake2AsHex(externalDemocracyProposal.asInline, 256); + } else if(externalDemocracyProposal.isLegacy) { + proposalHash = blake2AsHex(externalDemocracyProposal.asLegacy, 256); + } else { + proposalHash = blake2AsHex(externalDemocracyProposal.asLookup, 256); + } + + const voringPeriod = 7200; + const delay = 10; + + const democracyFastTrack = api.tx.democracy.fastTrack(proposalHash, voringPeriod, delay); + + const techCommThreshold = ((await api.query.technicalCommittee.members()).toJSON() as any[]).length; + const techCommProposal = api.tx.technicalCommittee.propose( + techCommThreshold, + democracyFastTrack.method.toHex(), + democracyFastTrack.encodedLength, + ); + + const encodedCall = techCommProposal.method.toHex(); + + console.log('-----------------'); + console.log('Fast Treck Proposal: ', `https://polkadot.js.org/apps/?rpc=${networkUrl}#/extrinsics/decode/${encodedCall}`); + console.log('-----------------'); + + await api.disconnect(); +} + +await main();