getAccountByAddress method

Future<AccountResponse> getAccountByAddress(
  1. String address, {
  2. bool throwOnEmptyBalance = true,
  3. int? round,
  4. List<Exclude>? exclude,
  5. bool? includeAll,
  6. CancelToken? cancelToken,
  7. ProgressCallback? onSendProgress,
  8. ProgressCallback? onReceiveProgress,
})

Lookup account information by a given account address.

If throwOnEmptyBalance is true, an AlgorandException will be thrown, otherwise an empty account will be returned.

Throws an AlgorandException if there is an HTTP error, or an invalid address is passed. Returns the account information for the given account id.

Implementation

Future<AccountResponse> getAccountByAddress(
  String address, {
  bool throwOnEmptyBalance = true,
  int? round,
  List<Exclude>? exclude,
  bool? includeAll,
  CancelToken? cancelToken,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  try {
    final response = await _accountsApi.getAccountByAddress(
      address,
      round: round,
      exclude: exclude,
      includeAll: includeAll,
      cancelToken: cancelToken,
      onSendProgress: onSendProgress,
      onReceiveProgress: onReceiveProgress,
    );

    return response;
  } on AlgorandException catch (ex) {
    final statusCode = ex.statusCode;
    if (statusCode == 404 && !throwOnEmptyBalance) {
      return Future.value(
        AccountResponse(
          currentRound: 0,
          account: AccountInformation.empty(address),
        ),
      );
    }

    rethrow;
  }
}