estimateGas method

Future<double> estimateGas(
  1. Tx simTx,
  2. double? gasAdjustment,
  3. List messages
)

//

// // // // // //

Implementation

Future<double> estimateGas(
    Core.Tx simTx, double? gasAdjustment, List<dynamic> messages) async {
  var gasAdjs =
      gasAdjustment ?? TerraClientConfiguration.lcdConfig!.gasAdjustment;

  var rootPath =
      "${TerraClientConfiguration.blockchainResourcePath}${CosmosBaseConstants.COSMOS_TX_ESTIMATE_GAS_USAGE}";

  var dataEncoded = simTx.toProtoWithType(messages);

  print(dataEncoded);

  String data = encode(dataEncoded);
  var response = await apiRequester.postAsync(
      rootPath, json.encode(TxUploadContainerJSON(tx_bytes: data).toJson()));

  if (response.successful!) {
    var result = TxUploadContainerJSON.fromJson(response.result!);
    return gasAdjs! * double.parse(result.gas_info!.gas_used);
  }

  throw Exception("cannot append signature");
}