Skip to content
Snippets Groups Projects
Verified Commit a89d7eae authored by Pascal Engélibert's avatar Pascal Engélibert :bicyclist:
Browse files

feat: tech comm vote command

parent 21a9b4e4
No related branches found
No related tags found
No related merge requests found
use crate::{gdev, indexer::*, Args, Client};
use anyhow::Result;
use sp_core::sr25519::Pair;
use sp_core::H256;
use subxt::tx::{BaseExtrinsicParamsBuilder, PairSigner};
pub async fn technical_committee_members(client: Client, args: &Args) -> Result<()> {
let parent_hash = client
......@@ -73,7 +76,7 @@ pub async fn technical_committee_proposals(client: Client) -> Result<()> {
.iter(
gdev::storage()
.technical_committee()
.proposal_of(sp_core::H256::default()),
.proposal_of(H256::default()),
10,
Some(parent_hash),
)
......@@ -86,3 +89,24 @@ pub async fn technical_committee_proposals(client: Client) -> Result<()> {
Ok(())
}
pub async fn technical_committee_vote(
pair: Pair,
client: Client,
proposal_hash: H256,
proposal_index: u32,
vote: bool,
) -> Result<()> {
client
.tx()
.sign_and_submit_then_watch(
&gdev::tx()
.technical_committee()
.vote(proposal_hash, proposal_index, vote),
&PairSigner::new(pair),
BaseExtrinsicParamsBuilder::new(),
)
.await?;
Ok(())
}
......@@ -8,6 +8,7 @@ use codec::Encode;
use sp_core::{
crypto::{Pair as _, Ss58Codec},
sr25519::Pair,
H256,
};
use std::str::FromStr;
......@@ -142,7 +143,17 @@ pub enum Subcommand {
},
/// List members of the technical committee
TechMembers,
/// List proposals to the technical committee
TechProposals,
/// Vote a proposal to the technical committee
TechVote {
/// Proposal hash
hash: H256,
/// Proposal index
index: u32,
/// Vote (0=against, 1=for)
vote: u8,
},
Transfer {
/// Amount to transfer
amount: u64,
......@@ -320,6 +331,21 @@ async fn main() -> Result<()> {
Subcommand::TechProposals => {
commands::collective::technical_committee_proposals(client).await?
}
Subcommand::TechVote { hash, index, vote } => {
let vote = match vote {
0 => false,
1 => true,
_ => panic!("Vote must be written 0 if you disagree, or 1 if you agree."),
};
commands::collective::technical_committee_vote(
pair.expect("This subcommand needs a secret."),
client,
hash, //H256::from_str(&hash).expect("Invalid hash formatting"),
index,
vote,
)
.await?
}
Subcommand::Transfer {
amount,
dest,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment