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

add distance evaluation request

parent 56ebb044
No related branches found
No related tags found
1 merge request!15update to runtime 800
This commit is part of merge request !15. Comments created here will be created in the context of that merge request.
......@@ -2,14 +2,24 @@ use crate::*;
/// request distance evaluation
pub async fn request_distance_evaluation(data: &Data) -> Result<(), subxt::Error> {
let progress = submit_call(
submit_call_and_look_event::<
runtime::distance::events::EvaluationRequested,
Payload<runtime::distance::calls::types::RequestDistanceEvaluation>,
>(
data,
&runtime::tx().distance().request_distance_evaluation(),
)
.await?;
if data.args.no_wait {
return Ok(());
}
let _ = track_progress(progress).await?;
Ok(())
.await
}
/// request distance evaluation for someone else (must be unvalidated)
pub async fn request_distance_evaluation_for(data: &Data, target: IdtyId) -> Result<(), subxt::Error> {
submit_call_and_look_event::<
runtime::distance::events::EvaluationRequested,
Payload<runtime::distance::calls::types::RequestDistanceEvaluationFor>,
>(
data,
&runtime::tx().distance().request_distance_evaluation_for(target),
)
.await
}
......@@ -34,9 +34,8 @@ pub enum Subcommand {
/// Request distance evaluation
/// make sure that it's ok otherwise currency is slashed
RequestDistanceEvaluation,
/// Renew membership
/// When membership comes to and end, it should be renewed for the identity to stay member
RenewMembership,
/// Request distance evaluation for unvalidated identity
RequestDistanceEvaluationFor { target: IdtyId },
/// Certify an identity
Certify { target: IdtyId },
/// Revoke an identity immediately
......@@ -94,8 +93,8 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE
Subcommand::RequestDistanceEvaluation => {
commands::distance::request_distance_evaluation(&data).await?;
}
Subcommand::RenewMembership => {
renew_membership(&data).await?;
Subcommand::RequestDistanceEvaluationFor {target} => {
commands::distance::request_distance_evaluation_for(&data, target).await?;
}
Subcommand::Certify { target } => {
data = data.fetch_idty_index().await?;
......@@ -276,17 +275,6 @@ pub async fn confirm_identity(data: &Data, name: String) -> Result<(), subxt::Er
.await
}
/// renew membership
pub async fn renew_membership(data: &Data) -> Result<(), subxt::Error> {
submit_call_and_look_event::<
runtime::membership::events::MembershipRenewed,
Payload<runtime::distance::calls::types::RequestDistanceEvaluation>,
>(
data,
&runtime::tx().distance().request_distance_evaluation(),
)
.await
}
/// generate revokation document and submit it immediately
pub async fn revoke_identity(data: &Data) -> Result<(), subxt::Error> {
......
......@@ -55,9 +55,9 @@ impl DisplayEvent for runtime::identity::events::IdtyChangedOwnerKey {
format!("identity changed owner key {:?}", self)
}
}
impl DisplayEvent for runtime::membership::events::MembershipRenewed {
impl DisplayEvent for runtime::distance::events::EvaluationRequested {
fn display(&self, _data: &Data) -> String {
format!("membership renewed {:?}", self)
format!("evaluation requested {:?}", self)
}
}
impl DisplayEvent for runtime::identity::events::IdtyRemoved {
......
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