Skip to content
Snippets Groups Projects
Select Git revision
  • a4adb75bfda5febaa7de916f2af8ce34f69f3a26
  • master default protected
  • fix_picked_up_file_in_runtime_release
  • network/gtest-1000 protected
  • upgradable-multisig
  • runtime/gtest-1000
  • network/gdev-800 protected
  • cgeek/issue-297-cpu
  • gdev-800-tests
  • update-docker-compose-rpc-squid-names
  • fix-252
  • 1000i100-test
  • hugo/tmp-0.9.1
  • network/gdev-803 protected
  • hugo/endpoint-gossip
  • network/gdev-802 protected
  • hugo/distance-precompute
  • network/gdev-900 protected
  • tuxmain/anonymous-tx
  • debug/podman
  • hugo/195-doc
  • gtest-1000-0.11.1 protected
  • gtest-1000-0.11.0 protected
  • gtest-1000 protected
  • gdev-900-0.10.1 protected
  • gdev-900-0.10.0 protected
  • gdev-900-0.9.2 protected
  • gdev-800-0.8.0 protected
  • gdev-900-0.9.1 protected
  • gdev-900-0.9.0 protected
  • gdev-803 protected
  • gdev-802 protected
  • runtime-801 protected
  • gdev-800 protected
  • runtime-800-bis protected
  • runtime-800 protected
  • runtime-800-backup protected
  • runtime-701 protected
  • runtime-700 protected
  • runtime-600 protected
  • runtime-500 protected
41 results

manual.md

Blame
    • Pascal Engélibert's avatar
      4234da98
      Distance Oracle (nodes/rust/duniter-v2s!105) · 4234da98
      Pascal Engélibert authored and Hugo Trentesaux's avatar Hugo Trentesaux committed
      * Fix distance-oracle EvaluationPool type
      
      * Remove instanciation and dep to certification
      
      * Doc comments, make max size params const
      
      * Fix default distance dir
      
      * Rename pool accessors
      
      * doc add READMEs
      
      * fix(distance): Remember account_id who reserved
      
      * Log, comments, crate author
      
      * feat: distance
      
      * integration tests, expiration
      
      * fixes & working end2end tests
      
      * fix(distance): max_depth, compute min_certs_for_referee
      
      * fix(distance): add distance pallet to gtest, g1
      
      * test(distance): WiP end2end test
      
      * feat: distance
      4234da98
      History
      Distance Oracle (nodes/rust/duniter-v2s!105)
      Pascal Engélibert authored and Hugo Trentesaux's avatar Hugo Trentesaux committed
      * Fix distance-oracle EvaluationPool type
      
      * Remove instanciation and dep to certification
      
      * Doc comments, make max size params const
      
      * Fix default distance dir
      
      * Rename pool accessors
      
      * doc add READMEs
      
      * fix(distance): Remember account_id who reserved
      
      * Log, comments, crate author
      
      * feat: distance
      
      * integration tests, expiration
      
      * fixes & working end2end tests
      
      * fix(distance): max_depth, compute min_certs_for_referee
      
      * fix(distance): add distance pallet to gtest, g1
      
      * test(distance): WiP end2end test
      
      * feat: distance
    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())
    		.await?
    		.unwrap_or_default()
    	{
    		println!(
    			"{}",
    			if let Some(indexer) = &indexer {
    				indexer
    					.username_by_pubkey(&account_id.to_string())
    					.await
    					.ok()
    					.flatten()
    			} else {
    				client
    					.storage()
    					.at(parent_hash)
    					.fetch(&runtime::storage().identity().identity_index_of(&account_id))
    					.await
    					.ok()
    					.flatten()
    					.map(|identity_id| format!("{identity_id}"))
    			}
    			.unwrap_or_else(|| account_id.to_string(),)
    		);
    	}
    
    	Ok(())
    }
    
    /// list technical committee proposals
    // TODO:
    // * better formatting (format pubkeys to SS58 and add usernames)
    // * display proposals indices
    pub async fn technical_committee_proposals(client: &Client) -> Result<()> {
    	let parent_hash = client
    		.storage()
    		.at_latest()
    		.await?
    		.fetch(&runtime::storage().system().parent_hash())
    		.await?
    		.unwrap();
    
    	let mut proposals_iter = client
    		.storage()
    		.at(parent_hash)
    		.iter(runtime::storage().technical_committee().proposal_of_iter())
    		.await?;
    	while let Some(Ok((proposal_hash, proposal))) = proposals_iter.next().await {
    		println!("{}", hex::encode(&proposal_hash[32..64]));
    		println!("{proposal:#?}");
    		println!();
    	}
    
    	Ok(())
    }
    
    /// submit vote to technical committee
    pub async fn technical_committee_vote(
    	data: &Data,
    	proposal_hash: Hash,
    	proposal_index: u32,
    	vote: bool,
    ) -> Result<(), subxt::Error> {
    	submit_call_and_look_event::<
    		runtime::technical_committee::events::Voted,
    		Payload<runtime::technical_committee::calls::types::Vote>,
    	>(
    		data,
    		&runtime::tx()
    			.technical_committee()
    			.vote(proposal_hash, proposal_index, vote),
    	)
    	.await
    }