-
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: propose-upgrade governance script (#1019)
* feat: governance scripts * fix: move propose-upgrade script to tests
- Loading branch information
1 parent
8af05a8
commit 092e9b8
Showing
2 changed files
with
42 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,7 +130,8 @@ | |
"polkadot-types-from-defs": "ts-node --esm ./node_modules/.bin/polkadot-types-from-defs --endpoint src/interfaces/metadata.json --input src/interfaces/ --package .", | ||
"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" | ||
"generateEnv": "ts-node --esm ./src/generateEnv.ts", | ||
"propose-upgrade": "ts-node --esm ./src/proposeupgrade.ts" | ||
}, | ||
"author": "", | ||
"license": "SEE LICENSE IN ../LICENSE", | ||
|
@@ -159,4 +160,4 @@ | |
}, | ||
"type": "module", | ||
"packageManager": "[email protected]" | ||
} | ||
} |
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,39 @@ | ||
import {ApiPromise, WsProvider} from '@polkadot/api'; | ||
import {blake2AsHex} from '@polkadot/util-crypto'; | ||
import {readFileSync} from 'fs'; | ||
|
||
async function main() { | ||
const networkUrl = process.argv[2]; | ||
const wasmFile = process.argv[3]; | ||
|
||
const wsProvider = new WsProvider(networkUrl); | ||
const api = await ApiPromise.create({provider: wsProvider}); | ||
|
||
const wasmFileBytes = readFileSync(wasmFile); | ||
const wasmFileHash = blake2AsHex(wasmFileBytes, 256); | ||
|
||
const authorizeUpgrade = api.tx.parachainSystem.authorizeUpgrade(wasmFileHash, true); | ||
|
||
const councilMembers = (await api.query.council.members()).toJSON() as any[]; | ||
const councilProposalThreshold = Math.floor(councilMembers.length / 2) + 1; | ||
|
||
const democracyProposal = api.tx.democracy.externalProposeDefault({ | ||
Inline: authorizeUpgrade.method.toHex(), | ||
}); | ||
|
||
const councilProposal = api.tx.council.propose( | ||
councilProposalThreshold, | ||
democracyProposal, | ||
democracyProposal.method.encodedLength, | ||
); | ||
|
||
const encodedCall = councilProposal.method.toHex(); | ||
|
||
console.log('-----------------'); | ||
console.log('Upgrade Proposal: ', `https://polkadot.js.org/apps/?rpc=${networkUrl}#/extrinsics/decode/${encodedCall}`); | ||
console.log('-----------------'); | ||
|
||
await api.disconnect(); | ||
} | ||
|
||
await main(); |