Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/src/algorand.dart
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,9 @@ class Algorand {
Future<BigInt> getBalance(String address) async {
final response = await _indexer.getAccountByAddress(address);

return response.account.amountWithoutPendingRewards;
return response.account != null
? response.account!.amountWithoutPendingRewards
: BigInt.zero;
}

/// Get the list of pending transactions by address, sorted by priority,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/api/responses/accounts/account_lookup_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ part 'account_lookup_response.g.dart';
@JsonSerializable(fieldRename: FieldRename.kebab)
class AccountResponse {
/// Round at which the results were computed.
final int currentRound;
final AccountInformation account;
final int? currentRound;
final AccountInformation? account;

AccountResponse({required this.currentRound, required this.account});

Expand Down
7 changes: 4 additions & 3 deletions lib/src/api/responses/accounts/account_lookup_response.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lib/src/clients/algorand_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ abstract class AlgorandClient {

final options = BaseOptions(
baseUrl: apiUrl,
connectTimeout: connectTimeout.inMilliseconds,
receiveTimeout: receiveTimeout.inMilliseconds,
sendTimeout: sendTimeout.inMilliseconds,
connectTimeout: connectTimeout,
receiveTimeout: receiveTimeout,
sendTimeout: sendTimeout,
headers: headers,
);

Expand Down
4 changes: 2 additions & 2 deletions lib/src/exceptions/algorand_exception.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class AlgorandException implements Exception {
this.cause,
}) : _message = message;

factory AlgorandException.fromDioError(DioError error) {
factory AlgorandException.fromDioError(DioException error) {
return AlgorandException(
statusCode: error.response?.statusCode,
message: error.message,
message: error.message!,
cause: error,
);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/src/repositories/application_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class ApplicationRepository {
Future<TealCompilation> compileTEAL(String sourceCode) async {
try {
return await applicationService.compileTEAL(sourceCode);
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand All @@ -34,8 +34,8 @@ class ApplicationRepository {
Future<DryRunResponse> dryrun(DryRunRequest request) async {
try {
return await applicationService.dryrun(request.toMessagePack());
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}
}
24 changes: 12 additions & 12 deletions lib/src/repositories/indexer_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class IndexerRepository {
Future<IndexerHealth> health() async {
try {
return await indexerService.health();
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand Down Expand Up @@ -71,8 +71,8 @@ class IndexerRepository {
}

return await indexerService.searchTransactions(queryParams);
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand All @@ -85,8 +85,8 @@ class IndexerRepository {
) async {
try {
return await assetService.searchAssets(queryParams);
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand All @@ -111,8 +111,8 @@ class IndexerRepository {
}

return await accountService.searchAccounts(queryParams);
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand All @@ -125,8 +125,8 @@ class IndexerRepository {
) async {
try {
return await applicationService.searchApplications(queryParams);
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand All @@ -137,8 +137,8 @@ class IndexerRepository {
Future<TransactionResponse> getTransactionById(String transactionId) async {
try {
return await indexerService.getTransactionById(transactionId);
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}
}
18 changes: 9 additions & 9 deletions lib/src/repositories/node_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class NodeRepository {
try {
final genesis = await service.genesis();
return genesis;
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand All @@ -28,7 +28,7 @@ class NodeRepository {
try {
await service.health();
return true;
} on DioError {
} on DioException {
return false;
}
}
Expand All @@ -40,8 +40,8 @@ class NodeRepository {
Future<NodeStatus> status() async {
try {
return await service.status();
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand All @@ -57,8 +57,8 @@ class NodeRepository {
Future<NodeStatus> statusAfterRound(int round) async {
try {
return await service.statusAfterRound(round);
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand All @@ -69,8 +69,8 @@ class NodeRepository {
Future<LedgerSupply> supply() async {
try {
return await service.supply();
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}
}
36 changes: 18 additions & 18 deletions lib/src/repositories/transaction_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class TransactionRepository {
Future<TransactionParams> getSuggestedTransactionParams() async {
try {
return await transactionService.getSuggestedTransactionParams();
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand All @@ -48,8 +48,8 @@ class TransactionRepository {
await this.waitForConfirmation(response.transactionId, timeout: timeout);

return response.transactionId;
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand Down Expand Up @@ -77,8 +77,8 @@ class TransactionRepository {
await this.waitForConfirmation(response.transactionId, timeout: timeout);

return response.transactionId;
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand All @@ -102,8 +102,8 @@ class TransactionRepository {
await this.waitForConfirmation(response.transactionId, timeout: timeout);

return response.transactionId;
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand Down Expand Up @@ -131,8 +131,8 @@ class TransactionRepository {
await this.waitForConfirmation(response.transactionId, timeout: timeout);

return response.transactionId;
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand All @@ -152,8 +152,8 @@ class TransactionRepository {
address,
max: max,
);
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand All @@ -169,8 +169,8 @@ class TransactionRepository {
}) async {
try {
return transactionService.getPendingTransactions(max: max);
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand All @@ -195,8 +195,8 @@ class TransactionRepository {
) async {
try {
return transactionService.getPendingTransactionById(transactionId);
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}
}

Expand Down Expand Up @@ -227,8 +227,8 @@ class TransactionRepository {
await nodeService.statusAfterRound(currentRound);
currentRound++;
}
} on DioError catch (ex) {
throw AlgorandException(message: ex.message, cause: ex);
} on DioException catch (ex) {
throw AlgorandException(message: ex.message!, cause: ex);
}

throw AlgorandException(
Expand Down
Loading