From 9af2d293a38f5ff1d5511ba9b39e88c1534a129e Mon Sep 17 00:00:00 2001 From: Konstantinos Demartinos Date: Tue, 18 Feb 2025 13:59:41 +0200 Subject: [PATCH] refactor(rest-api): use v2 of system state summary --- crates/iota-rest-api/openapi/openapi.json | 4 ++-- crates/iota-rest-api/src/reader.rs | 10 +++++++--- crates/iota-rest-api/src/system.rs | 10 +++++----- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/crates/iota-rest-api/openapi/openapi.json b/crates/iota-rest-api/openapi/openapi.json index 1aefc158881..207a15eaf06 100644 --- a/crates/iota-rest-api/openapi/openapi.json +++ b/crates/iota-rest-api/openapi/openapi.json @@ -4126,12 +4126,12 @@ "type": "boolean" }, "safe_mode_computation_charges": { - "description": "Amount of computation rewards accumulated (and not yet distributed) during safe mode.", + "description": "Amount of computation charges accumulated (and not yet distributed) during safe mode.", "type": "string", "format": "u64" }, "safe_mode_computation_charges_burned": { - "description": "Amount of burned computation rewards accumulated during safe mode.", + "description": "Amount of burned computation charges accumulated during safe mode.", "type": "string", "format": "u64" }, diff --git a/crates/iota-rest-api/src/reader.rs b/crates/iota-rest-api/src/reader.rs index d7c1966c800..05b731d9113 100644 --- a/crates/iota-rest-api/src/reader.rs +++ b/crates/iota-rest-api/src/reader.rs @@ -55,13 +55,17 @@ impl StateReader { } pub fn get_system_state_summary(&self) -> Result { - use iota_types::iota_system_state::IotaSystemStateTrait; + use iota_types::iota_system_state::{ + IotaSystemStateTrait, iota_system_state_summary::IotaSystemStateSummaryV2, + }; let system_state = iota_types::iota_system_state::get_iota_system_state(self.inner()) .map_err(StorageError::custom)?; - let summary = system_state.into_iota_system_state_summary().into(); + let summary = + IotaSystemStateSummaryV2::try_from(system_state.into_iota_system_state_summary()) + .map_err(StorageError::custom)?; - Ok(summary) + Ok(summary.into()) } pub fn get_transaction( diff --git a/crates/iota-rest-api/src/system.rs b/crates/iota-rest-api/src/system.rs index f4200ea96c4..bd01f9da4c7 100644 --- a/crates/iota-rest-api/src/system.rs +++ b/crates/iota-rest-api/src/system.rs @@ -117,12 +117,12 @@ pub struct SystemStateSummary { #[serde_as(as = "iota_types::iota_serde::BigInt")] #[schemars(with = "crate::_schemars::U64")] pub safe_mode_storage_charges: u64, - /// Amount of computation rewards accumulated (and not yet distributed) + /// Amount of computation charges accumulated (and not yet distributed) /// during safe mode. #[serde_as(as = "iota_types::iota_serde::BigInt")] #[schemars(with = "crate::_schemars::U64")] pub safe_mode_computation_charges: u64, - /// Amount of burned computation rewards accumulated during safe mode. + /// Amount of burned computation charges accumulated during safe mode. #[serde_as(as = "iota_types::iota_serde::BigInt")] #[schemars(with = "crate::_schemars::U64")] pub safe_mode_computation_charges_burned: u64, @@ -430,13 +430,13 @@ impl From +impl From for SystemStateSummary { fn from( - value: iota_types::iota_system_state::iota_system_state_summary::IotaSystemStateSummary, + value: iota_types::iota_system_state::iota_system_state_summary::IotaSystemStateSummaryV2, ) -> Self { - let iota_types::iota_system_state::iota_system_state_summary::IotaSystemStateSummary { + let iota_types::iota_system_state::iota_system_state_summary::IotaSystemStateSummaryV2 { epoch, protocol_version, system_state_version,