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 {
pub async fn execute_tx(
&self,
mut builder: TxBuilder,
) -> Result<tx_commit::Response, CosmosClientError> {
let gas_info = self.gas_info()?;
builder.set_fee(GAS_AMOUNT, &gas_info.denom, GAS_LIMIT);
let signed_bytes = builder.get_signed_bytes()?;
let simulation = self.simulate(signed_bytes).await?;
builder.fees = Some(gas_info.fee(simulation)?);
let signed_bytes = builder.get_signed_bytes()?;
self.broadcast_tx(signed_bytes).await
}
}