Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalized querier getter #318

Merged
7 changes: 4 additions & 3 deletions cw-orch-daemon/src/queriers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,19 @@ macro_rules! cosmos_query {
mod authz;
mod bank;
mod cosmwasm;
mod env;
mod feegrant;
mod gov;
mod ibc;
mod node;
mod staking;

pub use authz::Authz;
pub use bank::{cosmrs_to_cosmwasm_coins, Bank};
pub use cosmwasm::CosmWasm;
pub use bank::{cosmrs_to_cosmwasm_coins, Bank, DaemonBankQuerier};
pub use cosmwasm::{CosmWasm, DaemonWasmQuerier};
pub use feegrant::Feegrant;
pub use ibc::Ibc;
pub use node::Node;
pub use node::{DaemonNodeQuerier, Node};

// this two containt structs that are helpers for the queries
pub use gov::*;
Expand Down
12 changes: 6 additions & 6 deletions cw-orch-daemon/src/queriers/bank.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{cosmos_modules, error::DaemonError, Daemon};
use cosmrs::proto::cosmos::base::{query::v1beta1::PageRequest, v1beta1::Coin};
use cosmwasm_std::StdError;
use cw_orch_core::environment::queriers::bank::{BankQuerier, BankQuerierGetter};
use cw_orch_core::environment::{BankQuerier, Querier, QuerierGetter};
use tokio::runtime::Handle;
use tonic::transport::Channel;

Expand Down Expand Up @@ -157,17 +157,17 @@
}
}

impl BankQuerierGetter<DaemonError> for Daemon {
type Querier = DaemonBankQuerier;
impl Querier for DaemonBankQuerier {
type Error = DaemonError;
}

fn bank_querier(&self) -> Self::Querier {
impl QuerierGetter<DaemonBankQuerier> for Daemon {
fn querier(&self) -> DaemonBankQuerier {
DaemonBankQuerier::new(self)
}
}

impl BankQuerier for DaemonBankQuerier {
type Error = DaemonError;

fn balance(
&self,
address: impl Into<String>,
Expand All @@ -183,21 +183,21 @@
})??)
}

fn total_supply(&self) -> Result<Vec<cosmwasm_std::Coin>, Self::Error> {
Ok(self
.rt_handle
.block_on(Bank::new(self.channel.clone()).total_supply())
.map(|c| {
c.into_iter()
.map(cosmrs_to_cosmwasm_coins)
.collect::<Result<Vec<_>, StdError>>()
})??)
}

Check warning on line 195 in cw-orch-daemon/src/queriers/bank.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch-daemon/src/queriers/bank.rs#L186-L195

Added lines #L186 - L195 were not covered by tests

fn supply_of(&self, denom: impl Into<String>) -> Result<cosmwasm_std::Coin, Self::Error> {
Ok(self
.rt_handle
.block_on(Bank::new(self.channel.clone()).supply_of(denom))
.map(cosmrs_to_cosmwasm_coins)??)
}

Check warning on line 202 in cw-orch-daemon/src/queriers/bank.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch-daemon/src/queriers/bank.rs#L197-L202

Added lines #L197 - L202 were not covered by tests
}
16 changes: 8 additions & 8 deletions cw-orch-daemon/src/queriers/cosmwasm.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{cosmos_modules, error::DaemonError, Daemon};
use cosmrs::proto::cosmos::base::query::v1beta1::PageRequest;
use cosmwasm_std::{from_json, to_json_binary, CodeInfoResponse, ContractInfoResponse};
use cw_orch_core::environment::queriers::wasm::{WasmQuerier, WasmQuerierGetter};
use cw_orch_core::environment::{Querier, QuerierGetter, WasmQuerier};
use tokio::runtime::Handle;
use tonic::transport::Channel;

Expand Down Expand Up @@ -187,17 +187,17 @@
}
}

