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

add new smith commands

parent a14024bb
No related branches found
No related tags found
1 merge request!15update to runtime 800
......@@ -56,6 +56,12 @@ pub enum Subcommand {
},
/// List online authorities
ShowOnline,
/// Invite identity to become smith
Invite{target: IdtyId},
/// Accept invitation
Accept,
/// Certify smith
Certify{target: IdtyId},
}
/// handle smith commands
......@@ -81,13 +87,21 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
set_session_keys(&data, session_keys).await?;
}
Subcommand::ShowExpire { blocks, sessions } => {
data = data.build_client().await?.build_indexer().await?;
data = data.build_indexer().await?;
commands::expire::monitor_expirations(&data, blocks, sessions).await?
}
Subcommand::ShowOnline => {
data = data.build_client().await?;
online(&data).await?
}
Subcommand::Invite { target } => {
invite_smith(&data, target).await?
}
Subcommand::Accept => {
accept_invitation(&data).await?
}
Subcommand::Certify { target } => {
certify_smith(&data, target).await?
}
};
Ok(())
......@@ -254,3 +268,30 @@ pub async fn online(data: &Data) -> Result<(), anyhow::Error> {
Ok(())
}
/// invite identity to join smith
pub async fn invite_smith(data: &Data, target: IdtyId) -> Result<(), subxt::Error> {
submit_call_and_look_event::<
runtime::smith_members::events::InvitationSent,
Payload<runtime::smith_members::calls::types::InviteSmith>,
>(data, &runtime::tx().smith_members().invite_smith(target))
.await
}
/// accept invitation
pub async fn accept_invitation(data: &Data) -> Result<(), subxt::Error> {
submit_call_and_look_event::<
runtime::smith_members::events::InvitationAccepted,
Payload<runtime::smith_members::calls::types::AcceptInvitation>,
>(data, &runtime::tx().smith_members().accept_invitation())
.await
}
/// invite identity to join smith
pub async fn certify_smith(data: &Data, target: IdtyId) -> Result<(), subxt::Error> {
submit_call_and_look_event::<
runtime::smith_members::events::CertificationReceived,
Payload<runtime::smith_members::calls::types::CertifySmith>,
>(data, &runtime::tx().smith_members().certify_smith(target))
.await
}
......@@ -60,6 +60,21 @@ impl DisplayEvent for runtime::distance::events::EvaluationRequested {
format!("evaluation requested {:?}", self)
}
}
impl DisplayEvent for runtime::smith_members::events::InvitationSent {
fn display(&self, _data: &Data) -> String {
format!("sent smith invitation {:?}", self)
}
}
impl DisplayEvent for runtime::smith_members::events::InvitationAccepted {
fn display(&self, _data: &Data) -> String {
format!("accepted smith invitation {:?}", self)
}
}
impl DisplayEvent for runtime::smith_members::events::CertificationReceived {
fn display(&self, _data: &Data) -> String {
format!("new smith certification {:?}", self)
}
}
impl DisplayEvent for runtime::identity::events::IdtyRemoved {
fn display(&self, _data: &Data) -> String {
format!("identity removed {:?}", 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