getAuthorizationGrants method

Future<List<AuthorizationGrant>> getAuthorizationGrants(
  1. String walletGranter,
  2. String walletGrantee, {
  3. String msgTypeUrl = "",
})

Implementation

Future<List<AuthorizationGrant>> getAuthorizationGrants(
    String walletGranter, String walletGrantee,
    {String msgTypeUrl = ""}) async {
  String rootPath =
      "${TerraClientConfiguration.blockchainResourcePath}${CosmosBaseConstants.COSMOS_AUTHZ_GRANTS}";

  String getPath = "$rootPath?granter=$walletGranter&grantee=$walletGrantee";
  if (msgTypeUrl.isNotBlank && msgTypeUrl.isNotEmpty) {
    getPath += "&msg_type_url=$msgTypeUrl";
  }

  var response =
      await apiRequester.getAsync<AuthorizationGrantsJSON>(getPath);
  if (response.successful!) {
    var cgrants = AuthorizationGrantsJSON.fromJson(response.result!).grants;
    return cgrants
        .map((grant) =>
            AuthorizationGrant(grant.authorization, grant.expiration))
        .toList();
  }

  throw Exception(
      "Could not successfully fetch the authorization information for wallet granter: $walletGranter");
}