impl WasmQuerierGetter<DaemonError> for Daemon {
type Querier = DaemonWasmQuerier;

fn wasm_querier(&self) -> Self::Querier {
impl QuerierGetter<DaemonWasmQuerier> for Daemon {
fn querier(&self) -> DaemonWasmQuerier {
DaemonWasmQuerier::new(self)
}
}

impl WasmQuerier for DaemonWasmQuerier {
impl Querier for DaemonWasmQuerier {
type Error = DaemonError;
}

impl WasmQuerier for DaemonWasmQuerier {
fn code_id_hash(&self, code_id: u64) -> Result<String, Self::Error> {
self.rt_handle
.block_on(CosmWasm::new(self.channel.clone()).code_id_hash(code_id))
Expand All @@ -215,32 +215,32 @@
c.code_id = contract_info.code_id;
c.creator = contract_info.creator;
c.admin = if contract_info.admin.is_empty() {
None

Check warning on line 218 in cw-orch-daemon/src/queriers/cosmwasm.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch-daemon/src/queriers/cosmwasm.rs#L218

Added line #L218 was not covered by tests
} else {
Some(contract_info.admin)
};
c.ibc_port = if contract_info.ibc_port_id.is_empty() {
None
} else {
Some(contract_info.ibc_port_id)

Check warning on line 225 in cw-orch-daemon/src/queriers/cosmwasm.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch-daemon/src/queriers/cosmwasm.rs#L225

Added line #L225 was not covered by tests
};

Ok(c)
}

fn contract_raw_state(
fn raw_query(
&self,
address: impl Into<String>,
query_data: Vec<u8>,
) -> Result<Vec<u8>, Self::Error> {
let response = self.rt_handle.block_on(
CosmWasm::new(self.channel.clone()).contract_raw_state(address, query_data),
)?;

Check warning on line 238 in cw-orch-daemon/src/queriers/cosmwasm.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch-daemon/src/queriers/cosmwasm.rs#L231-L238

Added lines #L231 - L238 were not covered by tests

Ok(response.data)
}

Check warning on line 241 in cw-orch-daemon/src/queriers/cosmwasm.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch-daemon/src/queriers/cosmwasm.rs#L240-L241

Added lines #L240 - L241 were not covered by tests

fn contract_smart_state<Q: serde::Serialize, T: serde::de::DeserializeOwned>(
fn smart_query<Q: serde::Serialize, T: serde::de::DeserializeOwned>(
&self,
address: impl Into<String>,
query_data: &Q,
Expand All @@ -248,21 +248,21 @@
let response = self.rt_handle.block_on(
CosmWasm::new(self.channel.clone())
.contract_state(address, to_json_binary(&query_data)?.to_vec()),
)?;

Check warning on line 251 in cw-orch-daemon/src/queriers/cosmwasm.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch-daemon/src/queriers/cosmwasm.rs#L251

Added line #L251 was not covered by tests

Ok(from_json(response)?)
}

fn code(&self, code_id: u64) -> Result<cosmwasm_std::CodeInfoResponse, Self::Error> {
let response = self
.rt_handle
.block_on(CosmWasm::new(self.channel.clone()).code(code_id))?;

Check warning on line 259 in cw-orch-daemon/src/queriers/cosmwasm.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch-daemon/src/queriers/cosmwasm.rs#L256-L259

Added lines #L256 - L259 were not covered by tests

let mut c = CodeInfoResponse::default();
c.code_id = code_id;
c.creator = response.creator;
c.checksum = response.data_hash.into();

Ok(c)
}

Check warning on line 267 in cw-orch-daemon/src/queriers/cosmwasm.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch-daemon/src/queriers/cosmwasm.rs#L261-L267

Added lines #L261 - L267 were not covered by tests
}
14 changes: 14 additions & 0 deletions cw-orch-daemon/src/queriers/env.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use cw_orch_core::environment::{EnvironmentInfo, EnvironmentQuerier};

use crate::Daemon;

impl EnvironmentQuerier for Daemon {
fn env_info(&self) -> EnvironmentInfo {
let state = &self.daemon.sender.daemon_state;
EnvironmentInfo {
chain_id: state.chain_data.chain_id.to_string(),
chain_name: state.chain_data.chain_name.clone(),
deployment_id: state.deployment_id.clone(),
}
}

Check warning on line 13 in cw-orch-daemon/src/queriers/env.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch-daemon/src/queriers/env.rs#L6-L13

Added lines #L6 - L13 were not covered by tests
}
12 changes: 6 additions & 6 deletions cw-orch-daemon/src/queriers/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
};
use cosmwasm_std::BlockInfo;
use cw_orch_core::{
environment::queriers::node::{NodeQuerier, NodeQuerierGetter},
environment::{NodeQuerier, Querier, QuerierGetter},
log::query_target,
CwOrchEnvVars,
};
Expand Down Expand Up @@ -346,17 +346,17 @@
}
}

impl NodeQuerierGetter<DaemonError> for Daemon {
type Querier = DaemonNodeQuerier;

fn node_querier(&self) -> Self::Querier {
impl QuerierGetter<DaemonNodeQuerier> for Daemon {
fn querier(&self) -> DaemonNodeQuerier {
DaemonNodeQuerier::new(self)
}
}

impl NodeQuerier for DaemonNodeQuerier {
impl Querier for DaemonNodeQuerier {
type Error = DaemonError;
}

impl NodeQuerier for DaemonNodeQuerier {
type Response = CosmTxResponse;

fn latest_block(&self) -> Result<cosmwasm_std::BlockInfo, Self::Error> {
Expand All @@ -364,33 +364,33 @@
.block_on(Node::new(self.channel.clone()).block_info())
}

fn block_by_height(&self, height: u64) -> Result<cosmwasm_std::BlockInfo, Self::Error> {
let block = self
.rt_handle
.block_on(Node::new(self.channel.clone()).block_by_height(height))?;

Check warning on line 370 in cw-orch-daemon/src/queriers/node.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch-daemon/src/queriers/node.rs#L367-L370

Added lines #L367 - L370 were not covered by tests

block_to_block_info(block)
}

Check warning on line 373 in cw-orch-daemon/src/queriers/node.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch-daemon/src/queriers/node.rs#L372-L373

Added lines #L372 - L373 were not covered by tests

fn block_height(&self) -> Result<u64, Self::Error> {
self.rt_handle
.block_on(Node::new(self.channel.clone()).block_height())
}

Check warning on line 378 in cw-orch-daemon/src/queriers/node.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch-daemon/src/queriers/node.rs#L375-L378

Added lines #L375 - L378 were not covered by tests

fn block_time(&self) -> Result<u128, Self::Error> {
self.rt_handle
.block_on(Node::new(self.channel.clone()).block_time())
}

Check warning on line 383 in cw-orch-daemon/src/queriers/node.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch-daemon/src/queriers/node.rs#L380-L383

Added lines #L380 - L383 were not covered by tests

fn simulate_tx(&self, tx_bytes: Vec<u8>) -> Result<u64, Self::Error> {
self.rt_handle
.block_on(Node::new(self.channel.clone()).simulate_tx(tx_bytes))
}

Check warning on line 388 in cw-orch-daemon/src/queriers/node.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch-daemon/src/queriers/node.rs#L385-L388

Added lines #L385 - L388 were not covered by tests

fn find_tx(&self, hash: String) -> Result<Self::Response, Self::Error> {
self.rt_handle
.block_on(Node::new(self.channel.clone()).find_tx(hash))
}

Check warning on line 393 in cw-orch-daemon/src/queriers/node.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch-daemon/src/queriers/node.rs#L390-L393

Added lines #L390 - L393 were not covered by tests
}

fn block_to_block_info(block: Block) -> Result<BlockInfo, DaemonError> {
Expand Down
45 changes: 6 additions & 39 deletions cw-orch-daemon/src/sync/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@ use std::{fmt::Debug, sync::Arc, time::Duration};

use super::super::{sender::Wallet, DaemonAsync};
use crate::{
queriers::{DaemonQuerier, Node},
queriers::{DaemonBankQuerier, DaemonNodeQuerier, DaemonQuerier, DaemonWasmQuerier, Node},
CosmTxResponse, DaemonBuilder, DaemonError, DaemonState,
};

use cosmrs::tendermint::Time;
use cosmwasm_std::{Addr, Coin};
use cw_orch_core::{
contract::{interface_traits::Uploadable, WasmPath},
environment::{
queriers::QueryHandler, ChainState, EnvironmentInfo, EnvironmentQuerier, TxHandler,
},
environment::{ChainState, DefaultQueriers, QueryHandler, TxHandler},
};
use cw_orch_traits::stargate::Stargate;
use serde::Serialize;
Expand Down Expand Up @@ -218,40 +215,10 @@ impl QueryHandler for Daemon {
}
Ok(())
}

fn block_info(&self) -> Result<cosmwasm_std::BlockInfo, DaemonError> {
let block = self
.rt_handle
.block_on(self.query_client::<Node>().latest_block())?;
let since_epoch = block.header.time.duration_since(Time::unix_epoch())?;
let time = cosmwasm_std::Timestamp::from_nanos(since_epoch.as_nanos() as u64);
Ok(cosmwasm_std::BlockInfo {
height: block.header.height.value(),
time,
chain_id: block.header.chain_id.to_string(),
})
}

fn query<
Q: serde::Serialize + std::fmt::Debug,
T: serde::Serialize + serde::de::DeserializeOwned,
>(
&self,
query_msg: &Q,
contract_address: &cosmwasm_std::Addr,
) -> Result<T, Self::Error> {
self.rt_handle
.block_on(self.daemon.query(query_msg, contract_address))
}
}

impl EnvironmentQuerier for Daemon {
fn env_info(&self) -> EnvironmentInfo {
let state = &self.daemon.sender.daemon_state;
EnvironmentInfo {
chain_id: state.chain_data.chain_id.to_string(),
chain_name: state.chain_data.chain_name.clone(),
deployment_id: state.deployment_id.clone(),
}
}
impl DefaultQueriers for Daemon {
type B = DaemonBankQuerier;
type W = DaemonWasmQuerier;
type N = DaemonNodeQuerier;
}
7 changes: 4 additions & 3 deletions cw-orch-daemon/tests/authz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod tests {
bank::v1beta1::MsgSend,
};
use cosmwasm_std::coins;
use cw_orch_core::environment::{BankQuerier, TxHandler};
use cw_orch_core::environment::{BankQuerier, DefaultQueriers, QueryHandler, TxHandler};
use cw_orch_daemon::{queriers::Authz, Daemon};
use cw_orch_networks::networks::LOCAL_JUNO;
use cw_orch_traits::Stargate;
Expand Down Expand Up @@ -138,8 +138,9 @@ mod tests {

// the balance of the grantee whould be 6_000_000 or close

let grantee_balance =
daemon.balance(grantee.clone(), Some(LOCAL_JUNO.gas_denom.to_string()))?;
let grantee_balance = daemon
.bank_querier()
.balance(grantee.clone(), Some(LOCAL_JUNO.gas_denom.to_string()))?;

assert_eq!(grantee_balance.first().unwrap().amount.u128(), 6_000_000);

Expand Down
5 changes: 1 addition & 4 deletions cw-orch/examples/complex_osmosis_test_tube.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ use counter_contract::{
CounterContract, CounterExecuteMsgFns, CounterQueryMsgFns,
};

use cw_orch::prelude::bank::BankQuerier;
use cw_orch::prelude::bank::BankQuerierGetter;
use cw_orch::prelude::{CallAs, ContractInstance, OsmosisTestTube};
use cw_orch::prelude::{CwOrchExecute, CwOrchInstantiate, CwOrchUpload};
use cw_orch::prelude::*;
use cw_orch_traits::Stargate;
use osmosis_std::types::{
cosmos::base::v1beta1::Coin,
Expand Down
7 changes: 1 addition & 6 deletions cw-orch/examples/complex_testnet_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ use counter_contract::{
msg::{ExecuteMsg, GetCountResponse, InstantiateMsg, QueryMsg},
CounterContract, CounterExecuteMsgFns, CounterQueryMsgFns,
};
use cw_orch::prelude::bank::BankQuerier;
use cw_orch::prelude::bank::BankQuerierGetter;
use cw_orch::prelude::{
ContractInstance, CwOrchExecute, CwOrchInstantiate, CwOrchQuery, CwOrchUpload, Daemon,
TxHandler,
};
use cw_orch::prelude::*;
use cw_orch_traits::Stargate;
use osmosis_std::types::{
cosmos::base::v1beta1::Coin,
Expand Down
12 changes: 6 additions & 6 deletions cw-orch/src/osmosis_test_tube/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
use crate::prelude::Uploadable;
use cosmwasm_std::Addr;

use cw_orch_core::environment::queriers::bank::{BankQuerier, BankQuerierGetter};
use cw_orch_core::environment::BankSetter;
use cw_orch_core::environment::{BankQuerier, BankSetter, DefaultQueriers};
use cw_orch_traits::stargate::Stargate;

use cosmwasm_std::{Binary, Coin, Uint128};
Expand Down Expand Up @@ -33,6 +32,8 @@

pub use osmosis_test_tube;

use super::queriers::bank::OsmosisTestTubeBankQuerier;

/// Wrapper around a osmosis-test-tube [`OsmosisTestApp`](osmosis_test_tube::OsmosisTestApp) backend.
///
/// Stores a local state with a mapping of contract_id -> code_id/address
Expand Down Expand Up @@ -65,7 +66,7 @@
pub app: Rc<RefCell<OsmosisTestApp>>,
}

pub(crate) fn map_err(e: RunnerError) -> CwOrchError {

Check warning on line 69 in cw-orch/src/osmosis_test_tube/core.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch/src/osmosis_test_tube/core.rs#L69

Added line #L69 was not covered by tests
CwOrchError::StdErr(e.to_string())
}

Expand Down Expand Up @@ -139,10 +140,10 @@
/// Query the (bank) balance of a native token for and address.
/// Returns the amount of the native token.
pub fn query_balance(&self, address: &str, denom: &str) -> Result<Uint128, CwOrchError> {
let amount = self
.bank_querier()
.balance(address, Some(denom.to_string()))?;
Ok(amount.first().unwrap().amount)

Check warning on line 146 in cw-orch/src/osmosis_test_tube/core.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch/src/osmosis_test_tube/core.rs#L143-L146

Added lines #L143 - L146 were not covered by tests
}

/// Fetch all the balances of an address.
Expand All @@ -150,7 +151,7 @@
&self,
address: &str,
) -> Result<Vec<cosmwasm_std::Coin>, CwOrchError> {
let amount = self.bank_querier().balance(address, None)?;

Check warning on line 154 in cw-orch/src/osmosis_test_tube/core.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch/src/osmosis_test_tube/core.rs#L154

Added line #L154 was not covered by tests
Ok(amount)
}
}
Expand Down Expand Up @@ -269,6 +270,8 @@
}

impl BankSetter for OsmosisTestTube {
type T = OsmosisTestTubeBankQuerier;

/// It's impossible to set the balance of an address directly in OsmosisTestTub
/// So for this implementation, we use a weird algorithm
fn set_balance(
Expand Down Expand Up @@ -304,10 +307,7 @@
pub mod tests {
use cosmwasm_std::{coins, ContractInfoResponse};

use cw_orch_core::environment::queriers::{
bank::{BankQuerier, BankQuerierGetter},
wasm::{WasmQuerier, WasmQuerierGetter},
};
use cw_orch_core::environment::*;
use osmosis_test_tube::Account;

use super::OsmosisTestTube;
Expand Down
21 changes: 10 additions & 11 deletions cw-orch/src/osmosis_test_tube/queriers/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
use cosmwasm_std::coin;
use cw_orch_core::{
environment::{
queriers::bank::{BankQuerier, BankQuerierGetter},
StateInterface, TxHandler,
Querier, StateInterface, {BankQuerier, QuerierGetter},
},
CwEnvError,
};
Expand All @@ -16,29 +15,29 @@
use osmosis_test_tube::osmosis_std::types::cosmos::bank::v1beta1::{
QueryAllBalancesRequest, QueryBalanceRequest,
};
pub struct MockBankQuerier {
pub struct OsmosisTestTubeBankQuerier {
app: Rc<RefCell<OsmosisTestApp>>,
}

impl MockBankQuerier {
impl OsmosisTestTubeBankQuerier {
fn new<S: StateInterface>(mock: &OsmosisTestTube<S>) -> Self {
Self {
app: mock.app.clone(),
}
}
}

impl<S: StateInterface> BankQuerierGetter<<Self as TxHandler>::Error> for OsmosisTestTube<S> {
type Querier = MockBankQuerier;
impl Querier for OsmosisTestTubeBankQuerier {
type Error = CwEnvError;
}

fn bank_querier(&self) -> Self::Querier {
MockBankQuerier::new(self)
impl<S: StateInterface> QuerierGetter<OsmosisTestTubeBankQuerier> for OsmosisTestTube<S> {
fn querier(&self) -> OsmosisTestTubeBankQuerier {
OsmosisTestTubeBankQuerier::new(self)
}
}

impl BankQuerier for MockBankQuerier {
type Error = CwEnvError;

impl BankQuerier for OsmosisTestTubeBankQuerier {
fn balance(
&self,
address: impl Into<String>,
Expand All @@ -60,15 +59,15 @@
.unwrap_or(coin(0, &denom));
Ok(vec![amount])
} else {
let amount = Bank::new(&*self.app.borrow())
.query_all_balances(&QueryAllBalancesRequest {
address: address.into(),
pagination: None,
})
.map_err(map_err)?

Check warning on line 67 in cw-orch/src/osmosis_test_tube/queriers/bank.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch/src/osmosis_test_tube/queriers/bank.rs#L62-L67

Added lines #L62 - L67 were not covered by tests
.balances;

Ok(try_proto_to_cosmwasm_coins(amount)?)

Check warning on line 70 in cw-orch/src/osmosis_test_tube/queriers/bank.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch/src/osmosis_test_tube/queriers/bank.rs#L70

Added line #L70 was not covered by tests
}
}

Expand Down Expand Up @@ -98,7 +97,7 @@
.unwrap_or(coin(0, &denom)))
}

fn total_supply(&self) -> Result<Vec<cosmwasm_std::Coin>, Self::Error> {
unimplemented!()
}

Check warning on line 102 in cw-orch/src/osmosis_test_tube/queriers/bank.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch/src/osmosis_test_tube/queriers/bank.rs#L100-L102

Added lines #L100 - L102 were not covered by tests
}
9 changes: 6 additions & 3 deletions cw-orch/src/osmosis_test_tube/queriers/env.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
use crate::osmosis_test_tube::OsmosisTestTube;
use cw_orch_core::environment::{EnvironmentInfo, EnvironmentQuerier, QueryHandler};
use cw_orch_core::environment::{
EnvironmentInfo, EnvironmentQuerier, QueryHandler, StateInterface,
};

impl EnvironmentQuerier for OsmosisTestTube {
use crate::prelude::OsmosisTestTube;

impl<S: StateInterface> EnvironmentQuerier for OsmosisTestTube<S> {
fn env_info(&self) -> EnvironmentInfo {
let block = self.block_info().unwrap();
let chain_id = block.chain_id;
let chain_name = chain_id.rsplitn(2, '-').collect::<Vec<_>>()[1].to_string();

EnvironmentInfo {
chain_id,
chain_name,
deployment_id: "default".to_string(),
}
}

Check warning on line 18 in cw-orch/src/osmosis_test_tube/queriers/env.rs

View check run for this annotation

Codecov / codecov/patch

cw-orch/src/osmosis_test_tube/queriers/env.rs#L8-L18

Added lines #L8 - L18 were not covered by tests
}
Loading
Loading