diff --git a/cw-orch-daemon/Cargo.toml b/cw-orch-daemon/Cargo.toml index d2f327527..27c081ae9 100644 --- a/cw-orch-daemon/Cargo.toml +++ b/cw-orch-daemon/Cargo.toml @@ -77,6 +77,7 @@ uid = "0.1.7" # Deserialize network config toml = "0.8" http = "1.1.0" +libc-print = "0.1.23" [dev-dependencies] cw-orch-daemon = { path = "." } diff --git a/cw-orch-daemon/src/log.rs b/cw-orch-daemon/src/log.rs index c28a58b6c..b246ee067 100644 --- a/cw-orch-daemon/src/log.rs +++ b/cw-orch-daemon/src/log.rs @@ -10,9 +10,9 @@ static LOGS_DISABLED: Once = Once::new(); pub fn print_if_log_disabled() -> Result<(), DaemonError> { LOGS_DISABLED.call_once(|| { // Here we check for logging capabilities. - if !log::log_enabled!(log::Level::Info) && DaemonEnvVars::logs_message(){ + if !log::log_enabled!(log::Level::Info) && DaemonEnvVars::logs_message() { println!( - "Warning: It seems like you haven't enabled logs. In order to do so, you have to : + "Warning: It seems like you haven't enabled logs. In order to do so, you have to : - use `env_logger::init()` at the start of your script. - Set the env variable `RUST_LOG=info` for standard logs. See https://docs.rs/env_logger/latest/env_logger/" ) diff --git a/cw-orch-daemon/src/senders/cosmos.rs b/cw-orch-daemon/src/senders/cosmos.rs index 952253f6f..5a762e1ff 100644 --- a/cw-orch-daemon/src/senders/cosmos.rs +++ b/cw-orch-daemon/src/senders/cosmos.rs @@ -347,7 +347,7 @@ impl Wallet { } // If there is not enough asset balance, we need to warn the user - println!( + log::info!( "Not enough funds on chain {} at address {} to deploy the contract. Needed: {}{} but only have: {}. Press 'y' when the wallet balance has been increased to resume deployment", @@ -371,7 +371,7 @@ impl Wallet { }) } } else { - println!("No Manual Interactions, defaulting to 'no'"); + log::info!("No Manual Interactions, defaulting to 'no'"); return Err(DaemonError::NotEnoughBalance { expected: fee.clone(), current: balance, diff --git a/cw-orch-daemon/src/state.rs b/cw-orch-daemon/src/state.rs index 80d88fcfe..fb78f2d24 100644 --- a/cw-orch-daemon/src/state.rs +++ b/cw-orch-daemon/src/state.rs @@ -334,7 +334,6 @@ pub trait DeployedChains: cw_orch_core::contract::Deploy { /// ... /// }, /// "uni-6": { - /// } /// } /// ... diff --git a/cw-orch-daemon/tests/authz.rs b/cw-orch-daemon/tests/authz.rs index 520444397..ae1058d09 100644 --- a/cw-orch-daemon/tests/authz.rs +++ b/cw-orch-daemon/tests/authz.rs @@ -26,6 +26,7 @@ mod tests { #[test] #[serial_test::serial] fn authz() -> anyhow::Result<()> { + super::common::enable_logger(); use cw_orch_networks::networks; let daemon = Daemon::builder(networks::LOCAL_JUNO) diff --git a/cw-orch-daemon/tests/common/mod.rs b/cw-orch-daemon/tests/common/mod.rs index f3aab1991..fd3bd2dc5 100644 --- a/cw-orch-daemon/tests/common/mod.rs +++ b/cw-orch-daemon/tests/common/mod.rs @@ -3,6 +3,7 @@ pub use node::*; #[cfg(feature = "node-tests")] mod node { + use libc_print::libc_println; use std::{env, fs, path::Path, thread::sleep, time::Duration}; use ctor::{ctor, dtor}; @@ -21,30 +22,29 @@ mod node { const LOCAL_MNEMONIC: &str = "clip hire initial neck maid actor venue client foam budget lock catalog sweet steak waste crater broccoli pipe steak sister coyote moment obvious choose"; pub mod state_file { - use super::{fs, Path}; - + use super::*; pub fn exists(file: &str) -> bool { if Path::new(file).exists() { - log::info!("File found: {}", file); + libc_println!("File found: {}", file); true } else { - log::info!("File not found: {}", file); + libc_println!("File not found: {}", file); false } } pub fn remove(file: &str) { if self::exists(file) { - log::info!("Removing state file: {}", file); + libc_println!("Removing state file: {}", file); let _ = fs::remove_file(file); } } } pub mod container { - use crate::common::STAKE_TOKEN; - use super::cmd; + use super::*; + use crate::common::STAKE_TOKEN; pub fn find(name: &String) -> bool { let read = cmd!("docker", "container", "ls", "--all") @@ -56,7 +56,7 @@ mod node { match read { Ok(val) => { - log::info!("Container found: {}", name); + libc_println!("Container found: {}", name); val == *name } Err(_) => false, @@ -98,7 +98,7 @@ mod node { return true; } - log::info!("Stopping container: {}", name); + libc_println!("Stopping container: {}", name); let res = cmd!("docker", "container", "stop", name) .read() @@ -113,7 +113,7 @@ mod node { return true; } - log::info!("Removing container: {}", name); + libc_println!("Removing container: {}", name); let res = cmd!("docker", "container", "rm", name).read().ok().unwrap(); @@ -128,7 +128,7 @@ mod node { } pub fn docker_container_start() { - log::info!("Running docker_container_start"); + libc_println!("Running docker_container_start"); // Set environment variables // this does not seems to be working in this case @@ -150,13 +150,13 @@ mod node { env::set_var("LOCAL_MNEMONIC", LOCAL_MNEMONIC); } - log::info!("Using RUST_LOG: {}", env::var("RUST_LOG").unwrap()); - log::info!("Using CONTAINER_NAME: {}", container); - log::info!( + libc_println!("Using RUST_LOG: {}", env::var("RUST_LOG").unwrap()); + libc_println!("Using CONTAINER_NAME: {}", &container); + libc_println!( "Using STATE_FILE: {}", DaemonEnvVars::state_file().display() ); - log::info!( + libc_println!( "Using LOCAL_MNEMONIC: {:?}", DaemonEnvVars::local_mnemonic() ); @@ -168,7 +168,7 @@ mod node { } pub fn docker_container_stop() { - log::info!("Running docker_container_stop"); + libc_println!("Running docker_container_stop"); container::ensure_removal(&env::var("CONTAINER_NAME").unwrap()); let temp_dir = env::temp_dir(); let expected_state_file = temp_dir.join("cw_orch_test_local.json"); @@ -179,14 +179,19 @@ mod node { #[ctor] fn common_start() { - env_logger::Builder::new() - .filter_level(log::LevelFilter::Debug) - .init(); - docker_container_start() + docker_container_start(); + libc_println!("Finish start"); } #[dtor] fn common_stop() { docker_container_stop() } + + #[cfg(test)] + pub fn enable_logger() { + let _ = env_logger::Builder::new() + .filter_level(log::LevelFilter::Debug) + .try_init(); + } } diff --git a/cw-orch-daemon/tests/daemon_helpers.rs b/cw-orch-daemon/tests/daemon_helpers.rs index 89be56190..1eccfbf28 100644 --- a/cw-orch-daemon/tests/daemon_helpers.rs +++ b/cw-orch-daemon/tests/daemon_helpers.rs @@ -16,6 +16,7 @@ mod tests { #[test] #[serial_test::serial] fn helper_traits() { + super::common::enable_logger(); use cw_orch_networks::networks; let mut daemon = Daemon::builder(networks::LOCAL_JUNO) @@ -87,6 +88,7 @@ mod tests { #[test] #[serial_test::serial] fn cw_orch_interface_traits() { + super::common::enable_logger(); use cw_orch_networks::networks; let daemon = Daemon::builder(networks::LOCAL_JUNO) diff --git a/cw-orch-daemon/tests/index.rs b/cw-orch-daemon/tests/index.rs index 04ba39300..f39fa4bd3 100644 --- a/cw-orch-daemon/tests/index.rs +++ b/cw-orch-daemon/tests/index.rs @@ -9,6 +9,7 @@ mod tests { #[serial_test::serial] fn mnemonic_index() -> anyhow::Result<()> { use cw_orch_networks::networks; + super::common::enable_logger(); let daemon = Daemon::builder(networks::LOCAL_JUNO) .is_test(true) diff --git a/cw-orch-daemon/tests/instantiate2.rs b/cw-orch-daemon/tests/instantiate2.rs index ac8f533b9..b1a16aeab 100644 --- a/cw-orch-daemon/tests/instantiate2.rs +++ b/cw-orch-daemon/tests/instantiate2.rs @@ -15,6 +15,7 @@ pub mod test { #[test] #[serial_test::serial] fn instantiate2() -> anyhow::Result<()> { + super::common::enable_logger(); let app = Daemon::builder(networks::LOCAL_JUNO) .is_test(true) .build() diff --git a/cw-orch-interchain/examples/doc_daemon.rs b/cw-orch-interchain/examples/doc_daemon.rs index 659a9e77e..e312bd797 100644 --- a/cw-orch-interchain/examples/doc_daemon.rs +++ b/cw-orch-interchain/examples/doc_daemon.rs @@ -3,7 +3,6 @@ use cw_orch::prelude::*; use cw_orch_interchain::{ ChannelCreationValidator, ChannelCreator, DaemonInterchain, InterchainEnv, Starship, }; -/// Others fn create_daemon_env() -> cw_orch::anyhow::Result { // ANCHOR: DAEMON_INTERCHAIN_CREATION diff --git a/cw-orch/examples/async_daemon.rs b/cw-orch/examples/async_daemon.rs index 48e5d9512..355f39cc8 100644 --- a/cw-orch/examples/async_daemon.rs +++ b/cw-orch/examples/async_daemon.rs @@ -3,7 +3,9 @@ use cw_orch_daemon::DaemonAsync; use cw_orch_mock::Mock; /// In order to use this script, you need to set the following env variables +/// /// RUST_LOG (recommended value `info`) to see the app logs +/// /// TEST_MNEMONIC to be able to sign and broadcast a transaction on UNI testnet #[tokio::main] pub async fn main() -> anyhow::Result<()> { diff --git a/cw-orch/examples/complex_testnet_daemon.rs b/cw-orch/examples/complex_testnet_daemon.rs index f1b9d8dd2..894f3d569 100644 --- a/cw-orch/examples/complex_testnet_daemon.rs +++ b/cw-orch/examples/complex_testnet_daemon.rs @@ -19,6 +19,7 @@ // pub const SUBDENOM: &str = "complex-test"; /// In order to use this script, you need to set the following env variables +/// /// RUST_LOG (recommended value `info`) to see the app logs /// TEST_MNEMONIC to be able to sign and broadcast a transaction on UNI testnet pub fn main() { diff --git a/cw-orch/examples/testnet_daemon.rs b/cw-orch/examples/testnet_daemon.rs index cab2c5069..ebdcf6535 100644 --- a/cw-orch/examples/testnet_daemon.rs +++ b/cw-orch/examples/testnet_daemon.rs @@ -8,6 +8,7 @@ use cw_orch::{ }; /// In order to use this script, you need to set the following env variables +/// /// RUST_LOG (recommended value `info`) to see the app logs /// TEST_MNEMONIC to be able to sign and broadcast a transaction on UNI testnet pub fn main() { diff --git a/cw-orch/src/snapshots.rs b/cw-orch/src/snapshots.rs index e20ccfb18..65fa8f7de 100644 --- a/cw-orch/src/snapshots.rs +++ b/cw-orch/src/snapshots.rs @@ -22,7 +22,6 @@ pub fn parse_storage(storage: &[(Vec, Vec)]) -> Vec<(String, String)> { /// The name you input to the function should be different from all other snapshots in your repository /// Find more details on how snapshot testing works on the official quick-start guide: https://insta.rs/docs/quickstart/ /// This function will panic if the snapshot is different from the reference snapshot - #[macro_export] macro_rules! take_storage_snapshot { ($chain: ident, $name: literal) => { @@ -49,7 +48,7 @@ macro_rules! take_storage_snapshot { } #[cfg(test)] -pub mod tests { +mod tests { use crate::mock::cw_multi_test::ContractWrapper; use cosmwasm_std::Empty; use cw_orch::prelude::{CwOrchInstantiate, CwOrchUpload, Mock}; diff --git a/packages/cw-orch-networks/src/networks/mod.rs b/packages/cw-orch-networks/src/networks/mod.rs index 77fa10f30..f7dd0fe5e 100644 --- a/packages/cw-orch-networks/src/networks/mod.rs +++ b/packages/cw-orch-networks/src/networks/mod.rs @@ -44,7 +44,6 @@ pub use xion::XION_TESTNET_1; /// ``` /// --- /// supported chains are defined by the `SUPPORT_NETWORKS` variable - pub fn parse_network(net_id: &str) -> Result { SUPPORTED_NETWORKS .iter() diff --git a/packages/interchain/interchain-core/src/channel.rs b/packages/interchain/interchain-core/src/channel.rs index 60edb6c60..30859fa06 100644 --- a/packages/interchain/interchain-core/src/channel.rs +++ b/packages/interchain/interchain-core/src/channel.rs @@ -1,4 +1,5 @@ //! This defines types and traits associated with IBC channels. +//! //! Those structures are mostly used internally for dealing with channel creation and analysis //! But they can also be used in a user application if they need specific channel description diff --git a/packages/interchain/interchain-core/src/env.rs b/packages/interchain/interchain-core/src/env.rs index c760eb481..30d1c76ab 100644 --- a/packages/interchain/interchain-core/src/env.rs +++ b/packages/interchain/interchain-core/src/env.rs @@ -29,7 +29,6 @@ use crate::{ /// In this example the struct contains all transaction results for channel creation /// Those transactions are usually sent by a validator /// [More info about channel creation here](https://github.com/cosmos/ibc/blob/main/spec/core/ics-004-channel-and-packet-semantics/README.md) - pub struct ChannelCreation { /// First step, channel creation open-initialization (src_chain) pub init: R, @@ -57,6 +56,7 @@ impl ChannelCreation { pub type ChainId<'a> = &'a str; /// This trait allows to extend `cw_orch::prelude::CwEnv` with interchain capabilities +/// /// The center of those capabilities is the ability to follow the execution of outgoing IBC packets /// This enables users to script chain execution even throughout IBC executions which are more asynchronous than usual transactions. /// With the following simple syntax, users are even able to await and analyze the execution of all packets submitted in a single transactions @@ -73,9 +73,9 @@ pub type ChainId<'a> = &'a str; /// use cw_orch::mock::cw_multi_test::Executor; /// use cw_orch_interchain::prelude::*; /// use ibc_relayer_types::core::ics24_host::identifier::PortId; - +/// /// let interchain = MockInterchainEnv::new(vec![("juno-1", "sender"), ("stargaze-1", "sender")]); - +/// /// let channel = interchain.create_channel( /// "juno-1", /// "stargaze-1", @@ -86,11 +86,11 @@ pub type ChainId<'a> = &'a str; /// ).unwrap(); /// let juno = interchain.get_chain("juno-1").unwrap(); /// let stargaze = interchain.get_chain("stargaze-1").unwrap(); - +/// /// let channel = channel /// .interchain_channel /// .get_ordered_ports_from("juno-1").unwrap(); - +/// /// juno.add_balance(&juno.sender_addr(), vec![coin(100_000, "ujuno")]).unwrap(); /// let tx_resp = juno.app.borrow_mut().execute( /// juno.sender_addr(), @@ -105,7 +105,7 @@ pub type ChainId<'a> = &'a str; /// memo: None, /// }), /// ).unwrap(); - +/// /// // This makes sure that the packets arrive successfully and present a success ack /// let result = interchain.await_and_check_packets("juno-1", tx_resp).unwrap(); /// ``` @@ -379,9 +379,9 @@ pub trait InterchainEnv { /// use cw_orch::mock::cw_multi_test::Executor; /// use cw_orch_interchain::prelude::*; /// use ibc_relayer_types::core::ics24_host::identifier::PortId; - + /// /// let interchain = MockInterchainEnv::new(vec![("juno-1", "sender"), ("stargaze-1", "sender")]); - + /// /// let channel = interchain.create_channel( /// "juno-1", /// "stargaze-1", @@ -392,11 +392,11 @@ pub trait InterchainEnv { /// ).unwrap(); /// let juno = interchain.get_chain("juno-1").unwrap(); /// let stargaze = interchain.get_chain("stargaze-1").unwrap(); - + /// /// let channel = channel /// .interchain_channel /// .get_ordered_ports_from("juno-1").unwrap(); - + /// /// juno.add_balance(&juno.sender_addr(), vec![coin(100_000, "ujuno")]).unwrap(); /// let tx_resp = juno.app.borrow_mut().execute( /// juno.sender_addr(), @@ -411,7 +411,7 @@ pub trait InterchainEnv { /// memo: None, /// }), /// ).unwrap(); - + /// /// // This makes sure that the packets arrive successfully and present a success ack /// let result = interchain.await_and_check_packets("juno-1", tx_resp).unwrap(); /// ``` diff --git a/packages/interchain/interchain-daemon/src/interchain_log.rs b/packages/interchain/interchain-daemon/src/interchain_log.rs index 4727d4fcf..956cedd6b 100644 --- a/packages/interchain/interchain-daemon/src/interchain_log.rs +++ b/packages/interchain/interchain-daemon/src/interchain_log.rs @@ -62,7 +62,6 @@ impl InterchainLog { /// Initiates an interchain log setup /// This will log the different chain interactions and updates on separate files for each chain. /// This is useful for tracking operations happenning on IBC chains - pub fn new() -> Self { Self::default() } diff --git a/packages/interchain/interchain-mock/src/interchain.rs b/packages/interchain/interchain-mock/src/interchain.rs index 920ca6bec..c15f4c168 100644 --- a/packages/interchain/interchain-mock/src/interchain.rs +++ b/packages/interchain/interchain-mock/src/interchain.rs @@ -37,7 +37,6 @@ 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 - pub struct MockInterchainEnvBase { /// Mock chains registered within the structure pub mocks: HashMap>, diff --git a/packages/macros/cw-orch-fns-derive/src/lib.rs b/packages/macros/cw-orch-fns-derive/src/lib.rs index 49f2c5c74..8fce2c42f 100644 --- a/packages/macros/cw-orch-fns-derive/src/lib.rs +++ b/packages/macros/cw-orch-fns-derive/src/lib.rs @@ -11,6 +11,7 @@ use proc_macro::TokenStream; use syn::{parse_macro_input, ItemEnum}; /// Available attributes are : +/// /// payable - The Execute function can accept funds /// fn_name - Modify the generated function name (useful for query or execute variants for instance) /// disable_fields_sorting - By default the fields are sorted on named variants. Disabled this behavior @@ -23,6 +24,7 @@ pub fn cw_orch_execute(input: TokenStream) -> TokenStream { } /// Available attributes are : +/// /// returns - The return type of the query /// fn_name - Modify the generated function name (useful for query or execute variants for instance) /// disable_fields_sorting - By default the fields are sorted on named variants. Disabled this behavior