diff --git a/common/cosmwasm-smart-contracts/mixnet-contract/src/mixnode.rs b/common/cosmwasm-smart-contracts/mixnet-contract/src/mixnode.rs index 43a33c5d3e..fb03a1034b 100644 --- a/common/cosmwasm-smart-contracts/mixnet-contract/src/mixnode.rs +++ b/common/cosmwasm-smart-contracts/mixnet-contract/src/mixnode.rs @@ -17,6 +17,7 @@ use crate::{ use cosmwasm_schema::cw_serde; use cosmwasm_std::{Addr, Coin, Decimal, StdResult, Uint128}; use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; /// Full details associated with given mixnode. @@ -647,14 +648,39 @@ impl From for u8 { export_to = "ts-packages/types/src/types/rust/PendingMixnodeChanges.ts" ) )] -#[cw_serde] -#[derive(Default, Copy)] +// note: we had to remove `#[cw_serde]` as it enforces `#[serde(deny_unknown_fields)]` which we do not want +// with the addition of .cost_params_change field +#[derive( + ::cosmwasm_schema::serde::Serialize, + ::cosmwasm_schema::serde::Deserialize, + ::std::clone::Clone, + ::std::fmt::Debug, + ::std::cmp::PartialEq, + ::cosmwasm_schema::schemars::JsonSchema, + Default, + Copy, +)] +#[schemars(crate = "::cosmwasm_schema::schemars")] pub struct PendingMixNodeChanges { pub pledge_change: Option, + #[serde(default)] pub cost_params_change: Option, } +#[derive(Default, Copy, Clone, Debug, Serialize, Deserialize, JsonSchema)] +pub struct LegacyPendingMixNodeChanges { + pub pledge_change: Option, +} + +impl From for LegacyPendingMixNodeChanges { + fn from(value: PendingMixNodeChanges) -> Self { + LegacyPendingMixNodeChanges { + pledge_change: value.pledge_change, + } + } +} + impl PendingMixNodeChanges { pub fn new_empty() -> PendingMixNodeChanges { PendingMixNodeChanges { diff --git a/nym-api/nym-api-requests/src/legacy.rs b/nym-api/nym-api-requests/src/legacy.rs index f7af56252c..f0810ffa8e 100644 --- a/nym-api/nym-api-requests/src/legacy.rs +++ b/nym-api/nym-api-requests/src/legacy.rs @@ -2,10 +2,8 @@ // SPDX-License-Identifier: GPL-3.0-only use cosmwasm_std::Decimal; -use nym_mixnet_contract_common::mixnode::PendingMixNodeChanges; -use nym_mixnet_contract_common::{ - GatewayBond, LegacyMixLayer, MixNodeBond, MixNodeDetails, NodeId, NodeRewarding, -}; +use nym_mixnet_contract_common::mixnode::LegacyPendingMixNodeChanges; +use nym_mixnet_contract_common::{GatewayBond, LegacyMixLayer, MixNodeBond, NodeId, NodeRewarding}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::ops::Deref; @@ -64,7 +62,7 @@ pub struct LegacyMixNodeDetailsWithLayer { /// Adjustments to the mixnode that are ought to happen during future epoch transitions. #[serde(default)] - pub pending_changes: PendingMixNodeChanges, + pub pending_changes: LegacyPendingMixNodeChanges, } impl LegacyMixNodeDetailsWithLayer { @@ -80,13 +78,3 @@ impl LegacyMixNodeDetailsWithLayer { self.bond_information.is_unbonding } } - -impl From for MixNodeDetails { - fn from(value: LegacyMixNodeDetailsWithLayer) -> Self { - MixNodeDetails { - bond_information: value.bond_information.into(), - rewarding_details: value.rewarding_details, - pending_changes: value.pending_changes, - } - } -} diff --git a/nym-api/src/nym_contract_cache/cache/refresher.rs b/nym-api/src/nym_contract_cache/cache/refresher.rs index 0e9e6f45f9..badf0e2344 100644 --- a/nym-api/src/nym_contract_cache/cache/refresher.rs +++ b/nym-api/src/nym_contract_cache/cache/refresher.rs @@ -173,7 +173,7 @@ impl NymContractCacheRefresher { layer, }, rewarding_details: detail.rewarding_details, - pending_changes: detail.pending_changes, + pending_changes: detail.pending_changes.into(), }) }