Skip to main content

ic_query_cli/presentation/nns/registry/
mod.rs

1use crate::presentation::text_value::field;
2use ic_host_text::timestamp::format_utc_timestamp_secs;
3
4use crate::presentation::human_quantity::byte_count_text;
5use ic_query::nns::registry::NnsRegistryVersionReport;
6
7#[must_use]
8/// Render the NNS registry version report as human-facing text.
9pub fn nns_registry_version_report_text(report: &NnsRegistryVersionReport) -> String {
10    let [
11        registry_id,
12        version,
13        network,
14        fetched_at,
15        endpoint,
16        fetched_by,
17    ] = crate::presentation::nns::render::registry_provenance_lines(&report.provenance);
18    [
19        network,
20        registry_id,
21        version,
22        fetched_at,
23        endpoint,
24        fetched_by,
25        "assurance: certified".to_string(),
26        field(
27            "certificate_verified",
28            &(report.certification.certificate_verified),
29        ),
30        field(
31            "certificate_time",
32            &(format_utc_timestamp_secs(
33                report.certification.certificate_time_nanos / 1_000_000_000,
34            )),
35        ),
36        field("root_key_digest", &(report.certification.root_key_digest)),
37        field(
38            "certificate_bytes",
39            &(byte_count_text(report.certification.certificate_bytes() as u128)),
40        ),
41        field(
42            "hash_tree_bytes",
43            &(byte_count_text(report.certification.hash_tree_bytes() as u128)),
44        ),
45    ]
46    .join("\n")
47}