diff --git a/Cargo.toml b/Cargo.toml index 16553dede..b02bca409 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,11 +29,7 @@ repository = "https://github.com/AbstractSDK/cw-orchestrator" [workspace.dependencies] cw-utils = { version = "2.0.0" } -cosmwasm-std = { version = "2.1", features = [ - "cosmwasm_2_0", - "staking", - "stargate", -] } +cosmwasm-std = { version = "2.1" } cw-storage-plus = { version = "2.0.0" } cosmos-sdk-proto = { version = "0.24.0", default-features = false } @@ -49,6 +45,7 @@ neutron-test-tube = { version = "4.2.3" } anyhow = "1.0" serde = { version = "1.0.208", default-features = false, features = ["derive"] } tokio = { version = "1.39", features = ["full"] } +async-std = "1.13.0" cw-orch = { path = "./cw-orch", version = "0.27.0" } cw-orch-daemon = { path = "./cw-orch-daemon", version = "0.28.0" } diff --git a/artifacts/checksums.txt b/artifacts/checksums.txt index a85e2ea5e..da824cbbf 100644 --- a/artifacts/checksums.txt +++ b/artifacts/checksums.txt @@ -1,4 +1,5 @@ -cc02664dc02c571fd0e4bb02061b737571a510a6a4ac01f8cc783545bec6fff4 counter_contract.wasm +9f8d3bc6ea5c58c31dbed31588df591447ffd2410b3c4d1587e2adb8a29c0931 counter_contract.wasm +4bb1891434224d710cb1f9eea1da1a2a0aa3c4a133d699d58e26e72daf51b63b counter_cousin_contract.wasm a266c5ab0ffdf78b3aee593d07d3c822fa3c2745bc7bc8210e49860439d65a73 cw_orch_compatibility_test.wasm -0dc79fb31e732310554a07881cfe8a193c068d2f93539356817e5aaf551650dd mock_contract.wasm -08d65b781d7357a6777c836229d971b6c87a5fdfc7cba9806ed508f917859f08 mock_contract_u64.wasm +322d2535c672abb0338f23689d703a468d6bdebe9ce975a842e9a8d5e95bf770 mock_contract.wasm +cdc883c20f370bd68494912e28053f0bef666e8f96c889ba8412b50f4a2cd1ed mock_contract_u64.wasm diff --git a/artifacts/counter_contract.wasm b/artifacts/counter_contract.wasm index 2ee52daf1..e3cad79f0 100644 Binary files a/artifacts/counter_contract.wasm and b/artifacts/counter_contract.wasm differ diff --git a/artifacts/counter_cousin_contract.wasm b/artifacts/counter_cousin_contract.wasm new file mode 100644 index 000000000..bff262991 Binary files /dev/null and b/artifacts/counter_cousin_contract.wasm differ diff --git a/artifacts/mock_contract.wasm b/artifacts/mock_contract.wasm index 256dae795..26fef7d31 100644 Binary files a/artifacts/mock_contract.wasm and b/artifacts/mock_contract.wasm differ diff --git a/artifacts/mock_contract_u64.wasm b/artifacts/mock_contract_u64.wasm index e5108ea3d..0dc066d01 100644 Binary files a/artifacts/mock_contract_u64.wasm and b/artifacts/mock_contract_u64.wasm differ diff --git a/contracts-ws/Cargo.toml b/contracts-ws/Cargo.toml index e9b454ef9..3b015d278 100644 --- a/contracts-ws/Cargo.toml +++ b/contracts-ws/Cargo.toml @@ -12,6 +12,7 @@ cosmwasm-std = "2.0.0" cw20 = { version = "2.0.0" } cw20-base = { version = "2.0.0" } cw-storage-plus = { version = "2.0.0" } +async-std = "1.13.0" serde = { version = "1.0.103", default-features = false, features = ["derive"] } anyhow = "1.0" diff --git a/contracts-ws/contracts/counter/Cargo.toml b/contracts-ws/contracts/counter/Cargo.toml index 86b59ea77..8aa09c816 100644 --- a/contracts-ws/contracts/counter/Cargo.toml +++ b/contracts-ws/contracts/counter/Cargo.toml @@ -24,7 +24,7 @@ serde = { workspace = true } serde_json = "1.0.125" cw-orch = { workspace = true, features = ["daemon"] } # Unused, only there to check for wasm compatibility -cw-orch-interchain = { workspace = true, features = ["daemon"] } +# cw-orch-interchain = { workspace = true, features = ["daemon"] } [[example]] name = "deploy" @@ -35,3 +35,4 @@ dotenv = { version = "0.15.0" } pretty_env_logger = { version = "0.5.0" } cw-orch = { workspace = true, features = ["daemon"] } anyhow = { workspace = true } +async-std = { workspace = true } diff --git a/contracts-ws/contracts/counter/examples/async.rs b/contracts-ws/contracts/counter/examples/async.rs index 320b595c8..93083fb4d 100644 --- a/contracts-ws/contracts/counter/examples/async.rs +++ b/contracts-ws/contracts/counter/examples/async.rs @@ -1,12 +1,12 @@ // ANCHOR: full_async_example use counter_contract::AsyncCounterQueryMsgFns; use counter_contract::CounterContract; -use cw_orch::{anyhow, prelude::*, tokio}; +use cw_orch::{anyhow, prelude::*}; // From https://github.com/CosmosContracts/juno/blob/32568dba828ff7783aea8cb5bb4b8b5832888255/docker/test-user.env#L2 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"; -#[tokio::main] +#[async_std::main] pub async fn main() -> anyhow::Result<()> { std::env::set_var("LOCAL_MNEMONIC", LOCAL_MNEMONIC); dotenv::dotenv().ok(); // Used to load the `.env` file if any diff --git a/contracts-ws/contracts/counter_cousin/Cargo.toml b/contracts-ws/contracts/counter_cousin/Cargo.toml index 7463af099..5d5dc7722 100644 --- a/contracts-ws/contracts/counter_cousin/Cargo.toml +++ b/contracts-ws/contracts/counter_cousin/Cargo.toml @@ -24,7 +24,7 @@ serde = { workspace = true } serde_json = "1.0.125" cw-orch = { workspace = true, features = ["daemon"] } # Unused, only there to check for wasm compatibility -cw-orch-interchain = { workspace = true, features = ["daemon"] } +# cw-orch-interchain = { workspace = true, features = ["daemon"] } cw-orch-on-chain = { path = "../../../packages/cw-orch-on-chain" } @@ -34,3 +34,4 @@ dotenv = { version = "0.15.0" } pretty_env_logger = { version = "0.5.0" } cw-orch = { workspace = true, features = ["daemon"] } anyhow = { workspace = true } +cw-orch-osmosis-test-tube = { path = "../../../packages/cw-orch-osmosis-test-tube" } diff --git a/contracts-ws/contracts/counter_cousin/src/contract.rs b/contracts-ws/contracts/counter_cousin/src/contract.rs index bff16dc53..736c7a6d5 100644 --- a/contracts-ws/contracts/counter_cousin/src/contract.rs +++ b/contracts-ws/contracts/counter_cousin/src/contract.rs @@ -22,7 +22,6 @@ pub fn instantiate( let state = State { count: msg.count, owner: info.sender.clone(), - cousin: None, }; set_contract_version(deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?; STATE.save(deps.storage, &state)?; @@ -52,7 +51,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { match msg { QueryMsg::GetCount {} => to_json_binary(&query::count(deps)?), QueryMsg::GetCousinCount {} => to_json_binary(&query::cousin_count(deps, env)?), - QueryMsg::GetRawCousinCount {} => to_json_binary(&query::raw_cousin_count(deps)?), + QueryMsg::GetRawCousinCount {} => to_json_binary(&query::raw_cousin_count(deps, &env)?), } } diff --git a/contracts-ws/contracts/counter_cousin/src/execute.rs b/contracts-ws/contracts/counter_cousin/src/execute.rs index cc7bce6f8..da898d556 100644 --- a/contracts-ws/contracts/counter_cousin/src/execute.rs +++ b/contracts-ws/contracts/counter_cousin/src/execute.rs @@ -1,5 +1,7 @@ use cosmwasm_std::{DepsMut, Env, MessageInfo, Response}; +use cw_orch::prelude::*; +use crate::CounterContract; use crate::{error::*, state::*}; pub fn increment(deps: DepsMut) -> Result { @@ -23,18 +25,16 @@ pub fn reset(deps: DepsMut, info: MessageInfo, count: i32) -> Result Result { + assert_owner(deps.as_ref(), &info)?; + let cousin_addr = deps.api.addr_validate(&cousin)?; - let state = STATE.load(deps.storage)?; - if info.sender != state.owner { - return Err(ContractError::Unauthorized {}); - } - crate::CounterContract::save(deps.branch(), &env, "cousin", cousin_addr.clone()); + CounterContract::load(deps, &env, "cousin").set_address(&cousin_addr); Ok(Response::new().add_attribute("action", "set_cousin")) } diff --git a/contracts-ws/contracts/counter_cousin/src/interface.rs b/contracts-ws/contracts/counter_cousin/src/interface.rs index 0ad420b02..7e18cb059 100644 --- a/contracts-ws/contracts/counter_cousin/src/interface.rs +++ b/contracts-ws/contracts/counter_cousin/src/interface.rs @@ -5,7 +5,6 @@ use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}; use cw_orch_on_chain::core::OnChain; use cosmwasm_std::{Deps, Env}; -use std::collections::HashMap; #[interface(InstantiateMsg, ExecuteMsg, QueryMsg, MigrateMsg)] pub struct CounterContract; @@ -14,7 +13,7 @@ impl Uploadable for CounterContract { /// Return the path to the wasm file corresponding to the contract fn wasm(_chain: &ChainInfoOwned) -> WasmPath { artifacts_dir_from_workspace!() - .find_wasm_path("counter_contract") + .find_wasm_path("counter_cousin_contract") .unwrap() } /// Returns a CosmWasm contract wrapper @@ -27,11 +26,7 @@ impl Uploadable for CounterContract { } } // ANCHOR_END: custom_interface - -use crate::contract::CONTRACT_NAME; use cosmwasm_std::DepsMut; -use cw_orch::anyhow::Result; -use cw_orch::prelude::queriers::Node; use cw_orch_on_chain::core::OnChainDeps; impl<'a> CounterContract> { @@ -68,36 +63,3 @@ impl<'a> CounterContract> { contract } } - -// ANCHOR: daemon -impl CounterContract { - /// Deploys the counter contract at a specific block height - pub fn await_launch(&self) -> Result<()> { - let daemon = self.environment(); - let rt = daemon.rt_handle.clone(); - - rt.block_on(async { - // Get the node query client, there are a lot of other clients available. - let node: Node = daemon.querier(); - let mut latest_block = node.latest_block().unwrap(); - - while latest_block.height < 100 { - // wait for the next block - daemon.next_block().unwrap(); - latest_block = node.latest_block().unwrap(); - } - }); - - let contract = CounterContract::new(CONTRACT_NAME, daemon.clone()); - - // Upload the contract - contract.upload().unwrap(); - - // Instantiate the contract - let msg = InstantiateMsg { count: 1i32 }; - contract.instantiate(&msg, None, &[]).unwrap(); - - Ok(()) - } -} -// ANCHOR_END: daemon diff --git a/contracts-ws/contracts/counter_cousin/src/msg.rs b/contracts-ws/contracts/counter_cousin/src/msg.rs index a936c42cb..d660815a7 100644 --- a/contracts-ws/contracts/counter_cousin/src/msg.rs +++ b/contracts-ws/contracts/counter_cousin/src/msg.rs @@ -22,7 +22,9 @@ pub enum ExecuteMsg { /// Count value after reset count: i32, }, + /// Sets the cousin contract, that this contract can query SetCousin { + /// Address of the cousin contract of this counter cousin: String, }, } diff --git a/contracts-ws/contracts/counter_cousin/src/query.rs b/contracts-ws/contracts/counter_cousin/src/query.rs index 9ff77bc95..8f2e3ab21 100644 --- a/contracts-ws/contracts/counter_cousin/src/query.rs +++ b/contracts-ws/contracts/counter_cousin/src/query.rs @@ -1,11 +1,9 @@ -use cosmwasm_std::{to_json_binary, Deps, Env, QueryRequest, StdResult, WasmQuery}; +use cosmwasm_std::{Deps, Env, StdResult}; use crate::interface::CounterContract; use crate::msg::QueryMsgFns; -use crate::{ - msg::{GetCountResponse, QueryMsg}, - state::STATE, -}; +use crate::{msg::GetCountResponse, state::STATE}; +use cw_orch::prelude::*; pub fn count(deps: Deps) -> StdResult { let state = STATE.load(deps.storage)?; @@ -18,9 +16,8 @@ pub fn cousin_count(deps: Deps, env: Env) -> StdResult { .map_err(Into::into) } -pub fn raw_cousin_count(deps: Deps) -> StdResult { - let state = STATE.load(deps.storage)?; - let cousin_state = STATE.query(&deps.querier, state.cousin.unwrap())?; +pub fn raw_cousin_count(deps: Deps, env: &Env) -> StdResult { + let cousin_state = CounterContract::load(deps, env, "cousin").item_query(STATE)?; Ok(GetCountResponse { count: cousin_state.count, }) diff --git a/contracts-ws/contracts/counter_cousin/src/state.rs b/contracts-ws/contracts/counter_cousin/src/state.rs index 7fe15222f..d3493aa65 100644 --- a/contracts-ws/contracts/counter_cousin/src/state.rs +++ b/contracts-ws/contracts/counter_cousin/src/state.rs @@ -1,14 +1,22 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use cosmwasm_std::Addr; +use crate::ContractError; +use cosmwasm_std::{Addr, Deps, MessageInfo}; use cw_storage_plus::Item; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] pub struct State { pub count: i32, pub owner: Addr, - pub cousin: Option, } pub const STATE: Item = Item::new("state"); + +pub fn assert_owner(deps: Deps, info: &MessageInfo) -> Result<(), ContractError> { + let state = STATE.load(deps.storage)?; + if info.sender != state.owner { + return Err(ContractError::Unauthorized {}); + } + Ok(()) +} diff --git a/contracts-ws/contracts/counter_cousin/tests/integration_tests.rs b/contracts-ws/contracts/counter_cousin/tests/integration_tests.rs index 5ae44b909..bb24b1eba 100644 --- a/contracts-ws/contracts/counter_cousin/tests/integration_tests.rs +++ b/contracts-ws/contracts/counter_cousin/tests/integration_tests.rs @@ -1,21 +1,18 @@ -// ANCHOR: all use counter_cousin_contract::{ - msg::{GetCountResponse, InstantiateMsg, QueryMsg}, - ContractError, CounterContract, CounterExecuteMsgFns, CounterQueryMsgFns, + msg::InstantiateMsg, CounterContract, CounterExecuteMsgFns, CounterQueryMsgFns, }; // Use prelude to get all the necessary imports use cw_orch::prelude::*; +use cw_orch_osmosis_test_tube::OsmosisTestTube; -use cosmwasm_std::Addr; +use cosmwasm_std::{coins, Addr}; // consts for testing const USER: &str = "user"; const ADMIN: &str = "admin"; -// ANCHOR: integration_test -// ANCHOR: count_test #[test] -fn count() -> anyhow::Result<()> { +fn mock() -> anyhow::Result<()> { // Create the mock. This will be our chain object throughout let mock = Mock::new(ADMIN); let user = Addr::unchecked(USER); @@ -45,9 +42,45 @@ fn count() -> anyhow::Result<()> { Ok(()) } -// ANCHOR_END: count_test -// ANCHOR: setup +#[test] +fn test_tube() -> anyhow::Result<()> { + // Create the mock. This will be our chain object throughout + let mut test_tube = OsmosisTestTube::new(coins(100_000_000_000_000, "uosmo")); + let user = test_tube.init_account(coins(100_000_000_000_000, "uosmo"))?; + + // Set up the contract (Definition below) ↓↓ + let (contract, cousin) = setup(test_tube.clone())?; + + // Increment the count of the contract + contract.call_as(&user).increment()?; + contract.call_as(&user).increment()?; + + cousin.call_as(&user).increment()?; + cousin.call_as(&user).increment()?; + cousin.call_as(&user).increment()?; + + let count = contract.get_count()?; + assert_eq!(count.count, 3); + + let count = contract.get_cousin_count()?; + assert_eq!(count.count, 4); + + let count = cousin.get_count()?; + assert_eq!(count.count, 4); + + let count = cousin.get_cousin_count()?; + assert_eq!(count.count, 3); + + let count = contract.get_raw_cousin_count()?; + assert_eq!(count.count, 4); + + let count = cousin.get_raw_cousin_count()?; + assert_eq!(count.count, 3); + + Ok(()) +} + /// Instantiate the contract in any CosmWasm environment fn setup( chain: Chain, @@ -73,7 +106,3 @@ fn setup( // Return the interface Ok((contract, cousin)) } -// ANCHOR_END: setup - -// ANCHOR_END: integration_test -// ANCHOR_END: all diff --git a/contracts-ws/contracts/mock_contract/src/msg_tests.rs b/contracts-ws/contracts/mock_contract/src/msg_tests.rs index e4f9333c4..34d668c39 100644 --- a/contracts-ws/contracts/mock_contract/src/msg_tests.rs +++ b/contracts-ws/contracts/mock_contract/src/msg_tests.rs @@ -57,19 +57,19 @@ pub fn execute_ordered( pub fn query(_deps: Deps, _env: Env, _msg: Empty) -> StdResult { Ok(vec![].into()) } -#[cfg(not(target_arch = "wasm32"))] + mod interface { use super::*; use cw_orch::prelude::*; impl Uploadable for TestContract { - fn wrapper() -> ::ContractSource { + fn wrapper() -> Box> { Box::new(ContractWrapper::new_with_empty(execute, instantiate, query)) } } impl Uploadable for OrderedTestContract { - fn wrapper() -> ::ContractSource { + fn wrapper() -> Box> { Box::new(ContractWrapper::new_with_empty( execute_ordered, instantiate, diff --git a/cw-orch-daemon/Cargo.toml b/cw-orch-daemon/Cargo.toml index 23c7feea0..f24dfd8cc 100644 --- a/cw-orch-daemon/Cargo.toml +++ b/cw-orch-daemon/Cargo.toml @@ -44,7 +44,6 @@ bitcoin = { version = "0.32.2" } bech32 = { version = "0.11.0", default-features = false, features = ["alloc"] } hex = { version = "0.4.3" } ripemd = { version = "0.1.3" } -tokio = { workspace = true, features = ["full"] } tonic = { workspace = true, features = ["tls"] } reqwest = { version = "0.12.5" } base64 = { version = "0.22.1" } @@ -78,6 +77,7 @@ uid = "0.1.7" toml = "0.8" http = "1.1.0" libc-print = "0.1.23" +async-std = { workspace = true, features = ["attributes"] } [dev-dependencies] cw-orch-daemon = { path = "." } diff --git a/cw-orch-daemon/examples/batch-sender.rs b/cw-orch-daemon/examples/batch-sender.rs index f64f1178c..c0e521035 100644 --- a/cw-orch-daemon/examples/batch-sender.rs +++ b/cw-orch-daemon/examples/batch-sender.rs @@ -1,3 +1,4 @@ +use async_std::task::block_on; use counter_contract::{ msg::InstantiateMsg, CounterContract, CounterExecuteMsgFns, CounterQueryMsgFns, }; @@ -26,7 +27,7 @@ pub fn main() -> anyhow::Result<()> { let count = counter.get_count()?; assert_eq!(count.count, 0); - chain.rt_handle.block_on(chain.sender().broadcast(None))?; + block_on(chain.sender().broadcast(None))?; let count = counter.get_count()?; assert_eq!(count.count, 1); @@ -39,7 +40,7 @@ pub fn main() -> anyhow::Result<()> { counter.increment()?; counter.increment()?; - chain.rt_handle.block_on(chain.sender().broadcast(None))?; + block_on(chain.sender().broadcast(None))?; let count = counter.get_count()?; assert_eq!(count.count, 7); diff --git a/cw-orch-daemon/examples/daemon-capabilities.rs b/cw-orch-daemon/examples/daemon-capabilities.rs index 25b7cf49b..a492c32fc 100644 --- a/cw-orch-daemon/examples/daemon-capabilities.rs +++ b/cw-orch-daemon/examples/daemon-capabilities.rs @@ -3,6 +3,7 @@ use std::str::FromStr; use cosmrs::{tx::Msg, AccountId, Coin, Denom}; use cosmwasm_std::{coins, Addr}; // ANCHOR: full_counter_example +use async_std::task::block_on; use cw_orch_daemon::senders::tx::TxSender; use cw_orch_daemon::DaemonBuilder; use cw_orch_networks::networks; @@ -21,8 +22,7 @@ pub fn main() -> anyhow::Result<()> { // ANCHOR: send_tx let wallet = daemon.sender(); - let rt = daemon.rt_handle.clone(); - rt.block_on(wallet.bank_send( + block_on(wallet.bank_send( &Addr::unchecked(""), coins(345, "ujunox"), ))?; @@ -45,11 +45,11 @@ pub fn main() -> anyhow::Result<()> { denom: Denom::from_str("ujuno").unwrap(), }, }; - rt.block_on(wallet.commit_tx(vec![tx_msg.clone()], None))?; + block_on(wallet.commit_tx(vec![tx_msg.clone()], None))?; // ANCHOR_END: cosmrs_tx // ANCHOR: any_tx - rt.block_on(wallet.commit_tx_any( + block_on(wallet.commit_tx_any( vec![cosmrs::Any { type_url: "/cosmos.staking.v1beta1.MsgBeginRedelegate".to_string(), value: tx_msg.to_any().unwrap().value, @@ -59,8 +59,7 @@ pub fn main() -> anyhow::Result<()> { // ANCHOR_END: any_tx // ANCHOR: simulate_tx - let (gas_needed, fee_needed) = - rt.block_on(wallet.simulate(vec![tx_msg.to_any().unwrap()], None))?; + let (gas_needed, fee_needed) = block_on(wallet.simulate(vec![tx_msg.to_any().unwrap()], None))?; log::info!( "Submitting this transaction will necessitate: diff --git a/cw-orch-daemon/examples/hd_index.rs b/cw-orch-daemon/examples/hd_index.rs index c407e3496..3acbc1681 100644 --- a/cw-orch-daemon/examples/hd_index.rs +++ b/cw-orch-daemon/examples/hd_index.rs @@ -1,3 +1,4 @@ +use async_std::task::block_on; use cosmwasm_std::coins; use cw_orch::{anyhow, prelude::*}; use cw_orch_daemon::CosmosOptions; @@ -16,7 +17,7 @@ pub fn main() -> anyhow::Result<()> { .authz_granter(&Addr::unchecked(LOCAL_JUNO_GRANTER)); let chain = Daemon::builder(network).build_sender(sender)?; - chain.rt_handle.block_on( + block_on( chain .sender() .bank_send(&Addr::unchecked(LOCAL_JUNO_GRANTER), coins(10000, "ujuno")), diff --git a/cw-orch-daemon/src/channel.rs b/cw-orch-daemon/src/channel.rs index 6f58ac461..d3505fc59 100644 --- a/cw-orch-daemon/src/channel.rs +++ b/cw-orch-daemon/src/channel.rs @@ -84,7 +84,7 @@ mod tests { use crate::DaemonAsync; use speculoos::prelude::*; - #[tokio::test] + #[async_std::test] #[serial_test::serial] async fn no_connection() { let mut chain = cw_orch_daemon::networks::LOCAL_JUNO; @@ -103,7 +103,7 @@ mod tests { )) } - #[tokio::test] + #[async_std::test] #[serial_test::serial] async fn network_grpcs_list_is_empty() { let mut chain = cw_orch_daemon::networks::LOCAL_JUNO; diff --git a/cw-orch-daemon/src/core.rs b/cw-orch-daemon/src/core.rs index f3b7f5fd9..5835be81c 100644 --- a/cw-orch-daemon/src/core.rs +++ b/cw-orch-daemon/src/core.rs @@ -173,12 +173,12 @@ impl DaemonAsyncBase { let wait_time = average_block_speed.mul_f64(amount as f64); // now wait for that amount of time - tokio::time::sleep(wait_time).await; + async_std::task::sleep(wait_time).await; // now check every block until we hit the target while last_height < end_height { // wait - tokio::time::sleep(average_block_speed).await; + async_std::task::sleep(average_block_speed).await; // ping latest block last_height = Node::new_async(self.channel())._block_height().await?; @@ -188,7 +188,7 @@ impl DaemonAsyncBase { /// Wait for a given amount of seconds. pub async fn wait_seconds(&self, secs: u64) -> Result<(), DaemonError> { - tokio::time::sleep(Duration::from_secs(secs)).await; + async_std::task::sleep(Duration::from_secs(secs)).await; Ok(()) } diff --git a/cw-orch-daemon/src/lib.rs b/cw-orch-daemon/src/lib.rs index 18f529eac..2e1045296 100644 --- a/cw-orch-daemon/src/lib.rs +++ b/cw-orch-daemon/src/lib.rs @@ -55,7 +55,3 @@ pub(crate) mod cosmos_modules { tendermint::v0_34::abci as tendermint_abci, }; } - -lazy_static::lazy_static! { - pub static ref RUNTIME: tokio::runtime::Runtime = tokio::runtime::Runtime::new().unwrap(); -} diff --git a/cw-orch-daemon/src/live_mock.rs b/cw-orch-daemon/src/live_mock.rs index 98aae87cc..e67b2fd18 100644 --- a/cw-orch-daemon/src/live_mock.rs +++ b/cw-orch-daemon/src/live_mock.rs @@ -4,7 +4,7 @@ use crate::queriers::Bank; use crate::queriers::CosmWasm; use crate::queriers::Staking; -use crate::RUNTIME; +use async_std::task::block_on; use cosmwasm_std::testing::{MockApi, MockStorage}; use cosmwasm_std::Addr; use cosmwasm_std::AllBalanceResponse; @@ -78,20 +78,17 @@ impl WasmMockQuerier { /// Function used to handle a query and customize the query behavior /// This implements some queries by querying an actual node for the responses pub fn handle_query(&self, request: &QueryRequest) -> QuerierResult { - let handle = RUNTIME.handle(); match &request { QueryRequest::Wasm(x) => { - let querier = CosmWasm::new_sync(self.channel.clone(), handle); + let querier = CosmWasm::new_sync(self.channel.clone()); match x { WasmQuery::Smart { contract_addr, msg } => { // We forward the request to the cosmwasm querier - let query_result: Result = handle - .block_on( - querier - ._contract_state(&Addr::unchecked(contract_addr), msg.to_vec()), - ) - .map(|query_result| query_result.into()); + let query_result: Result = block_on( + querier._contract_state(&Addr::unchecked(contract_addr), msg.to_vec()), + ) + .map(|query_result| query_result.into()); SystemResult::Ok(ContractResult::from(query_result)) } WasmQuery::Raw { contract_addr, key } => { @@ -111,7 +108,6 @@ impl WasmMockQuerier { QueryRequest::Bank(x) => { let querier = Bank { channel: self.channel.clone(), - rt_handle: Some(handle.clone()), }; match x { BankQuery::Balance { address, denom } => { @@ -140,8 +136,7 @@ impl WasmMockQuerier { let querier = Staking::new_async(self.channel.clone()); match x { StakingQuery::BondedDenom {} => { - let query_result = handle - .block_on(querier._params()) + let query_result = block_on(querier._params()) .map(|result| { BondedDenomResponse::new(result.params.unwrap().bond_denom) }) @@ -152,29 +147,28 @@ impl WasmMockQuerier { // This query is not perfect. I guess that on_chain you should be able to get ALL delegations and not a paginated result // TODO, do better here StakingQuery::AllDelegations { delegator } => { - let query_result = handle - .block_on( - querier._delegator_delegations(&Addr::unchecked(delegator), None), - ) - .map(|result| { - AllDelegationsResponse::new( - result - .delegation_responses - .into_iter() - .filter_map(|delegation| { - delegation.delegation.map(|d| { - Delegation::new( - Addr::unchecked(d.delegator_address), - d.validator_address, - to_cosmwasm_coin(delegation.balance.unwrap()), - ) - }) + let query_result = block_on( + querier._delegator_delegations(&Addr::unchecked(delegator), None), + ) + .map(|result| { + AllDelegationsResponse::new( + result + .delegation_responses + .into_iter() + .filter_map(|delegation| { + delegation.delegation.map(|d| { + Delegation::new( + Addr::unchecked(d.delegator_address), + d.validator_address, + to_cosmwasm_coin(delegation.balance.unwrap()), + ) }) - .collect(), - ) - }) - .map(|query_result| to_json_binary(&query_result)) - .unwrap(); + }) + .collect(), + ) + }) + .map(|query_result| to_json_binary(&query_result)) + .unwrap(); SystemResult::Ok(ContractResult::from(query_result)) } _ => todo!(), @@ -191,12 +185,11 @@ impl WasmMockQuerier { impl WasmMockQuerier { /// Creates a querier from chain information pub fn new(chain: ChainInfoOwned) -> Self { - let channel = RUNTIME - .block_on(GrpcChannel::connect( - &chain.grpc_urls, - chain.chain_id.as_str(), - )) - .unwrap(); + let channel = block_on(GrpcChannel::connect( + &chain.grpc_urls, + chain.chain_id.as_str(), + )) + .unwrap(); WasmMockQuerier { channel } } diff --git a/cw-orch-daemon/src/queriers/authz.rs b/cw-orch-daemon/src/queriers/authz.rs index 14766f873..08bbe8348 100644 --- a/cw-orch-daemon/src/queriers/authz.rs +++ b/cw-orch-daemon/src/queriers/authz.rs @@ -2,29 +2,23 @@ use crate::{cosmos_modules, error::DaemonError, Daemon}; use cosmrs::proto::cosmos::base::query::v1beta1::PageRequest; use cosmwasm_std::Addr; use cw_orch_core::environment::{Querier, QuerierGetter}; -use tokio::runtime::Handle; use tonic::transport::Channel; /// Queries for Cosmos AuthZ Module /// All the async function are prefixed with `_` pub struct Authz { pub channel: Channel, - pub rt_handle: Option, } impl Authz { pub fn new(daemon: &Daemon) -> Self { Self { channel: daemon.channel(), - rt_handle: Some(daemon.rt_handle.clone()), } } pub fn new_async(channel: Channel) -> Self { - Self { - channel, - rt_handle: None, - } + Self { channel } } } diff --git a/cw-orch-daemon/src/queriers/bank.rs b/cw-orch-daemon/src/queriers/bank.rs index ac7fa3831..3539cdf6a 100644 --- a/cw-orch-daemon/src/queriers/bank.rs +++ b/cw-orch-daemon/src/queriers/bank.rs @@ -1,29 +1,24 @@ use crate::{cosmos_modules, error::DaemonError, senders::query::QuerySender, DaemonBase}; +use async_std::task::block_on; use cosmrs::proto::cosmos::base::query::v1beta1::PageRequest; use cosmwasm_std::{Addr, Coin, StdError}; use cw_orch_core::environment::{BankQuerier, Querier, QuerierGetter}; -use tokio::runtime::Handle; use tonic::transport::Channel; /// Queries for Cosmos Bank Module /// All the async function are prefixed with `_` pub struct Bank { pub channel: Channel, - pub rt_handle: Option, } impl Bank { pub fn new(daemon: &DaemonBase) -> Self { Self { channel: daemon.channel(), - rt_handle: Some(daemon.rt_handle.clone()), } } pub fn new_async(channel: Channel) -> Self { - Self { - channel, - rt_handle: None, - } + Self { channel } } } @@ -169,23 +164,14 @@ impl BankQuerier for Bank { address: &Addr, denom: Option, ) -> Result, Self::Error> { - self.rt_handle - .as_ref() - .ok_or(DaemonError::QuerierNeedRuntime)? - .block_on(self._balance(address, denom)) + block_on(self._balance(address, denom)) } fn total_supply(&self) -> Result, Self::Error> { - self.rt_handle - .as_ref() - .ok_or(DaemonError::QuerierNeedRuntime)? - .block_on(self._total_supply()) + block_on(self._total_supply()) } fn supply_of(&self, denom: impl Into) -> Result { - self.rt_handle - .as_ref() - .ok_or(DaemonError::QuerierNeedRuntime)? - .block_on(self._supply_of(denom)) + block_on(self._supply_of(denom)) } } diff --git a/cw-orch-daemon/src/queriers/cosmwasm.rs b/cw-orch-daemon/src/queriers/cosmwasm.rs index 6fa942e91..0f1a2699c 100644 --- a/cw-orch-daemon/src/queriers/cosmwasm.rs +++ b/cw-orch-daemon/src/queriers/cosmwasm.rs @@ -3,6 +3,7 @@ use std::{marker::PhantomData, str::FromStr}; use crate::senders::query::QuerySender; use crate::senders::QueryOnlySender; use crate::{cosmos_modules, error::DaemonError, DaemonBase}; +use async_std::task::block_on; use cosmrs::proto::cosmos::base::query::v1beta1::PageRequest; use cosmrs::AccountId; use cosmwasm_std::{ @@ -14,14 +15,12 @@ use cw_orch_core::{ contract::interface_traits::Uploadable, environment::{Querier, QuerierGetter, WasmQuerier}, }; -use tokio::runtime::Handle; use tonic::transport::Channel; /// Querier for the CosmWasm SDK module /// All the async function are prefixed with `_` pub struct CosmWasmBase { pub channel: Channel, - pub rt_handle: Option, _sender: PhantomData, } @@ -31,21 +30,18 @@ impl CosmWasmBase { pub fn new(daemon: &DaemonBase) -> Self { Self { channel: daemon.channel(), - rt_handle: Some(daemon.rt_handle.clone()), _sender: PhantomData, } } pub fn new_async(channel: Channel) -> Self { Self { channel, - rt_handle: None, _sender: PhantomData, } } - pub fn new_sync(channel: Channel, handle: &Handle) -> Self { + pub fn new_sync(channel: Channel) -> Self { Self { channel, - rt_handle: Some(handle.clone()), _sender: PhantomData, } } @@ -238,28 +234,18 @@ impl CosmWasmBase { impl WasmQuerier for CosmWasmBase { type Chain = DaemonBase; fn code_id_hash(&self, code_id: u64) -> Result { - self.rt_handle - .as_ref() - .ok_or(DaemonError::QuerierNeedRuntime)? - .block_on(self._code_id_hash(code_id)) + block_on(self._code_id_hash(code_id)) } fn contract_info( &self, address: &Addr, ) -> Result { - self.rt_handle - .as_ref() - .ok_or(DaemonError::QuerierNeedRuntime)? - .block_on(self._contract_info(address)) + block_on(self._contract_info(address)) } fn raw_query(&self, address: &Addr, query_data: Vec) -> Result, Self::Error> { - let response = self - .rt_handle - .as_ref() - .ok_or(DaemonError::QuerierNeedRuntime)? - .block_on(self._contract_raw_state(address, query_data))?; + let response = block_on(self._contract_raw_state(address, query_data))?; Ok(response.data) } @@ -269,20 +255,14 @@ impl WasmQuerier for CosmWasmBase { address: &Addr, query_data: &Q, ) -> Result { - let response = self - .rt_handle - .as_ref() - .ok_or(DaemonError::QuerierNeedRuntime)? - .block_on(self._contract_state(address, to_json_binary(&query_data)?.to_vec()))?; + let response = + block_on(self._contract_state(address, to_json_binary(&query_data)?.to_vec()))?; Ok(from_json(response)?) } fn code(&self, code_id: u64) -> Result { - self.rt_handle - .as_ref() - .ok_or(DaemonError::QuerierNeedRuntime)? - .block_on(self._code(code_id)) + block_on(self._code(code_id)) } fn instantiate2_addr( diff --git a/cw-orch-daemon/src/queriers/feegrant.rs b/cw-orch-daemon/src/queriers/feegrant.rs index a899f1598..ac024b1e9 100644 --- a/cw-orch-daemon/src/queriers/feegrant.rs +++ b/cw-orch-daemon/src/queriers/feegrant.rs @@ -2,28 +2,24 @@ use crate::{cosmos_modules, error::DaemonError, Daemon}; use cosmrs::proto::cosmos::base::query::v1beta1::PageRequest; use cosmwasm_std::Addr; use cw_orch_core::environment::{Querier, QuerierGetter}; -use tokio::runtime::Handle; use tonic::transport::Channel; /// Querier for the Cosmos Gov module /// All the async function are prefixed with `_` pub struct FeeGrant { pub channel: Channel, - pub rt_handle: Option, } impl FeeGrant { pub fn new(daemon: &Daemon) -> Self { Self { channel: daemon.channel(), - rt_handle: Some(daemon.rt_handle.clone()), } } pub fn new_async(channel: Channel) -> Self { Self { channel, - rt_handle: None, } } } diff --git a/cw-orch-daemon/src/queriers/gov.rs b/cw-orch-daemon/src/queriers/gov.rs index 18cfcb916..b9ecfb72b 100644 --- a/cw-orch-daemon/src/queriers/gov.rs +++ b/cw-orch-daemon/src/queriers/gov.rs @@ -2,29 +2,23 @@ use crate::{cosmos_modules, error::DaemonError, Daemon}; use cosmrs::proto::cosmos::base::query::v1beta1::PageRequest; use cosmwasm_std::Addr; use cw_orch_core::environment::{Querier, QuerierGetter}; -use tokio::runtime::Handle; use tonic::transport::Channel; /// Querier for the Cosmos Gov module /// All the async function are prefixed with `_` pub struct Gov { pub channel: Channel, - pub rt_handle: Option, } impl Gov { pub fn new(daemon: &Daemon) -> Self { Self { channel: daemon.channel(), - rt_handle: Some(daemon.rt_handle.clone()), } } pub fn new_async(channel: Channel) -> Self { - Self { - channel, - rt_handle: None, - } + Self { channel } } } diff --git a/cw-orch-daemon/src/queriers/ibc.rs b/cw-orch-daemon/src/queriers/ibc.rs index 0c96f00b9..699db75e2 100644 --- a/cw-orch-daemon/src/queriers/ibc.rs +++ b/cw-orch-daemon/src/queriers/ibc.rs @@ -12,29 +12,23 @@ use cosmrs::proto::ibc::{ }; use cw_orch_core::environment::{Querier, QuerierGetter}; use prost::Message; -use tokio::runtime::Handle; use tonic::transport::Channel; /// Querier for the Cosmos IBC module /// All the async function are prefixed with `_` pub struct Ibc { pub channel: Channel, - pub rt_handle: Option, } impl Ibc { pub fn new(daemon: &Daemon) -> Self { Self { channel: daemon.channel(), - rt_handle: Some(daemon.rt_handle.clone()), } } pub fn new_async(channel: Channel) -> Self { - Self { - channel, - rt_handle: None, - } + Self { channel } } } diff --git a/cw-orch-daemon/src/queriers/node.rs b/cw-orch-daemon/src/queriers/node.rs index 0958da8a2..cf7876ca0 100644 --- a/cw-orch-daemon/src/queriers/node.rs +++ b/cw-orch-daemon/src/queriers/node.rs @@ -5,6 +5,7 @@ use crate::{ tx_resp::CosmTxResponse, DaemonBase, }; +use async_std::task::block_on; use cosmrs::{ proto::cosmos::{ base::query::v1beta1::PageRequest, @@ -17,7 +18,6 @@ use cw_orch_core::{ environment::{NodeQuerier, Querier, QuerierGetter}, log::query_target, }; -use tokio::runtime::Handle; use tonic::transport::Channel; /// Querier for the Tendermint node. @@ -25,21 +25,16 @@ use tonic::transport::Channel; /// All the async function are prefixed with `_` pub struct Node { pub channel: Channel, - pub rt_handle: Option, } impl Node { pub fn new(daemon: &DaemonBase) -> Self { Self { channel: daemon.channel(), - rt_handle: Some(daemon.rt_handle.clone()), } } pub fn new_async(channel: Channel) -> Self { - Self { - channel, - rt_handle: None, - } + Self { channel } } } @@ -123,7 +118,7 @@ impl Node { while latest_block_height <= 1 { // wait to get some blocks - tokio::time::sleep(Duration::from_secs(1)).await; + async_std::task::sleep(Duration::from_secs(1)).await; latest_block = self._latest_block().await?; latest_block_height = latest_block.header.height.value(); } @@ -263,7 +258,7 @@ impl Node { } log::debug!(target: &query_target(), "TX not found with error: {:?}", err); log::debug!(target: &query_target(), "Waiting {} milli-seconds", block_speed.as_millis()); - tokio::time::sleep(block_speed).await; + async_std::task::sleep(block_speed).await; } } } @@ -340,7 +335,7 @@ impl Node { if retry_on_empty && resp.is_empty() { log::debug!(target: &query_target(), "No TX found with events {:?}", events); log::debug!(target: &query_target(), "Waiting 10s"); - tokio::time::sleep(Duration::from_secs(10)).await; + async_std::task::sleep(Duration::from_secs(10)).await; } else { log::debug!( target: &query_target(), @@ -353,7 +348,7 @@ impl Node { Err(err) => { log::debug!(target: &query_target(), "TX not found with error: {:?}", err); log::debug!(target: &query_target(), "Waiting 10s"); - tokio::time::sleep(Duration::from_secs(10)).await; + async_std::task::sleep(Duration::from_secs(10)).await; } } } @@ -371,48 +366,29 @@ impl NodeQuerier for Node { type Response = CosmTxResponse; fn latest_block(&self) -> Result { - self.rt_handle - .as_ref() - .ok_or(DaemonError::QuerierNeedRuntime)? - .block_on(self._block_info()) + block_on(self._block_info()) } fn block_by_height(&self, height: u64) -> Result { - let block = self - .rt_handle - .as_ref() - .ok_or(DaemonError::QuerierNeedRuntime)? - .block_on(self._block_by_height(height))?; + let block = block_on(self._block_by_height(height))?; block_to_block_info(block) } fn block_height(&self) -> Result { - self.rt_handle - .as_ref() - .ok_or(DaemonError::QuerierNeedRuntime)? - .block_on(self._block_height()) + block_on(self._block_height()) } fn block_time(&self) -> Result { - self.rt_handle - .as_ref() - .ok_or(DaemonError::QuerierNeedRuntime)? - .block_on(self._block_time()) + block_on(self._block_time()) } fn simulate_tx(&self, tx_bytes: Vec) -> Result { - self.rt_handle - .as_ref() - .ok_or(DaemonError::QuerierNeedRuntime)? - .block_on(self._simulate_tx(tx_bytes)) + block_on(self._simulate_tx(tx_bytes)) } fn find_tx(&self, hash: String) -> Result { - self.rt_handle - .as_ref() - .ok_or(DaemonError::QuerierNeedRuntime)? - .block_on(self._find_tx(hash)) + block_on(self._find_tx(hash)) } } diff --git a/cw-orch-daemon/src/queriers/staking.rs b/cw-orch-daemon/src/queriers/staking.rs index 98936ea43..a4cf66e4a 100644 --- a/cw-orch-daemon/src/queriers/staking.rs +++ b/cw-orch-daemon/src/queriers/staking.rs @@ -4,7 +4,6 @@ use crate::{cosmos_modules, error::DaemonError, Daemon}; use cosmrs::proto::cosmos::base::query::v1beta1::PageRequest; use cosmwasm_std::{Addr, StdError}; use cw_orch_core::environment::{Querier, QuerierGetter}; -use tokio::runtime::Handle; use tonic::transport::Channel; use super::bank::cosmrs_to_cosmwasm_coin; @@ -13,22 +12,17 @@ use super::bank::cosmrs_to_cosmwasm_coin; /// All the async function are prefixed with `_` pub struct Staking { pub channel: Channel, - pub rt_handle: Option, } impl Staking { pub fn new(daemon: &Daemon) -> Self { Self { channel: daemon.channel(), - rt_handle: Some(daemon.rt_handle.clone()), } } pub fn new_async(channel: Channel) -> Self { - Self { - channel, - rt_handle: None, - } + Self { channel } } } diff --git a/cw-orch-daemon/src/sync/builder.rs b/cw-orch-daemon/src/sync/builder.rs index 79d90ef16..26d6bae81 100644 --- a/cw-orch-daemon/src/sync/builder.rs +++ b/cw-orch-daemon/src/sync/builder.rs @@ -1,6 +1,7 @@ use crate::senders::builder::SenderBuilder; -use crate::{DaemonAsyncBuilder, DaemonBase, DaemonState, Wallet, RUNTIME}; +use crate::{DaemonAsyncBuilder, DaemonBase, DaemonState, Wallet}; +use async_std::task::block_on; use cw_orch_core::environment::ChainInfoOwned; use super::super::error::DaemonError; @@ -21,7 +22,6 @@ pub struct DaemonBuilder { pub(crate) chain: ChainInfoOwned, // # Optional - pub(crate) handle: Option, pub(crate) deployment_id: Option, pub(crate) state_path: Option, // State from rebuild or existing daemon @@ -38,7 +38,6 @@ impl DaemonBuilder { pub fn new(chain: impl Into) -> Self { Self { chain: chain.into(), - handle: None, deployment_id: None, state_path: None, state: None, @@ -49,24 +48,6 @@ impl DaemonBuilder { } } - /// Set a custom tokio runtime handle to use for the Daemon - /// - /// ## Example - /// ```no_run - /// use cw_orch_daemon::{Daemon, networks}; - /// use tokio::runtime::Runtime; - /// let rt = Runtime::new().unwrap(); - /// let Daemon = Daemon::builder(networks::LOCAL_JUNO) - /// .handle(rt.handle()) - /// // ... - /// .build() - /// .unwrap(); - /// ``` - pub fn handle(&mut self, handle: &tokio::runtime::Handle) -> &mut Self { - self.handle = Some(handle.clone()); - self - } - /// Set the deployment id to use for the Daemon interactions /// Defaults to `default` pub fn deployment_id(&mut self, deployment_id: impl Into) -> &mut Self { @@ -139,17 +120,12 @@ impl DaemonBuilder { /// Build a Daemon with the default [`Wallet`] implementation. pub fn build(&self) -> Result, DaemonError> { - let rt_handle = self - .handle - .clone() - .unwrap_or_else(|| RUNTIME.handle().clone()); - let builder = self.clone(); // build the underlying daemon - let daemon = rt_handle.block_on(DaemonAsyncBuilder::from(builder).build())?; + let daemon = block_on(DaemonAsyncBuilder::from(builder).build())?; - Ok(DaemonBase { rt_handle, daemon }) + Ok(DaemonBase { daemon }) } /// Build a daemon @@ -157,18 +133,12 @@ impl DaemonBuilder { &self, sender_options: T, ) -> Result, DaemonError> { - let rt_handle = self - .handle - .clone() - .unwrap_or_else(|| RUNTIME.handle().clone()); - let builder = self.clone(); // build the underlying daemon - let daemon = - rt_handle.block_on(DaemonAsyncBuilder::from(builder).build_sender(sender_options))?; + let daemon = block_on(DaemonAsyncBuilder::from(builder).build_sender(sender_options))?; - Ok(DaemonBase { rt_handle, daemon }) + Ok(DaemonBase { daemon }) } /// Specifies path to the daemon state file diff --git a/cw-orch-daemon/src/sync/core.rs b/cw-orch-daemon/src/sync/core.rs index 7320cc17b..8e77f1438 100644 --- a/cw-orch-daemon/src/sync/core.rs +++ b/cw-orch-daemon/src/sync/core.rs @@ -6,6 +6,7 @@ use crate::{ senders::{builder::SenderBuilder, query::QuerySender}, CosmTxResponse, DaemonAsyncBase, DaemonBuilder, DaemonError, DaemonState, }; +use async_std::task::block_on; use cosmwasm_std::{Addr, Coin}; use cw_orch_core::{ contract::{interface_traits::Uploadable, WasmPath}, @@ -13,7 +14,6 @@ use cw_orch_core::{ }; use cw_orch_traits::stargate::Stargate; use serde::Serialize; -use tokio::runtime::Handle; use tonic::transport::Channel; use crate::senders::tx::TxSender; @@ -29,9 +29,7 @@ Is constructed with the [DaemonBuilder]. ```rust,no_run use cw_orch_daemon::{Daemon, networks}; -use tokio::runtime::Runtime; -let rt = Runtime::new().unwrap(); let daemon: Daemon = Daemon::builder(networks::JUNO_1) .build() .unwrap(); @@ -47,8 +45,6 @@ See [Querier](crate::queriers) for examples. */ pub struct DaemonBase { pub(crate) daemon: DaemonAsyncBase, - /// Runtime handle to execute async tasks - pub rt_handle: Handle, } impl DaemonBase { @@ -73,13 +69,8 @@ impl DaemonBase { self, sender_options: T, ) -> DaemonBase<::Sender> { - let new_daemon = self - .rt_handle - .block_on(self.daemon.new_sender(sender_options)); - DaemonBase { - daemon: new_daemon, - rt_handle: self.rt_handle.clone(), - } + let new_daemon = block_on(self.daemon.new_sender(sender_options)); + DaemonBase { daemon: new_daemon } } /// Flushes all the state related to the current chain @@ -110,7 +101,6 @@ impl DaemonBase { deployment_id: Some(self.daemon.state.deployment_id.clone()), state_path: None, write_on_change: None, - handle: Some(self.rt_handle.clone()), mnemonic: None, // If it was test it will just use same tempfile as state is_test: false, @@ -172,7 +162,7 @@ impl TxHandler for DaemonBase { } fn upload(&self, uploadable: &T) -> Result { - self.rt_handle.block_on(self.daemon.upload(uploadable)) + block_on(self.daemon.upload(uploadable)) } fn execute( @@ -181,8 +171,7 @@ impl TxHandler for DaemonBase { coins: &[cosmwasm_std::Coin], contract_address: &Addr, ) -> Result { - self.rt_handle - .block_on(self.daemon.execute(exec_msg, coins, contract_address)) + block_on(self.daemon.execute(exec_msg, coins, contract_address)) } fn instantiate( @@ -193,7 +182,7 @@ impl TxHandler for DaemonBase { admin: Option<&Addr>, coins: &[Coin], ) -> Result { - self.rt_handle.block_on( + block_on( self.daemon .instantiate(code_id, init_msg, label, admin, coins), ) @@ -205,7 +194,7 @@ impl TxHandler for DaemonBase { new_code_id: u64, contract_address: &Addr, ) -> Result { - self.rt_handle.block_on( + block_on( self.daemon .migrate(migrate_msg, new_code_id, contract_address), ) @@ -220,7 +209,7 @@ impl TxHandler for DaemonBase { coins: &[cosmwasm_std::Coin], salt: cosmwasm_std::Binary, ) -> Result { - self.rt_handle.block_on( + block_on( self.daemon .instantiate2(code_id, init_msg, label, admin, coins, salt), ) @@ -231,7 +220,7 @@ impl TxHandler for DaemonBase { contract_source: &T, access_config: Option, ) -> Result { - self.rt_handle.block_on( + block_on( self.daemon .upload_with_access_config(contract_source, access_config), ) @@ -244,19 +233,18 @@ impl Stargate for DaemonBase { msgs: Vec, memo: Option<&str>, ) -> Result { - self.rt_handle - .block_on( - self.sender().commit_tx_any( - msgs.iter() - .map(|msg| cosmrs::Any { - type_url: msg.type_url.clone(), - value: msg.value.clone(), - }) - .collect(), - memo, - ), - ) - .map_err(Into::into) + block_on( + self.sender().commit_tx_any( + msgs.iter() + .map(|msg| cosmrs::Any { + type_url: msg.type_url.clone(), + value: msg.value.clone(), + }) + .collect(), + memo, + ), + ) + .map_err(Into::into) } } @@ -264,19 +252,19 @@ impl QueryHandler for DaemonBase { type Error = DaemonError; fn wait_blocks(&self, amount: u64) -> Result<(), DaemonError> { - self.rt_handle.block_on(self.daemon.wait_blocks(amount))?; + block_on(self.daemon.wait_blocks(amount))?; Ok(()) } fn wait_seconds(&self, secs: u64) -> Result<(), DaemonError> { - self.rt_handle.block_on(self.daemon.wait_seconds(secs))?; + block_on(self.daemon.wait_seconds(secs))?; Ok(()) } fn next_block(&self) -> Result<(), DaemonError> { - self.rt_handle.block_on(self.daemon.next_block())?; + block_on(self.daemon.next_block())?; Ok(()) } diff --git a/cw-orch-daemon/src/tx_broadcaster.rs b/cw-orch-daemon/src/tx_broadcaster.rs index e4c295290..a6197c6f4 100644 --- a/cw-orch-daemon/src/tx_broadcaster.rs +++ b/cw-orch-daemon/src/tx_broadcaster.rs @@ -99,7 +99,7 @@ impl TxBroadcaster { block_speed.as_millis(), s.reason ); - tokio::time::sleep(block_speed).await; + async_std::task::sleep(block_speed).await; tx_response = broadcast_helper(&mut tx_builder, signer).await; continue; diff --git a/cw-orch-daemon/tests/authz.rs b/cw-orch-daemon/tests/authz.rs index a90e18008..0655c0895 100644 --- a/cw-orch-daemon/tests/authz.rs +++ b/cw-orch-daemon/tests/authz.rs @@ -4,7 +4,6 @@ mod tests { /* Authz tests */ - use cosmrs::proto::cosmos::{ authz::v1beta1::{ GenericAuthorization, GrantAuthorization, MsgGrant, QueryGranteeGrantsResponse, @@ -45,8 +44,6 @@ mod tests { ) .unwrap(); - let runtime = daemon.rt_handle.clone(); - let grantee = second_daemon.sender_addr(); let current_timestamp = daemon.block_info()?.time; @@ -91,7 +88,7 @@ mod tests { // Grants let authz_querier: Authz = daemon.querier(); - let grants: QueryGrantsResponse = runtime.block_on(async { + let grants: QueryGrantsResponse = block_on(async { authz_querier ._grants(&sender, &grantee, MsgSend::type_url(), None) .await @@ -100,34 +97,33 @@ mod tests { // Grantee grants let grantee_grants: QueryGranteeGrantsResponse = - runtime.block_on(async { authz_querier._grantee_grants(&grantee, None).await })?; + block_on(async { authz_querier._grantee_grants(&grantee, None).await })?; assert_eq!(grantee_grants.grants, vec![grant_authorization.clone()]); // Granter grants let granter_grants: QueryGranterGrantsResponse = - runtime.block_on(async { authz_querier._granter_grants(&sender, None).await })?; + block_on(async { authz_querier._granter_grants(&sender, None).await })?; assert_eq!(granter_grants.grants, vec![grant_authorization]); // No grant gives out an error - runtime - .block_on(async { - authz_querier - ._grants(&grantee, &sender, MsgSend::type_url(), None) - .await - }) - .unwrap_err(); + block_on(async { + authz_querier + ._grants(&grantee, &sender, MsgSend::type_url(), None) + .await + }) + .unwrap_err(); // Check use of grants // The we send some funds to the account - runtime.block_on( + block_on( daemon .sender() .bank_send(&grantee, coins(100_000, LOCAL_JUNO.gas_denom)), )?; - + use async_std::task::block_on; // And send a large amount of tokens on their behalf - runtime.block_on( + block_on( second_daemon .sender() .bank_send(&grantee, coins(500_000, LOCAL_JUNO.gas_denom)), diff --git a/cw-orch-daemon/tests/querier.rs b/cw-orch-daemon/tests/querier.rs index 9bc334d1d..26c063a89 100644 --- a/cw-orch-daemon/tests/querier.rs +++ b/cw-orch-daemon/tests/querier.rs @@ -2,6 +2,7 @@ mod common; #[cfg(feature = "node-tests")] mod queriers { + use async_std::task::block_on; use cosmwasm_std::Addr; use cw_orch_core::contract::interface_traits::*; @@ -16,7 +17,6 @@ mod queriers { queriers::{CosmWasm, Gov, Ibc, Node, Staking}, Daemon, DaemonError, }; - use tokio::runtime::Runtime; use cosmrs::{ cosmwasm::MsgExecuteContract, @@ -43,12 +43,11 @@ mod queriers { */ #[test] fn ibc() { - let rt = Runtime::new().unwrap(); - let channel = rt.block_on(build_channel()); + let channel = block_on(build_channel()); let ibc = Ibc::new_async(channel); - let clients = rt.block_on(ibc._clients()); + let clients = block_on(ibc._clients()); asserting!("clients is ok").that(&clients).is_ok(); } @@ -57,15 +56,14 @@ mod queriers { */ #[test] fn staking() { - let rt = Runtime::new().unwrap(); - let channel = rt.block_on(build_channel()); + let channel = block_on(build_channel()); let staking = Staking::new_async(channel); - let params = rt.block_on(staking._params()); + let params = block_on(staking._params()); asserting!("params is ok").that(¶ms).is_ok(); - let validators = rt.block_on(staking._validators(StakingBondStatus::Bonded)); + let validators = block_on(staking._validators(StakingBondStatus::Bonded)); asserting!("validators is ok").that(&validators).is_ok(); asserting!("validators is not empty") .that(&validators.unwrap().len()) @@ -77,12 +75,11 @@ mod queriers { */ #[test] fn gov() { - let rt = Runtime::new().unwrap(); - let channel = rt.block_on(build_channel()); + let channel = block_on(build_channel()); let gov = Gov::new_async(channel); - let params = rt.block_on(gov._params("voting")); + let params = block_on(gov._params("voting")); asserting!("params is ok").that(¶ms).is_ok(); } @@ -91,39 +88,38 @@ mod queriers { */ #[test] fn bank() { - let rt = Runtime::new().unwrap(); - let channel = rt.block_on(build_channel()); + let channel = block_on(build_channel()); let bank = Bank::new_async(channel); - let params = rt.block_on(bank._params()); + let params = block_on(bank._params()); asserting!("params is ok").that(¶ms).is_ok(); - let balances = rt.block_on(bank._balance( + let balances = block_on(bank._balance( &Addr::unchecked("juno16g2rahf5846rxzp3fwlswy08fz8ccuwk03k57y"), None, )); asserting!("balances is ok").that(&balances).is_ok(); - let spendable_balances = rt.block_on(bank._spendable_balances(&Addr::unchecked( + let spendable_balances = block_on(bank._spendable_balances(&Addr::unchecked( "juno16g2rahf5846rxzp3fwlswy08fz8ccuwk03k57y", ))); asserting!("spendable_balances is ok") .that(&spendable_balances) .is_ok(); - let total_supply = rt.block_on(bank._total_supply()); + let total_supply = block_on(bank._total_supply()); asserting!("total_supply is ok").that(&total_supply).is_ok(); - let supply_of = rt.block_on(bank._supply_of("ujunox")); + let supply_of = block_on(bank._supply_of("ujunox")); asserting!("supply_of is ok").that(&supply_of).is_ok(); - let denom_metadata = rt.block_on(bank._denom_metadata("ucosm")); + let denom_metadata = block_on(bank._denom_metadata("ucosm")); asserting!("denom_metadata is err, should not exists") .that(&denom_metadata) .is_err(); - let denoms_metadata = rt.block_on(bank._denoms_metadata(None)); + let denoms_metadata = block_on(bank._denoms_metadata(None)); asserting!("denoms_metadata is ok, but empty") .that(&denoms_metadata) .is_ok(); @@ -134,12 +130,11 @@ mod queriers { */ #[test] fn cosmwasm() { - let rt = Runtime::new().unwrap(); - let channel = rt.block_on(build_channel()); + let channel = block_on(build_channel()); let cw = CosmWasm::new_async(channel); - let params = rt.block_on(cw._params()); + let params = block_on(cw._params()); asserting!("params is ok").that(¶ms).is_ok(); } @@ -148,27 +143,24 @@ mod queriers { */ #[test] fn node() { - let rt = Runtime::new().unwrap(); - let channel = rt.block_on(build_channel()); + let channel = block_on(build_channel()); let node = Node::new_async(channel); - let block_height = rt.block_on(node._block_height()); + let block_height = block_on(node._block_height()); asserting!("block_height is ok").that(&block_height).is_ok(); - let latest_block = rt.block_on(node._latest_block()); + let latest_block = block_on(node._latest_block()); asserting!("latest_block is ok").that(&latest_block).is_ok(); - let block_time = rt.block_on(node._block_time()); + let block_time = block_on(node._block_time()); asserting!("block_time is ok").that(&block_time).is_ok(); } #[test] #[serial_test::serial] fn simulate_tx() { - let rt = Runtime::new().unwrap(); - - let channel = rt.block_on(build_channel()); + let channel = block_on(build_channel()); let node = Node::new_async(channel); @@ -200,7 +192,7 @@ mod queriers { let body = tx::Body::new(msgs, memo, 100u32); - let simulate_tx = rt.block_on(node._simulate_tx(body.into_bytes().unwrap())); + let simulate_tx = block_on(node._simulate_tx(body.into_bytes().unwrap())); asserting!("that simulate_tx worked but msg is wrong") .that(&simulate_tx) @@ -213,8 +205,7 @@ mod queriers { use cw_orch_daemon::TxSender; use cw_orch_networks::networks; - let rt = Runtime::new().unwrap(); - let channel = rt.block_on(build_channel()); + let channel = block_on(build_channel()); let cosm_wasm = CosmWasm::new_async(channel); let daemon = Daemon::builder(networks::LOCAL_JUNO) .is_test(true) @@ -233,7 +224,7 @@ mod queriers { let contract_address = contract.address().unwrap(); - let contract_info = rt.block_on(cosm_wasm._contract_info(&contract_address)); + let contract_info = block_on(cosm_wasm._contract_info(&contract_address)); asserting!("contract info is ok") .that(&contract_info) diff --git a/cw-orch-interchain/Cargo.toml b/cw-orch-interchain/Cargo.toml index 85d6565d6..9f22b1e95 100644 --- a/cw-orch-interchain/Cargo.toml +++ b/cw-orch-interchain/Cargo.toml @@ -32,6 +32,7 @@ cw-orch-interchain-mock = { workspace = true } cw-orch-interchain-daemon = { workspace = true, optional = true } cw-orch-starship = { workspace = true, optional = true } ibc-relayer-types.workspace = true +async-std = { workspace = true } #Used only for testing cosmwasm-std.workspace = true @@ -50,7 +51,6 @@ env_logger = "0.11.5" ibc-relayer-types.workspace = true log.workspace = true speculoos.workspace = true -tokio = "1.39.2" cosmos-sdk-proto = { workspace = true } prost-types = { workspace = true } ibc-proto = { workspace = true } diff --git a/cw-orch-interchain/tests/common/bank.rs b/cw-orch-interchain/tests/common/bank.rs index f6c04b782..5ffeb93e7 100644 --- a/cw-orch-interchain/tests/common/bank.rs +++ b/cw-orch-interchain/tests/common/bank.rs @@ -1,3 +1,4 @@ +use async_std::task::block_on; use cosmwasm_std::{BankMsg, Coin, CosmosMsg}; use cw_orch::prelude::*; @@ -36,7 +37,6 @@ impl BankModule for Daemon { recipient: &Addr, funds: Vec, ) -> Result<::Response, ::Error> { - self.rt_handle - .block_on(self.sender().bank_send(recipient, funds)) + block_on(self.sender().bank_send(recipient, funds)) } } diff --git a/cw-orch/Cargo.toml b/cw-orch/Cargo.toml index d86f7a3c2..df148412a 100644 --- a/cw-orch/Cargo.toml +++ b/cw-orch/Cargo.toml @@ -41,12 +41,7 @@ required-features = ["daemon"] [features] default = [] # enable the optional dependencies -daemon = [ - "dep:tokio", - "dep:cosmrs", - "dep:cw-orch-daemon", - "dep:cw-orch-networks", -] +daemon = ["dep:cosmrs", "dep:cw-orch-daemon", "dep:cw-orch-networks"] eth = ["daemon", "cw-orch-core/eth", "cw-orch-daemon?/eth"] snapshot-testing = ["dep:insta", "dep:sanitize-filename"] @@ -55,11 +50,16 @@ snapshot-testing = ["dep:insta", "dep:sanitize-filename"] cw-orch-contract-derive = { workspace = true } cw-orch-fns-derive = { workspace = true } +# Moved from wasm protected +anyhow = { workspace = true } +cw-orch-traits = { workspace = true } +cw-orch-core = { workspace = true } +cosmwasm-std = { workspace = true } + [target.'cfg(not(target_arch = "wasm32"))'.dependencies] # Daemon deps cw-orch-networks = { workspace = true, optional = true } -tokio = { workspace = true, features = ["full"], optional = true } cosmrs = { workspace = true, features = [ "dev", "cosmwasm", @@ -75,9 +75,7 @@ insta = { version = "1.39.0", features = ["yaml"], optional = true } sanitize-filename = { version = "0.5.0", optional = true } # Default deps -cosmwasm-std = { workspace = true } cw-utils = { workspace = true } -anyhow = { workspace = true } serde = { workspace = true } schemars = "0.8.21" log = { workspace = true } @@ -87,8 +85,6 @@ hex = "0.4.3" # Env deps # This packages will most likely make wasm not compilable cw-orch-daemon = { workspace = true, optional = true } -cw-orch-traits = { workspace = true } -cw-orch-core = { workspace = true } cw-orch-mock = { workspace = true } [dev-dependencies] @@ -103,3 +99,4 @@ dotenv = "0.15.0" osmosis-std = "0.26.0" prost = { workspace = true } prost-types = { workspace = true } +async-std = { workspace = true } diff --git a/cw-orch/examples/async_daemon.rs b/cw-orch/examples/async_daemon.rs index 355f39cc8..4816de26f 100644 --- a/cw-orch/examples/async_daemon.rs +++ b/cw-orch/examples/async_daemon.rs @@ -7,7 +7,7 @@ use cw_orch_mock::Mock; /// 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] +#[async_std::main] pub async fn main() -> anyhow::Result<()> { // We start by loading environment variables from a .env file. // You can use a .env file to specify environment variables. diff --git a/cw-orch/examples/complex_testnet_daemon.rs b/cw-orch/examples/complex_testnet_daemon.rs index b3175a78e..76e55638a 100644 --- a/cw-orch/examples/complex_testnet_daemon.rs +++ b/cw-orch/examples/complex_testnet_daemon.rs @@ -1,3 +1,4 @@ +use async_std::task::block_on; use cosmwasm_std::coins; use counter_contract::{ msg::{ExecuteMsg, GetCountResponse, InstantiateMsg, QueryMsg}, @@ -98,14 +99,12 @@ pub fn main() { .unwrap(); // We send some funds to the counter contract let contract_addr = counter.address().unwrap(); - daemon - .rt_handle - .block_on( - daemon - .sender() - .bank_send(&contract_addr, coins(50_000, denom.clone())), - ) - .unwrap(); + block_on( + daemon + .sender() + .bank_send(&contract_addr, coins(50_000, denom.clone())), + ) + .unwrap(); // We verify they have received their funds assert_eq!( daemon diff --git a/cw-orch/examples/queries/testnet_queries.rs b/cw-orch/examples/queries/testnet_queries.rs index 8899e9e6a..f5fc816de 100644 --- a/cw-orch/examples/queries/testnet_queries.rs +++ b/cw-orch/examples/queries/testnet_queries.rs @@ -1,10 +1,12 @@ use anyhow::Result as AnyResult; +use async_std::task::block_on; use cosmwasm_std::Addr; use cw_orch::daemon::Daemon; use cw_orch::prelude::BankQuerier; use cw_orch::prelude::QuerierGetter; use cw_orch_daemon::queriers::Ibc; use cw_orch_daemon::queriers::{Bank, Staking}; + pub const TEST_MNEMONIC: &str="scare silent genuine cheese monitor industry item cloth pet gather cruise long confirm van lunar tomato scrub silk guide eight truly rural remember swim"; pub fn main() -> AnyResult<()> { @@ -23,18 +25,14 @@ pub fn main() -> AnyResult<()> { let staking_query_client: Staking = daemon.querier(); let validator = Addr::unchecked("junovaloper185hgkqs8q8ysnc8cvkgd8j2knnq2m0ah6ae73gntv9ampgwpmrxqlfzywn"); - let validator_result = daemon - .rt_handle - .block_on(staking_query_client._validator(&validator))?; + let validator_result = block_on(staking_query_client._validator(&validator))?; println!("Validator info of {} : {:?}", sender, validator_result); // We do an actual IBC query on MAINNET let ibc_query_client: Ibc = daemon.querier(); let port_id = "transfer"; let channel_id = "channel-0"; - let channel_result = daemon - .rt_handle - .block_on(ibc_query_client._channel(port_id, channel_id))?; + let channel_result = block_on(ibc_query_client._channel(port_id, channel_id))?; println!( "Channel info of {port_id}:{channel_id} : {:?}", channel_result diff --git a/cw-orch/src/lib.rs b/cw-orch/src/lib.rs index 7dd770f75..5b0e49fc9 100644 --- a/cw-orch/src/lib.rs +++ b/cw-orch/src/lib.rs @@ -7,10 +7,8 @@ pub use cw_orch_contract_derive::interface; pub use cw_orch_fns_derive::{ExecuteFns, QueryFns}; // prelude -#[cfg(not(target_arch = "wasm32"))] pub mod prelude; -#[cfg(not(target_arch = "wasm32"))] mod error; #[cfg(not(target_arch = "wasm32"))] @@ -21,21 +19,20 @@ pub mod daemon; #[cfg(feature = "snapshot-testing")] pub mod snapshots; +/// Re-export anyhow for use in the macros +pub extern crate anyhow; +// This re-export should not be touched or the derive macros WILL break +pub use cw_orch_core as core; +pub use cw_orch_core::{build, contract}; +/// Related to execution environments +pub mod environment { + pub use cw_orch_core::environment::*; +} + #[cfg(not(target_arch = "wasm32"))] /// used to avoid repeating the #[cfg(not(target_arch = "wasm32"))] macro for each export pub mod wasm_protected { - /// Re-export anyhow for use in the macros - pub extern crate anyhow; - - // This re-export should not be touched or the derive macros WILL break - pub use cw_orch_core as core; - pub use cw_orch_core::{build, contract}; - - /// Related to execution environments - pub mod environment { - pub use cw_orch_core::environment::*; - } /// Related environment variables definition pub mod env_vars { pub use cw_orch_core::CoreEnvVars; @@ -44,10 +41,6 @@ pub mod wasm_protected { } pub use cw_orch_mock as mock; - /// Re-export tokio, the async runtime when using daemons. - #[cfg(feature = "daemon")] - pub extern crate tokio; - // Rexporting for the macro to work properly #[cfg(feature = "snapshot-testing")] pub extern crate insta; diff --git a/cw-orch/src/prelude.rs b/cw-orch/src/prelude.rs index c2cfdc0c3..89b8564c4 100644 --- a/cw-orch/src/prelude.rs +++ b/cw-orch/src/prelude.rs @@ -36,6 +36,7 @@ pub use cw_orch_core::environment::Environment; // Chains pub use crate::environment::{ChainInfo, ChainInfoOwned}; +#[cfg(not(target_arch = "wasm32"))] // Mock for testing pub use crate::mock::{Mock, MockBech32}; @@ -50,6 +51,7 @@ pub use crate::core::contract::{ContractWrapper, MockContract}; pub use cosmwasm_std::{Addr, Coin, Empty}; // builder, core type, networks mod, queriers mod, traits +#[cfg(not(target_arch = "wasm32"))] #[cfg(feature = "daemon")] pub use crate::daemon::{ live_mock, @@ -62,6 +64,7 @@ pub use crate::daemon::{ DaemonBuilder, }; +#[cfg(not(target_arch = "wasm32"))] #[cfg(feature = "daemon")] pub use cw_orch_networks::networks; diff --git a/packages/clone-testing/Cargo.toml b/packages/clone-testing/Cargo.toml index fda562ad1..4af704e8b 100644 --- a/packages/clone-testing/Cargo.toml +++ b/packages/clone-testing/Cargo.toml @@ -15,16 +15,17 @@ cosmwasm-std = { workspace = true } cw-orch-core = { workspace = true } cw-orch-daemon = { workspace = true } -clone-cw-multi-test = { version = "0.6.1" } +# clone-cw-multi-test = { version = "0.6.1" } +clone-cw-multi-test = { path = "../../../cw-multi-test" } cw-utils = { workspace = true } serde = { workspace = true } log = { workspace = true } anyhow = { workspace = true } -tokio = { workspace = true } itertools = "0.12.0" sha2 = "0.10.8" tonic = { workspace = true } +async-std = { workspace = true } [dev-dependencies] cosmwasm-schema = "2.0.0" diff --git a/packages/clone-testing/src/core.rs b/packages/clone-testing/src/core.rs index daad975e9..72a469617 100644 --- a/packages/clone-testing/src/core.rs +++ b/packages/clone-testing/src/core.rs @@ -1,5 +1,6 @@ use std::{cell::RefCell, fmt::Debug, io::Read, rc::Rc}; +use async_std::task::block_on; use clone_cw_multi_test::{ addons::{MockAddressGenerator, MockApiBech32}, wasm_emulation::{channel::RemoteChannel, storage::analyzer::StorageAnalyzer}, @@ -17,10 +18,9 @@ use cw_orch_core::{ }, CwEnvError, }; -use cw_orch_daemon::{queriers::Node, read_network_config, DEFAULT_DEPLOYMENT, RUNTIME}; +use cw_orch_daemon::{queriers::Node, read_network_config, DEFAULT_DEPLOYMENT}; use cw_utils::NativeBalance; use serde::Serialize; -use tokio::runtime::Runtime; use crate::{contract::CloneTestingContract, queriers::bank::CloneBankQuerier}; @@ -60,9 +60,8 @@ pub type CloneTestingApp = App; /// // We just use the MockState as an example here, but you can implement your own state struct. /// use cw_orch_clone_testing::MockState as CustomState; /// -/// let rt = tokio::runtime::Runtime::new().unwrap(); /// let chain = cw_orch_daemon::networks::JUNO_1; -/// let mock: CloneTesting = CloneTesting::new_custom(&rt, chain.clone(), CustomState::new(chain.clone().into(), "mock")).unwrap(); +/// let mock: CloneTesting = CloneTesting::new_custom(chain.clone(), CustomState::new(chain.clone().into(), "mock")).unwrap(); /// ``` #[derive(Clone)] pub struct CloneTesting { @@ -168,32 +167,21 @@ impl CloneTesting { impl CloneTesting { /// Create a mock environment with the default mock state. - pub fn new(chain: impl Into) -> Result { - Self::new_with_runtime(&RUNTIME, chain) - } - /// Create a mock environment with the default mock state. - /// It uses a custom runtime object to control async requests - pub fn new_with_runtime( - rt: &Runtime, - chain: impl Into, - ) -> Result { + pub fn new(chain: impl Into) -> Result { let chain_data = chain.into(); CloneTesting::new_custom( - rt, chain_data.clone(), MockState::new(chain_data, DEFAULT_DEPLOYMENT), ) } pub fn new_with_deployment_id( - rt: &Runtime, chain: impl Into, deployment_id: &str, ) -> Result { let chain_data = chain.into(); CloneTesting::new_custom( - rt, chain_data.clone(), MockState::new(chain_data, deployment_id), ) @@ -204,7 +192,6 @@ impl CloneTesting { /// Create a mock environment with a custom mock state. /// The state is customizable by implementing the `StateInterface` trait on a custom struct and providing it on the custom constructor. pub fn new_custom( - rt: &Runtime, chain: impl Into, custom_state: S, ) -> Result { @@ -218,7 +205,6 @@ impl CloneTesting { let pub_address_prefix = chain.network_info.pub_address_prefix.clone(); let remote_channel = RemoteChannel::new( - rt, &chain .grpc_urls .iter() @@ -236,10 +222,8 @@ impl CloneTesting { let bank = BankKeeper::new().with_remote(remote_channel.clone()); // We update the block_height - let block_info = remote_channel - .rt - .block_on(Node::new_async(remote_channel.channel.clone())._block_info()) - .unwrap(); + let block_info = + block_on(Node::new_async(remote_channel.channel.clone())._block_info()).unwrap(); // Finally we instantiate a new app let app = AppBuilder::default() @@ -631,10 +615,9 @@ mod test { let denom = "uosmo"; let chain = JUNO_1; - let rt = Runtime::new().unwrap(); let mock_state = MockState::new(JUNO_1.into(), "default_id"); - let chain: CloneTesting = CloneTesting::<_>::new_custom(&rt, chain, mock_state)?; + let chain: CloneTesting = CloneTesting::<_>::new_custom(chain, mock_state)?; let recipient = chain.init_account(); chain diff --git a/packages/cw-orch-core/Cargo.toml b/packages/cw-orch-core/Cargo.toml index 7a8d3c20e..f8a1b812e 100644 --- a/packages/cw-orch-core/Cargo.toml +++ b/packages/cw-orch-core/Cargo.toml @@ -18,12 +18,17 @@ all-features = true [features] default = [] +cosmwasm_2_0 = ["cosmwasm-std/cosmwasm_2_0"] mock = ["dep:cw-multi-test"] eth = ["dep:snailquote"] [dependencies] thiserror = { workspace = true } -cosmwasm-std = { workspace = true } +cosmwasm-std = { workspace = true, features = [ + "cosmwasm_1_2", + "staking", + "stargate", +] } serde = { workspace = true } log = { workspace = true } diff --git a/packages/cw-orch-core/src/contract/wrapper.rs b/packages/cw-orch-core/src/contract/wrapper.rs index 84fad3ffe..02452ffdd 100644 --- a/packages/cw-orch-core/src/contract/wrapper.rs +++ b/packages/cw-orch-core/src/contract/wrapper.rs @@ -683,6 +683,7 @@ where CosmosMsg::Distribution(distribution) => CosmosMsg::Distribution(distribution), CosmosMsg::Custom(_) => unreachable!(), CosmosMsg::Ibc(ibc) => CosmosMsg::Ibc(ibc), + #[cfg(feature = "cosmwasm_2_0")] CosmosMsg::Any(any) => CosmosMsg::Any(any), _ => panic!("unknown message variant {:?}", msg), }, diff --git a/packages/integrations/cw-plus/Cargo.toml b/packages/integrations/cw-plus/Cargo.toml index 940438667..31bb9e3c7 100644 --- a/packages/integrations/cw-plus/Cargo.toml +++ b/packages/integrations/cw-plus/Cargo.toml @@ -41,4 +41,4 @@ dotenv = "0.15.0" octocrab = "0.39.0" pretty_env_logger = "0.5.0" reqwest = "0.12.7" -tokio.workspace = true +async-std = { workspace = true } diff --git a/packages/integrations/cw-plus/examples/download_wasms.rs b/packages/integrations/cw-plus/examples/download_wasms.rs index 89f82d73b..bfe5d1ec2 100644 --- a/packages/integrations/cw-plus/examples/download_wasms.rs +++ b/packages/integrations/cw-plus/examples/download_wasms.rs @@ -16,7 +16,7 @@ pub const ALL_CONTRACTS: &[&str] = &[ "cw20_ics20", ]; -#[tokio::main] +#[async_std::main] async fn main() -> anyhow::Result<()> { let crate_dir = env!("CARGO_MANIFEST_DIR"); let artifacts_dir = PathBuf::from_str(crate_dir)?.join("artifacts"); diff --git a/packages/interchain/interchain-core/Cargo.toml b/packages/interchain/interchain-core/Cargo.toml index a9ce3f71c..287395553 100644 --- a/packages/interchain/interchain-core/Cargo.toml +++ b/packages/interchain/interchain-core/Cargo.toml @@ -28,7 +28,6 @@ prost = "0.13.1" serde_json = { workspace = true } serde = { workspace = true } thiserror = { workspace = true } -tokio = "1.39.2" tonic = { workspace = true, features = ["tls", "tls-roots"] } [dev-dependencies] diff --git a/packages/interchain/interchain-daemon/Cargo.toml b/packages/interchain/interchain-daemon/Cargo.toml index 627d35b0b..e0bc231a4 100644 --- a/packages/interchain/interchain-daemon/Cargo.toml +++ b/packages/interchain/interchain-daemon/Cargo.toml @@ -16,8 +16,6 @@ repository.workspace = true cw-orch-daemon = { workspace = true } cw-orch-core = { workspace = true } -tokio = { workspace = true } - async-recursion = "1.1.1" base64 = "0.22.1" cosmwasm-schema = "2.1.3" @@ -37,6 +35,7 @@ cw-orch-interchain-core = { workspace = true, features = ["daemon"] } cw-orch-starship = { workspace = true } dialoguer = "0.11.0" cosmwasm-std = { workspace = true } +async-std = "1.13.0" [dev-dependencies] diff --git a/packages/interchain/interchain-daemon/examples/starship_channel.rs b/packages/interchain/interchain-daemon/examples/starship_channel.rs index da1060fac..1ff677e46 100644 --- a/packages/interchain/interchain-daemon/examples/starship_channel.rs +++ b/packages/interchain/interchain-daemon/examples/starship_channel.rs @@ -1,3 +1,4 @@ +use async_std::task::block_on; use cosmwasm_std::IbcOrder; use cw_orch_core::environment::QuerierGetter; use cw_orch_daemon::queriers::Ibc; @@ -17,7 +18,7 @@ fn assert_ordering( .interchain_channel .get_ordered_ports_from("juno-1")?; - let channel_info = juno.rt_handle.block_on(ibc_querier._channel( + let channel_info = block_on(ibc_querier._channel( channel.0.port.to_string(), channel.0.channel.unwrap().to_string(), ))?; diff --git a/packages/interchain/interchain-daemon/src/channel_creator.rs b/packages/interchain/interchain-daemon/src/channel_creator.rs index 524b0f884..aed4aa99b 100644 --- a/packages/interchain/interchain-daemon/src/channel_creator.rs +++ b/packages/interchain/interchain-daemon/src/channel_creator.rs @@ -1,3 +1,4 @@ +use async_std::task::block_on; use cosmwasm_std::IbcOrder; use cw_orch_interchain_core::env::ChainId; use cw_orch_starship::Starship; @@ -63,7 +64,7 @@ impl ChannelCreator for Starship { order: Option, ) -> Result { // The connection_id is decided upon automatically by starship and returned by the client - let connection_id = self.rt_handle.block_on(self.client().create_channel( + let connection_id = block_on(self.client().create_channel( src_chain, dst_chain, src_port.as_str(), diff --git a/packages/interchain/interchain-daemon/src/ibc_tracker.rs b/packages/interchain/interchain-daemon/src/ibc_tracker.rs index 52ccb6a35..62d94e507 100644 --- a/packages/interchain/interchain-daemon/src/ibc_tracker.rs +++ b/packages/interchain/interchain-daemon/src/ibc_tracker.rs @@ -12,7 +12,6 @@ use futures_util::future::join_all; use futures_util::stream::FuturesUnordered; use futures_util::StreamExt; use log::*; -use tokio::runtime::Handle; use std::collections::HashMap; use std::collections::HashSet; @@ -65,16 +64,16 @@ pub trait IbcTracker: ChannelAccess + Send + Sync + Clone { state.update_state(self.channel(), &chain_id).await?; debug!(target: &chain_id, "state updated"); } - tokio::time::sleep(config.log_interval).await; + async_std::task::sleep(config.log_interval).await; } } - fn detach_cron_log(self, rt: &Handle, config: IbcTrackerConfig) -> Result<(), Box> + fn detach_cron_log(self, config: IbcTrackerConfig) -> Result<(), Box> where S: 'static, Self: 'static, { - rt.spawn(async move { + async_std::task::spawn(async move { self.cron_log(config).await.unwrap(); }); Ok(()) @@ -102,7 +101,7 @@ impl> IbcPacketLogger for T { let channel = daemon.channel().clone(); - daemon.rt_handle.spawn(async move { + async_std::task::spawn(async move { channel.cron_log(config).await.unwrap(); }); Ok(()) diff --git a/packages/interchain/interchain-daemon/src/interchain_env.rs b/packages/interchain/interchain-daemon/src/interchain_env.rs index bcf0d1f8d..9436c73da 100644 --- a/packages/interchain/interchain-daemon/src/interchain_env.rs +++ b/packages/interchain/interchain-daemon/src/interchain_env.rs @@ -1,13 +1,14 @@ use cosmwasm_std::IbcOrder; use cw_orch_core::environment::{ChainInfoOwned, ChainState, IndexResponse}; use cw_orch_daemon::queriers::{Ibc, Node}; -use cw_orch_daemon::{CosmTxResponse, Daemon, DaemonError, RUNTIME}; +use cw_orch_daemon::{CosmTxResponse, Daemon, DaemonError}; use cw_orch_interchain_core::channel::{IbcPort, InterchainChannel}; use cw_orch_interchain_core::env::{ChainId, ChannelCreation}; use cw_orch_interchain_core::{InterchainEnv, NestedPacketsFlow, SinglePacketFlow}; +use async_std::task::block_on; +use async_std::task::sleep; use ibc_relayer_types::core::ics04_channel::packet::Sequence; -use tokio::time::sleep; use tonic::transport::Channel; use crate::channel_creator::{ChannelCreationValidator, ChannelCreator}; @@ -24,7 +25,6 @@ use futures::future::try_join4; use std::collections::HashMap; use std::str::FromStr; use std::time::Duration; -use tokio::runtime::Handle; /// Represents a set of locally running blockchain nodes and a Hermes relayer. #[derive(Clone)] @@ -36,8 +36,6 @@ pub struct DaemonInterchain { // Allows logging on separate files log: Option, - - rt_handle: Handle, } impl DaemonInterchain { @@ -49,27 +47,11 @@ impl DaemonInterchain { where T: Into, { - Self::new_with_runtime(chains, channel_creator, RUNTIME.handle()) - } - - /// Builds a new [`DaemonInterchain`] instance. - /// For use with starship, we advise to use [`cw_orch_starship::Starship::interchain_env`] instead - /// channel_creator allows you to specify an object that is able to create channels - /// Use [`crate::ChannelCreationValidator`] for manual channel creations. - /// runtime allows you to control the async runtime (for advanced devs) - pub fn new_with_runtime( - chains: Vec, - channel_creator: &C, - runtime: &Handle, - ) -> IcDaemonResult - where - T: Into, - { - let mut env = Self::raw(runtime, channel_creator); + let mut env = Self::raw(channel_creator); // We create daemons for each chains for chain_data in chains { - env.build_daemon(runtime, chain_data.into(), None::)?; + env.build_daemon(chain_data.into(), None::)?; } Ok(env) @@ -79,42 +61,35 @@ impl DaemonInterchain { /// The `channel_creator` argument will be responsible for creation interchain channel /// If using starship, prefer using Starship::interchain_env for environment creation pub fn from_daemons(daemons: Vec, channel_creator: &C) -> Self { - let mut env = Self::raw(&daemons.first().unwrap().rt_handle, channel_creator); + let mut env = Self::raw(channel_creator); env.add_daemons(daemons); env } - fn raw(rt: &Handle, channel_creator: &C) -> Self { + fn raw(channel_creator: &C) -> Self { Self { daemons: HashMap::new(), channel_creator: channel_creator.clone(), log: None, - rt_handle: rt.clone(), } } /// Build a daemon from chain data and mnemonic and add it to the current configuration fn build_daemon( &mut self, - runtime: &Handle, chain_data: ChainInfoOwned, mnemonic: Option>, ) -> IcDaemonResult<()> { let mut daemon_builder = Daemon::builder(chain_data); - let mut daemon_builder = daemon_builder.handle(runtime); - daemon_builder = if let Some(mn) = mnemonic { - daemon_builder.mnemonic(mn) - } else { - daemon_builder - }; + if let Some(mn) = mnemonic { + daemon_builder.mnemonic(mn); + } // 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 - }; + if let Some(daemon) = self.daemons.values().next() { + daemon_builder.state(daemon.state()); + } let daemon = daemon_builder.build().unwrap(); @@ -197,7 +172,7 @@ impl InterchainEnv for DaemonInterchain { let (src_port, dst_port) = ibc_channel.get_mut_ordered_ports_from(src_chain)?; // We start by getting the connection-id of the counterparty chain - let connection_end = self.rt_handle.block_on( + let connection_end = block_on( Ibc::new_async(src_port.chain.clone()) ._connection_end(src_port.connection_id.clone().unwrap()), )?; @@ -205,9 +180,7 @@ impl InterchainEnv for DaemonInterchain { dst_port.connection_id = Some(connection_end.unwrap().counterparty.unwrap().connection_id); // Then we make sure the channel is indeed created between the two chains - let channel_creation = self - .rt_handle - .block_on(self.find_channel_creation_tx(src_chain, ibc_channel))?; + let channel_creation = block_on(self.find_channel_creation_tx(src_chain, ibc_channel))?; let src_channel_id = channel_creation .ack @@ -250,14 +223,10 @@ impl InterchainEnv for DaemonInterchain { ); // We crate an interchain env object that is safe to send between threads - let interchain_env = self - .rt_handle - .block_on(PacketInspector::new(self.daemons.values().collect()))?; + let interchain_env = block_on(PacketInspector::new(self.daemons.values().collect()))?; // We follow the trail - let ibc_trail = self - .rt_handle - .block_on(interchain_env.wait_ibc(chain_id.to_string(), tx_response))?; + let ibc_trail = block_on(interchain_env.wait_ibc(chain_id.to_string(), tx_response))?; Ok(ibc_trail) } @@ -272,12 +241,10 @@ impl InterchainEnv for DaemonInterchain { sequence: Sequence, ) -> Result, Self::Error> { // We crate an interchain env object that is safe to send between threads - let interchain_env = self - .rt_handle - .block_on(PacketInspector::new(self.daemons.values().collect()))?; + let interchain_env = block_on(PacketInspector::new(self.daemons.values().collect()))?; // We follow the trail - let ibc_trail = self.rt_handle.block_on(interchain_env.follow_packet( + let ibc_trail = block_on(interchain_env.follow_packet( src_chain, src_port, src_channel, @@ -325,9 +292,8 @@ impl DaemonInterchain { ) -> Result, InterchainDaemonError> { let grpc_channel1 = self.get_chain(chain_id)?.channel(); - let tx = self.rt_handle.block_on( - Node::new_async(grpc_channel1.clone())._find_tx(packet_send_tx_hash.clone()), - )?; + let tx = + block_on(Node::new_async(grpc_channel1.clone())._find_tx(packet_send_tx_hash.clone()))?; let ibc_trail = self.await_packets(chain_id, tx)?; diff --git a/packages/interchain/proto/Cargo.toml b/packages/interchain/proto/Cargo.toml index 28324984c..efa95e347 100644 --- a/packages/interchain/proto/Cargo.toml +++ b/packages/interchain/proto/Cargo.toml @@ -22,7 +22,6 @@ prost = { workspace = true } cosmwasm-std = { workspace = true } ibc-relayer-types = { workspace = true } log = { workspace = true } -tokio = { workspace = true } tonic = { workspace = true } osmosis-std = { version = "0.26.0" } diff --git a/packages/interchain/starship/Cargo.toml b/packages/interchain/starship/Cargo.toml index b85c6ab98..07ac658e0 100644 --- a/packages/interchain/starship/Cargo.toml +++ b/packages/interchain/starship/Cargo.toml @@ -23,6 +23,7 @@ cosmwasm-std = { workspace = true } cw-orch-daemon = { workspace = true } cw-orch-core = { workspace = true } tokio = { workspace = true } +async-std = { workspace = true } url = "2.5.2" log.workspace = true diff --git a/packages/interchain/starship/src/client/core.rs b/packages/interchain/starship/src/client/core.rs index f0ad4a5f2..75d302ff7 100644 --- a/packages/interchain/starship/src/client/core.rs +++ b/packages/interchain/starship/src/client/core.rs @@ -1,12 +1,12 @@ //! Interactions with docker using bollard use std::fmt::Debug; +use async_std::task::block_on; use cosmwasm_std::IbcOrder; use ibc_chain_registry::chain::ChainData; use kube::runtime::reflector::Lookup; use serde_json::Value; use tokio::io::AsyncReadExt; -use tokio::runtime::Handle; use url::Url; use crate::client::StarshipClientError; @@ -50,11 +50,10 @@ impl Debug for StarshipClient { impl StarshipClient { /// Create a Starship object from the localhost chain registry. pub fn new( - rt: Handle, url: Option<&str>, starship_config: Option, ) -> StarshipClientResult { - let starship = rt.block_on(Self::new_async(url, starship_config))?; + let starship = block_on(Self::new_async(url, starship_config))?; Ok(starship) } diff --git a/packages/interchain/starship/src/lib.rs b/packages/interchain/starship/src/lib.rs index 01e22c92b..4e60701d7 100644 --- a/packages/interchain/starship/src/lib.rs +++ b/packages/interchain/starship/src/lib.rs @@ -7,12 +7,12 @@ pub const STARSHIP_CONFIG_ENV_NAME: &str = "CW_ORCH_STARSHIP_CONFIG_PATH"; pub mod client; use crate::client::StarshipClient; +use async_std::task::block_on; use cw_orch_core::environment::{ChainInfoOwned, ChainState, NetworkInfoOwned}; use cw_orch_core::CwEnvError; -use cw_orch_daemon::{Daemon, DaemonBuilder, RUNTIME}; +use cw_orch_daemon::{Daemon, DaemonBuilder}; use ibc_chain_registry::chain::ChainData; use std::collections::HashMap; -use tokio::runtime::Handle; #[derive(Clone)] /// Starship integration @@ -20,19 +20,11 @@ pub struct Starship { /// Daemon objects representing all the chains available inside the starship environment pub daemons: HashMap, starship_client: StarshipClient, - /// Runtime handle for awaiting async functions - pub rt_handle: Handle, } impl Starship { /// Creates a new instance and connects to a starship deployment pub fn new(url: Option<&str>) -> Result { - let runtime = RUNTIME.handle(); - Self::new_with_runtime(runtime, url) - } - - /// Creates a new instance and connects to a starship deployment - pub fn new_with_runtime(rt_handle: &Handle, url: Option<&str>) -> Result { let starship_config = match try_to_read_starship_config() { Ok(config) => Some(config), Err(e) => { @@ -40,11 +32,11 @@ impl Starship { None } }; - let starship_client = StarshipClient::new(rt_handle.clone(), url, starship_config)?; + let starship_client = StarshipClient::new(url, starship_config)?; let mut daemons: HashMap = HashMap::new(); for chain in starship_client.chains.iter() { - let mnemonic = rt_handle.block_on(async { + let mnemonic = block_on(async { let registry = starship_client.registry().await; registry .test_mnemonic(chain.chain_id.as_str()) @@ -53,11 +45,7 @@ impl Starship { }); let mut daemon_builder = DaemonBuilder::new(chain_data_conversion(chain.clone())); - let mut daemon_builder = daemon_builder - .mnemonic(mnemonic) - .load_network(false) - .handle(rt_handle); - + let mut daemon_builder = daemon_builder.mnemonic(mnemonic).load_network(false); if let Some(existing_daemon) = daemons.values().next() { daemon_builder = daemon_builder.state(existing_daemon.state()) } @@ -68,9 +56,9 @@ impl Starship { Ok(Self { daemons, starship_client, - rt_handle: rt_handle.clone(), }) } + /// Get a chain daemon from the starship infrastructure pub fn daemon(&self, chain_id: &str) -> Result<&Daemon, CwEnvError> { self.daemons diff --git a/packages/macros/cw-orch-contract-derive/src/lib.rs b/packages/macros/cw-orch-contract-derive/src/lib.rs index a1f891d23..685ff57a4 100644 --- a/packages/macros/cw-orch-contract-derive/src/lib.rs +++ b/packages/macros/cw-orch-contract-derive/src/lib.rs @@ -224,22 +224,13 @@ pub fn interface(attrs: TokenStream, input: TokenStream) -> TokenStream { ) }; let struct_def = quote!( - #[cfg(not(target_arch = "wasm32"))] #[derive( ::std::clone::Clone, )] pub struct #name(::cw_orch::core::contract::Contract, #(#all_phantom_markers,)*); - #[cfg(target_arch = "wasm32")] - #[derive( - ::std::clone::Clone, - )] - pub struct #name; - - #[cfg(not(target_arch = "wasm32"))] #default_num - #[cfg(not(target_arch = "wasm32"))] impl ::cw_orch::core::contract::interface_traits::ContractInstance for #name { fn as_instance(&self) -> &::cw_orch::core::contract::Contract { &self.0 @@ -249,22 +240,18 @@ pub fn interface(attrs: TokenStream, input: TokenStream) -> TokenStream { } } - #[cfg(not(target_arch = "wasm32"))] impl ::cw_orch::core::contract::interface_traits::InstantiableContract for #name #all_debug_serialize { type InstantiateMsg = #init; } - #[cfg(not(target_arch = "wasm32"))] impl ::cw_orch::core::contract::interface_traits::ExecutableContract for #name #all_debug_serialize { type ExecuteMsg = #exec; } - #[cfg(not(target_arch = "wasm32"))] impl ::cw_orch::core::contract::interface_traits::QueryableContract for #name #all_debug_serialize { type QueryMsg = #query; } - #[cfg(not(target_arch = "wasm32"))] impl ::cw_orch::core::contract::interface_traits::MigratableContract for #name #all_debug_serialize { type MigrateMsg = #migrate; } diff --git a/packages/macros/cw-orch-fns-derive/src/fns_derive.rs b/packages/macros/cw-orch-fns-derive/src/fns_derive.rs index 4f1b9b7e9..fec8c8b89 100644 --- a/packages/macros/cw-orch-fns-derive/src/fns_derive.rs +++ b/packages/macros/cw-orch-fns-derive/src/fns_derive.rs @@ -260,17 +260,10 @@ pub fn fns_derive(msg_type: MsgType, sync_type: SyncType, mut input: ItemEnum) - let trait_condition = quote!(::cw_orch::core::contract::interface_traits::#trait_name); let derived_trait = quote!( - #[cfg(not(target_arch = "wasm32"))] /// Automatically derived trait that allows you to call the variants of the message directly without the need to construct the struct yourself. pub trait #bname #cw_orch_generics : #trait_condition #combined_trait_where_clause { #(#variant_fns)* } - - #[cfg(target_arch = "wasm32")] - /// Automatically derived trait that allows you to call the variants of the message directly without the need to construct the struct yourself. - pub trait #bname{ - - } ); // Generating the generics for the blanket implementation @@ -296,7 +289,6 @@ pub fn fns_derive(msg_type: MsgType, sync_type: SyncType, mut input: ItemEnum) - let expand = quote!( #derived_trait - #[cfg(not(target_arch = "wasm32"))] #derived_trait_blanket_impl );