Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api-scripts: add helper script to make sudo the membership screening …
…authority
- Loading branch information
Showing
3 changed files
with
42 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
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,38 @@ | ||
/* global api, hashing, keyring, types, util, joy, window */ | ||
|
||
// run this script with: | ||
// yarn workspace api-scripts script set-sudo-as-screening-auth | ||
// | ||
// or copy and paste the code into the pioneer javascript toolbox at: | ||
// https://testnet.joystream.org/#/js | ||
// | ||
// requires nicaea release+ | ||
|
||
const script = async ({ api, keyring }) => { | ||
const sudoAddress = (await api.query.sudo.key()).toString() | ||
let sudo | ||
if (typeof window === 'undefined') { | ||
// In node, get the keyPair if the keyring was provided | ||
sudo = keyring.getPair(sudoAddress) | ||
} else { | ||
// Pioneer: let the UI Signer handle it | ||
sudo = sudoAddress | ||
} | ||
|
||
const tx = api.tx.members.setScreeningAuthority(sudoAddress) | ||
|
||
const nonce = (await api.query.system.account(sudoAddress)).nonce | ||
const sudoTx = api.tx.sudo.sudo(tx) | ||
const signed = sudoTx.sign(sudo, { nonce }) | ||
await signed.send() | ||
|
||
console.log(`sent tx with nonce: ${nonce.toNumber()}, tx hash: ${signed.hash}`) | ||
} | ||
|
||
if (typeof module === 'undefined') { | ||
// Pioneer js-toolbox | ||
script({ api, hashing, keyring, types, util, joy }) | ||
} else { | ||
// Node | ||
module.exports = script | ||
} |