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

get cert count from cert meta

parent ae6b4202
No related branches found
No related tags found
1 merge request!28get cert count from cert meta
...@@ -193,7 +193,9 @@ struct IdtyView { ...@@ -193,7 +193,9 @@ struct IdtyView {
old_owner_key: Vec<AccountId>, old_owner_key: Vec<AccountId>,
expire_on: BlockNumber, expire_on: BlockNumber,
cert_issued: Vec<String>, cert_issued: Vec<String>,
cert_issued_count: u32,
cert_received: Vec<String>, cert_received: Vec<String>,
cert_received_count: u32,
smith: Option<SmithView>, smith: Option<SmithView>,
linked_account: Vec<AccountId>, linked_account: Vec<AccountId>,
} }
...@@ -210,16 +212,14 @@ impl std::fmt::Display for IdtyView { ...@@ -210,16 +212,14 @@ impl std::fmt::Display for IdtyView {
writeln!( writeln!(
f, f,
"Certifications: issued {}, received {}", "Certifications: issued {}, received {}",
self.cert_issued.len(), self.cert_issued_count, self.cert_received_count
self.cert_received.len()
)?; )?;
if let Some(smith) = &self.smith { if let Some(smith) = &self.smith {
writeln!(f, "Smith status: {:?}", smith.status)?; writeln!(f, "Smith status: {:?}", smith.status)?;
writeln!( writeln!(
f, f,
"Smith certs: issued {}, received {}", "Smith certs: issued {}, received {}",
smith.cert_issued.len(), smith.cert_issued_count, smith.cert_received_count
smith.cert_received.len()
)?; )?;
} }
let a = self.linked_account.len(); let a = self.linked_account.len();
...@@ -234,7 +234,9 @@ impl std::fmt::Display for IdtyView { ...@@ -234,7 +234,9 @@ impl std::fmt::Display for IdtyView {
struct SmithView { struct SmithView {
status: SmithStatus, status: SmithStatus,
cert_issued: Vec<String>, cert_issued: Vec<String>,
cert_issued_count: usize,
cert_received: Vec<String>, cert_received: Vec<String>,
cert_received_count: usize,
} }
/// get identity /// get identity
...@@ -281,6 +283,19 @@ pub async fn get_identity( ...@@ -281,6 +283,19 @@ pub async fn get_identity(
"<no indexer>".to_string() "<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 // get certs if possible
let (cert_issued, cert_received, linked_account, smith_cert_issued, smith_cert_received) = let (cert_issued, cert_received, linked_account, smith_cert_issued, smith_cert_received) =
if let Some(indexer) = &indexer { if let Some(indexer) = &indexer {
...@@ -315,7 +330,9 @@ pub async fn get_identity( ...@@ -315,7 +330,9 @@ pub async fn get_identity(
let smith = get_smith(client, index).await?; let smith = get_smith(client, index).await?;
let smith = smith.map(|s| SmithView { let smith = smith.map(|s| SmithView {
status: s.status, status: s.status,
cert_issued_count: smith_cert_issued.len(),
cert_issued: smith_cert_issued, cert_issued: smith_cert_issued,
cert_received_count: smith_cert_received.len(),
cert_received: smith_cert_received, cert_received: smith_cert_received,
}); });
...@@ -328,7 +345,9 @@ pub async fn get_identity( ...@@ -328,7 +345,9 @@ pub async fn get_identity(
old_owner_key: vec![], // TODO fetch history of owner key change old_owner_key: vec![], // TODO fetch history of owner key change
expire_on: value.next_scheduled, // TODO if zero use membership instead expire_on: value.next_scheduled, // TODO if zero use membership instead
cert_issued, cert_issued,
cert_issued_count: cert_meta.issued_count,
cert_received, cert_received,
cert_received_count: cert_meta.received_count,
smith, smith,
linked_account, linked_account,
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment