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

get cert count from cert meta (clients/rust/gcli-v2s!28)

* also for smith cert

* get cert count from cert meta
parent ae6b4202
No related branches found
No related tags found
No related merge requests found
......@@ -193,7 +193,9 @@ struct IdtyView {
old_owner_key: Vec<AccountId>,
expire_on: BlockNumber,
cert_issued: Vec<String>,
cert_issued_count: u32,
cert_received: Vec<String>,
cert_received_count: u32,
smith: Option<SmithView>,
linked_account: Vec<AccountId>,
}
......@@ -210,16 +212,14 @@ impl std::fmt::Display for IdtyView {
writeln!(
f,
"Certifications: issued {}, received {}",
self.cert_issued.len(),
self.cert_received.len()
self.cert_issued_count, self.cert_received_count
)?;
if let Some(smith) = &self.smith {
writeln!(f, "Smith status: {:?}", smith.status)?;
writeln!(
f,
"Smith certs: issued {}, received {}",
smith.cert_issued.len(),
smith.cert_received.len()
smith.cert_issued_count, smith.cert_received_count
)?;
}
let a = self.linked_account.len();
......@@ -234,7 +234,9 @@ impl std::fmt::Display for IdtyView {
struct SmithView {
status: SmithStatus,
cert_issued: Vec<String>,
cert_issued_count: usize,
cert_received: Vec<String>,
cert_received_count: usize,
}
/// get identity
......@@ -281,6 +283,19 @@ pub async fn get_identity(
"<no indexer>".to_string()
});
// get cert meta
let cert_meta = client
.storage()
.at_latest()
.await?
.fetch(
&runtime::storage()
.certification()
.storage_idty_cert_meta(index),
)
.await?
.expect("expected cert meta");
// get certs if possible
let (cert_issued, cert_received, linked_account, smith_cert_issued, smith_cert_received) =
if let Some(indexer) = &indexer {
......@@ -315,7 +330,9 @@ pub async fn get_identity(
let smith = get_smith(client, index).await?;
let smith = smith.map(|s| SmithView {
status: s.status,
cert_issued_count: s.issued_certs.len(),
cert_issued: smith_cert_issued,
cert_received_count: s.received_certs.len(),
cert_received: smith_cert_received,
});
......@@ -328,7 +345,9 @@ pub async fn get_identity(
old_owner_key: vec![], // TODO fetch history of owner key change
expire_on: value.next_scheduled, // TODO if zero use membership instead
cert_issued,
cert_issued_count: cert_meta.issued_count,
cert_received,
cert_received_count: cert_meta.received_count,
smith,
linked_account,
};
......
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