use cosmrs::tendermint::abci::Code;
use cosmrs::tendermint::block::Height;
use cosmrs::tendermint::merkle::proof::ProofOps;
use prost::Message;
use serde::{Deserialize, Serialize};
use tendermint_rpc::endpoint::abci_query::AbciQuery;
mod account;
pub mod broadcast_tx;
pub mod error;
pub mod execute_tx;
pub mod gas_info;
pub mod http_client;
#[cfg(any(test, feature = "test_scenario"))]
pub mod mock_client;
pub mod query_contract;
pub mod simulate;
pub mod websocket_client;
pub use websocket_client::CosmosClient;
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct QueryResponse<T> {
pub code: Code,
pub log: String,
pub info: String,
pub index: i64,
pub key: Vec<u8>,
pub value: T,
pub proof: Option<ProofOps>,
pub height: Height,
pub codespace: String,
}
impl<T: Message + Default> From<AbciQuery> for QueryResponse<T> {
fn from(value: AbciQuery) -> Self {
Self {
code: value.code,
log: value.log,
info: value.info,
index: value.index,
key: value.key,
value: T::decode(value.value.as_slice()).unwrap(),
proof: value.proof,
height: value.height,
codespace: value.codespace,
}
}
}