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

add certify command

parent 020be31e
No related branches found
No related tags found
1 merge request!9add smith and membership commands
pub mod account;
pub mod blockchain;
pub mod certification;
pub mod collective;
pub mod expire;
pub mod identity;
......
......@@ -32,7 +32,7 @@ pub async fn handle_command(data: Data, command: Subcommand) -> anyhow::Result<(
match command {
Subcommand::Balance => {
data = data.fetch_system_properties().await?;
commands::account::get_balance(data).await?
get_balance(data).await?
}
Subcommand::Transfer {
amount,
......
use crate::*;
/// submit a certification and track progress
pub async fn certify(data: &Data, receiver: u32) -> Result<(), anyhow::Error> {
let progress = data
.client()
.tx()
.sign_and_submit_then_watch(
&runtime::tx()
.cert()
.add_cert(data.idty_index(), receiver),
&PairSigner::new(data.keypair()),
BaseExtrinsicParamsBuilder::new(),
)
.await?;
let events = track_progress(progress).await?;
// look for the expected event
let new_cert_event = events.find_first::<runtime::cert::events::NewCert>()?;
let renew_cert_event = events.find_first::<runtime::cert::events::RenewedCert>()?;
if let Some(event) = new_cert_event {
println!("{event:?}");
}
if let Some(event) = renew_cert_event {
println!("{event:?}");
}
Ok(())
}
......@@ -30,6 +30,8 @@ pub enum Subcommand {
///
/// To be called by the certified not-yet-member account, to become member.
Confirm { name: String },
/// Certify an identity
Certify { target: u32 },
/// Revoke an identity immediately
Revoke,
/// Generate a revocation document for the provided account
......@@ -61,6 +63,12 @@ pub async fn handle_command(data: Data, command: Subcommand) -> anyhow::Result<(
Subcommand::Confirm { name } => {
commands::identity::confirm_identity(data.keypair(), data.client(), name).await?;
}
Subcommand::Certify { target } => {
data = data.fetch_idty_index().await?;
// TODO fetch target username / key / index
// and ask user to confirm certification
commands::certification::certify(&data, target).await?;
}
Subcommand::Revoke => {
data = data.fetch_idty_index().await?;
commands::identity::revoke_identity(data).await?;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment