@@ -152,12 +152,12 @@ impl FullDelegation {
152152#[ derive( Serialize , Deserialize , Clone , Debug , PartialEq , Eq , JsonSchema ) ]
153153#[ non_exhaustive]
154154pub struct AllValidatorsResponse {
155- pub validators : Vec < Validator > ,
155+ pub validators : Vec < ValidatorMetadata > ,
156156}
157157
158158impl QueryResponseType for AllValidatorsResponse { }
159159
160- impl_hidden_constructor ! ( AllValidatorsResponse , validators: Vec <Validator >) ;
160+ impl_hidden_constructor ! ( AllValidatorsResponse , validators: Vec <ValidatorMetadata >) ;
161161
162162/// The data format returned from StakingRequest::Validator query
163163#[ derive( Serialize , Deserialize , Clone , Debug , PartialEq , Eq , JsonSchema ) ]
@@ -173,7 +173,7 @@ impl_hidden_constructor!(ValidatorResponse, validator: Option<Validator>);
173173/// Instances are created in the querier.
174174#[ derive( Serialize , Deserialize , Clone , Debug , PartialEq , Eq , JsonSchema ) ]
175175#[ non_exhaustive]
176- pub struct Validator {
176+ pub struct ValidatorMetadata {
177177 /// The operator address of the validator (e.g. cosmosvaloper1...).
178178 /// See https://github.com/cosmos/cosmos-sdk/blob/v0.47.4/proto/cosmos/staking/v1beta1/staking.proto#L95-L96
179179 /// for more information.
@@ -188,13 +188,30 @@ pub struct Validator {
188188}
189189
190190impl_hidden_constructor ! (
191- Validator ,
191+ ValidatorMetadata ,
192192 address: String ,
193193 commission: Decimal ,
194194 max_commission: Decimal ,
195195 max_change_rate: Decimal
196196) ;
197197
198+ /// Instances are created in the querier.
199+ #[ derive( Serialize , Deserialize , Clone , Debug , PartialEq , Eq , JsonSchema ) ]
200+ #[ non_exhaustive]
201+ pub struct Validator {
202+ /// The operator address of the validator (e.g. cosmosvaloper1...).
203+ /// See https://github.com/cosmos/cosmos-sdk/blob/v0.47.4/proto/cosmos/staking/v1beta1/staking.proto#L95-L96
204+ /// for more information.
205+ ///
206+ /// This uses `String` instead of `Addr` since the bech32 address prefix is different from
207+ /// the ones that regular user accounts use.
208+ pub address : String ,
209+ pub commission : Decimal ,
210+ pub max_commission : Decimal ,
211+ /// The maximum daily increase of the commission
212+ pub max_change_rate : Decimal ,
213+ }
214+
198215impl Validator {
199216 /// Creates a new validator.
200217 ///
@@ -214,3 +231,24 @@ impl Validator {
214231 }
215232 }
216233}
234+
235+ impl_hidden_constructor ! (
236+ Validator ,
237+ address: String ,
238+ commission: Decimal ,
239+ max_commission: Decimal ,
240+ max_change_rate: Decimal
241+ ) ;
242+
243+ // Validator should contain all data that ValidatorMetadata has + maybe some additional data
244+ // that is expensive to query, so we can convert ValidatorMetadata to Validator easily.
245+ impl From < Validator > for ValidatorMetadata {
246+ fn from ( validator : Validator ) -> Self {
247+ ValidatorMetadata {
248+ address : validator. address ,
249+ commission : validator. commission ,
250+ max_commission : validator. max_commission ,
251+ max_change_rate : validator. max_change_rate ,
252+ }
253+ }
254+ }
0 commit comments