41fb17a31b
* WIP adding derive(ToSchema) * Derive ToSchema for more types * ContractBuildInformation on /nym_contracts_detailed * rustfmt * Add cfg_attr * A bunch of annotations * Compiles with utoipa 5.2 * WIP * Post rebase fixes * Gitattributes to ignore .sqlx diffs * generate Sqlx schema files * Improvements * Move ecash schema out of ecash crate * Move redocly config to nym-api/ * Move redocly config to nym-api/ * Remove ErrorResponse * Move generated openapi spec to .gitignore * Include BSL licence * Remove utoipa from ecash toml file * Remove placeholder annotations * Chain-watcher rebase changes * Update licence info * Treat Scalar as String in OpenAPI
81 lines
2.3 KiB
Rust
81 lines
2.3 KiB
Rust
// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
use cosmwasm_std::Decimal;
|
|
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;
|
|
use utoipa::ToSchema;
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ToSchema)]
|
|
pub struct LegacyGatewayBondWithId {
|
|
// we need to flatten it so that consumers of endpoints that returned `GatewayBond` wouldn't break
|
|
#[serde(flatten)]
|
|
pub bond: GatewayBond,
|
|
pub node_id: NodeId,
|
|
}
|
|
|
|
impl Deref for LegacyGatewayBondWithId {
|
|
type Target = GatewayBond;
|
|
fn deref(&self) -> &Self::Target {
|
|
&self.bond
|
|
}
|
|
}
|
|
|
|
impl From<LegacyGatewayBondWithId> for GatewayBond {
|
|
fn from(value: LegacyGatewayBondWithId) -> Self {
|
|
value.bond
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ToSchema)]
|
|
pub struct LegacyMixNodeBondWithLayer {
|
|
// we need to flatten it so that consumers of endpoints that returned `MixNodeBond` wouldn't break
|
|
#[serde(flatten)]
|
|
pub bond: MixNodeBond,
|
|
|
|
pub layer: LegacyMixLayer,
|
|
}
|
|
|
|
impl Deref for LegacyMixNodeBondWithLayer {
|
|
type Target = MixNodeBond;
|
|
fn deref(&self) -> &Self::Target {
|
|
&self.bond
|
|
}
|
|
}
|
|
|
|
impl From<LegacyMixNodeBondWithLayer> for MixNodeBond {
|
|
fn from(value: LegacyMixNodeBondWithLayer) -> Self {
|
|
value.bond
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, ToSchema)]
|
|
pub struct LegacyMixNodeDetailsWithLayer {
|
|
/// Basic bond information of this mixnode, such as owner address, original pledge, etc.
|
|
pub bond_information: LegacyMixNodeBondWithLayer,
|
|
|
|
/// Details used for computation of rewarding related data.
|
|
pub rewarding_details: NodeRewarding,
|
|
|
|
/// Adjustments to the mixnode that are ought to happen during future epoch transitions.
|
|
#[serde(default)]
|
|
pub pending_changes: LegacyPendingMixNodeChanges,
|
|
}
|
|
|
|
impl LegacyMixNodeDetailsWithLayer {
|
|
pub fn mix_id(&self) -> NodeId {
|
|
self.bond_information.mix_id
|
|
}
|
|
|
|
pub fn total_stake(&self) -> Decimal {
|
|
self.rewarding_details.node_bond()
|
|
}
|
|
|
|
pub fn is_unbonding(&self) -> bool {
|
|
self.bond_information.is_unbonding
|
|
}
|
|
}
|