From 20a46122c43ef5c98167c76f73aa3ee228e11769 Mon Sep 17 00:00:00 2001 From: Kayanski <44806566+Kayanski@users.noreply.github.com> Date: Thu, 13 Jun 2024 11:34:05 +0200 Subject: [PATCH] Release/0.23 (#416) * Changed versions * Version updates * Version * Description * Better makefile * Added starship update * Added Clone * version * Added remove state in trait * Added remove * Added ibctxanalyssis to check ibc return * Updated docs and starship --- CHANGELOG.md | 3 ++- Cargo.toml | 19 ++++++------- cw-orch-daemon/Cargo.toml | 2 +- cw-orch-daemon/src/error.rs | 2 +- cw-orch-daemon/src/state.rs | 27 +++++++++++++++++++ cw-orch-interchain/Cargo.toml | 2 +- cw-orch/Cargo.toml | 2 +- cw-orch/src/prelude.rs | 13 --------- docs/src/integrations/daemon.md | 21 +++++++++++++++ packages/clone-testing/Cargo.toml | 2 +- packages/clone-testing/src/core.rs | 3 --- packages/clone-testing/src/state.rs | 8 ++++++ packages/cw-orch-core/Cargo.toml | 2 +- .../src/contract/contract_instance.rs | 9 +++++++ .../src/contract/interface_traits.rs | 10 +++++++ .../cw-orch-core/src/environment/state.rs | 20 ++++++++++++++ packages/cw-orch-mock/Cargo.toml | 2 +- packages/cw-orch-mock/src/core.rs | 4 --- packages/cw-orch-mock/src/state.rs | 8 ++++++ packages/cw-orch-networks/Cargo.toml | 2 +- packages/cw-orch-osmosis-test-tube/Cargo.toml | 3 ++- .../interchain/interchain-core/Cargo.toml | 2 +- .../interchain/interchain-core/src/env.rs | 6 +++-- .../interchain/interchain-daemon/Cargo.toml | 2 +- .../interchain-daemon/src/interchain_env.rs | 12 +++++++-- .../interchain-daemon/src/interchain_log.rs | 1 + .../interchain/interchain-mock/Cargo.toml | 2 +- .../interchain-mock/src/interchain.rs | 3 ++- packages/interchain/proto/Cargo.toml | 2 +- packages/interchain/starship/Cargo.toml | 2 +- packages/interchain/starship/src/lib.rs | 17 +++++++----- .../interchain/starship/starship/Makefile | 20 +++++++------- packages/macros/cw-orch-fns-derive/Cargo.toml | 2 +- 33 files changed, 169 insertions(+), 66 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9684e4e92..a2060007b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # cw-orchestrator Changelog -## Unreleased +## 0.23.0 - Added a test to make sure the derive macros stay compatible with new cw-orch versions - Changed the derive macros import from cw_orch to cw_orch_core. This allows changing the cw-orch API without breaking the derive macros. @@ -19,6 +19,7 @@ - Writing to a file happens when all Daemon's that use same file dropped instead of hot writes - `force_write` added to the `DaemonState` to allow force write of the state - Added `event_attr_values` to get all the attribute values corresponding to a key +- Added `remove_{address,code_id}` functions to be able to erase an entry in state. Involves core, mock, daemon, osmosis-test-tube, clone-testing - Added `state` to DaemonBuilder to be able to share state between daemons ### Breaking diff --git a/Cargo.toml b/Cargo.toml index 00f27fb0d..4deda34a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,28 +35,29 @@ anyhow = "1.0" serde = { version = "1.0.103", default-features = false, features = ["derive"] } tokio = { version = "1.4", features = ["full"] } -cw-orch = { path = "./cw-orch", version = "0.22.0" } -cw-orch-daemon = { path = "./cw-orch-daemon", version = "0.22.0" } -cw-orch-core = { path = "packages/cw-orch-core", version = "1.0.0" } +cw-orch = { path = "./cw-orch", version = "0.23.0" } +cw-orch-daemon = { path = "./cw-orch-daemon", version = "0.23.2" } +cw-orch-core = { path = "packages/cw-orch-core", version = "1.1.1" } cw-orch-traits = { path = "packages/cw-orch-traits", version = "0.22.0" } cw-orch-mock = { path = "packages/cw-orch-mock", version = "0.22.0" } cw-orch-networks = { path = "packages/cw-orch-networks", version = "0.22.0" } # Macros cw-orch-contract-derive = { path = "packages/macros/cw-orch-contract-derive", version = "0.21.0" } -cw-orch-fns-derive = { path = "packages/macros/cw-orch-fns-derive", version = "0.20.0" } +cw-orch-fns-derive = { path = "packages/macros/cw-orch-fns-derive", version = "0.21.0" } # Extensions cw-orch-osmosis-test-tube = { version = "0.1.0", path = "packages/cw-orch-osmosis-test-tube" } # Interchain -cw-orch-interchain-core = { path = "packages/interchain/interchain-core", version = "0.2.0" } -cw-orch-interchain-daemon = { path = "packages/interchain/interchain-daemon", version = "0.2.0" } -cw-orch-interchain-mock = { path = "packages/interchain/interchain-mock", version = "0.2.0" } -cw-orch-starship = { path = "packages/interchain/starship", version = "0.2.0" } +cw-orch-interchain = { path = "cw-orch-interchain", version = "0.2.0" } +cw-orch-interchain-core = { path = "packages/interchain/interchain-core", version = "0.3.0" } +cw-orch-interchain-daemon = { path = "packages/interchain/interchain-daemon", version = "0.3.2" } +cw-orch-interchain-mock = { path = "packages/interchain/interchain-mock", version = "0.3.1" } +cw-orch-starship = { path = "packages/interchain/starship", version = "0.3.0" } #Clone Testing -cw-orch-clone-testing = { version = "0.4.1", path = "packages/clone-testing" } +cw-orch-clone-testing = { version = "0.5.0", path = "packages/clone-testing" } thiserror = { version = "1.0.21" } diff --git a/cw-orch-daemon/Cargo.toml b/cw-orch-daemon/Cargo.toml index 520f5851e..9583f962e 100644 --- a/cw-orch-daemon/Cargo.toml +++ b/cw-orch-daemon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-orch-daemon" -version = "0.22.2" +version = "0.23.3" authors = { workspace = true } edition = { workspace = true } license = { workspace = true } diff --git a/cw-orch-daemon/src/error.rs b/cw-orch-daemon/src/error.rs index 57d8bd159..51e400a39 100644 --- a/cw-orch-daemon/src/error.rs +++ b/cw-orch-daemon/src/error.rs @@ -124,7 +124,7 @@ pub enum DaemonError { Instantiate2Error(#[from] Instantiate2AddressError), #[error("Error opening file {0},err: ({1})")] OpenFile(String, String), - #[error("State file {0} already locked, use another state file or clone daemon which holds the lock")] + #[error("State file {0} already locked, use another state file, clone daemon which holds the lock, or use `state` method of Builder")] StateAlreadyLocked(String), } diff --git a/cw-orch-daemon/src/state.rs b/cw-orch-daemon/src/state.rs index 1a3cba6ca..ea12a50eb 100644 --- a/cw-orch-daemon/src/state.rs +++ b/cw-orch-daemon/src/state.rs @@ -192,6 +192,25 @@ impl DaemonState { Ok(()) } + /// Remove a stateful value using the chainId and networkId + pub fn remove(&mut self, key: &str, contract_id: &str) -> Result<(), DaemonError> { + let json_file_state = match &mut self.json_state { + DaemonStateFile::ReadOnly { path } => { + return Err(DaemonError::StateReadOnly(path.clone())) + } + DaemonStateFile::FullAccess { json_file_state } => json_file_state, + }; + + let mut json_file_lock = json_file_state.lock().unwrap(); + let val = json_file_lock.get_mut( + &self.chain_data.network_info.chain_name, + &self.chain_data.chain_id, + ); + val[key][contract_id] = Value::Null; + + Ok(()) + } + /// Forcefully write current json to a file pub fn force_write(&mut self) -> Result<(), DaemonError> { let json_file_state = match &mut self.json_state { @@ -247,6 +266,11 @@ impl StateInterface for DaemonState { .unwrap(); } + fn remove_address(&mut self, contract_id: &str) { + let deployment_id = self.deployment_id.clone(); + self.remove(&deployment_id, contract_id).unwrap(); + } + /// Get the locally-saved version of the contract's version on this network fn get_code_id(&self, contract_id: &str) -> Result { let value = self @@ -262,6 +286,9 @@ impl StateInterface for DaemonState { fn set_code_id(&mut self, contract_id: &str, code_id: u64) { self.set("code_ids", contract_id, code_id).unwrap(); } + fn remove_code_id(&mut self, contract_id: &str) { + self.remove("code_ids", contract_id).unwrap(); + } /// Get all addresses for deployment id from state file fn get_all_addresses(&self) -> Result, CwEnvError> { diff --git a/cw-orch-interchain/Cargo.toml b/cw-orch-interchain/Cargo.toml index ba6022866..b19d6a64e 100644 --- a/cw-orch-interchain/Cargo.toml +++ b/cw-orch-interchain/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-orch-interchain" -version = "0.1.0" +version = "0.2.0" authors = { workspace = true } edition = { workspace = true } license = { workspace = true } diff --git a/cw-orch/Cargo.toml b/cw-orch/Cargo.toml index 62c7871c9..e9693070c 100644 --- a/cw-orch/Cargo.toml +++ b/cw-orch/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-orch" -version = "0.22.3" +version = "0.23.0" authors = { workspace = true } edition = { workspace = true } license = { workspace = true } diff --git a/cw-orch/src/prelude.rs b/cw-orch/src/prelude.rs index 6190be3b1..20493b2d9 100644 --- a/cw-orch/src/prelude.rs +++ b/cw-orch/src/prelude.rs @@ -68,16 +68,3 @@ pub use cw_orch_traits::*; #[cfg(feature = "snapshot-testing")] pub use crate::take_storage_snapshot; - -#[cfg(feature = "interchain")] -/// Everything that concerns interchain capabilities -pub mod interchain { - pub use cw_orch_interchain_core::{IbcQueryHandler, InterchainEnv}; - pub use cw_orch_interchain_daemon::{ - ChannelCreationValidator, ChannelCreator, DaemonInterchainEnv, - }; - pub use cw_orch_interchain_mock::{MockBech32InterchainEnv, MockInterchainEnv}; - pub use cw_orch_starship::Starship; -} -#[cfg(feature = "interchain")] -pub use interchain::*; diff --git a/docs/src/integrations/daemon.md b/docs/src/integrations/daemon.md index d52f574fc..0aec1ebd1 100644 --- a/docs/src/integrations/daemon.md +++ b/docs/src/integrations/daemon.md @@ -21,6 +21,27 @@ This simple script actually hides another parameter which is the `LOCAL_MNEMONIC > > Under the hood, the `DaemonBuilder` struct creates a `tokio::Runtime`. Be careful because this builder is not usable in an `async` function. In such function, you can use `DaemonAsync` +
+ +When using multiple Daemons with the same state file, you should re-use a single Daemon State to avoid conflicts and panics: + +```rust,ignore +let daemon1 = Daemon::builder() + .chain(OSMOSIS_1) + .build()?; +// If you don't use the `state` method here, this will fail with: +// State file already locked, use another state file, clone daemon which holds the lock, or use `state` method of Builder +let daemon2 = Daemon::builder() + .chain(JUNO_1) + .state(daemon1.state()) + .build()?; +``` + + +
+ + + ## Interacting with contracts You can then use the resulting `Daemon` variable to interact with your [contracts](../contracts/index.md): diff --git a/packages/clone-testing/Cargo.toml b/packages/clone-testing/Cargo.toml index 842f41f65..5c5413d3a 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.4.1" +version = "0.5.1" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/packages/clone-testing/src/core.rs b/packages/clone-testing/src/core.rs index af79c0249..8da6420cd 100644 --- a/packages/clone-testing/src/core.rs +++ b/packages/clone-testing/src/core.rs @@ -454,11 +454,8 @@ mod test { use cw_orch_core::environment::QueryHandler; use cw_orch_daemon::networks::JUNO_1; use cw_orch_mock::cw_multi_test::{Contract as MockContract, ContractWrapper}; - use serde::Serialize; use speculoos::prelude::*; - #[derive(Debug, Serialize)] - struct MigrateMsg {} pub struct MockCw20; fn execute( diff --git a/packages/clone-testing/src/state.rs b/packages/clone-testing/src/state.rs index d9cbe7832..36fca13f8 100644 --- a/packages/clone-testing/src/state.rs +++ b/packages/clone-testing/src/state.rs @@ -51,6 +51,10 @@ impl StateInterface for MockState { .insert(contract_id.to_string(), address.to_owned()); } + fn remove_address(&mut self, contract_id: &str) { + self.addresses.remove(contract_id); + } + /// Get the locally-saved version of the contract's version on this network fn get_code_id(&self, contract_id: &str) -> Result { self.code_ids @@ -66,6 +70,10 @@ impl StateInterface for MockState { self.code_ids.insert(contract_id.to_string(), code_id); } + fn remove_code_id(&mut self, contract_id: &str) { + self.code_ids.remove(contract_id); + } + fn get_all_addresses(&self) -> Result, CwEnvError> { let mock_addresses = self.addresses.clone(); let daemon_addresses = self.daemon_state.get_all_addresses().unwrap_or_default(); diff --git a/packages/cw-orch-core/Cargo.toml b/packages/cw-orch-core/Cargo.toml index 6f6b4c7b5..ea440de92 100644 --- a/packages/cw-orch-core/Cargo.toml +++ b/packages/cw-orch-core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-orch-core" -version = "1.0.0" +version = "1.1.1" authors = { workspace = true } edition = { workspace = true } license = { workspace = true } diff --git a/packages/cw-orch-core/src/contract/contract_instance.rs b/packages/cw-orch-core/src/contract/contract_instance.rs index d8b915bc3..a16be32b3 100644 --- a/packages/cw-orch-core/src/contract/contract_instance.rs +++ b/packages/cw-orch-core/src/contract/contract_instance.rs @@ -71,6 +71,11 @@ impl Contract { self.chain.state().set_address(&self.id, address) } + /// Remove state address for contract + pub fn remove_address(&self) { + self.chain.state().remove_address(&self.id) + } + /// Returns state code_id for contract pub fn code_id(&self) -> Result { let state_code_id = self.chain.state().get_code_id(&self.id); @@ -83,6 +88,10 @@ impl Contract { pub fn set_code_id(&self, code_id: u64) { self.chain.state().set_code_id(&self.id, code_id) } + /// Remove state code_id for contract + pub fn remove_code_id(&self) { + self.chain.state().remove_code_id(&self.id) + } } /// Expose chain and state function to call them on the contract diff --git a/packages/cw-orch-core/src/contract/interface_traits.rs b/packages/cw-orch-core/src/contract/interface_traits.rs index fbf10c2c3..6b3b15ee6 100644 --- a/packages/cw-orch-core/src/contract/interface_traits.rs +++ b/packages/cw-orch-core/src/contract/interface_traits.rs @@ -47,6 +47,11 @@ pub trait ContractInstance { Contract::set_address(self.as_instance(), address) } + /// Removes the address for the contract + fn remove_address(&self) { + Contract::remove_address(self.as_instance()) + } + /// Sets a default address for the contract. If the contract already has an address registered in the state, this won't be used. /// This is mostly used to ship address with a cw-orch package. fn set_default_address(&mut self, address: &Addr) { @@ -59,6 +64,11 @@ pub trait ContractInstance { Contract::set_code_id(self.as_instance(), code_id) } + /// Removes the code_id for the contract + fn remove_code_id(&self) { + Contract::remove_code_id(self.as_instance()) + } + /// Sets a default address for the contract. If the contract already has an address registered in the state, this won't be used. /// This is mostly used to ship address with a cw-orch package. fn set_default_code_id(&mut self, code_id: u64) { diff --git a/packages/cw-orch-core/src/environment/state.rs b/packages/cw-orch-core/src/environment/state.rs index e75db0ab8..228e771b0 100644 --- a/packages/cw-orch-core/src/environment/state.rs +++ b/packages/cw-orch-core/src/environment/state.rs @@ -21,12 +21,24 @@ pub trait StateInterface: Clone { /// Set the address of a contract using the specified contract id. fn set_address(&mut self, contract_id: &str, address: &Addr); + /// Removes the address of a contract using the specified contract id. + fn remove_address(&mut self, _contract_id: &str) { + // Using default impl to avoid breaking changes + unimplemented!() + } + /// Get the code id for a contract with the specified contract id. fn get_code_id(&self, contract_id: &str) -> Result; /// Set the code id for a contract with the specified contract id. fn set_code_id(&mut self, contract_id: &str, code_id: u64); + /// Removes the code id for a contract with the specified contract id. + fn remove_code_id(&mut self, _contract_id: &str) { + // Using default impl to avoid breaking changes + unimplemented!() + } + /// Get all addresses related to this deployment. fn get_all_addresses(&self) -> Result, CwEnvError>; @@ -58,6 +70,14 @@ impl StateInterface for Rc> { fn get_all_code_ids(&self) -> Result, CwEnvError> { (**self).borrow().get_all_code_ids() } + + fn remove_address(&mut self, contract_id: &str) { + (**self).borrow_mut().remove_address(contract_id) + } + + fn remove_code_id(&mut self, contract_id: &str) { + (**self).borrow_mut().remove_code_id(contract_id) + } } impl StateInterface for Rc { diff --git a/packages/cw-orch-mock/Cargo.toml b/packages/cw-orch-mock/Cargo.toml index 882163ee3..8966a140a 100644 --- a/packages/cw-orch-mock/Cargo.toml +++ b/packages/cw-orch-mock/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-orch-mock" -version = "0.22.2" +version = "0.22.4" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/packages/cw-orch-mock/src/core.rs b/packages/cw-orch-mock/src/core.rs index 195454392..21661982a 100644 --- a/packages/cw-orch-mock/src/core.rs +++ b/packages/cw-orch-mock/src/core.rs @@ -255,7 +255,6 @@ mod test { }; use cw_multi_test::ContractWrapper; use cw_orch_core::environment::{BankQuerier, DefaultQueriers, QueryHandler}; - use serde::Serialize; use speculoos::prelude::*; use crate::core::*; @@ -263,9 +262,6 @@ mod test { const SENDER: &str = "cosmos123"; const BALANCE_ADDR: &str = "cosmos456"; - #[derive(Debug, Serialize)] - struct MigrateMsg {} - fn execute( _deps: DepsMut, _env: Env, diff --git a/packages/cw-orch-mock/src/state.rs b/packages/cw-orch-mock/src/state.rs index e25b5db0f..56f54021d 100644 --- a/packages/cw-orch-mock/src/state.rs +++ b/packages/cw-orch-mock/src/state.rs @@ -61,6 +61,10 @@ impl StateInterface for MockState { .insert(contract_id.to_string(), address.to_owned()); } + fn remove_address(&mut self, contract_id: &str) { + self.addresses.remove(contract_id); + } + /// Get the locally-saved version of the contract's version on this network fn get_code_id(&self, contract_id: &str) -> Result { self.code_ids @@ -74,6 +78,10 @@ impl StateInterface for MockState { self.code_ids.insert(contract_id.to_string(), code_id); } + fn remove_code_id(&mut self, contract_id: &str) { + self.code_ids.remove(contract_id); + } + fn get_all_addresses(&self) -> Result, CwEnvError> { Ok(self.addresses.clone()) } diff --git a/packages/cw-orch-networks/Cargo.toml b/packages/cw-orch-networks/Cargo.toml index dad57c46f..dcecaebe8 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.22.0" +version = "0.22.1" authors = { workspace = true } edition = { workspace = true } license = { workspace = true } diff --git a/packages/cw-orch-osmosis-test-tube/Cargo.toml b/packages/cw-orch-osmosis-test-tube/Cargo.toml index f885e6588..9a46ed6f7 100644 --- a/packages/cw-orch-osmosis-test-tube/Cargo.toml +++ b/packages/cw-orch-osmosis-test-tube/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "cw-orch-osmosis-test-tube" -version = "0.1.0" +version = "0.1.1" +description = "Cw-orch environment adapter for osmosis-test-tube" 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 7322f6a05..e2bcf6e3d 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.2.0" +version = "0.3.2" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/packages/interchain/interchain-core/src/env.rs b/packages/interchain/interchain-core/src/env.rs index b63df8ad2..00cdfbf18 100644 --- a/packages/interchain/interchain-core/src/env.rs +++ b/packages/interchain/interchain-core/src/env.rs @@ -234,7 +234,7 @@ pub trait InterchainEnv { &self, chain_id: ChainId, tx_response: ::Response, - ) -> Result<(), InterchainError> { + ) -> Result, InterchainError> { let tx_result = self.wait_ibc(chain_id, tx_response).map_err(Into::into)?; ensure!( @@ -242,7 +242,9 @@ pub trait InterchainEnv { InterchainError::NoPacketsFound {} ); - tx_result.into_result() + tx_result.into_result()?; + + Ok(tx_result) } /// Follow every IBC packets sent out during the transaction diff --git a/packages/interchain/interchain-daemon/Cargo.toml b/packages/interchain/interchain-daemon/Cargo.toml index 339175bab..bb01ef3b9 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.2.0" +version = "0.3.2" 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-daemon/src/interchain_env.rs b/packages/interchain/interchain-daemon/src/interchain_env.rs index 6abc2c182..b0ec67507 100644 --- a/packages/interchain/interchain-daemon/src/interchain_env.rs +++ b/packages/interchain/interchain-daemon/src/interchain_env.rs @@ -28,6 +28,7 @@ use std::time::Duration; use tokio::runtime::Handle; /// Represents a set of locally running blockchain nodes and a Hermes relayer. +#[derive(Clone)] pub struct DaemonInterchainEnv { /// Daemons indexable by network id, i.e. "juno-1", "osmosis-2", ... daemons: HashMap, @@ -89,14 +90,21 @@ impl DaemonInterchainEnv { mnemonic: Option, ) -> IcDaemonResult<()> { let mut daemon_builder = Daemon::builder(); - let daemon_builder = daemon_builder.chain(chain_data.clone()).handle(runtime); + let mut daemon_builder = daemon_builder.chain(chain_data.clone()).handle(runtime); - let daemon_builder = if let Some(mn) = mnemonic { + daemon_builder = if let Some(mn) = mnemonic { daemon_builder.mnemonic(mn) } else { daemon_builder }; + // State is shared between daemons, so if a daemon already exists, we use its state + daemon_builder = if let Some(daemon) = self.daemons.values().next() { + daemon_builder.state(daemon.state()) + } else { + daemon_builder + }; + let daemon = daemon_builder.build().unwrap(); self.add_daemons(vec![daemon]); diff --git a/packages/interchain/interchain-daemon/src/interchain_log.rs b/packages/interchain/interchain-daemon/src/interchain_log.rs index 9372480d6..4727d4fcf 100644 --- a/packages/interchain/interchain-daemon/src/interchain_log.rs +++ b/packages/interchain/interchain-daemon/src/interchain_log.rs @@ -11,6 +11,7 @@ use log4rs::{ }; /// Store the log configuration of the daemon environment +#[derive(Clone)] pub struct InterchainLog { handle: log4rs::Handle, chain_ids: Vec, diff --git a/packages/interchain/interchain-mock/Cargo.toml b/packages/interchain/interchain-mock/Cargo.toml index 24ed2a223..f61339e9a 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.2.0" +version = "0.3.1" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/packages/interchain/interchain-mock/src/interchain.rs b/packages/interchain/interchain-mock/src/interchain.rs index 8eb52e051..575bf0dec 100644 --- a/packages/interchain/interchain-mock/src/interchain.rs +++ b/packages/interchain/interchain-mock/src/interchain.rs @@ -37,6 +37,7 @@ pub type MockBase = cw_orch_mock::MockBase; /// Interchain environment for cw_multi_test Mock environment /// This leverages Abstract's fork of cw_multi_test enabling IBC interactions +#[derive(Clone)] pub struct MockInterchainEnvBase { /// Mock chains registered within the structure pub mocks: HashMap>, @@ -107,7 +108,7 @@ impl MockInterchainEnvBase { } } -impl InterchainEnv> for MockInterchainEnvBase { +impl InterchainEnv> for MockInterchainEnvBase { type ChannelCreationResult = ChannelCreationResult; type Error = InterchainMockError; diff --git a/packages/interchain/proto/Cargo.toml b/packages/interchain/proto/Cargo.toml index 2fe949953..73f3e4d61 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.2.0" +version = "0.3.0" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/packages/interchain/starship/Cargo.toml b/packages/interchain/starship/Cargo.toml index 6ca358b1f..f26021338 100644 --- a/packages/interchain/starship/Cargo.toml +++ b/packages/interchain/starship/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-orch-starship" -version = "0.2.0" +version = "0.3.1" authors.workspace = true edition.workspace = true license.workspace = true diff --git a/packages/interchain/starship/src/lib.rs b/packages/interchain/starship/src/lib.rs index 23de77995..63c9c1023 100644 --- a/packages/interchain/starship/src/lib.rs +++ b/packages/interchain/starship/src/lib.rs @@ -4,7 +4,7 @@ pub mod client; use crate::client::StarshipClient; -use cw_orch_core::environment::{ChainInfoOwned, NetworkInfoOwned}; +use cw_orch_core::environment::{ChainInfoOwned, ChainState, NetworkInfoOwned}; use cw_orch_core::CwEnvError; use cw_orch_daemon::{Daemon, DaemonBuilder}; use ibc_chain_registry::chain::ChainData; @@ -26,7 +26,7 @@ impl Starship { pub fn new(rt_handle: &Handle, url: Option<&str>) -> Result { let starship_client = StarshipClient::new(rt_handle.clone(), url)?; - let mut daemons = HashMap::new(); + let mut daemons: HashMap = HashMap::new(); for chain in starship_client.chains.iter() { let mnemonic = rt_handle.block_on(async { let registry = starship_client.registry().await; @@ -36,12 +36,17 @@ impl Starship { .unwrap() }); - let daemon = DaemonBuilder::default() + let mut daemon_builder = DaemonBuilder::default(); + let mut daemon_builder = daemon_builder .chain(chain_data_conversion(chain.clone())) .mnemonic(mnemonic) - .handle(rt_handle) - .build()?; - daemons.insert(chain.chain_id.to_string(), daemon); + .handle(rt_handle); + + if let Some(existing_daemon) = daemons.values().next() { + daemon_builder = daemon_builder.state(existing_daemon.state()) + } + + daemons.insert(chain.chain_id.to_string(), daemon_builder.build()?); } Ok(Self { diff --git a/packages/interchain/starship/starship/Makefile b/packages/interchain/starship/starship/Makefile index 6dcf77fac..86f254457 100644 --- a/packages/interchain/starship/starship/Makefile +++ b/packages/interchain/starship/starship/Makefile @@ -1,16 +1,17 @@ NAME = tutorial -FILE = ../examples/starship.yaml +FILE = examples/starship.yaml +PORT_FORWARDING_FILE = ../examples/starship.yaml HELM_REPO = starship HELM_CHART = devnet -HELM_VERSION = 0.1.46-rc2 +HELM_VERSION = 0.2.3 ############################################################################### ### All commands ### ############################################################################### .PHONY: setup -setup: setup-helm setup-kind +setup: setup-deps setup-helm setup-kind .PHONY: stop stop: stop-forward delete @@ -24,25 +25,24 @@ clean: stop clean-kind .PHONY: setup-deps setup-deps: - bash $(CURDIR)/scripts/dev-setup.sh + npm install -g @starship-ci/cli + starship install ############################################################################### ### Helm Charts ### ############################################################################### setup-helm: - helm repo add $(HELM_REPO) https://cosmology-tech.github.io/starship/ - helm repo update - helm search repo $(HELM_REPO)/$(HELM_CHART) --version $(HELM_VERSION) + starship setup install: - helm install -f $(FILE) $(NAME) $(HELM_REPO)/$(HELM_CHART) --version $(HELM_VERSION) + starship start --helmFile $(FILE) install-tiny: $(MAKE) install FILE=$(TINY_FILE) delete: - -helm delete $(NAME) + starship stop ############################################################################### ### Port forward ### @@ -50,7 +50,7 @@ delete: .PHONY: port-forward port-forward: - bash $(CURDIR)/port-forward.sh --config=$(FILE) + bash $(CURDIR)/port-forward.sh --config=$(PORT_FORWARDING_FILE) .PHONY: stop-forward stop-forward: diff --git a/packages/macros/cw-orch-fns-derive/Cargo.toml b/packages/macros/cw-orch-fns-derive/Cargo.toml index 2703cad7f..e4caee27c 100644 --- a/packages/macros/cw-orch-fns-derive/Cargo.toml +++ b/packages/macros/cw-orch-fns-derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cw-orch-fns-derive" -version = "0.20.0" +version = "0.21.0" authors = { workspace = true } edition = { workspace = true } license = { workspace = true }