Skip to content

Commit

Permalink
Remove ibc3 feature
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Oct 6, 2023
1 parent 03edcaa commit 4ab25f2
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 39 deletions.
17 changes: 12 additions & 5 deletions contracts/ibc-reflect-send/src/ibc.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use cosmwasm_std::{
entry_point, from_json, to_json_binary, DepsMut, Env, IbcBasicResponse, IbcChannelCloseMsg,
IbcChannelConnectMsg, IbcChannelOpenMsg, IbcMsg, IbcOrder, IbcPacketAckMsg,
IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, Never, StdError, StdResult,
entry_point, from_json, to_json_binary, DepsMut, Env, Ibc3ChannelOpenResponse,
IbcBasicResponse, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg,
IbcChannelOpenResponse, IbcMsg, IbcOrder, IbcPacketAckMsg, IbcPacketReceiveMsg,
IbcPacketTimeoutMsg, IbcReceiveResponse, Never, StdError, StdResult,
};

use crate::ibc_msg::{
Expand All @@ -17,7 +18,11 @@ pub const PACKET_LIFETIME: u64 = 60 * 60;

#[entry_point]
/// enforces ordering and versioing constraints
pub fn ibc_channel_open(_deps: DepsMut, _env: Env, msg: IbcChannelOpenMsg) -> StdResult<()> {
pub fn ibc_channel_open(
_deps: DepsMut,
_env: Env,
msg: IbcChannelOpenMsg,
) -> StdResult<IbcChannelOpenResponse> {
let channel = msg.channel();

if channel.order != IbcOrder::Ordered {
Expand All @@ -37,7 +42,9 @@ pub fn ibc_channel_open(_deps: DepsMut, _env: Env, msg: IbcChannelOpenMsg) -> St
}
}

Ok(())
Ok(Some(Ibc3ChannelOpenResponse {
version: IBC_APP_VERSION.to_string(),
}))
}

#[entry_point]
Expand Down
2 changes: 1 addition & 1 deletion contracts/ibc-reflect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ backtraces = ["cosmwasm-std/backtraces", "cosmwasm-vm/backtraces"]

[dependencies]
cosmwasm-schema = { path = "../../packages/schema" }
cosmwasm-std = { path = "../../packages/std", features = ["iterator", "ibc3"] }
cosmwasm-std = { path = "../../packages/std", features = ["iterator", "stargate"] }
schemars = "0.8.3"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }

Expand Down
1 change: 0 additions & 1 deletion docs/USING_COSMWASM_STD.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ The libarary comes with the following features:
| iterator | x | Storage iterators |
| abort | x | A panic handler that aborts the contract execution with a helpful message |
| stargate | | Cosmos SDK 0.40+ features and IBC |
| ibc3 | | New fields added in IBC v3 |
| staking | | Access to the staking module |
| backtraces | | Add backtraces to errors (for unit testing) |
| cosmwasm_1_1 | | Features that require CosmWasm 1.1+ on the chain |
Expand Down
2 changes: 1 addition & 1 deletion packages/go-gen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish = false

[dependencies]
schemars = "0.8.3"
cosmwasm-std = { path = "../std", version = "1.4.0", features = ["cosmwasm_1_4", "staking", "stargate", "ibc3"] }
cosmwasm-std = { path = "../std", version = "1.4.0", features = ["cosmwasm_1_4", "staking", "stargate"] }
cosmwasm-schema = { path = "../schema", version = "1.4.0" }
anyhow = "1"
Inflector = "0.11.4"
Expand Down
5 changes: 1 addition & 4 deletions packages/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license = "Apache-2.0"
readme = "README.md"

[package.metadata.docs.rs]
features = ["abort", "stargate", "staking", "ibc3", "cosmwasm_1_3"]
features = ["abort", "stargate", "staking", "cosmwasm_1_3"]

[features]
default = ["iterator", "abort"]
Expand All @@ -30,9 +30,6 @@ backtraces = []
# stargate enables stargate-dependent messages and queries, like raw protobuf messages
# as well as ibc-related functionality
stargate = []
# ibc3 extends ibc messages with ibc-v3 only features. This should only be enabled on contracts
# that require these types. Without this, they get the smaller ibc-v1 API.
ibc3 = ["stargate"]
# This feature makes `BankQuery::Supply` available for the contract to call, but requires
# the host blockchain to run CosmWasm `1.1.0` or higher.
cosmwasm_1_1 = []
Expand Down
8 changes: 4 additions & 4 deletions packages/std/src/exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ use serde::de::DeserializeOwned;
use crate::deps::OwnedDeps;
#[cfg(feature = "stargate")]
use crate::ibc::{
IbcBasicResponse, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, IbcPacketAckMsg,
IbcBasicResponse, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcPacketAckMsg,
IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse,
};
use crate::ibc::{IbcChannelOpenMsg, IbcChannelOpenResponse};
use crate::imports::{ExternalApi, ExternalQuerier, ExternalStorage};
use crate::memory::{alloc, consume_region, release_buffer, Region};
#[cfg(feature = "abort")]
Expand Down Expand Up @@ -528,12 +529,11 @@ where
query_fn(deps.as_ref(), env, msg).into()
}

#[cfg(feature = "stargate")]
fn _do_ibc_channel_open<Q, E>(
contract_fn: &dyn Fn(DepsMut<Q>, Env, IbcChannelOpenMsg) -> Result<(), E>,
contract_fn: &dyn Fn(DepsMut<Q>, Env, IbcChannelOpenMsg) -> Result<IbcChannelOpenResponse, E>,
env_ptr: *mut Region,
msg_ptr: *mut Region,
) -> ContractResult<()>
) -> ContractResult<IbcChannelOpenResponse>
where
Q: CustomQuery,
E: ToString,
Expand Down
8 changes: 0 additions & 8 deletions packages/std/src/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use core::cmp::{Ord, Ordering, PartialOrd};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

