@@ -34,6 +34,7 @@ pub enum CosmosMsg<T = Empty> {
3434 Staking ( StakingMsg ) ,
3535 #[ cfg( feature = "staking" ) ]
3636 Distribution ( DistributionMsg ) ,
37+ #[ cfg( feature = "cosmwasm_2_0" ) ]
3738 Any ( AnyMsg ) ,
3839 #[ cfg( feature = "stargate" ) ]
3940 Ibc ( IbcMsg ) ,
@@ -385,6 +386,7 @@ impl<T> From<DistributionMsg> for CosmosMsg<T> {
385386
386387// By implementing `From<MyType> for cosmwasm_std::AnyMsg`,
387388// you automatically get a MyType -> CosmosMsg conversion.
389+ #[ cfg( feature = "cosmwasm_2_0" ) ]
388390impl < S : Into < AnyMsg > , T > From < S > for CosmosMsg < T > {
389391 fn from ( source : S ) -> Self {
390392 CosmosMsg :: < T > :: Any ( source. into ( ) )
@@ -414,7 +416,7 @@ impl<T> From<GovMsg> for CosmosMsg<T> {
414416#[ cfg( test) ]
415417mod tests {
416418 use super :: * ;
417- use crate :: { coin, coins, to_json_string } ;
419+ use crate :: { coin, coins} ;
418420
419421 #[ test]
420422 fn from_bank_msg_works ( ) {
@@ -429,6 +431,7 @@ mod tests {
429431 }
430432
431433 #[ test]
434+ #[ cfg( feature = "cosmwasm_2_0" ) ]
432435 fn from_any_msg_works ( ) {
433436 // should work with AnyMsg
434437 let any = AnyMsg {
@@ -519,13 +522,14 @@ mod tests {
519522 }
520523
521524 #[ test]
525+ #[ cfg( feature = "cosmwasm_2_0" ) ]
522526 fn any_msg_serializes_to_correct_json ( ) {
523527 // Same serialization as CosmosMsg::Stargate (see above), except the top level key
524528 let msg: CosmosMsg = CosmosMsg :: Any ( AnyMsg {
525529 type_url : "/cosmos.foo.v1beta.MsgBar" . to_string ( ) ,
526530 value : Binary :: from_base64 ( "5yu/rQ+HrMcxH1zdga7P5hpGMLE=" ) . unwrap ( ) ,
527531 } ) ;
528- let json = to_json_string ( & msg) . unwrap ( ) ;
532+ let json = crate :: to_json_string ( & msg) . unwrap ( ) ;
529533 assert_eq ! (
530534 json,
531535 r#"{"any":{"type_url":"/cosmos.foo.v1beta.MsgBar","value":"5yu/rQ+HrMcxH1zdga7P5hpGMLE="}}"# ,
0 commit comments