cosmwasm_std/query/
distribution.rs1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use crate::prelude::*;
5use crate::{Addr, Decimal256};
6
7use super::query_response::QueryResponseType;
8
9#[non_exhaustive]
10#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
11#[serde(rename_all = "snake_case")]
12pub enum DistributionQuery {
13 DelegatorWithdrawAddress { delegator_address: String },
15 #[cfg(feature = "cosmwasm_1_4")]
17 DelegationRewards {
18 delegator_address: String,
19 validator_address: String,
20 },
21 #[cfg(feature = "cosmwasm_1_4")]
23 DelegationTotalRewards { delegator_address: String },
24 #[cfg(feature = "cosmwasm_1_4")]
26 DelegatorValidators { delegator_address: String },
27}
28
29#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
31#[serde(rename_all = "snake_case")]
32#[non_exhaustive]
33pub struct DelegatorWithdrawAddressResponse {
34 pub withdraw_address: Addr,
35}
36
37impl_response_constructor!(DelegatorWithdrawAddressResponse, withdraw_address: Addr);
38impl QueryResponseType for DelegatorWithdrawAddressResponse {}
39
40#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
42#[serde(rename_all = "snake_case")]
43#[non_exhaustive]
44pub struct DelegationRewardsResponse {
45 pub rewards: Vec<DecCoin>,
46}
47
48impl_response_constructor!(DelegationRewardsResponse, rewards: Vec<DecCoin>);
49impl QueryResponseType for DelegationRewardsResponse {}
50
51#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
61#[serde(rename_all = "snake_case")]
62pub struct DecCoin {
63 pub denom: String,
64 pub amount: Decimal256,
69}
70
71impl DecCoin {
72 pub fn new(amount: impl Into<Decimal256>, denom: impl Into<String>) -> Self {
73 Self {
74 denom: denom.into(),
75 amount: amount.into(),
76 }
77 }
78}
79
80#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
82#[non_exhaustive]
83pub struct DelegationTotalRewardsResponse {
84 pub rewards: Vec<DelegatorReward>,
85 pub total: Vec<DecCoin>,
86}
87
88impl_response_constructor!(
89 DelegationTotalRewardsResponse,
90 rewards: Vec<DelegatorReward>,
91 total: Vec<DecCoin>
92);
93impl QueryResponseType for DelegationTotalRewardsResponse {}
94
95#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
96#[non_exhaustive]
97pub struct DelegatorReward {
98 pub validator_address: String,
99 pub reward: Vec<DecCoin>,
100}
101impl_response_constructor!(
102 DelegatorReward,
103 validator_address: String,
104 reward: Vec<DecCoin>
105);
106
107#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
109#[non_exhaustive]
110pub struct DelegatorValidatorsResponse {
111 pub validators: Vec<String>,
112}
113
114impl_response_constructor!(DelegatorValidatorsResponse, validators: Vec<String>);
115impl QueryResponseType for DelegatorValidatorsResponse {}