Skip to content
Snippets Groups Projects
Select Git revision
  • e4fbb11a9af226b9782cf746fc370f7fe7d187ed
  • master default protected
  • elois-ci-refactor protected
  • gtest
  • hugo/gtest
  • json-output
  • nostr
  • 48-error-base-58-requirement-is-violated
  • no-rename
  • hugo/tx-comments
  • poka/dev
  • hugo/dev
  • tuxmain/mail
  • test-gtest
  • 0.4.3-gtest-RC1
  • 0.4.3-RC2
  • 0.4.3-RC1
  • 0.4.2
  • 0.4.1
  • 0.4.0
  • 0.3.0
  • 0.2.17
  • 0.2.16
  • 0.2.15
  • 0.2.14
  • 0.2.13
  • 0.2.12
  • 0.2.10
  • 0.2.9
  • 0.2.8
  • 0.2.7
  • 0.2.6
  • 0.2.5
33 results

collective.rs

Blame
  • collective.rs 3.33 KiB
    use crate::*;
    
    use anyhow::Result;
    
    /// define technical committee subcommands
    #[derive(Clone, Default, Debug, clap::Parser)]
    pub enum Subcommand {
    	#[default]
    	/// List members of the technical committee
    	Members,
    	/// List proposals to the technical committee
    	Proposals,
    	/// Vote a proposal to the technical committee
    	Vote {
    		/// Proposal hash
    		hash: Hash,
    		/// Proposal index
    		index: u32,
    		/// Vote (0=against, 1=for)
    		vote: u8,
    	},
    }
    
    /// handle technical committee commands
    pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliError> {
    	let mut data = data.build_client().await?.build_indexer().await?;
    	match command {
    		Subcommand::Members => {
    			data = data.build_client().await?;
    			commands::collective::technical_committee_members(&data).await?
    		}
    		Subcommand::Proposals => {
    			data = data.build_client().await?;
    			commands::collective::technical_committee_proposals(data.client()).await?
    		}
    		Subcommand::Vote { hash, index, vote } => {
    			data = data.build_client().await?;
    			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(
    				&data, hash, //Hash::from_str(&hash).expect("Invalid hash formatting"),
    				index, vote,
    			)
    			.await?;
    		}
    	};
    
    	Ok(())
    }
    
    /// list technical committee members
    pub async fn technical_committee_members(data: &Data) -> Result<()> {
    	let client = data.client();
    	let indexer = data.indexer.clone();
    
    	let parent_hash = client
    		.storage()
    		.at_latest()
    		.await?
    		.fetch(&runtime::storage().system().parent_hash())
    		.await?
    		.unwrap();
    
    	for account_id in client
    		.storage()
    		.at(parent_hash)
    		.fetch(&runtime::storage().technical_committee().members())