use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::prelude::*;
use crate::{Addr, Decimal256};
use super::query_response::QueryResponseType;
use crate::utils::impl_hidden_constructor;
#[non_exhaustive]
#[derive(
Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier,
)]
#[serde(rename_all = "snake_case")]
pub enum DistributionQuery {
DelegatorWithdrawAddress { delegator_address: String },
#[cfg(feature = "cosmwasm_1_4")]
DelegationRewards {
delegator_address: String,
validator_address: String,
},
#[cfg(feature = "cosmwasm_1_4")]
DelegationTotalRewards { delegator_address: String },
#[cfg(feature = "cosmwasm_1_4")]
DelegatorValidators { delegator_address: String },
}
#[derive(
Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier,
)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub struct DelegatorWithdrawAddressResponse {
pub withdraw_address: Addr,
}
impl_hidden_constructor!(DelegatorWithdrawAddressResponse, withdraw_address: Addr);
impl QueryResponseType for DelegatorWithdrawAddressResponse {}
#[derive(
Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier,
)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub struct DelegationRewardsResponse {
pub rewards: Vec<DecCoin>,
}
impl_hidden_constructor!(DelegationRewardsResponse, rewards: Vec<DecCoin>);
impl QueryResponseType for DelegationRewardsResponse {}
#[derive(
Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier,
)]
#[serde(rename_all = "snake_case")]
pub struct DecCoin {
pub denom: String,
pub amount: Decimal256,
}
impl DecCoin {
pub fn new(amount: impl Into<Decimal256>, denom: impl Into<String>) -> Self {
Self {
denom: denom.into(),
amount: amount.into(),
}
}
}
#[derive(
Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier,
)]
#[non_exhaustive]
pub struct DelegationTotalRewardsResponse {
pub rewards: Vec<DelegatorReward>,
pub total: Vec<DecCoin>,
}
impl_hidden_constructor!(
DelegationTotalRewardsResponse,
rewards: Vec<DelegatorReward>,
total: Vec<DecCoin>
);
impl QueryResponseType for DelegationTotalRewardsResponse {}
#[derive(
Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier,
)]
#[non_exhaustive]
pub struct DelegatorReward {
pub validator_address: String,
pub reward: Vec<DecCoin>,
}
impl_hidden_constructor!(
DelegatorReward,
validator_address: String,
reward: Vec<DecCoin>
);
#[derive(
Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, cw_schema::Schemaifier,
)]
#[non_exhaustive]
pub struct DelegatorValidatorsResponse {
pub validators: Vec<String>,
}
impl_hidden_constructor!(DelegatorValidatorsResponse, validators: Vec<String>);
impl QueryResponseType for DelegatorValidatorsResponse {}