diff --git a/res/metadata.scale b/res/metadata.scale index 9b04918d2b88645a3e41c6d1ac9339d222188b2e..4f75555d61b51bfad4efd4f2d66048694ccefb78 100644 Binary files a/res/metadata.scale and b/res/metadata.scale differ diff --git a/src/commands/certification.rs b/src/commands/certification.rs index 1376b1044ac86ebab39b184e02ff697d698fcdd8..c1d299911fa66402c89ef5c925beef328cbab554 100644 --- a/src/commands/certification.rs +++ b/src/commands/certification.rs @@ -4,7 +4,9 @@ use crate::*; pub async fn certify(data: &Data, receiver: IdtyId) -> Result<(), anyhow::Error> { let progress = submit_call( data, - &runtime::tx().cert().add_cert(data.idty_index(), receiver), + &runtime::tx() + .certification() + .add_cert(data.idty_index(), receiver), ) .await?; if data.args.no_wait { @@ -12,7 +14,7 @@ pub async fn certify(data: &Data, receiver: IdtyId) -> Result<(), anyhow::Error> } let events = track_progress(progress).await?; // look for the expected event - look_event::<runtime::cert::events::NewCert>(data, &events)?; - look_event::<runtime::cert::events::RenewedCert>(data, &events)?; + look_event::<runtime::certification::events::CertAdded>(data, &events)?; + look_event::<runtime::certification::events::CertRenewed>(data, &events)?; Ok(()) } diff --git a/src/commands/distance.rs b/src/commands/distance.rs index 6eaaf4c53ad3604e3eebda42eebef747054914fa..fb80955a3d812a333cd75a9176b03d759e9e136e 100644 --- a/src/commands/distance.rs +++ b/src/commands/distance.rs @@ -13,25 +13,3 @@ pub async fn request_distance_evaluation(data: &Data) -> Result<(), subxt::Error let _ = track_progress(progress).await?; Ok(()) } - -/// get identity distance status -pub async fn get_identity_distance_status( - data: &Data, -) -> Result< - Option<( - AccountId, - runtime::runtime_types::pallet_distance::types::DistanceStatus, - )>, - subxt::Error, -> { - data.client() - .storage() - .at_latest() - .await? - .fetch( - &runtime::storage() - .distance() - .identity_distance_status(data.idty_index()), - ) - .await -} diff --git a/src/commands/expire.rs b/src/commands/expire.rs index f6b496331d2c370cd16a892eb5ba091cd8b8c2c6..d8f7bf0ed9d4b8f6822b4cd6fbef434003f5a976 100644 --- a/src/commands/expire.rs +++ b/src/commands/expire.rs @@ -33,7 +33,7 @@ pub async fn monitor_expirations(data: &Data, blocks: u32, _sessions: u32) -> an let mut basic_certs_iter = client .storage() .at(parent_hash) - .iter(runtime::storage().cert().storage_certs_removable_on_iter()) + .iter(runtime::storage().certification().certs_removable_on_iter()) .await?; let mut basic_certs = BTreeMap::new(); while let Some(Ok((k, v))) = basic_certs_iter.next().await { @@ -43,27 +43,7 @@ pub async fn monitor_expirations(data: &Data, blocks: u32, _sessions: u32) -> an } } - let mut smith_certs_iter = client - .storage() - .at(parent_hash) - .iter( - runtime::storage() - .smith_cert() - .storage_certs_removable_on_iter(), - ) - .await?; - let mut smith_certs = BTreeMap::new(); - while let Some(Ok((k, v))) = smith_certs_iter.next().await { - let block_number = BlockNumber::from_le_bytes(k[40..44].try_into().unwrap()); - if block_number < end_block { - smith_certs.insert(block_number - current_block, v); - } - } - - for (title, certs) in [ - ("Certifications", basic_certs), - ("Smith certifications", smith_certs), - ] { + for (title, certs) in [("Certifications", basic_certs)] { println!("\n{title}:"); for (blocks_left, certs) in certs { println!("{blocks_left} blocks before expiration:"); @@ -102,27 +82,7 @@ pub async fn monitor_expirations(data: &Data, blocks: u32, _sessions: u32) -> an } } - let mut smith_membership_iter = client - .storage() - .at(parent_hash) - .iter( - runtime::storage() - .smith_membership() - .memberships_expire_on_iter(), - ) - .await?; - let mut smith_memberships = BTreeMap::new(); - while let Some(Ok((k, v))) = smith_membership_iter.next().await { - let block_number = BlockNumber::from_le_bytes(k[40..44].try_into().unwrap()); - if block_number < end_block { - smith_memberships.insert(block_number - current_block, v); - } - } - - for (title, memberships) in [ - ("Memberships", basic_memberships), - ("Smith memberships", smith_memberships), - ] { + for (title, memberships) in [("Memberships", basic_memberships)] { println!("\n{title}:"); for (blocks_left, membership) in memberships { println!("{blocks_left} blocks before expiration:"); diff --git a/src/commands/identity.rs b/src/commands/identity.rs index fc4e7ba3c7fd29b8f1612ee99d91722b4be96708..9543c5744ff407d6a541da184cf2a1bad374b0dd 100644 --- a/src/commands/identity.rs +++ b/src/commands/identity.rs @@ -31,14 +31,9 @@ pub enum Subcommand { /// /// To be called by the certified not-yet-member account, to become member. Confirm { name: String }, - /// Validate an identity - /// Should be called when the distance has been evaluated positively - Validate { index: IdtyId }, /// Request distance evaluation /// make sure that it's ok otherwise currency is slashed RequestDistanceEvaluation, - /// Get distance status - DistanceStatus, /// Renew membership /// When membership comes to and end, it should be renewed for the identity to stay member RenewMembership, @@ -96,16 +91,9 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE Subcommand::Confirm { name } => { confirm_identity(&data, name).await?; } - Subcommand::Validate { index } => { - validate_identity(&data, index).await?; - } Subcommand::RequestDistanceEvaluation => { commands::distance::request_distance_evaluation(&data).await?; } - Subcommand::DistanceStatus => { - data = data.fetch_idty_index().await?; - dbg!(commands::distance::get_identity_distance_status(&data).await?); - } Subcommand::RenewMembership => { renew_membership(&data).await?; } @@ -288,21 +276,15 @@ pub async fn confirm_identity(data: &Data, name: String) -> Result<(), subxt::Er .await } -/// confirm identity -pub async fn validate_identity(data: &Data, index: IdtyId) -> Result<(), subxt::Error> { - submit_call_and_look_event::< - runtime::identity::events::IdtyValidated, - Payload<runtime::identity::calls::types::ValidateIdentity>, - >(data, &runtime::tx().identity().validate_identity(index)) - .await -} - /// renew membership pub async fn renew_membership(data: &Data) -> Result<(), subxt::Error> { submit_call_and_look_event::< runtime::membership::events::MembershipRenewed, - Payload<runtime::membership::calls::types::RenewMembership>, - >(data, &runtime::tx().membership().renew_membership()) + Payload<runtime::distance::calls::types::RequestDistanceEvaluation>, + >( + data, + &runtime::tx().distance().request_distance_evaluation(), + ) .await } diff --git a/src/commands/runtime.rs b/src/commands/runtime.rs index 2f51e6f6591523a312283fd20d4d9b77343da667..afed9abc28e59dfe32f571afe4fdf3423815afd0 100644 --- a/src/commands/runtime.rs +++ b/src/commands/runtime.rs @@ -6,15 +6,15 @@ pub async fn runtime_info(data: Data) { // certifications let cert_period = api .constants() - .at(&runtime::constants().cert().cert_period()) + .at(&runtime::constants().certification().cert_period()) .unwrap(); let max_by_issuer = api .constants() - .at(&runtime::constants().cert().max_by_issuer()) + .at(&runtime::constants().certification().max_by_issuer()) .unwrap(); let validity_period = api .constants() - .at(&runtime::constants().cert().validity_period()) + .at(&runtime::constants().certification().validity_period()) .unwrap(); println!("certification period: {cert_period} blocks"); diff --git a/src/commands/smith.rs b/src/commands/smith.rs index efd32d4f171560a9cdf32b34e1338d12d3fea014..2009d3c42c39ccef9f725a117b5b0f5964e5fefe 100644 --- a/src/commands/smith.rs +++ b/src/commands/smith.rs @@ -36,16 +36,6 @@ fn session_keys_decode(session_keys: SessionKeys) -> RuntimeSessionKeys { /// define smith subcommands #[derive(Clone, Default, Debug, clap::Parser)] pub enum Subcommand { - /// Request smith membership - Request, - /// Emit a smith certification - Cert { to: IdtyId }, - /// Claim smith membership - Claim, - /// Renew smith membership - Renew, - /// Revoke smith membership - Revoke, /// go online GoOnline, /// go offline @@ -66,36 +56,18 @@ pub enum Subcommand { }, /// List online authorities ShowOnline, - /// count of smith member - MemberCount, } /// handle smith commands pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliError> { let mut data = data.build_client().await?; match command { - Subcommand::Request => { - request_smith_membership(&data).await?; - } - Subcommand::Claim => { - claim_smith_membership(&data).await?; - } - Subcommand::Renew => { - renew_smith_membership(&data).await?; - } - Subcommand::Revoke => { - revoke_smith_membership(&data).await?; - } Subcommand::GoOnline => { go_online(&data).await?; } Subcommand::GoOffline => { go_offline(&data).await?; } - Subcommand::Cert { to } => { - data = data.fetch_idty_index().await?; - cert(&data, to).await? - } Subcommand::UpdateKeys => { update_session_keys(&data).await?; } @@ -116,21 +88,6 @@ pub async fn handle_command(data: Data, command: Subcommand) -> Result<(), GcliE data = data.build_client().await?; online(&data).await? } - Subcommand::MemberCount => { - println!( - "smith member count: {:?}", - data.client() - .storage() - .at_latest() - .await? - .fetch( - &runtime::storage() - .smith_membership() - .counter_for_membership(), - ) - .await? - ) - } }; Ok(()) @@ -154,15 +111,6 @@ pub async fn rotate_keys(data: &Data) -> Result<SessionKeys, anyhow::Error> { .map_err(|e| anyhow!("Session keys have wrong length: {:?}", e)) } -/// request smith membership -pub async fn request_smith_membership(data: &Data) -> Result<(), subxt::Error> { - submit_call_and_look_event::< - runtime::smith_membership::events::MembershipRequested, - Payload<runtime::smith_membership::calls::types::RequestMembership>, - >(data, &runtime::tx().smith_membership().request_membership()) - .await -} - /// set session keys pub async fn set_session_keys( data: &Data, @@ -217,33 +165,6 @@ pub async fn go_online(data: &Data) -> Result<(), GcliError> { .map_err(|e| e.into()) } -/// claim smith membership -pub async fn claim_smith_membership(data: &Data) -> Result<(), subxt::Error> { - submit_call_and_look_event::< - runtime::smith_membership::events::MembershipAcquired, - Payload<runtime::smith_membership::calls::types::ClaimMembership>, - >(data, &runtime::tx().smith_membership().claim_membership()) - .await -} - -/// renew smith membership -pub async fn renew_smith_membership(data: &Data) -> Result<(), subxt::Error> { - submit_call_and_look_event::< - runtime::smith_membership::events::MembershipRenewed, - Payload<runtime::smith_membership::calls::types::RenewMembership>, - >(data, &runtime::tx().smith_membership().renew_membership()) - .await -} - -/// revoke smith membership -pub async fn revoke_smith_membership(data: &Data) -> Result<(), subxt::Error> { - submit_call_and_look_event::< - runtime::smith_membership::events::MembershipRevoked, - Payload<runtime::smith_membership::calls::types::RevokeMembership>, - >(data, &runtime::tx().smith_membership().revoke_membership()) - .await -} - /// submit go_offline pub async fn go_offline(data: &Data) -> Result<(), subxt::Error> { submit_call_and_look_event::< @@ -333,22 +254,3 @@ pub async fn online(data: &Data) -> Result<(), anyhow::Error> { Ok(()) } - -/// submit a smith certification and track progress -pub async fn cert(data: &Data, receiver: IdtyId) -> Result<(), anyhow::Error> { - let progress = submit_call( - data, - &runtime::tx() - .smith_cert() - .add_cert(data.idty_index(), receiver), - ) - .await?; - if data.args.no_wait { - return Ok(()); - } - let events = track_progress(progress).await?; - // look for the expected event - look_event::<runtime::smith_cert::events::NewCert>(data, &events)?; - look_event::<runtime::smith_cert::events::RenewedCert>(data, &events)?; - Ok(()) -} diff --git a/src/commands/sudo.rs b/src/commands/sudo.rs index b9fce469a4849e275742ba21d4510986f08b6028..5c172b1c810e87f676ca2ec551117709cd18c646 100644 --- a/src/commands/sudo.rs +++ b/src/commands/sudo.rs @@ -9,7 +9,7 @@ pub enum Subcommand { Nothing, /// set sudo keys SetKey { new_key: AccountId }, - /// force set distance status to DistanceStatus::Valid + /// force valid distance status SetDistanceOk { identity: IdtyId }, } @@ -40,13 +40,7 @@ pub async fn set_key(data: &Data, new_key: AccountId) -> Result<(), subxt::Error /// set distance ok pub async fn set_distance_ok(data: &Data, identity: IdtyId) -> Result<(), subxt::Error> { - let inner = runtime::distance::Call::force_set_distance_status { - identity, - status: Some(( - data.address(), - runtime::runtime_types::pallet_distance::types::DistanceStatus::Valid, - )), - }; + let inner = runtime::distance::Call::force_valid_distance_status { identity }; let inner = runtime::Call::Distance(inner); submit_call_and_look_event::< runtime::sudo::events::Sudid, diff --git a/src/display.rs b/src/display.rs index 3320ab4391eff8de3f50b5cde7e96b99e8d163bf..bcfb3e9153ba421c5ba7ce3d0bf24696a55da52a 100644 --- a/src/display.rs +++ b/src/display.rs @@ -14,26 +14,16 @@ impl DisplayEvent for runtime::universal_dividend::events::UdsClaimed { ) } } -impl DisplayEvent for runtime::cert::events::NewCert { +impl DisplayEvent for runtime::certification::events::CertAdded { fn display(&self, _data: &Data) -> String { format!("new certification {} → {}", self.issuer, self.receiver) } } -impl DisplayEvent for runtime::cert::events::RenewedCert { +impl DisplayEvent for runtime::certification::events::CertRenewed { fn display(&self, _data: &Data) -> String { format!("renewed cert {:?}", self) } } -impl DisplayEvent for runtime::smith_cert::events::NewCert { - fn display(&self, _data: &Data) -> String { - format!("certified as smith {:?}", self) - } -} -impl DisplayEvent for runtime::smith_cert::events::RenewedCert { - fn display(&self, _data: &Data) -> String { - format!("renewed smith cert {:?}", self) - } -} impl DisplayEvent for runtime::account::events::AccountUnlinked { fn display(&self, _data: &Data) -> String { format!("account unlinked: {}", self.0) @@ -60,11 +50,6 @@ impl DisplayEvent for runtime::identity::events::IdtyConfirmed { ) } } -impl DisplayEvent for runtime::identity::events::IdtyValidated { - fn display(&self, _data: &Data) -> String { - format!("identity validated {:?}", self) - } -} impl DisplayEvent for runtime::identity::events::IdtyChangedOwnerKey { fn display(&self, _data: &Data) -> String { format!("identity changed owner key {:?}", self) @@ -95,31 +80,11 @@ impl DisplayEvent for runtime::oneshot_account::events::OneshotAccountConsumed { format!("oneshot {:?}", self) } } -impl DisplayEvent for runtime::smith_membership::events::MembershipRequested { - fn display(&self, _data: &Data) -> String { - format!("smith membership requested {:?}", self) - } -} impl DisplayEvent for runtime::authority_members::events::MemberGoOnline { fn display(&self, _data: &Data) -> String { format!("smith went online {:?}", self) } } -impl DisplayEvent for runtime::smith_membership::events::MembershipAcquired { - fn display(&self, _data: &Data) -> String { - format!("smith membership aquired {:?}", self) - } -} -impl DisplayEvent for runtime::smith_membership::events::MembershipRenewed { - fn display(&self, _data: &Data) -> String { - format!("smith membership renewed {:?}", self) - } -} -impl DisplayEvent for runtime::smith_membership::events::MembershipRevoked { - fn display(&self, _data: &Data) -> String { - format!("smith membership revoked {:?}", self) - } -} impl DisplayEvent for runtime::authority_members::events::MemberGoOffline { fn display(&self, _data: &Data) -> String { format!("smith went offline {:?}", self)