diff --git a/CHANGELOG.md b/CHANGELOG.md index cc5ea92c5..8ddace314 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,19 +2,25 @@ ## Unpublished -- Add methods to set the private key and mnemonic of an existing sender -- Deprecate `authz_granter` and `fee_granter` on `Daemon` struct -- Add a method on `TxHandler` to select instantiation permissions on Wasm upload -- Adds an `upload_wasm` function to CosmosSender to upload wasm code associated to no Contract structure -- Update syn to 2.0 -- Added cw-plus orchestrator interface to the repo. Pacing the way for more integrations inside this repository in the future -- Add easier way to get PublicKey for `cw_orch_daemon::Wallet` -- Added Cosmos hub Testnet + +### Breaking + + +## 0.26.0 [8. October 2024] + +- [daemon] Add methods to set the private key and mnemonic of an existing sender +- [daemon] Deprecate `authz_granter` and `fee_granter` on `Daemon` struct +- [core] Add a method on `TxHandler` to select instantiation permissions on Wasm upload +- [daemon] Adds an `upload_wasm` function to CosmosSender to upload wasm code associated to no Contract structure +- [Macros] Update syn to 2.0 +- [Integrations] Added cw-plus orchestrator interface to the repo. Pacing the way for more integrations inside this repository in the future +- [daemon] Add easier way to get PublicKey for `cw_orch_daemon::Wallet` +- [networks] Added Cosmos hub Testnet ### Breaking -- Added Support for more mnemonic lengths (at least 24 and 12). This is breaking because of how the mnemonic words are stored and retrieved (`words` method on `PrivateKey`) (published in cw-orch-daemon 0.26.0) -- Added `Signer` trait for being able to re-use the signing/broadcast flow (Unpublished) +- [Daemon] Added Support for more mnemonic lengths (at least 24 and 12). This is breaking because of how the mnemonic words are stored and retrieved (`words` method on `PrivateKey`) +- [Daemon] Added `Signer` trait for being able to re-use the signing/broadcast flow ## 0.25.0 diff --git a/Cargo.toml b/Cargo.toml index 61bacf1eb..1046dd545 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,6 @@ members = [ ] exclude = [ "test_contracts/compatibility-test", # TODO: add new after cw-orch-core 2.0.0 as it's breaking, it shouldn't be compatible - "packages/interchain/proto", # TODO: Release cw-orch-proto after osmosis-std reaches prost 0.13 ] resolver = "2" @@ -47,12 +46,12 @@ anyhow = "1.0" serde = { version = "1.0.208", default-features = false, features = ["derive"] } tokio = { version = "1.39", features = ["full"] } -cw-orch = { path = "./cw-orch", version = "0.25.0" } -cw-orch-daemon = { path = "./cw-orch-daemon", version = "0.26.0" } +cw-orch = { path = "./cw-orch", version = "0.26.0" } +cw-orch-daemon = { path = "./cw-orch-daemon", version = "0.27.0" } cw-orch-core = { path = "packages/cw-orch-core", version = "2.1.0" } cw-orch-traits = { path = "packages/cw-orch-traits", version = "0.24.0" } -cw-orch-mock = { path = "packages/cw-orch-mock", version = "0.24.0" } -cw-orch-networks = { path = "packages/cw-orch-networks", version = "0.24.0" } +cw-orch-mock = { path = "packages/cw-orch-mock", version = "0.24.2" } +cw-orch-networks = { path = "packages/cw-orch-networks", version = "0.24.3" } # Macros cw-orch-contract-derive = { path = "packages/macros/cw-orch-contract-derive", version = "0.21.0" } @@ -61,16 +60,17 @@ cw-orch-fns-derive = { path = "packages/macros/cw-orch-fns-derive", version = "0 # Extensions # cw-orch-osmosis-test-tube = { version = "0.3.0", path = "packages/cw-orch-osmosis-test-tube" } +#Clone Testing +cw-orch-clone-testing = { version = "0.8.0", path = "packages/clone-testing" } + # Interchain -cw-orch-interchain = { path = "cw-orch-interchain", version = "0.5.0" } -cw-orch-interchain-core = { path = "packages/interchain/interchain-core", version = "0.6.0" } -cw-orch-interchain-daemon = { path = "packages/interchain/interchain-daemon", version = "0.6.0" } -cw-orch-interchain-mock = { path = "packages/interchain/interchain-mock", version = "0.6.0" } -cw-orch-starship = { path = "packages/interchain/starship", version = "0.5.0" } -# cw-orch-proto = { path = "packages/interchain/proto", version = "0.5.0" } # prost, tonic, cosmrs bump locked by osmosis (we use it for tokenfactory) +cw-orch-interchain = { path = "cw-orch-interchain", version = "0.6.0" } +cw-orch-interchain-core = { path = "packages/interchain/interchain-core", version = "0.7.0" } +cw-orch-interchain-daemon = { path = "packages/interchain/interchain-daemon", version = "0.7.0" } +cw-orch-interchain-mock = { path = "packages/interchain/interchain-mock", version = "0.7.0" } +cw-orch-starship = { path = "packages/interchain/starship", version = "0.6.0" } +cw-orch-proto = { path = "packages/interchain/proto", version = "0.7.0" } -#Clone Testing -# cw-orch-clone-testing = { version = "0.6.1", path = "packages/clone-testing" } thiserror = { version = "1.0.63" } sha2 = { version = "0.10.8" } diff --git a/cw-orch-daemon/Cargo.toml b/cw-orch-daemon/Cargo.toml index ae126f3fb..94b39d725 100644 --- a/cw-orch-daemon/Cargo.toml +++ b/cw-orch-daemon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-orch-daemon" -version = "0.26.0" +version = "0.27.0" authors = { workspace = true } edition = { workspace = true } license = { workspace = true } diff --git a/cw-orch-interchain/Cargo.toml b/cw-orch-interchain/Cargo.toml index b15e7140a..3b1395c43 100644 --- a/cw-orch-interchain/Cargo.toml +++ b/cw-orch-interchain/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-orch-interchain" -version = "0.5.0" +version = "0.6.0" authors = { workspace = true } edition = { workspace = true } license = { workspace = true } diff --git a/cw-orch/Cargo.toml b/cw-orch/Cargo.toml index b50a96c20..8685dabd4 100644 --- a/cw-orch/Cargo.toml +++ b/cw-orch/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-orch" -version = "0.25.0" +version = "0.26.0" authors = { workspace = true } edition = { workspace = true } license = { workspace = true } @@ -100,6 +100,6 @@ mock-contract = { path = "../contracts-ws/contracts/mock_contract" } mock-contract-u64 = { path = "../contracts-ws/contracts/mock_contract_u64" } serde_json = { workspace = true } dotenv = "0.15.0" -osmosis-std = "0.25.0" +osmosis-std = "0.26.0" prost = { workspace = true } prost-types = { workspace = true } diff --git a/packages/clone-testing/Cargo.toml b/packages/clone-testing/Cargo.toml index e37faba5f..aded5abf9 100644 --- a/packages/clone-testing/Cargo.toml +++ b/packages/clone-testing/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-orch-clone-testing" -version = "0.7.1" +version = "0.8.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/packages/cw-orch-networks/Cargo.toml b/packages/cw-orch-networks/Cargo.toml index 50fb6f2df..5d16ea327 100644 --- a/packages/cw-orch-networks/Cargo.toml +++ b/packages/cw-orch-networks/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-orch-networks" -version = "0.24.2" +version = "0.24.3" authors = { workspace = true } edition = { workspace = true } license = { workspace = true } diff --git a/packages/interchain/interchain-core/Cargo.toml b/packages/interchain/interchain-core/Cargo.toml index b1b7ae150..710839da4 100644 --- a/packages/interchain/interchain-core/Cargo.toml +++ b/packages/interchain/interchain-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-orch-interchain-core" -version = "0.6.1" +version = "0.7.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/packages/interchain/interchain-daemon/Cargo.toml b/packages/interchain/interchain-daemon/Cargo.toml index 71271f249..e3456dea3 100644 --- a/packages/interchain/interchain-daemon/Cargo.toml +++ b/packages/interchain/interchain-daemon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-orch-interchain-daemon" -version = "0.6.1" +version = "0.7.0" description = "An interchain intergration crate for interacting with actual chain nodes (via gRPC)" authors.workspace = true edition.workspace = true diff --git a/packages/interchain/interchain-mock/Cargo.toml b/packages/interchain/interchain-mock/Cargo.toml index ba3e84b76..18621317e 100644 --- a/packages/interchain/interchain-mock/Cargo.toml +++ b/packages/interchain/interchain-mock/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-orch-interchain-mock" -version = "0.6.1" +version = "0.7.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/packages/interchain/proto/Cargo.toml b/packages/interchain/proto/Cargo.toml index 01149e1aa..32daef5f5 100644 --- a/packages/interchain/proto/Cargo.toml +++ b/packages/interchain/proto/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "cw-orch-proto" description = "A helper crate for interaction with protos from different chains. Mostly used for handling cw20 coins and ibc transfers" -version = "0.6.0" +version = "0.7.0" authors.workspace = true edition.workspace = true license.workspace = true @@ -16,14 +16,15 @@ cw-orch-core = { workspace = true } anyhow = { workspace = true } -cosmrs = { workspace = true } +ibc-proto = { workspace = true } +prost-types = { workspace = true } +prost = { workspace = true } cosmwasm-std = { workspace = true } ibc-relayer-types = { workspace = true } log = { workspace = true } -prost = { workspace = true } tokio = { workspace = true } tonic = { workspace = true } -osmosis-std = { version = "0.25.0" } +osmosis-std = { version = "0.26.0" } [dev-dependencies] cw-orch-starship = { workspace = true } diff --git a/packages/interchain/proto/src/ics20.rs b/packages/interchain/proto/src/ics20.rs deleted file mode 100644 index 0f8683293..000000000 --- a/packages/interchain/proto/src/ics20.rs +++ /dev/null @@ -1,264 +0,0 @@ -#![allow(non_snake_case)] - -use cosmrs::{proto::traits::Name, tx::Msg, ErrorReport, Result}; -/// MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between -/// ICS20 enabled chains. See ICS Spec here: -/// -#[allow(clippy::derive_partial_eq_without_eq)] -#[derive(Clone, PartialEq, prost::Message)] -pub struct ProtoMsgTransfer { - /// the port on which the packet will be sent - #[prost(string, tag = "1")] - pub source_port: ::prost::alloc::string::String, - /// the channel by which the packet will be sent - #[prost(string, tag = "2")] - pub source_channel: ::prost::alloc::string::String, - /// the tokens to be transferred - #[prost(message, optional, tag = "3")] - pub token: ::core::option::Option, - /// the sender address - #[prost(string, tag = "4")] - pub sender: ::prost::alloc::string::String, - /// the recipient address on the destination chain - #[prost(string, tag = "5")] - pub receiver: ::prost::alloc::string::String, - /// Timeout height relative to the current block height. - /// The timeout is disabled when set to 0. - #[prost(message, optional, tag = "6")] - pub timeout_height: ::core::option::Option, - /// Timeout timestamp in absolute nanoseconds since unix epoch. - /// The timeout is disabled when set to 0. - #[prost(uint64, tag = "7")] - pub timeout_timestamp: u64, - /// Optional memo - /// whole reason we are copying this from its original (proto::ibc::applications::transfer::v1::MsgTransfer) - #[prost(string, optional, tag = "8")] - pub memo: ::core::option::Option<::prost::alloc::string::String>, -} - -impl Name for ProtoMsgTransfer { - const NAME: &'static str = cosmrs::proto::ibc::applications::transfer::v1::MsgTransfer::NAME; - const PACKAGE: &'static str = - cosmrs::proto::ibc::applications::transfer::v1::MsgTransfer::PACKAGE; - - fn full_name() -> String { - cosmrs::proto::ibc::applications::transfer::v1::MsgTransfer::full_name() - } -} - -/// MsgSend represents a message to send coins from one account to another. -#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)] -pub struct MsgTransfer { - /// Sender's address. - pub source_port: String, - pub source_channel: String, - pub token: Option, - pub sender: cosmrs::AccountId, - pub receiver: cosmrs::AccountId, - pub timeout_height: Option, - pub timeout_revision: Option, - pub timeout_timestamp: u64, - pub memo: Option, -} - -impl Msg for MsgTransfer { - type Proto = ProtoMsgTransfer; -} - -impl TryFrom for MsgTransfer { - type Error = ErrorReport; - - fn try_from(proto: ProtoMsgTransfer) -> Result { - MsgTransfer::try_from(&proto) - } -} - -impl TryFrom<&ProtoMsgTransfer> for MsgTransfer { - type Error = ErrorReport; - - fn try_from(proto: &ProtoMsgTransfer) -> Result { - Ok(MsgTransfer { - source_port: proto.source_port.parse()?, - source_channel: proto.source_channel.parse()?, - token: proto.token.clone().map(TryFrom::try_from).transpose()?, - sender: proto.sender.parse()?, - receiver: proto.receiver.parse()?, - timeout_height: proto - .timeout_height - .clone() - .map(|h| h.revision_height.try_into()) - .transpose()?, - timeout_revision: proto.timeout_height.clone().map(|h| h.revision_number), - timeout_timestamp: proto.timeout_timestamp, - memo: proto.memo.clone(), - }) - } -} - -impl From for ProtoMsgTransfer { - fn from(coin: MsgTransfer) -> ProtoMsgTransfer { - ProtoMsgTransfer::from(&coin) - } -} - -impl From<&MsgTransfer> for ProtoMsgTransfer { - fn from(msg: &MsgTransfer) -> ProtoMsgTransfer { - ProtoMsgTransfer { - source_port: msg.source_port.clone(), - source_channel: msg.source_channel.clone(), - token: msg.token.clone().map(Into::into), - sender: msg.sender.to_string(), - receiver: msg.receiver.to_string(), - timeout_height: msg.timeout_height.map(|h| { - cosmrs::proto::ibc::core::client::v1::Height { - revision_number: msg.timeout_revision.unwrap(), - revision_height: h.value(), - } - }), - timeout_timestamp: msg.timeout_timestamp, - memo: msg.memo.clone(), - } - } -} - -// Tests -#[cfg(test)] -mod test { - - use std::time::{SystemTime, UNIX_EPOCH}; - - use anyhow::Result as AnyResult; - use cosmwasm_std::coin; - - use crate::tokenfactory::{ - create_denom, create_transfer_channel, get_denom, mint, transfer_tokens, - }; - use cw_orch_interchain_core::{ - channel::InterchainChannel, types::IbcPacketOutcome, IbcQueryHandler, InterchainEnv, - }; - use cw_orch_interchain_daemon::ChannelCreator; - use cw_orch_starship::Starship; - use cw_orch_traits::FullNode; - use speculoos::{assert_that, vec::VecAssertions}; - - const JUNO: &str = "juno-1"; - const STARGAZE: &str = "stargaze-1"; - - const TEST_AMOUNT: u128 = 100_000_000_000; - const TEST_SUBDENOM: &str = "testtoken"; - - /// This allows env_logger to start properly for tests - /// The logs will be printed only if the test fails ! - pub fn logger_test_init() { - let _ = env_logger::builder().is_test(true).try_init(); - } - - pub fn create_ics20_channel>( - interchain: &IBC, - chain_id1: &str, - chain_id2: &str, - ) -> AnyResult<( - InterchainChannel<::Handler>, - String, - )> { - let chain1 = interchain.get_chain(chain_id1).unwrap(); - - let sender = chain1.sender_addr().to_string(); - - let token_subdenom = format!( - "{}{}", - TEST_SUBDENOM, - SystemTime::now() - .duration_since(UNIX_EPOCH) - .unwrap() - .as_secs() - ); - - // Create Denom - create_denom(&chain1, token_subdenom.as_str()).unwrap(); - - // Mint Denom - mint( - &chain1, - sender.as_str(), - token_subdenom.as_str(), - TEST_AMOUNT, - ) - .unwrap(); - - // Create a channel between the 2 chains for the transfer ports - let interchain_channel = create_transfer_channel(chain_id1, chain_id2, interchain).unwrap(); - - let denom = get_denom(&chain1, &token_subdenom); - Ok((interchain_channel, denom)) - } - - #[ignore] - #[test] - pub fn create_ics20_channel_test() -> AnyResult<()> { - logger_test_init(); - - let starship = Starship::new(None).unwrap(); - let interchain = starship.interchain_env(); - - create_ics20_channel(&interchain, JUNO, STARGAZE)?; - - Ok(()) - } - - #[ignore] - #[test] - pub fn transfer_ics20_test() -> AnyResult<()> { - use cw_orch_core::environment::TxHandler; - - logger_test_init(); - - let starship = Starship::new(None).unwrap(); - let interchain = starship.interchain_env(); - let (interchain_channel, denom) = create_ics20_channel(&interchain, JUNO, STARGAZE)?; - - let chain1 = starship.daemon(JUNO)?; - let chain2 = starship.daemon(STARGAZE)?; - - // This should pass ok, the timeout was set right - let success_outcome = transfer_tokens( - chain1, - chain2.sender_addr().as_str(), - &coin(TEST_AMOUNT / 2, denom.clone()), - &interchain, - &interchain_channel, - None, - None, - )?; - - // We assert we had a success_outcome - assert_that!(success_outcome.packets).has_length(1); - - // We want to assert the acknowledgment - success_outcome.into_result()?; - - // This should timeout - let timeout_outcome = transfer_tokens( - chain1, - chain2.sender_addr().as_str(), - &coin(TEST_AMOUNT / 2, denom), - &interchain, - &interchain_channel, - Some(1), - None, - )?; - - // We assert we had a timeout_outcome - assert_that!(timeout_outcome.packets).has_length(1); - - let packet_outcome = timeout_outcome.packets[0].outcome.clone(); - - // We want to assert the acknowledgment - match packet_outcome { - IbcPacketOutcome::Timeout { .. } => {} - _ => panic!("Wrong packet outcome"), - }; - - Ok(()) - } -} diff --git a/packages/interchain/proto/src/lib.rs b/packages/interchain/proto/src/lib.rs index 1b89ae86c..0996d45ec 100644 --- a/packages/interchain/proto/src/lib.rs +++ b/packages/interchain/proto/src/lib.rs @@ -1,2 +1 @@ -pub mod ics20; pub mod tokenfactory; diff --git a/packages/interchain/proto/src/tokenfactory.rs b/packages/interchain/proto/src/tokenfactory.rs index cc677d5f0..bcde6ea54 100644 --- a/packages/interchain/proto/src/tokenfactory.rs +++ b/packages/interchain/proto/src/tokenfactory.rs @@ -1,29 +1,25 @@ #![allow(non_snake_case)] -use cosmrs::{ - proto::ibc::applications::transfer::v1::MsgTransferResponse, tx::Msg, AccountId, Result, -}; - use cw_orch_interchain_core::{ channel::InterchainChannel, types::IbcTxAnalysis, IbcQueryHandler, InterchainEnv, InterchainError, }; +use ibc_proto::ibc::{ + applications::transfer::v1::MsgTransferResponse, apps::transfer::v1::MsgTransfer, +}; use osmosis_std::types::osmosis::tokenfactory::v1beta1::{ MsgCreateDenom, MsgCreateDenomResponse, MsgMint, MsgMintResponse, }; +use prost::{Message, Name}; use tonic::transport::Channel; -use std::str::FromStr; - -use cosmrs::Denom; use cosmwasm_std::Coin; use cw_orch_core::environment::{CwEnv, TxHandler}; use cw_orch_traits::FullNode; use ibc_relayer_types::core::ics24_host::identifier::PortId; -use crate::ics20::MsgTransfer; - /// Creates a new denom using the token factory module. +/// /// This is used mainly for tests, but feel free to use that in production as well pub fn create_denom( chain: &Chain, @@ -37,13 +33,7 @@ pub fn create_denom( } .to_any(); - chain.commit_any::( - vec![cosmrs::Any { - type_url: any.type_url, - value: any.value, - }], - None, - )?; + chain.commit_any::(vec![any.into()], None)?; log::info!("Created denom {}", get_denom(chain, token_name)); @@ -51,6 +41,7 @@ pub fn create_denom( } /// Gets the denom of a token created by a daemon object +/// /// This actually creates the denom for a token created by an address (which is here taken to be the daemon sender address) /// This is mainly used for tests, but feel free to use that in production as well pub fn get_denom(daemon: &Chain, token_name: &str) -> String { @@ -59,6 +50,7 @@ pub fn get_denom(daemon: &Chain, token_name: &str) -> String { } /// Mints new subdenom token for which the minter is the sender of chain object +/// /// This mints new tokens to the receiver address /// This is mainly used for tests, but feel free to use that in production as well pub fn mint( @@ -80,13 +72,7 @@ pub fn mint( } .to_any(); - chain.commit_any::( - vec![cosmrs::Any { - type_url: any.type_url, - value: any.value, - }], - None, - )?; + chain.commit_any::(vec![any.into()], None)?; log::info!("Minted coins {} {}", amount, get_denom(chain, token_name)); @@ -97,6 +83,7 @@ pub fn mint( const TIMEOUT_IN_NANO_SECONDS: u64 = 3_600_000_000_000; /// Ibc token transfer +/// /// This allows transfering token over a channel using an interchain_channel object #[allow(clippy::too_many_arguments)] pub fn transfer_tokens>( @@ -112,30 +99,27 @@ pub fn transfer_tokens( - vec![cosmrs::Any { - type_url: any.type_url, - value: any.value, + vec![prost_types::Any { + type_url: MsgTransfer::full_name(), + value: msg_transfer.encode_to_vec(), }], None, ) diff --git a/packages/interchain/starship/Cargo.toml b/packages/interchain/starship/Cargo.toml index 72417f35a..68eaa809e 100644 --- a/packages/interchain/starship/Cargo.toml +++ b/packages/interchain/starship/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-orch-starship" -version = "0.5.0" +version = "0.6.0" authors.workspace = true edition.workspace = true license.workspace = true