getExchangeRate method

Future<Coin> getExchangeRate(
  1. String denom
)

Implementation

Future<Coin> getExchangeRate(String denom) async {
  var rootPath =
      "${TerraClientConfiguration.blockchainResourcePath}${CosmosBaseConstants.COSMOS_ORACLE_DENOMS}/$denom/${CosmosOracleConstants.EXCHANGE_RATE}";

  var response =
      await apiRequester.getAsync<OracleApiExchangeRateApi>(rootPath);
  if (response.successful!) {
    var result = OracleApiExchangeRateApi.fromJson(response.result!);

    return Coin.fromData(CoinDataArgs()
      ..amount = double.parse(result.exchange_rate)
      ..denom = denom);
  }

  throw Exception("");
}