getConsensusStateByID method

Future<List<ClientConsensusStates>> getConsensusStateByID(
  1. String clientId
)

Implementation

Future<List<ClientConsensusStates>> getConsensusStateByID(
    String clientId) async {
  String rootPath =
      "${TerraClientConfiguration.blockchainResourcePath}${CosmosBaseConstants.COSMOS_IBC_CORE_CLIENT_CONSENSUS_STATES}/$clientId";
  // if (options != null)
  // {
  //     rootPath += PaginationOptionExtensions.GetPaginationRules(options);
  // }

  var response = await apiRequester.getAsync<CommonIBCParamsJson>(rootPath);
  if (response.successful!) {
    var result = CommonIBCParamsJson.fromJson(response.result!);
    return result.consensus_states
        .map((e) => ClientConsensusStates(
            clientId, [ConsensusStateWithHeight.fromJSON(e)]))
        .toList();
  }

  throw Exception(
      "Could not successfully fetch the client state information for client Id: $clientId");
}