1pub use cli::CliClient;
2use cosmrs::tendermint::chain::Id;
3pub use grpc::GrpcClient;
4use hex::ToHex;
5use serde::de::DeserializeOwned;
6
7pub mod cli;
8
9pub mod grpc;
10
11#[async_trait::async_trait]
12pub trait CwClient {
13 type Address: AsRef<str>;
14 type Query: ToString;
15 type RawQuery: ToHex;
16 type ChainId: AsRef<str>;
17 type Error;
18
19 async fn query_smart<R: DeserializeOwned + Send>(
20 &self,
21 contract: &Self::Address,
22 query: Self::Query,
23 ) -> Result<R, Self::Error>;
24
25 async fn query_raw<R: DeserializeOwned + Default>(
26 &self,
27 contract: &Self::Address,
28 query: Self::RawQuery,
29 ) -> Result<R, Self::Error>;
30
31 fn query_tx<R: DeserializeOwned + Default>(&self, txhash: &str) -> Result<R, Self::Error>;
32
33 async fn tx_execute<M: ToString + Send>(
34 &self,
35 contract: &Self::Address,
36 chain_id: &Id,
37 gas: u64,
38 sender: &str,
39 msg: M,
40 pay_amount: &str,
41 ) -> Result<String, Self::Error>;
42
43 fn deploy<M: ToString>(
44 &self,
45 chain_id: &Id,
46 sender: &str, wasm_path: M,
48 ) -> Result<String, Self::Error>;
49
50 fn init<M: ToString>(
51 &self,
52 chain_id: &Id,
53 sender: &str,
54 admin: Option<&str>,
55 code_id: u64,
56 init_msg: M,
57 label: &str,
58 ) -> Result<String, Self::Error>;
59
60 fn trusted_height_hash(&self) -> Result<(u64, String), Self::Error>;
61}