getRewards method

Future<List<Rewards>> getRewards(
  1. String delegator
)

Implementation

Future<List<Rewards>> getRewards(String delegator) async {
  String root =
      "${TerraClientConfiguration.blockchainResourcePath}${CosmosBaseConstants.COSMOS_DISTRIBUTION_DELEGATORS}/$delegator/${CosmosDistributionResources.REWARDS}";

  var response =
      await apiRequester.getAsync<DistributionRewardsInfoJson>(root);
  if (response.successful!) {
    var rewards = DistributionRewardsInfoJson.fromJson(response.result!);

    return rewards.rewards!
        .map((e) =>
            Rewards(e.validator_address, CoinsExtensions.fromJSON(e.reward!)))
        .toList();
  }

  throw Exception("");
}