#[cfg(feature = "ibc3")]
use crate::addresses::Addr;
use crate::binary::Binary;
use crate::coin::Coin;
Expand Down Expand Up @@ -298,7 +297,6 @@ impl From<IbcChannelOpenMsg> for IbcChannel {
}

/// This serializes either as "null" or a JSON object.
#[cfg(feature = "ibc3")]
pub type IbcChannelOpenResponse = Option<Ibc3ChannelOpenResponse>;

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
Expand Down Expand Up @@ -400,12 +398,10 @@ impl From<IbcChannelCloseMsg> for IbcChannel {
#[non_exhaustive]
pub struct IbcPacketReceiveMsg {
pub packet: IbcPacket,
#[cfg(feature = "ibc3")]
pub relayer: Addr,
}

impl IbcPacketReceiveMsg {
#[cfg(feature = "ibc3")]
pub fn new(packet: IbcPacket, relayer: Addr) -> Self {
Self { packet, relayer }
}
Expand All @@ -417,12 +413,10 @@ impl IbcPacketReceiveMsg {
pub struct IbcPacketAckMsg {
pub acknowledgement: IbcAcknowledgement,
pub original_packet: IbcPacket,
#[cfg(feature = "ibc3")]
pub relayer: Addr,
}

impl IbcPacketAckMsg {
#[cfg(feature = "ibc3")]
pub fn new(
acknowledgement: IbcAcknowledgement,
original_packet: IbcPacket,
Expand All @@ -441,12 +435,10 @@ impl IbcPacketAckMsg {
#[non_exhaustive]
pub struct IbcPacketTimeoutMsg {
pub packet: IbcPacket,
#[cfg(feature = "ibc3")]
pub relayer: Addr,
}

impl IbcPacketTimeoutMsg {
#[cfg(feature = "ibc3")]
pub fn new(packet: IbcPacket, relayer: Addr) -> Self {
Self { packet, relayer }
}
Expand Down
1 change: 0 additions & 1 deletion packages/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ 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,
Expand Down
16 changes: 7 additions & 9 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 = "ibc3")]
#[cfg(feature = "stargate")]
use serde::Serialize;
#[cfg(feature = "cosmwasm_1_3")]
use std::collections::BTreeSet;
Expand All @@ -14,7 +14,7 @@ use crate::binary::Binary;
use crate::coin::Coin;
use crate::deps::OwnedDeps;
use crate::errors::{RecoverPubkeyError, StdError, StdResult, SystemError, VerificationError};
#[cfg(feature = "ibc3")]
#[cfg(feature = "stargate")]
use crate::ibc::{
IbcAcknowledgement, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg,
IbcTimeoutBlock,
Expand Down Expand Up @@ -356,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 = "ibc3")]
#[cfg(feature = "stargate")]
pub fn mock_ibc_packet_recv(
my_channel_id: &str,
data: &impl Serialize,
Expand All @@ -379,15 +379,14 @@ pub fn mock_ibc_packet_recv(
}
.into(),
},
#[cfg(feature = "ibc3")]
Addr::unchecked("relayer"),
))
}

/// 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 = "ibc3")]
#[cfg(feature = "stargate")]
fn mock_ibc_packet(my_channel_id: &str, data: &impl Serialize) -> StdResult<IbcPacket> {
Ok(IbcPacket {
data: to_json_binary(data)?,
Expand All @@ -411,7 +410,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 = "ibc3")]
#[cfg(feature = "stargate")]
pub fn mock_ibc_packet_ack(
my_channel_id: &str,
data: &impl Serialize,
Expand All @@ -422,15 +421,14 @@ pub fn mock_ibc_packet_ack(
Ok(IbcPacketAckMsg::new(
ack,
packet,
#[cfg(feature = "ibc3")]
Addr::unchecked("relayer"),
))
}

/// 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 = "ibc3")]
/// The difference from mock_ibc_packet_recv is if `my_channel_id` is src or dest.
#[cfg(feature = "stargate")]
pub fn mock_ibc_packet_timeout(
my_channel_id: &str,
data: &impl Serialize,
Expand Down
4 changes: 1 addition & 3 deletions packages/std/src/testing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ 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_channel_open_try, mock_ibc_packet_ack, mock_ibc_packet_recv, mock_ibc_packet_timeout,
};
#[cfg(feature = "ibc3")]
pub use mock::{mock_ibc_packet_ack, mock_ibc_packet_recv, mock_ibc_packet_timeout};
pub use shuffle::riffle_shuffle;
2 changes: 1 addition & 1 deletion packages/vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ backtraces = []
iterator = ["cosmwasm-std/iterator"]
staking = ["cosmwasm-std/staking"]
# this enables all stargate-related functionality, including the ibc entry points
stargate = ["cosmwasm-std/stargate", "cosmwasm-std/ibc3"]
stargate = ["cosmwasm-std/stargate"]
# Use cranelift backend instead of singlepass. This is required for development on Windows.
cranelift = ["wasmer/cranelift"]
# It's a bit unclear if interface_version_7 (CosmWasm 0.16) contracts are fully compatible
Expand Down
1 change: 0 additions & 1 deletion packages/vm/src/calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,6 @@ 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,
Expand Down

0 comments on commit 4ab25f2

Please sign in to comment.