-
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.
- Loading branch information
1 parent
1f26742
commit 881f1b1
Showing
5 changed files
with
681 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules/ | ||
.yarn/cache | ||
.yarn/install-state.gz |
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,16 @@ | ||
{ | ||
"name": "gov-scripts", | ||
"version": "1.0.0", | ||
"description": "Governance Scripts", | ||
"license": "MIT", | ||
"type": "module", | ||
"scripts": { | ||
"propose-upgrade": "ts-node --esm ./src/proposeupgrade.ts" | ||
}, | ||
"dependencies": { | ||
"@polkadot/api": "^10.10.1", | ||
"@types/node": "^20.4.2", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.1.6" | ||
} | ||
} |
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(); |
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,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2020", | ||
"moduleResolution": "node", | ||
"esModuleInterop": true, | ||
"resolveJsonModule": true, | ||
"module": "ESNext", | ||
"sourceMap": true, | ||
"outDir": "dist", | ||
"strict": true | ||
}, | ||
"include": ["./src/**/*"], | ||
"lib": ["es2017"], | ||
"ts-node": { | ||
"experimentalSpecifierResolution": "node" | ||
} | ||
} |
Oops, something went wrong.