@@ -11,9 +11,12 @@ use crate::errors::{RecoverPubkeyError, StdError, StdResult, SystemError, Verifi
11
11
#[ cfg( feature = "stargate" ) ]
12
12
use crate :: ibc:: { IbcChannel , IbcEndpoint , IbcOrder , IbcPacket , IbcTimeoutBlock } ;
13
13
use crate :: query:: {
14
- AllBalanceResponse , AllDelegationsResponse , BalanceResponse , BankQuery , BondedDenomResponse ,
15
- CustomQuery , DelegationResponse , FullDelegation , QueryRequest , StakingQuery , Validator ,
16
- ValidatorsResponse , WasmQuery ,
14
+ AllBalanceResponse , BalanceResponse , BankQuery , CustomQuery , QueryRequest , WasmQuery ,
15
+ } ;
16
+ #[ cfg( feature = "staking" ) ]
17
+ use crate :: query:: {
18
+ AllDelegationsResponse , BondedDenomResponse , DelegationResponse , FullDelegation , StakingQuery ,
19
+ Validator , ValidatorsResponse ,
17
20
} ;
18
21
use crate :: results:: { ContractResult , Empty , SystemResult } ;
19
22
use crate :: serde:: { from_slice, to_binary} ;
@@ -280,6 +283,7 @@ pub type MockQuerierCustomHandlerResult = SystemResult<ContractResult<Binary>>;
280
283
/// TODO: also allow querying contracts
281
284
pub struct MockQuerier < C : DeserializeOwned = Empty > {
282
285
bank : BankQuerier ,
286
+ #[ cfg( feature = "staking" ) ]
283
287
staking : StakingQuerier ,
284
288
// placeholder to add support later
285
289
wasm : NoWasmQuerier ,
@@ -294,6 +298,7 @@ impl<C: DeserializeOwned> MockQuerier<C> {
294
298
pub fn new ( balances : & [ ( & str , & [ Coin ] ) ] ) -> Self {
295
299
MockQuerier {
296
300
bank : BankQuerier :: new ( balances) ,
301
+ #[ cfg( feature = "staking" ) ]
297
302
staking : StakingQuerier :: default ( ) ,
298
303
wasm : NoWasmQuerier { } ,
299
304
// strange argument notation suggested as a workaround here: https://github.com/rust-lang/rust/issues/41078#issuecomment-294296365
@@ -353,6 +358,7 @@ impl<C: CustomQuery + DeserializeOwned> MockQuerier<C> {
353
358
match & request {
354
359
QueryRequest :: Bank ( bank_query) => self . bank . query ( bank_query) ,
355
360
QueryRequest :: Custom ( custom_query) => ( * self . custom_handler ) ( custom_query) ,
361
+ #[ cfg( feature = "staking" ) ]
356
362
QueryRequest :: Staking ( staking_query) => self . staking . query ( staking_query) ,
357
363
QueryRequest :: Wasm ( msg) => self . wasm . query ( msg) ,
358
364
#[ cfg( feature = "stargate" ) ]
@@ -427,13 +433,15 @@ impl BankQuerier {
427
433
}
428
434
}
429
435
436
+ #[ cfg( feature = "staking" ) ]
430
437
#[ derive( Clone , Default ) ]
431
438
pub struct StakingQuerier {
432
439
denom : String ,
433
440
validators : Vec < Validator > ,
434
441
delegations : Vec < FullDelegation > ,
435
442
}
436
443
444
+ #[ cfg( feature = "staking" ) ]
437
445
impl StakingQuerier {
438
446
pub fn new ( denom : & str , validators : & [ Validator ] , delegations : & [ FullDelegation ] ) -> Self {
439
447
StakingQuerier {
@@ -513,8 +521,9 @@ pub fn digit_sum(input: &[u8]) -> usize {
513
521
#[ cfg( test) ]
514
522
mod tests {
515
523
use super :: * ;
516
- use crate :: query:: Delegation ;
517
- use crate :: { coin, coins, from_binary, Decimal } ;
524
+ use crate :: { coin, coins, from_binary} ;
525
+ #[ cfg( feature = "staking" ) ]
526
+ use crate :: { Decimal , Delegation } ;
518
527
use hex_literal:: hex;
519
528
520
529
const SECP256K1_MSG_HASH_HEX : & str =
@@ -863,6 +872,7 @@ mod tests {
863
872
assert_eq ! ( res. amount, coin( 0 , "ELF" ) ) ;
864
873
}
865
874
875
+ #[ cfg( feature = "staking" ) ]
866
876
#[ test]
867
877
fn staking_querier_validators ( ) {
868
878
let val1 = Validator {
@@ -889,6 +899,7 @@ mod tests {
889
899
assert_eq ! ( vals. validators, vec![ val1, val2] ) ;
890
900
}
891
901
902
+ #[ cfg( feature = "staking" ) ]
892
903
// gets delegators from query or panic
893
904
fn get_all_delegators < U : Into < String > > (
894
905
staking : & StakingQuerier ,
@@ -904,6 +915,7 @@ mod tests {
904
915
dels. delegations
905
916
}
906
917
918
+ #[ cfg( feature = "staking" ) ]
907
919
// gets full delegators from query or panic
908
920
fn get_delegator < U : Into < String > , V : Into < String > > (
909
921
staking : & StakingQuerier ,
@@ -921,6 +933,7 @@ mod tests {
921
933
dels. delegation
922
934
}
923
935
936
+ #[ cfg( feature = "staking" ) ]
924
937
#[ test]
925
938
fn staking_querier_delegations ( ) {
926
939
let val1 = String :: from ( "validator-one" ) ;
0 commit comments