diff --git a/contracts/ibc-reflect-send/src/ibc.rs b/contracts/ibc-reflect-send/src/ibc.rs index 6faabd5c10..2a33b9aed6 100644 --- a/contracts/ibc-reflect-send/src/ibc.rs +++ b/contracts/ibc-reflect-send/src/ibc.rs @@ -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::{ @@ -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 { let channel = msg.channel(); if channel.order != IbcOrder::Ordered { @@ -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] diff --git a/contracts/ibc-reflect/Cargo.toml b/contracts/ibc-reflect/Cargo.toml index ead27d3725..cd16b206e3 100644 --- a/contracts/ibc-reflect/Cargo.toml +++ b/contracts/ibc-reflect/Cargo.toml @@ -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"] } diff --git a/docs/USING_COSMWASM_STD.md b/docs/USING_COSMWASM_STD.md index 19a04bdb66..49cf3511d4 100644 --- a/docs/USING_COSMWASM_STD.md +++ b/docs/USING_COSMWASM_STD.md @@ -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 | diff --git a/packages/go-gen/Cargo.toml b/packages/go-gen/Cargo.toml index 99693a0c37..a432ce0821 100644 --- a/packages/go-gen/Cargo.toml +++ b/packages/go-gen/Cargo.toml @@ -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" diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 323b73b70c..94246b2096 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -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"] @@ -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 = [] diff --git a/packages/std/src/exports.rs b/packages/std/src/exports.rs index 279b9d8bb3..9cbd92fb8e 100644 --- a/packages/std/src/exports.rs +++ b/packages/std/src/exports.rs @@ -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")] @@ -528,12 +529,11 @@ where query_fn(deps.as_ref(), env, msg).into() } -#[cfg(feature = "stargate")] fn _do_ibc_channel_open( - contract_fn: &dyn Fn(DepsMut, Env, IbcChannelOpenMsg) -> Result<(), E>, + contract_fn: &dyn Fn(DepsMut, Env, IbcChannelOpenMsg) -> Result, 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 e66655bf47..a77a57a0f1 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -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; @@ -298,7 +297,6 @@ impl From for IbcChannel { } /// This serializes either as "null" or a JSON object. -#[cfg(feature = "ibc3")] pub type IbcChannelOpenResponse = Option; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] @@ -400,12 +398,10 @@ impl From 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 } } @@ -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, @@ -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 } } diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index a2819f5f1e..0d49f1d5dd 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -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, diff --git a/packages/std/src/testing/mock.rs b/packages/std/src/testing/mock.rs index d19e384d09..2b17a05297 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 = "ibc3")] +#[cfg(feature = "stargate")] use serde::Serialize; #[cfg(feature = "cosmwasm_1_3")] use std::collections::BTreeSet; @@ -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, @@ -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, @@ -379,7 +379,6 @@ pub fn mock_ibc_packet_recv( } .into(), }, - #[cfg(feature = "ibc3")] Addr::unchecked("relayer"), )) } @@ -387,7 +386,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 = "ibc3")] +#[cfg(feature = "stargate")] fn mock_ibc_packet(my_channel_id: &str, data: &impl Serialize) -> StdResult { Ok(IbcPacket { data: to_json_binary(data)?, @@ -411,7 +410,7 @@ fn mock_ibc_packet(my_channel_id: &str, data: &impl Serialize) -> StdResult