Skip to main content

bolt_cw_sdk/cosmos_client/
mod.rs

1use cosmrs::tendermint::abci::Code;
2use cosmrs::tendermint::block::Height;
3use cosmrs::tendermint::merkle::proof::ProofOps;
4use prost::Message;
5use serde::{Deserialize, Serialize};
6use tendermint_rpc::endpoint::abci_query::AbciQuery;
7
8mod account;
9pub mod broadcast_tx;
10pub mod error;
11pub mod execute_tx;
12pub mod gas_info;
13pub mod http_client;
14#[cfg(any(test, feature = "test_scenario"))]
15pub mod mock_client;
16pub mod query_contract;
17pub mod simulate;
18pub mod websocket_client;
19
20pub use websocket_client::CosmosClient;
21
22#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
23pub struct QueryResponse<T> {
24    pub code: Code,
25    pub log: String,
26    pub info: String,
27    pub index: i64,
28    pub key: Vec<u8>,
29    pub value: T,
30    pub proof: Option<ProofOps>,
31    pub height: Height,
32    pub codespace: String,
33}
34
35impl<T: Message + Default> From<AbciQuery> for QueryResponse<T> {
36    fn from(value: AbciQuery) -> Self {
37        Self {
38            code: value.code,
39            log: value.log,
40            info: value.info,
41            index: value.index,
42            key: value.key,
43            value: T::decode(value.value.as_slice()).unwrap(),
44            proof: value.proof,
45            height: value.height,
46            codespace: value.codespace,
47        }
48    }
49}