prov_cosmwasm_std/query/
staking.rs1#![cfg(feature = "staking")]
2
3use schemars::JsonSchema;
4use serde::{Deserialize, Serialize};
5
6use crate::{Addr, Coin, Decimal};
7
8#[non_exhaustive]
9#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
10#[serde(rename_all = "snake_case")]
11pub enum StakingQuery {
12 BondedDenom {},
14 AllDelegations { delegator: String },
16 Delegation {
19 delegator: String,
20 validator: String,
21 },
22 AllValidators {},
26 Validator {
31 address: String,
33 },
34}
35
36#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
38#[serde(rename_all = "snake_case")]
39pub struct BondedDenomResponse {
40 pub denom: String,
41}
42
43#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
45#[serde(rename_all = "snake_case")]
46pub struct AllDelegationsResponse {
47 pub delegations: Vec<Delegation>,
48}
49
50#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
54pub struct Delegation {
55 pub delegator: Addr,
56 pub validator: String,
58 pub amount: Coin,
60}
61
62impl From<FullDelegation> for Delegation {
63 fn from(full: FullDelegation) -> Self {
64 Delegation {
65 delegator: full.delegator,
66 validator: full.validator,
67 amount: full.amount,
68 }
69 }
70}
71
72#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
74#[serde(rename_all = "snake_case")]
75pub struct DelegationResponse {
76 pub delegation: Option<FullDelegation>,
77}
78
79#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
84pub struct FullDelegation {
85 pub delegator: Addr,
86 pub validator: String,
88 pub amount: Coin,
90 pub can_redelegate: Coin,
94 pub accumulated_rewards: Vec<Coin>,
96}
97
98#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
100pub struct AllValidatorsResponse {
101 pub validators: Vec<Validator>,
102}
103
104#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
106pub struct ValidatorResponse {
107 pub validator: Option<Validator>,
108}
109
110#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
112pub struct Validator {
113 pub address: String,
115 pub commission: Decimal,
116 pub max_commission: Decimal,
117 pub max_change_rate: Decimal,
119}