@@ -11,9 +11,12 @@ use crate::errors::{RecoverPubkeyError, StdError, StdResult, SystemError, Verifi
1111#[ cfg( feature = "stargate" ) ]
1212use crate :: ibc:: { IbcChannel , IbcEndpoint , IbcOrder , IbcPacket , IbcTimeoutBlock } ;
1313use 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 ,
1720} ;
1821use crate :: results:: { ContractResult , Empty , SystemResult } ;
1922use crate :: serde:: { from_slice, to_binary} ;
@@ -280,6 +283,7 @@ pub type MockQuerierCustomHandlerResult = SystemResult<ContractResult<Binary>>;
280283/// TODO: also allow querying contracts
281284pub struct MockQuerier < C : DeserializeOwned = Empty > {
282285 bank : BankQuerier ,
286+ #[ cfg( feature = "staking" ) ]
283287 staking : StakingQuerier ,
284288 // placeholder to add support later
285289 wasm : NoWasmQuerier ,
@@ -294,6 +298,7 @@ impl<C: DeserializeOwned> MockQuerier<C> {
294298 pub fn new ( balances : & [ ( & str , & [ Coin ] ) ] ) -> Self {
295299 MockQuerier {
296300 bank : BankQuerier :: new ( balances) ,
301+ #[ cfg( feature = "staking" ) ]
297302 staking : StakingQuerier :: default ( ) ,
298303 wasm : NoWasmQuerier { } ,
299304 // 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> {
353358 match & request {
354359 QueryRequest :: Bank ( bank_query) => self . bank . query ( bank_query) ,
355360 QueryRequest :: Custom ( custom_query) => ( * self . custom_handler ) ( custom_query) ,
361+ #[ cfg( feature = "staking" ) ]
356362 QueryRequest :: Staking ( staking_query) => self . staking . query ( staking_query) ,
357363 QueryRequest :: Wasm ( msg) => self . wasm . query ( msg) ,
358364 #[ cfg( feature = "stargate" ) ]
@@ -427,13 +433,15 @@ impl BankQuerier {
427433 }
428434}
429435
436+ #[ cfg( feature = "staking" ) ]
430437#[ derive( Clone , Default ) ]
431438pub struct StakingQuerier {
432439 denom : String ,
433440 validators : Vec < Validator > ,
434441 delegations : Vec < FullDelegation > ,
435442}
436443
444+ #[ cfg( feature = "staking" ) ]
437445impl StakingQuerier {
438446 pub fn new ( denom : & str , validators : & [ Validator ] , delegations : & [ FullDelegation ] ) -> Self {
439447 StakingQuerier {
@@ -513,8 +521,9 @@ pub fn digit_sum(input: &[u8]) -> usize {
513521#[ cfg( test) ]
514522mod tests {
515523 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 } ;
518527 use hex_literal:: hex;
519528
520529 const SECP256K1_MSG_HASH_HEX : & str =
@@ -863,6 +872,7 @@ mod tests {
863872 assert_eq ! ( res. amount, coin( 0 , "ELF" ) ) ;
864873 }
865874
875+ #[ cfg( feature = "staking" ) ]
866876 #[ test]
867877 fn staking_querier_validators ( ) {
868878 let val1 = Validator {
@@ -889,6 +899,7 @@ mod tests {
889899 assert_eq ! ( vals. validators, vec![ val1, val2] ) ;
890900 }
891901
902+ #[ cfg( feature = "staking" ) ]
892903 // gets delegators from query or panic
893904 fn get_all_delegators < U : Into < String > > (
894905 staking : & StakingQuerier ,
@@ -904,6 +915,7 @@ mod tests {
904915 dels. delegations
905916 }
906917
918+ #[ cfg( feature = "staking" ) ]
907919 // gets full delegators from query or panic
908920 fn get_delegator < U : Into < String > , V : Into < String > > (
909921 staking : & StakingQuerier ,
@@ -921,6 +933,7 @@ mod tests {
921933 dels. delegation
922934 }
923935
936+ #[ cfg( feature = "staking" ) ]
924937 #[ test]
925938 fn staking_querier_delegations ( ) {
926939 let val1 = String :: from ( "validator-one" ) ;
0 commit comments