Skip to content

Commit

Permalink
Merge pull request #1594 from Phala-Network/scripts
Browse files Browse the repository at this point in the history
scripts: calculate preimage hash for inline ext proposal
  • Loading branch information
h4x3rotab authored Dec 9, 2024
2 parents 309e465 + 89ce828 commit 45bd877
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions scripts/js/bugfix-tools/calcInlineExternalHash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require('dotenv').config();
const fs = require('fs');
const { ApiPromise, WsProvider, Keyring } = require('@polkadot/api');

process.env.ENDPOINT = 'wss://phala-rpc.dwellir.com'

const { blake2AsHex } = require('@polkadot/util-crypto');

async function main() {
const wsProvider = new WsProvider(process.env.ENDPOINT);
const api = await ApiPromise.create({ provider: wsProvider });

const nextExt = (await api.query.democracy.nextExternal()).unwrap();
console.log([nextExt[0].toHuman(), nextExt[1].toHuman()])
const rawExt = nextExt[0].toHex();
const hash = blake2AsHex(nextExt[0].asInline); // special hash - only hash the content
console.log({rawExt, hash})
}

main().catch(console.error).finally(() => process.exit());

0 comments on commit 45bd877

Please sign in to comment.