bolt-cw-sdk 1.0.0

SDK for the BOLT protocol, providing utilities for interacting with the BOLT contracts.
Documentation
use crate::cosmos_client::error::CosmosClientError;
use crate::cosmos_client::CosmosClient;
use cosmrs::tendermint::block::Height;
use tendermint_rpc::endpoint::status;
use tendermint_rpc::{endpoint, Client, HttpClient};

impl CosmosClient<HttpClient> {
    pub async fn new(http_url: &str) -> Result<Self, CosmosClientError> {
        let client = HttpClient::new(http_url)?;

        Ok(Self {
            client,
            driver_handle: None,
            gas_info: None,
        })
    }

    pub async fn status(&self) -> Result<status::Response, CosmosClientError> {
        self.client
            .status()
            .await
            .map_err(CosmosClientError::Tendermint)
    }

    pub async fn block(&self, height: u64) -> Result<endpoint::block::Response, CosmosClientError> {
        self.client
            .block(Height::from(height as u32))
            .await
            .map_err(CosmosClientError::Tendermint)
    }

    pub async fn block_results(
        &self,
        height: u64,
    ) -> Result<endpoint::block_results::Response, CosmosClientError> {
        self.client
            .block_results(Height::from(height as u32))
            .await
            .map_err(CosmosClientError::Tendermint)
    }
}