@@ -152,12 +152,12 @@ impl FullDelegation {
152
152
#[ derive( Serialize , Deserialize , Clone , Debug , PartialEq , Eq , JsonSchema ) ]
153
153
#[ non_exhaustive]
154
154
pub struct AllValidatorsResponse {
155
- pub validators : Vec < Validator > ,
155
+ pub validators : Vec < ValidatorMetadata > ,
156
156
}
157
157
158
158
impl QueryResponseType for AllValidatorsResponse { }
159
159
160
- impl_hidden_constructor ! ( AllValidatorsResponse , validators: Vec <Validator >) ;
160
+ impl_hidden_constructor ! ( AllValidatorsResponse , validators: Vec <ValidatorMetadata >) ;
161
161
162
162
/// The data format returned from StakingRequest::Validator query
163
163
#[ derive( Serialize , Deserialize , Clone , Debug , PartialEq , Eq , JsonSchema ) ]
@@ -173,7 +173,7 @@ impl_hidden_constructor!(ValidatorResponse, validator: Option<Validator>);
173
173
/// Instances are created in the querier.
174
174
#[ derive( Serialize , Deserialize , Clone , Debug , PartialEq , Eq , JsonSchema ) ]
175
175
#[ non_exhaustive]
176
- pub struct Validator {
176
+ pub struct ValidatorMetadata {
177
177
/// The operator address of the validator (e.g. cosmosvaloper1...).
178
178
/// See https://github.com/cosmos/cosmos-sdk/blob/v0.47.4/proto/cosmos/staking/v1beta1/staking.proto#L95-L96
179
179
/// for more information.
@@ -188,13 +188,30 @@ pub struct Validator {
188
188
}
189
189
190
190
impl_hidden_constructor ! (
191
- Validator ,
191
+ ValidatorMetadata ,
192
192
address: String ,
193
193
commission: Decimal ,
194
194
max_commission: Decimal ,
195
195
max_change_rate: Decimal
196
196
) ;
197
197
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
+
198
215
impl Validator {
199
216
/// Creates a new validator.
200
217
///
@@ -214,3 +231,24 @@ impl Validator {
214
231
}
215
232
}
216
233
}
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