bolt-cw-sdk 1.0.0

SDK for the BOLT protocol, providing utilities for interacting with the BOLT contracts.
Documentation
use crate::tx_builder::TxBuilder;
use tendermint_rpc::endpoint::broadcast::tx_commit;

use super::error::CosmosClientError;
use super::CosmosClient;

const GAS_LIMIT: u64 = 800_000u64;
const GAS_AMOUNT: u128 = u32::MAX as u128;

impl CosmosClient {
    /// Handles simulation, signing and broadcasting of a TX
    pub async fn execute_tx(
        &self,
        mut builder: TxBuilder,
    ) -> Result<tx_commit::Response, CosmosClientError> {
        let gas_info = self.gas_info()?;

        // Simulate
        builder.set_fee(GAS_AMOUNT, &gas_info.denom, GAS_LIMIT);
        let signed_bytes = builder.get_signed_bytes()?;
        let simulation = self.simulate(signed_bytes).await?;

        // Add the real gas
        builder.fees = Some(gas_info.fee(simulation)?);
        let signed_bytes = builder.get_signed_bytes()?;
        self.broadcast_tx(signed_bytes).await
    }
}