Skip to content

Commit

Permalink
Remove old ibc functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Oct 6, 2023
1 parent 31c8b9f commit 03edcaa
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 44 deletions.
9 changes: 4 additions & 5 deletions packages/std/src/exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -531,10 +530,10 @@ where

#[cfg(feature = "stargate")]
fn _do_ibc_channel_open<Q, E>(
contract_fn: &dyn Fn(DepsMut<Q>, Env, IbcChannelOpenMsg) -> Result<IbcChannelOpenResponse, E>,
contract_fn: &dyn Fn(DepsMut<Q>, Env, IbcChannelOpenMsg) -> Result<(), E>,
env_ptr: *mut Region,
msg_ptr: *mut Region,
) -> ContractResult<IbcChannelOpenResponse>
) -> ContractResult<()>
where
Q: CustomQuery,
E: ToString,
Expand Down
21 changes: 0 additions & 21 deletions packages/std/src/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,6 @@ impl From<IbcChannelOpenMsg> 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<Ibc3ChannelOpenResponse>;
Expand Down Expand Up @@ -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 }
Expand All @@ -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,
Expand All @@ -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 }
Expand Down
8 changes: 5 additions & 3 deletions packages/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
25 changes: 12 additions & 13 deletions packages/std/src/testing/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<IbcPacket> {
Ok(IbcPacket {
data: to_json_binary(data)?,
Expand All @@ -408,7 +411,7 @@ fn mock_ibc_packet(my_channel_id: &str, data: &impl Serialize) -> StdResult<IbcP
/// Creates a IbcPacketAckMsg for testing ibc_packet_ack. 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")]
pub fn mock_ibc_packet_ack(
my_channel_id: &str,
data: &impl Serialize,
Expand All @@ -427,17 +430,13 @@ pub fn mock_ibc_packet_ack(
/// Creates a IbcPacketTimeoutMsg for testing ibc_packet_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")]
pub fn mock_ibc_packet_timeout(
my_channel_id: &str,
data: &impl Serialize,
) -> StdResult<IbcPacketTimeoutMsg> {
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
Expand Down
4 changes: 3 additions & 1 deletion packages/std/src/testing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
4 changes: 3 additions & 1 deletion packages/vm/src/calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 03edcaa

Please sign in to comment.