diff --git a/packages/std/src/exports.rs b/packages/std/src/exports.rs index c745bc82e7..279b9d8bb3 100644 --- a/packages/std/src/exports.rs +++ b/packages/std/src/exports.rs @@ -15,9 +15,8 @@ use serde::de::DeserializeOwned; use crate::deps::OwnedDeps; #[cfg(feature = "stargate")] use crate::ibc::{ - IbcBasicResponse, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, - IbcChannelOpenResponse, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, - IbcReceiveResponse, + IbcBasicResponse, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, IbcPacketAckMsg, + IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, }; use crate::imports::{ExternalApi, ExternalQuerier, ExternalStorage}; use crate::memory::{alloc, consume_region, release_buffer, Region}; @@ -531,10 +530,10 @@ where #[cfg(feature = "stargate")] fn _do_ibc_channel_open( - contract_fn: &dyn Fn(DepsMut, Env, IbcChannelOpenMsg) -> Result, + contract_fn: &dyn Fn(DepsMut, Env, IbcChannelOpenMsg) -> Result<(), E>, env_ptr: *mut Region, msg_ptr: *mut Region, -) -> ContractResult +) -> ContractResult<()> where Q: CustomQuery, E: ToString, diff --git a/packages/std/src/ibc.rs b/packages/std/src/ibc.rs index 1ad33e3667..e66655bf47 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -297,9 +297,6 @@ impl From for IbcChannel { } } -/// Note that this serializes as "null". -#[cfg(not(feature = "ibc3"))] -pub type IbcChannelOpenResponse = (); /// This serializes either as "null" or a JSON object. #[cfg(feature = "ibc3")] pub type IbcChannelOpenResponse = Option; @@ -408,11 +405,6 @@ pub struct IbcPacketReceiveMsg { } impl IbcPacketReceiveMsg { - #[cfg(not(feature = "ibc3"))] - pub fn new(packet: IbcPacket) -> Self { - Self { packet } - } - #[cfg(feature = "ibc3")] pub fn new(packet: IbcPacket, relayer: Addr) -> Self { Self { packet, relayer } @@ -430,14 +422,6 @@ pub struct IbcPacketAckMsg { } impl IbcPacketAckMsg { - #[cfg(not(feature = "ibc3"))] - pub fn new(acknowledgement: IbcAcknowledgement, original_packet: IbcPacket) -> Self { - Self { - acknowledgement, - original_packet, - } - } - #[cfg(feature = "ibc3")] pub fn new( acknowledgement: IbcAcknowledgement, @@ -462,11 +446,6 @@ pub struct IbcPacketTimeoutMsg { } impl IbcPacketTimeoutMsg { - #[cfg(not(feature = "ibc3"))] - pub fn new(packet: IbcPacket) -> Self { - Self { packet } - } - #[cfg(feature = "ibc3")] pub fn new(packet: IbcPacket, relayer: Addr) -> Self { Self { packet, relayer } diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index dcf106b96e..a2819f5f1e 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -51,11 +51,13 @@ pub use crate::errors::{ VerificationError, }; pub use crate::hex_binary::HexBinary; +#[cfg(feature = "ibc3")] +pub use crate::ibc::IbcChannelOpenResponse; pub use crate::ibc::{ Ibc3ChannelOpenResponse, IbcAcknowledgement, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, - IbcChannelConnectMsg, IbcChannelOpenMsg, IbcChannelOpenResponse, IbcEndpoint, IbcMsg, IbcOrder, - IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, - IbcTimeout, IbcTimeoutBlock, + IbcChannelConnectMsg, IbcChannelOpenMsg, IbcEndpoint, IbcMsg, IbcOrder, IbcPacket, + IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, IbcTimeout, + IbcTimeoutBlock, }; #[cfg(feature = "iterator")] pub use crate::iterator::{Order, Record}; diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index d2ca6d65f6..d19e384d09 100644 --- a/packages/std/src/testing/mock.rs +++ b/packages/std/src/testing/mock.rs @@ -3,7 +3,7 @@ use core::marker::PhantomData; #[cfg(feature = "cosmwasm_1_3")] use core::ops::Bound; use serde::de::DeserializeOwned; -#[cfg(feature = "stargate")] +#[cfg(feature = "ibc3")] use serde::Serialize; #[cfg(feature = "cosmwasm_1_3")] use std::collections::BTreeSet; @@ -14,12 +14,15 @@ use crate::binary::Binary; use crate::coin::Coin; use crate::deps::OwnedDeps; use crate::errors::{RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError}; -#[cfg(feature = "stargate")] +#[cfg(feature = "ibc3")] use crate::ibc::{ - IbcAcknowledgement, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, - IbcEndpoint, IbcOrder, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, + IbcAcknowledgement, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcTimeoutBlock, }; +#[cfg(feature = "stargate")] +use crate::ibc::{ + IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, IbcEndpoint, IbcOrder, +}; use crate::math::Uint128; #[cfg(feature = "cosmwasm_1_1")] use crate::query::SupplyResponse; @@ -353,7 +356,7 @@ pub fn mock_ibc_channel_close_confirm( /// Creates a IbcPacketReceiveMsg for testing ibc_packet_receive. You set a few key parameters that are /// often parsed. If you want to set more, use this as a default and mutate other fields -#[cfg(feature = "stargate")] +#[cfg(feature = "ibc3")] pub fn mock_ibc_packet_recv( my_channel_id: &str, data: &impl Serialize, @@ -384,7 +387,7 @@ pub fn mock_ibc_packet_recv( /// Creates a IbcPacket for testing ibc_packet_{ack,timeout}. You set a few key parameters that are /// often parsed. If you want to set more, use this as a default and mutate other fields. /// The difference from mock_ibc_packet_recv is if `my_channel_id` is src or dest. -#[cfg(feature = "stargate")] +#[cfg(feature = "ibc3")] fn mock_ibc_packet(my_channel_id: &str, data: &impl Serialize) -> StdResult { Ok(IbcPacket { data: to_json_binary(data)?, @@ -408,7 +411,7 @@ fn mock_ibc_packet(my_channel_id: &str, data: &impl Serialize) -> StdResult StdResult { let packet = mock_ibc_packet(my_channel_id, data)?; - Ok(IbcPacketTimeoutMsg::new( - packet, - #[cfg(feature = "ibc3")] - Addr::unchecked("relayer"), - )) + Ok(IbcPacketTimeoutMsg::new(packet, Addr::unchecked("relayer"))) } /// The same type as cosmwasm-std's QuerierResult, but easier to reuse in diff --git a/packages/std/src/testing/mod.rs b/packages/std/src/testing/mod.rs index 14b362ce42..7977061e49 100644 --- a/packages/std/src/testing/mod.rs +++ b/packages/std/src/testing/mod.rs @@ -24,6 +24,8 @@ pub use mock::{ pub use mock::{ mock_ibc_channel, mock_ibc_channel_close_confirm, mock_ibc_channel_close_init, mock_ibc_channel_connect_ack, mock_ibc_channel_connect_confirm, mock_ibc_channel_open_init, - mock_ibc_channel_open_try, mock_ibc_packet_ack, mock_ibc_packet_recv, mock_ibc_packet_timeout, + mock_ibc_channel_open_try, }; +#[cfg(feature = "ibc3")] +pub use mock::{mock_ibc_packet_ack, mock_ibc_packet_recv, mock_ibc_packet_timeout}; pub use shuffle::riffle_shuffle; diff --git a/packages/vm/src/calls.rs b/packages/vm/src/calls.rs index 3f3037b8e0..05501d2b31 100644 --- a/packages/vm/src/calls.rs +++ b/packages/vm/src/calls.rs @@ -825,9 +825,11 @@ mod tests { use crate::testing::{ mock_env, mock_info, mock_instance, MockApi, MockQuerier, MockStorage, }; + #[cfg(feature = "ibc3")] + use cosmwasm_std::testing::mock_ibc_packet_timeout; use cosmwasm_std::testing::{ mock_ibc_channel_close_init, mock_ibc_channel_connect_ack, mock_ibc_channel_open_init, - mock_ibc_packet_ack, mock_ibc_packet_recv, mock_ibc_packet_timeout, mock_wasmd_attr, + mock_ibc_packet_ack, mock_ibc_packet_recv, mock_wasmd_attr, }; use cosmwasm_std::{ Empty, Event, IbcAcknowledgement, IbcOrder, Reply, ReplyOn, SubMsgResponse,