diff --git a/.circleci/config.yml b/.circleci/config.yml index b1cb18cd7b..e1144eec9a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -726,7 +726,7 @@ jobs: keys: - cargocache-v2-contract_ibc_callbacks-rust:1.74-{{ checksum "Cargo.lock" }} - check_contract: - min_version: "2.1" + min_version: "3.0" - save_cache: paths: - /usr/local/cargo/registry @@ -1120,7 +1120,7 @@ jobs: name: Clippy linting on std (all feature flags) working_directory: ~/project/packages/std # change to --all-features once `abort` is removed - command: cargo clippy --all-targets --tests --features staking,stargate,cosmwasm_2_2 -- -D warnings + command: cargo clippy --all-targets --tests --features staking,stargate,cosmwasm_3_0 -- -D warnings - run: name: Clippy linting on vm (no feature flags) working_directory: ~/project/packages/vm diff --git a/contracts/ibc-callbacks/Cargo.toml b/contracts/ibc-callbacks/Cargo.toml index d839475e2c..989f1ee432 100644 --- a/contracts/ibc-callbacks/Cargo.toml +++ b/contracts/ibc-callbacks/Cargo.toml @@ -27,6 +27,7 @@ cosmwasm-schema = { path = "../../packages/schema" } cosmwasm-std = { path = "../../packages/std", features = [ "iterator", "stargate", + "cosmwasm_3_0", ] } schemars = "0.8.3" serde = { version = "1.0.103", default-features = false, features = ["derive"] } diff --git a/contracts/ibc-reflect-send/schema/ibc-reflect-send.json b/contracts/ibc-reflect-send/schema/ibc-reflect-send.json index c05a88159f..3c91ffab8e 100644 --- a/contracts/ibc-reflect-send/schema/ibc-reflect-send.json +++ b/contracts/ibc-reflect-send/schema/ibc-reflect-send.json @@ -402,22 +402,6 @@ } ] }, - "Hop": { - "type": "object", - "required": [ - "channel_id", - "port_id" - ], - "properties": { - "channel_id": { - "type": "string" - }, - "port_id": { - "type": "string" - } - }, - "additionalProperties": false - }, "IbcMsg": { "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", "oneOf": [ @@ -474,65 +458,6 @@ }, "additionalProperties": false }, - { - "description": "Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to.", - "type": "object", - "required": [ - "transfer_v2" - ], - "properties": { - "transfer_v2": { - "type": "object", - "required": [ - "channel_id", - "forwarding", - "timeout", - "to_address", - "tokens" - ], - "properties": { - "channel_id": { - "description": "existing channel to send the tokens over", - "type": "string" - }, - "forwarding": { - "type": "array", - "items": { - "$ref": "#/definitions/Hop" - } - }, - "memo": { - "description": "An optional memo. See the blog post [\"Moving Beyond Simple Token Transfers\"](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b) for more information.\n\nThere is no difference between setting this to `None` or an empty string.\n\nThis field is only supported on chains with CosmWasm >= 2.0 and silently ignored on older chains. If you need support for both 1.x and 2.x chain with the same codebase, it is recommended to use `CosmosMsg::Stargate` with a custom MsgTransfer protobuf encoder instead.", - "type": [ - "string", - "null" - ] - }, - "timeout": { - "description": "when packet times out, measured on remote chain", - "allOf": [ - { - "$ref": "#/definitions/IbcTimeout" - } - ] - }, - "to_address": { - "description": "address on the remote chain to receive these tokens", - "type": "string" - }, - "tokens": { - "description": "MsgTransfer in v2 version supports multiple coins", - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, { "description": "Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.", "type": "object", diff --git a/contracts/ibc-reflect-send/schema/ibc/packet_msg.json b/contracts/ibc-reflect-send/schema/ibc/packet_msg.json index a46034252b..974ced2dc5 100644 --- a/contracts/ibc-reflect-send/schema/ibc/packet_msg.json +++ b/contracts/ibc-reflect-send/schema/ibc/packet_msg.json @@ -343,22 +343,6 @@ } ] }, - "Hop": { - "type": "object", - "required": [ - "channel_id", - "port_id" - ], - "properties": { - "channel_id": { - "type": "string" - }, - "port_id": { - "type": "string" - } - }, - "additionalProperties": false - }, "IbcMsg": { "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", "oneOf": [ @@ -415,65 +399,6 @@ }, "additionalProperties": false }, - { - "description": "Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to.", - "type": "object", - "required": [ - "transfer_v2" - ], - "properties": { - "transfer_v2": { - "type": "object", - "required": [ - "channel_id", - "forwarding", - "timeout", - "to_address", - "tokens" - ], - "properties": { - "channel_id": { - "description": "existing channel to send the tokens over", - "type": "string" - }, - "forwarding": { - "type": "array", - "items": { - "$ref": "#/definitions/Hop" - } - }, - "memo": { - "description": "An optional memo. See the blog post [\"Moving Beyond Simple Token Transfers\"](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b) for more information.\n\nThere is no difference between setting this to `None` or an empty string.\n\nThis field is only supported on chains with CosmWasm >= 2.0 and silently ignored on older chains. If you need support for both 1.x and 2.x chain with the same codebase, it is recommended to use `CosmosMsg::Stargate` with a custom MsgTransfer protobuf encoder instead.", - "type": [ - "string", - "null" - ] - }, - "timeout": { - "description": "when packet times out, measured on remote chain", - "allOf": [ - { - "$ref": "#/definitions/IbcTimeout" - } - ] - }, - "to_address": { - "description": "address on the remote chain to receive these tokens", - "type": "string" - }, - "tokens": { - "description": "MsgTransfer in v2 version supports multiple coins", - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, { "description": "Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.", "type": "object", diff --git a/contracts/ibc-reflect-send/schema/raw/execute.json b/contracts/ibc-reflect-send/schema/raw/execute.json index 4fae1d499b..8841eded49 100644 --- a/contracts/ibc-reflect-send/schema/raw/execute.json +++ b/contracts/ibc-reflect-send/schema/raw/execute.json @@ -391,22 +391,6 @@ } ] }, - "Hop": { - "type": "object", - "required": [ - "channel_id", - "port_id" - ], - "properties": { - "channel_id": { - "type": "string" - }, - "port_id": { - "type": "string" - } - }, - "additionalProperties": false - }, "IbcMsg": { "description": "These are messages in the IBC lifecycle. Only usable by IBC-enabled contracts (contracts that directly speak the IBC protocol via 6 entry points)", "oneOf": [ @@ -463,65 +447,6 @@ }, "additionalProperties": false }, - { - "description": "Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to.", - "type": "object", - "required": [ - "transfer_v2" - ], - "properties": { - "transfer_v2": { - "type": "object", - "required": [ - "channel_id", - "forwarding", - "timeout", - "to_address", - "tokens" - ], - "properties": { - "channel_id": { - "description": "existing channel to send the tokens over", - "type": "string" - }, - "forwarding": { - "type": "array", - "items": { - "$ref": "#/definitions/Hop" - } - }, - "memo": { - "description": "An optional memo. See the blog post [\"Moving Beyond Simple Token Transfers\"](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b) for more information.\n\nThere is no difference between setting this to `None` or an empty string.\n\nThis field is only supported on chains with CosmWasm >= 2.0 and silently ignored on older chains. If you need support for both 1.x and 2.x chain with the same codebase, it is recommended to use `CosmosMsg::Stargate` with a custom MsgTransfer protobuf encoder instead.", - "type": [ - "string", - "null" - ] - }, - "timeout": { - "description": "when packet times out, measured on remote chain", - "allOf": [ - { - "$ref": "#/definitions/IbcTimeout" - } - ] - }, - "to_address": { - "description": "address on the remote chain to receive these tokens", - "type": "string" - }, - "tokens": { - "description": "MsgTransfer in v2 version supports multiple coins", - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, { "description": "Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.", "type": "object", diff --git a/contracts/ibc-reflect/schema/ibc/packet_msg.json b/contracts/ibc-reflect/schema/ibc/packet_msg.json index 4d43e9d4ed..eec0371bd4 100644 --- a/contracts/ibc-reflect/schema/ibc/packet_msg.json +++ b/contracts/ibc-reflect/schema/ibc/packet_msg.json @@ -403,22 +403,6 @@ } ] }, - "Hop": { - "type": "object", - "required": [ - "channel_id", - "port_id" - ], - "properties": { - "channel_id": { - "type": "string" - }, - "port_id": { - "type": "string" - } - }, - "additionalProperties": false - }, "IbcAcknowledgement": { "type": "object", "required": [ @@ -516,65 +500,6 @@ }, "additionalProperties": false }, - { - "description": "Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to.", - "type": "object", - "required": [ - "transfer_v2" - ], - "properties": { - "transfer_v2": { - "type": "object", - "required": [ - "channel_id", - "forwarding", - "timeout", - "to_address", - "tokens" - ], - "properties": { - "channel_id": { - "description": "existing channel to send the tokens over", - "type": "string" - }, - "forwarding": { - "type": "array", - "items": { - "$ref": "#/definitions/Hop" - } - }, - "memo": { - "description": "An optional memo. See the blog post [\"Moving Beyond Simple Token Transfers\"](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b) for more information.\n\nThere is no difference between setting this to `None` or an empty string.\n\nThis field is only supported on chains with CosmWasm >= 2.0 and silently ignored on older chains. If you need support for both 1.x and 2.x chain with the same codebase, it is recommended to use `CosmosMsg::Stargate` with a custom MsgTransfer protobuf encoder instead.", - "type": [ - "string", - "null" - ] - }, - "timeout": { - "description": "when packet times out, measured on remote chain", - "allOf": [ - { - "$ref": "#/definitions/IbcTimeout" - } - ] - }, - "to_address": { - "description": "address on the remote chain to receive these tokens", - "type": "string" - }, - "tokens": { - "description": "MsgTransfer in v2 version supports multiple coins", - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, { "description": "Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.", "type": "object", diff --git a/contracts/reflect/schema/raw/execute.json b/contracts/reflect/schema/raw/execute.json index 5d6a404709..60689b4e44 100644 --- a/contracts/reflect/schema/raw/execute.json +++ b/contracts/reflect/schema/raw/execute.json @@ -476,22 +476,6 @@ } ] }, - "Hop": { - "type": "object", - "required": [ - "channel_id", - "port_id" - ], - "properties": { - "channel_id": { - "type": "string" - }, - "port_id": { - "type": "string" - } - }, - "additionalProperties": false - }, "IbcAcknowledgement": { "type": "object", "required": [ @@ -589,65 +573,6 @@ }, "additionalProperties": false }, - { - "description": "Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to.", - "type": "object", - "required": [ - "transfer_v2" - ], - "properties": { - "transfer_v2": { - "type": "object", - "required": [ - "channel_id", - "forwarding", - "timeout", - "to_address", - "tokens" - ], - "properties": { - "channel_id": { - "description": "existing channel to send the tokens over", - "type": "string" - }, - "forwarding": { - "type": "array", - "items": { - "$ref": "#/definitions/Hop" - } - }, - "memo": { - "description": "An optional memo. See the blog post [\"Moving Beyond Simple Token Transfers\"](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b) for more information.\n\nThere is no difference between setting this to `None` or an empty string.\n\nThis field is only supported on chains with CosmWasm >= 2.0 and silently ignored on older chains. If you need support for both 1.x and 2.x chain with the same codebase, it is recommended to use `CosmosMsg::Stargate` with a custom MsgTransfer protobuf encoder instead.", - "type": [ - "string", - "null" - ] - }, - "timeout": { - "description": "when packet times out, measured on remote chain", - "allOf": [ - { - "$ref": "#/definitions/IbcTimeout" - } - ] - }, - "to_address": { - "description": "address on the remote chain to receive these tokens", - "type": "string" - }, - "tokens": { - "description": "MsgTransfer in v2 version supports multiple coins", - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, { "description": "Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.", "type": "object", diff --git a/contracts/reflect/schema/reflect.json b/contracts/reflect/schema/reflect.json index 0cf5892c72..9a4c0e5364 100644 --- a/contracts/reflect/schema/reflect.json +++ b/contracts/reflect/schema/reflect.json @@ -486,22 +486,6 @@ } ] }, - "Hop": { - "type": "object", - "required": [ - "channel_id", - "port_id" - ], - "properties": { - "channel_id": { - "type": "string" - }, - "port_id": { - "type": "string" - } - }, - "additionalProperties": false - }, "IbcAcknowledgement": { "type": "object", "required": [ @@ -599,65 +583,6 @@ }, "additionalProperties": false }, - { - "description": "Sends bank tokens owned by the contract to the given address on another chain. The channel must already be established between the ibctransfer module on this chain and a matching module on the remote chain. We cannot select the port_id, this is whatever the local chain has bound the ibctransfer module to.", - "type": "object", - "required": [ - "transfer_v2" - ], - "properties": { - "transfer_v2": { - "type": "object", - "required": [ - "channel_id", - "forwarding", - "timeout", - "to_address", - "tokens" - ], - "properties": { - "channel_id": { - "description": "existing channel to send the tokens over", - "type": "string" - }, - "forwarding": { - "type": "array", - "items": { - "$ref": "#/definitions/Hop" - } - }, - "memo": { - "description": "An optional memo. See the blog post [\"Moving Beyond Simple Token Transfers\"](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b) for more information.\n\nThere is no difference between setting this to `None` or an empty string.\n\nThis field is only supported on chains with CosmWasm >= 2.0 and silently ignored on older chains. If you need support for both 1.x and 2.x chain with the same codebase, it is recommended to use `CosmosMsg::Stargate` with a custom MsgTransfer protobuf encoder instead.", - "type": [ - "string", - "null" - ] - }, - "timeout": { - "description": "when packet times out, measured on remote chain", - "allOf": [ - { - "$ref": "#/definitions/IbcTimeout" - } - ] - }, - "to_address": { - "description": "address on the remote chain to receive these tokens", - "type": "string" - }, - "tokens": { - "description": "MsgTransfer in v2 version supports multiple coins", - "type": "array", - "items": { - "$ref": "#/definitions/Coin" - } - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, { "description": "Sends an IBC packet with given data over the existing channel. Data should be encoded in a format defined by the channel version, and the module on the other side should know how to parse this.", "type": "object", diff --git a/packages/check/src/main.rs b/packages/check/src/main.rs index e211a405b5..c49c351417 100644 --- a/packages/check/src/main.rs +++ b/packages/check/src/main.rs @@ -14,7 +14,7 @@ use cosmwasm_vm::internals::{check_wasm, compile, make_compiling_engine, LogOutp use cosmwasm_vm::{capabilities_from_csv, WasmLimits}; const DEFAULT_AVAILABLE_CAPABILITIES: &str = - "iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3,cosmwasm_1_4,cosmwasm_2_0,cosmwasm_2_1,cosmwasm_2_2"; + "iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3,cosmwasm_1_4,cosmwasm_2_0,cosmwasm_2_1,cosmwasm_2_2,cosmwasm_3_0"; pub fn main() { let matches = Command::new("Contract checking") diff --git a/packages/go-gen/Cargo.toml b/packages/go-gen/Cargo.toml index 8f24c3d8a6..93731e2d58 100644 --- a/packages/go-gen/Cargo.toml +++ b/packages/go-gen/Cargo.toml @@ -10,7 +10,7 @@ release = false [dependencies] cosmwasm-std = { version = "2.2.0-rc.1", path = "../std", features = [ - "cosmwasm_2_2", + "cosmwasm_3_0", "staking", "stargate", ] } diff --git a/packages/std/Cargo.toml b/packages/std/Cargo.toml index 7d15f3e17b..6d1d3d8445 100644 --- a/packages/std/Cargo.toml +++ b/packages/std/Cargo.toml @@ -55,6 +55,9 @@ cosmwasm_2_1 = ["cosmwasm_2_0"] # This enables functionality that is only available on 2.2 chains. # It adds `IbcMsg::PayPacketFee` and `IbcMsg::PayPacketFeeAsync`. cosmwasm_2_2 = ["cosmwasm_2_1"] +# This enables functionality that is only available on 3.0 chains. +# It adds `IbcMsg::TransferV2` message +cosmwasm_3_0 = ["cosmwasm_2_2"] [dependencies] base64 = "0.22.0" diff --git a/packages/std/src/exports.rs b/packages/std/src/exports.rs index 17e2cf22d7..c445a996ea 100644 --- a/packages/std/src/exports.rs +++ b/packages/std/src/exports.rs @@ -76,6 +76,10 @@ extern "C" fn requires_cosmwasm_2_1() {} #[no_mangle] extern "C" fn requires_cosmwasm_2_2() {} +#[cfg(feature = "cosmwasm_3_0")] +#[no_mangle] +extern "C" fn requires_cosmwasm_3_0() {} + /// interface_version_* exports mark which Wasm VM interface level this contract is compiled for. /// They can be checked by cosmwasm_vm. /// Update this whenever the Wasm VM interface breaks. diff --git a/packages/std/src/ibc.rs b/packages/std/src/ibc.rs index 2c6ff15759..3d8c1505d3 100644 --- a/packages/std/src/ibc.rs +++ b/packages/std/src/ibc.rs @@ -15,13 +15,14 @@ use crate::{Addr, Timestamp}; mod callbacks; mod transfer_msg_builder; +#[cfg(feature = "cosmwasm_3_0")] mod transfer_msg_builder_v2; pub use callbacks::*; pub use transfer_msg_builder::*; +#[cfg(feature = "cosmwasm_3_0")] pub use transfer_msg_builder_v2::*; -#[non_exhaustive] #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] #[serde(rename_all = "snake_case")] pub struct Hop { @@ -68,14 +69,15 @@ pub enum IbcMsg { /// and a matching module on the remote chain. /// We cannot select the port_id, this is whatever the local chain has bound the ibctransfer /// module to. + #[cfg(feature = "cosmwasm_3_0")] TransferV2 { - /// existing channel to send the tokens over + /// Existing channel to send the tokens over. channel_id: String, - /// address on the remote chain to receive these tokens + /// Address on the remote chain to receive these tokens. to_address: String, - /// MsgTransfer in v2 version supports multiple coins + /// MsgTransfer in v2 version supports multiple coins. tokens: Vec, - /// when packet times out, measured on remote chain + /// when packet times out, measured on remote chain. timeout: IbcTimeout, /// An optional memo. See the blog post /// ["Moving Beyond Simple Token Transfers"](https://medium.com/the-interchain-foundation/moving-beyond-simple-token-transfers-d42b2b1dc29b) @@ -89,8 +91,8 @@ pub enum IbcMsg { /// it is recommended to use `CosmosMsg::Stargate` with a custom MsgTransfer /// protobuf encoder instead. memo: Option, - // a struct containing the list of next hops, - // determining where the tokens must be forwarded next, + // A struct containing the list of next hops, + // determining where the tokens must be forwarded next. forwarding: Vec, }, /// Sends an IBC packet with given data over the existing channel. diff --git a/packages/std/src/lib.rs b/packages/std/src/lib.rs index fbb2566dc2..bf176e79e4 100644 --- a/packages/std/src/lib.rs +++ b/packages/std/src/lib.rs @@ -69,13 +69,15 @@ pub use crate::errors::{ pub use crate::eureka::{EurekaMsg, EurekaPayload}; pub use crate::hex_binary::HexBinary; pub use crate::ibc::IbcChannelOpenResponse; +#[cfg(feature = "cosmwasm_3_0")] +pub use crate::ibc::TransferMsgBuilderV2; pub use crate::ibc::{ Hop, Ibc3ChannelOpenResponse, IbcAckCallbackMsg, IbcAcknowledgement, IbcBasicResponse, IbcCallbackRequest, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, IbcChannelOpenMsg, IbcDestinationCallbackMsg, IbcDstCallback, IbcEndpoint, IbcFee, IbcMsg, IbcOrder, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, IbcSourceCallbackMsg, IbcSrcCallback, IbcTimeout, IbcTimeoutBlock, IbcTimeoutCallbackMsg, - TransferMsgBuilder, TransferMsgBuilderV2, + TransferMsgBuilder, }; #[cfg(feature = "iterator")] pub use crate::iterator::{Order, Record}; diff --git a/packages/vm/src/testing/instance.rs b/packages/vm/src/testing/instance.rs index 6701cab256..94785968aa 100644 --- a/packages/vm/src/testing/instance.rs +++ b/packages/vm/src/testing/instance.rs @@ -98,7 +98,7 @@ impl MockInstanceOptions<'_> { fn default_capabilities() -> HashSet { #[allow(unused_mut)] let mut out = capabilities_from_csv( - "iterator,staking,cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3,cosmwasm_1_4,cosmwasm_2_0,cosmwasm_2_1,cosmwasm_2_2", + "iterator,staking,cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3,cosmwasm_1_4,cosmwasm_2_0,cosmwasm_2_1,cosmwasm_2_2,cosmwasm_3_0", ); #[cfg(feature = "stargate")] out.insert("stargate".to_string());