Skip to content
Snippets Groups Projects
Commit 03def054 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

add tech propose

parent 292ab353
No related branches found
No related tags found
1 merge request!15update to runtime 800
...@@ -8,6 +8,8 @@ pub enum Subcommand { ...@@ -8,6 +8,8 @@ pub enum Subcommand {
#[default] #[default]
/// List members of the technical committee /// List members of the technical committee
Members, Members,
/// Propose a hex encoded call
Propose { hex: String },
/// List proposals to the technical committee /// List proposals to the technical committee
Proposals, Proposals,
/// Vote a proposal to the technical committee /// Vote a proposal to the technical committee
...@@ -23,24 +25,18 @@ pub enum Subcommand { ...@@ -23,24 +25,18 @@ pub enum Subcommand {
/// handle technical committee commands /// handle technical committee commands
pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliError> { pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliError> {
let mut data = data.build_client().await?.build_indexer().await?; let data = data.build_client().await?;
match command { match command {
Subcommand::Members => { Subcommand::Members => technical_committee_members(&data).await?,
data = data.build_client().await?; Subcommand::Propose { hex } => technical_committee_propose(&data, &hex).await?,
commands::collective::technical_committee_members(&data).await? Subcommand::Proposals => technical_committee_proposals(data.client()).await?,
}
Subcommand::Proposals => {
data = data.build_client().await?;
commands::collective::technical_committee_proposals(data.client()).await?
}
Subcommand::Vote { hash, index, vote } => { Subcommand::Vote { hash, index, vote } => {
data = data.build_client().await?;
let vote = match vote { let vote = match vote {
0 => false, 0 => false,
1 => true, 1 => true,
_ => panic!("Vote must be written 0 if you disagree, or 1 if you agree."), _ => panic!("Vote must be written 0 if you disagree, or 1 if you agree."),
}; };
commands::collective::technical_committee_vote( technical_committee_vote(
&data, hash, //Hash::from_str(&hash).expect("Invalid hash formatting"), &data, hash, //Hash::from_str(&hash).expect("Invalid hash formatting"),
index, vote, index, vote,
) )
...@@ -141,3 +137,17 @@ pub async fn technical_committee_vote( ...@@ -141,3 +137,17 @@ pub async fn technical_committee_vote(
) )
.await .await
} }
/// propose call given as hexadecimal
/// can be generated with `subxt explore` for example
pub async fn technical_committee_propose(data: &Data, proposal: &str) -> Result<(), subxt::Error> {
let raw_call = hex::decode(proposal).expect("invalid hex");
let call = codec::decode_from_bytes(raw_call.into()).expect("invalid call");
let payload = runtime::tx().technical_committee().propose(5, call, 100);
submit_call_and_look_event::<
runtime::technical_committee::events::Proposed,
Payload<runtime::technical_committee::calls::types::Propose>,
>(data, &payload)
.await
}
...@@ -150,3 +150,8 @@ impl DisplayEvent for runtime::sudo::events::Sudid { ...@@ -150,3 +150,8 @@ impl DisplayEvent for runtime::sudo::events::Sudid {
format!("SUDO call succeeded {:?}", self) format!("SUDO call succeeded {:?}", self)
} }
} }
impl DisplayEvent for runtime::technical_committee::events::Proposed {
fn display(&self, _data: &Data) -> String {
format!("proposed {:?}", self)
}
}
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