From d55f955bf74516ba03eb7d973e31c31432001116 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Stuczy=C5=84ski?= Date: Tue, 5 Dec 2023 17:00:07 +0000 Subject: [PATCH 1/3] added support for validator-related queries in staking module --- cosmrs/src/staking.rs | 22 +++- cosmrs/src/staking/commission.rs | 49 +++++++++ cosmrs/src/staking/commission_rates.rs | 35 ++++++ cosmrs/src/staking/description.rs | 44 ++++++++ cosmrs/src/staking/historical_info.rs | 40 +++++++ .../staking/query_historical_info_request.rs | 29 +++++ .../staking/query_historical_info_response.rs | 34 ++++++ cosmrs/src/staking/query_validator_request.rs | 28 +++++ .../src/staking/query_validator_response.rs | 29 +++++ .../src/staking/query_validators_request.rs | 34 ++++++ .../src/staking/query_validators_response.rs | 43 ++++++++ cosmrs/src/staking/validator.rs | 102 ++++++++++++++++++ 12 files changed, 487 insertions(+), 2 deletions(-) create mode 100644 cosmrs/src/staking/commission.rs create mode 100644 cosmrs/src/staking/commission_rates.rs create mode 100644 cosmrs/src/staking/description.rs create mode 100644 cosmrs/src/staking/historical_info.rs create mode 100644 cosmrs/src/staking/query_historical_info_request.rs create mode 100644 cosmrs/src/staking/query_historical_info_response.rs create mode 100644 cosmrs/src/staking/query_validator_request.rs create mode 100644 cosmrs/src/staking/query_validator_response.rs create mode 100644 cosmrs/src/staking/query_validators_request.rs create mode 100644 cosmrs/src/staking/query_validators_response.rs create mode 100644 cosmrs/src/staking/validator.rs diff --git a/cosmrs/src/staking.rs b/cosmrs/src/staking.rs index 00f91a3b..6abd61f6 100644 --- a/cosmrs/src/staking.rs +++ b/cosmrs/src/staking.rs @@ -2,11 +2,29 @@ //! //! +mod commission; +mod commission_rates; +mod description; +mod historical_info; mod msg_begin_redelegate; mod msg_delegate; mod msg_undelegate; +mod query_historical_info_request; +mod query_historical_info_response; +mod query_validator_request; +mod query_validator_response; +mod query_validators_request; +mod query_validators_response; +mod validator; pub use self::{ - msg_begin_redelegate::MsgBeginRedelegate, msg_delegate::MsgDelegate, - msg_undelegate::MsgUndelegate, + commission::Commission, commission_rates::CommissionRates, description::Description, + historical_info::HistoricalInfo, msg_begin_redelegate::MsgBeginRedelegate, + msg_delegate::MsgDelegate, msg_undelegate::MsgUndelegate, + query_historical_info_request::QueryHistoricalInfoRequest, + query_historical_info_response::QueryHistoricalInfoResponse, + query_validator_request::QueryValidatorRequest, + query_validator_response::QueryValidatorResponse, + query_validators_request::QueryValidatorsRequest, + query_validators_response::QueryValidatorsResponse, validator::Validator, }; diff --git a/cosmrs/src/staking/commission.rs b/cosmrs/src/staking/commission.rs new file mode 100644 index 00000000..67471f2c --- /dev/null +++ b/cosmrs/src/staking/commission.rs @@ -0,0 +1,49 @@ +use crate::staking::CommissionRates; +use crate::{proto, ErrorReport, Result}; +use cosmos_sdk_proto::Timestamp; +use tendermint::Time; + +/// Commission defines commission parameters for a given validator. +#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] +pub struct Commission { + /// commission_rates defines the initial commission rates to be used for creating a validator. + pub commission_rates: Option, + + /// update_time is the last time the commission rate was changed. + pub update_time: Option