-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add propose-fast-track (#1022)
* feat: add propose-fast-track * fix: propose-upgrade * fix: fasttrack preimage
- Loading branch information
1 parent
c7ac6d0
commit 951758d
Showing
3 changed files
with
60 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = externalDemocracyProposal.asLegacy.toJSON().hash; | ||
} else { | ||
proposalHash = externalDemocracyProposal.asLookup.toJSON().hash; | ||
} | ||
|
||
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 Track Proposal: ', `https://polkadot.js.org/apps/?rpc=${networkUrl}#/extrinsics/decode/${encodedCall}`); | ||
console.log('-----------------'); | ||
|
||
await api.disconnect(); | ||
} | ||
|
||
await main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters