Skip to content

Commit

Permalink
move around implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberHoward committed Jul 16, 2024
1 parent 5c7f603 commit 1c06b2e
Show file tree
Hide file tree
Showing 56 changed files with 2,626 additions and 331 deletions.
6 changes: 3 additions & 3 deletions cw-orch-daemon/src/core.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
queriers::CosmWasm,
queriers::{CosmWasm, CosmWasmBase},

Check failure on line 2 in cw-orch-daemon/src/core.rs

View workflow job for this annotation

GitHub Actions / clippy

unresolved imports `crate::queriers::CosmWasm`, `crate::queriers::CosmWasmBase`

error[E0432]: unresolved imports `crate::queriers::CosmWasm`, `crate::queriers::CosmWasmBase` --> cw-orch-daemon/src/core.rs:2:16 | 2 | queriers::{CosmWasm, CosmWasmBase}, | ^^^^^^^^ ^^^^^^^^^^^^ no `CosmWasmBase` in `queriers` | | | no `CosmWasm` in `queriers` | = help: consider importing this type alias through its public re-export instead: crate::queriers::clients::CosmWasm = help: consider importing this struct through its public re-export instead: crate::queriers::clients::CosmWasmBase
senders::{builder::SenderBuilder, query::QuerySender},
DaemonAsyncBuilder, DaemonState,
};
Expand Down Expand Up @@ -149,10 +149,10 @@ impl<Sender: QuerySender> DaemonAsyncBase<Sender> {
query_msg: &Q,
contract_address: &Addr,
) -> Result<R, DaemonError> {
let querier = CosmWasm::new(self.channel());
let querier = CosmWasmBase::<Sender>::new_async(self.channel());

let resp: Vec<u8> = querier
.contract_state(contract_address, serde_json::to_vec(&query_msg)?)
._contract_state(contract_address, serde_json::to_vec(&query_msg)?)
.await?;

Ok(from_str(from_utf8(&resp).unwrap())?)
Expand Down
144 changes: 0 additions & 144 deletions cw-orch-daemon/src/grpc_channel.rs

This file was deleted.

13 changes: 1 addition & 12 deletions cw-orch-daemon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,7 @@ mod state;
mod sync;
mod tx_resp;

#[cfg(feature = "rpc")]
pub mod rpc_channel;
#[cfg(feature = "rpc")]
pub use self::rpc_channel::*;

#[cfg(feature = "grpc")]
pub mod grpc_channel;
#[cfg(feature = "grpc")]
pub use self::grpc_channel::*;


pub use self::{builder::*, channel::*, core::*, error::*, state::*, sync::*, tx_resp::*};
pub use self::{builder::*, core::*, error::*, state::*, sync::*, tx_resp::*};
pub use cw_orch_networks::networks;
pub use senders::{query::QuerySender, tx::TxSender, CosmosOptions, Wallet};
pub use tx_builder::TxBuilder;
Expand Down
3 changes: 1 addition & 2 deletions cw-orch-daemon/src/live_mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use cosmwasm_std::Binary;
use cosmwasm_std::Delegation;
use cosmwasm_std::Empty;
use cosmwasm_std::StakingQuery;
use ibc_chain_registry::chain::ChainData;
use tokio::runtime::Runtime;

Check failure on line 16 in cw-orch-daemon/src/live_mock.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `tokio::runtime::Runtime`

error: unused import: `tokio::runtime::Runtime` --> cw-orch-daemon/src/live_mock.rs:16:5 | 16 | use tokio::runtime::Runtime; | ^^^^^^^^^^^^^^^^^^^^^^^

use cosmwasm_std::{
Expand Down Expand Up @@ -190,7 +189,7 @@ impl WasmMockQuerier {
/// Creates a querier from chain information
pub fn new(chain: ChainInfoOwned) -> Self {
let channel = RUNTIME
.block_on(GrpcChannel::connect(
.block_on(CosmosClient::connect(

Check failure on line 192 in cw-orch-daemon/src/live_mock.rs

View workflow job for this annotation

GitHub Actions / clippy

failed to resolve: use of undeclared type `CosmosClient`

error[E0433]: failed to resolve: use of undeclared type `CosmosClient` --> cw-orch-daemon/src/live_mock.rs:192:23 | 192 | .block_on(CosmosClient::connect( | ^^^^^^^^^^^^ use of undeclared type `CosmosClient` | help: consider importing this struct through its public re-export | 4 + use crate::senders::CosmosClient; |
&chain.grpc_urls,
chain.chain_id.as_str(),
))
Expand Down
1 change: 0 additions & 1 deletion cw-orch-daemon/src/proto/injective.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use cosmrs::tx::Raw;
use cosmrs::tx::SignDoc;
use cosmrs::{
proto::traits::{Message, Name},

Check failure on line 7 in cw-orch-daemon/src/proto/injective.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `Message`

error: unused import: `Message` --> cw-orch-daemon/src/proto/injective.rs:7:21 | 7 | proto::traits::{Message, Name}, | ^^^^^^^
tx::Raw,
};

#[cfg(feature = "eth")]
Expand Down
26 changes: 14 additions & 12 deletions cw-orch-daemon/src/queriers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub mod grpc;
#[cfg(feature = "grpc")]
pub use grpc::*;

Check failure on line 33 in cw-orch-daemon/src/queriers.rs

View workflow job for this annotation

GitHub Actions / clippy

unused import: `grpc::*`

error: unused import: `grpc::*` --> cw-orch-daemon/src/queriers.rs:33:9 | 33 | pub use grpc::*; | ^^^^^^^

pub mod clients;

/// Constructor for a querier over a given channel
pub trait DaemonQuerier {
/// Construct an new querier over a given channel
Expand Down Expand Up @@ -64,21 +66,21 @@ macro_rules! cosmos_query {
}

mod authz;
mod bank;
mod cosmwasm;
mod env;
mod feegrant;
mod gov;
mod ibc;
mod node;
mod staking;
// mod bank;
// mod cosmwasm;
// 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, CosmWasmBase};
pub use feegrant::FeeGrant;
pub use ibc::Ibc;
pub use node::Node;
// pub use bank::{cosmrs_to_cosmwasm_coins, Bank};
// pub use cosmwasm::{CosmWasm, CosmWasmBase};
// pub use feegrant::FeeGrant;
// pub use ibc::Ibc;
// pub use node::Node;

// this two containt structs that are helpers for the queries
pub use gov::*;

Check failure on line 86 in cw-orch-daemon/src/queriers.rs

View workflow job for this annotation

GitHub Actions / clippy

unresolved import `gov`

error[E0432]: unresolved import `gov` --> cw-orch-daemon/src/queriers.rs:86:9 | 86 | pub use gov::*; | ^^^ use of undeclared crate or module `gov`
Expand Down
32 changes: 32 additions & 0 deletions cw-orch-daemon/src/queriers/clients/auth.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Only a simple implementation to not overload the tx builder
use tonic::transport::Channel;

use crate::{cosmos_query, queriers::DaemonQuerier, DaemonError};

/// Queries for Cosmos Bank Module
pub struct Auth {
channel: Channel,
}

impl DaemonQuerier for Auth {

Check failure on line 11 in cw-orch-daemon/src/queriers/clients/auth.rs

View workflow job for this annotation

GitHub Actions / clippy

not all trait items implemented, missing: `new`

error[E0046]: not all trait items implemented, missing: `new` --> cw-orch-daemon/src/queriers/clients/auth.rs:11:1 | 11 | impl DaemonQuerier for Auth { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `new` in implementation | ::: cw-orch-daemon/src/queriers.rs:43:5 | 43 | fn new(channel: tonic::transport::Channel) -> Self; | --------------------------------------------------- `new` from trait
fn new(channel: Channel) -> Self {

Check failure on line 12 in cw-orch-daemon/src/queriers/clients/auth.rs

View workflow job for this annotation

GitHub Actions / clippy

method `new` has an incompatible type for trait

error[E0053]: method `new` has an incompatible type for trait --> cw-orch-daemon/src/queriers/clients/auth.rs:12:21 | 12 | fn new(channel: Channel) -> Self { | ^^^^^^^ | | | expected `cosmrs::tendermint_rpc::HttpClient`, found `tonic::transport::Channel` | help: change the parameter type to match the trait: `cosmrs::tendermint_rpc::HttpClient` | note: type in trait --> cw-orch-daemon/src/queriers.rs:41:20 | 41 | fn new(client: cosmrs::rpc::HttpClient) -> Self; | ^^^^^^^^^^^^^^^^^^^^^^^ = note: expected signature `fn(cosmrs::tendermint_rpc::HttpClient) -> queriers::clients::auth::Auth` found signature `fn(tonic::transport::Channel) -> queriers::clients::auth::Auth`
Self { channel }
}
}

impl Auth {
/// Query spendable balance for address
pub async fn account(&self, address: impl Into<String>) -> Result<Vec<u8>, DaemonError> {


let resp = cosmos_query!(

Check failure on line 22 in cw-orch-daemon/src/queriers/clients/auth.rs

View workflow job for this annotation

GitHub Actions / clippy

`cosmos_query` is ambiguous

error[E0659]: `cosmos_query` is ambiguous --> cw-orch-daemon/src/queriers/clients/auth.rs:22:20 | 22 | let resp = cosmos_query!( | ^^^^^^^^^^^^ ambiguous name | = note: ambiguous because of a conflict between a `macro_rules` name and a non-`macro_rules` name from another module note: `cosmos_query` could refer to the macro defined here --> cw-orch-daemon/src/queriers/clients/mod.rs:27:1 | 27 | / macro_rules! cosmos_query { 28 | | ($self:ident, $module:ident, $func_name:ident, $request_type:ident { $($field:ident : $value:expr),* $(,)? }) => { 29 | | { 30 | | use $crate::cosmos_modules::$module::{ ... | 44 | | }; 45 | | } | |_^ note: `cosmos_query` could also refer to the macro imported here --> cw-orch-daemon/src/queriers/clients/auth.rs:4:13 | 4 | use crate::{cosmos_query, queriers::DaemonQuerier, DaemonError}; | ^^^^^^^^^^^^ = help: use `self::cosmos_query` to refer to this macro unambiguously
self,
auth,
account,
QueryAccountRequest {
address: address.into()
}
);
Ok(resp.account.unwrap().value)
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ mod tx;

pub use auth::Auth;
pub use bank::Bank;
pub use cosmwasm::CosmWasm;
pub use cosmwasm::{CosmWasm, CosmWasmBase};
pub use feegrant::Feegrant;

Check failure on line 60 in cw-orch-daemon/src/queriers/clients/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

unresolved import `feegrant::Feegrant`

error[E0432]: unresolved import `feegrant::Feegrant` --> cw-orch-daemon/src/queriers/clients/mod.rs:60:9 | 60 | pub use feegrant::Feegrant; | ^^^^^^^^^^-------- | | | | | help: a similar name exists in the module: `FeeGrant` | no `Feegrant` in `queriers::clients::feegrant`
pub use ibc::Ibc;
pub use node::Node;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
21 changes: 21 additions & 0 deletions cw-orch-daemon/src/queriers/grpc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/// macro for constructing and performing a query on a CosmosSDK module.
#[macro_export]
macro_rules! cosmos_query {

Check failure on line 3 in cw-orch-daemon/src/queriers/grpc.rs

View workflow job for this annotation

GitHub Actions / clippy

the name `cosmos_query` is defined multiple times

error[E0428]: the name `cosmos_query` is defined multiple times --> cw-orch-daemon/src/queriers/grpc.rs:3:1 | 3 | macro_rules! cosmos_query { | ^^^^^^^^^^^^^^^^^^^^^^^^^ `cosmos_query` redefined here | ::: cw-orch-daemon/src/queriers.rs:48:1 | 48 | macro_rules! cosmos_query { | ------------------------- previous definition of the macro `cosmos_query` here | = note: `cosmos_query` must be defined only once in the macro namespace of this module
($self:ident, $module:ident, $func_name:ident, $request_type:ident { $($field:ident : $value:expr),* $(,)? }) => {
{
use $crate::cosmos_modules::$module::{
query_client::QueryClient, $request_type,
};
let mut client = QueryClient::new($self.channel.clone());
#[allow(clippy::redundant_field_names)]
let request = $request_type { $($field : $value),* };
let response = client.$func_name(request.clone()).await?.into_inner();
::log::trace!(
"cosmos_query: {:?} resulted in: {:?}",
request,
response
);
response
}
};
}
File renamed without changes.
Loading

0 comments on commit 1c06b2e

Please sign in to comment.