diff --git a/lib/src/algorand.dart b/lib/src/algorand.dart index 2a91ad6..e12cbf8 100644 --- a/lib/src/algorand.dart +++ b/lib/src/algorand.dart @@ -563,7 +563,9 @@ class Algorand { Future 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, diff --git a/lib/src/api/responses/accounts/account_lookup_response.dart b/lib/src/api/responses/accounts/account_lookup_response.dart index 8fd425c..6c70d64 100644 --- a/lib/src/api/responses/accounts/account_lookup_response.dart +++ b/lib/src/api/responses/accounts/account_lookup_response.dart @@ -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}); diff --git a/lib/src/api/responses/accounts/account_lookup_response.g.dart b/lib/src/api/responses/accounts/account_lookup_response.g.dart index 2769f7f..51dacec 100644 --- a/lib/src/api/responses/accounts/account_lookup_response.g.dart +++ b/lib/src/api/responses/accounts/account_lookup_response.g.dart @@ -8,9 +8,10 @@ part of 'account_lookup_response.dart'; AccountResponse _$AccountResponseFromJson(Map json) => AccountResponse( - currentRound: json['current-round'] as int, - account: - AccountInformation.fromJson(json['account'] as Map), + currentRound: json['current-round'] as int?, + account: json['account'] != null + ? AccountInformation.fromJson(json['account'] as Map) + : null, ); Map _$AccountResponseToJson(AccountResponse instance) => diff --git a/lib/src/clients/algorand_client.dart b/lib/src/clients/algorand_client.dart index e654c85..3b4aa09 100644 --- a/lib/src/clients/algorand_client.dart +++ b/lib/src/clients/algorand_client.dart @@ -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, ); diff --git a/lib/src/exceptions/algorand_exception.dart b/lib/src/exceptions/algorand_exception.dart index ad16bac..281cf1f 100644 --- a/lib/src/exceptions/algorand_exception.dart +++ b/lib/src/exceptions/algorand_exception.dart @@ -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, ); } diff --git a/lib/src/repositories/application_repository.dart b/lib/src/repositories/application_repository.dart index a74d705..4e794a3 100644 --- a/lib/src/repositories/application_repository.dart +++ b/lib/src/repositories/application_repository.dart @@ -21,8 +21,8 @@ class ApplicationRepository { Future 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); } } @@ -34,8 +34,8 @@ class ApplicationRepository { Future 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); } } } diff --git a/lib/src/repositories/indexer_repository.dart b/lib/src/repositories/indexer_repository.dart index a2e9239..a27af9c 100644 --- a/lib/src/repositories/indexer_repository.dart +++ b/lib/src/repositories/indexer_repository.dart @@ -29,8 +29,8 @@ class IndexerRepository { Future 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); } } @@ -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); } } @@ -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); } } @@ -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); } } @@ -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); } } @@ -137,8 +137,8 @@ class IndexerRepository { Future 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); } } } diff --git a/lib/src/repositories/node_repository.dart b/lib/src/repositories/node_repository.dart index 10d7730..4d19100 100644 --- a/lib/src/repositories/node_repository.dart +++ b/lib/src/repositories/node_repository.dart @@ -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); } } @@ -28,7 +28,7 @@ class NodeRepository { try { await service.health(); return true; - } on DioError { + } on DioException { return false; } } @@ -40,8 +40,8 @@ class NodeRepository { Future 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); } } @@ -57,8 +57,8 @@ class NodeRepository { Future 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); } } @@ -69,8 +69,8 @@ class NodeRepository { Future 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); } } } diff --git a/lib/src/repositories/transaction_repository.dart b/lib/src/repositories/transaction_repository.dart index 7b00404..2b46fa2 100644 --- a/lib/src/repositories/transaction_repository.dart +++ b/lib/src/repositories/transaction_repository.dart @@ -25,8 +25,8 @@ class TransactionRepository { Future 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); } } @@ -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); } } @@ -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); } } @@ -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); } } @@ -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); } } @@ -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); } } @@ -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); } } @@ -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); } } @@ -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( diff --git a/pubspec.lock b/pubspec.lock index e0c8bfa..f3f0efb 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,17 +5,18 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "0c80aeab9bc807ab10022cd3b2f4cf2ecdf231949dc1ddd9442406a003f19201" + sha256: ae92f5d747aee634b87f89d9946000c2de774be1d6ac3e58268224348cd0101a url: "https://pub.dev" source: hosted - version: "52.0.0" + version: "61.0.0" algorand_json: dependency: "direct main" description: - name: algorand_json - sha256: "0c6339e0fdb65ed1089c2ecf5260920361c00f68f4338034d0ae418e37d8adfd" - url: "https://pub.dev" - source: hosted + path: "." + ref: dart3 + resolved-ref: "01df951e65b21defcd892d4be17679c5840268bd" + url: "https://github.com/ArunBabu98/algorand-json" + source: git version: "0.0.2" algorand_msgpack: dependency: "direct main" @@ -29,10 +30,10 @@ packages: dependency: transitive description: name: analyzer - sha256: cd8ee83568a77f3ae6b913a36093a1c9b1264e7cb7f834d9ddd2311dade9c1f4 + sha256: ea3d8652bda62982addfd92fdc2d0214e5f82e43325104990d4f4c4a2a313562 url: "https://pub.dev" source: hosted - version: "5.4.0" + version: "5.13.0" args: dependency: transitive description: @@ -197,18 +198,18 @@ packages: dependency: transitive description: name: dart_style - sha256: "7a03456c3490394c8e7665890333e91ae8a49be43542b616e414449ac358acd4" + sha256: "1efa911ca7086affd35f463ca2fc1799584fb6aa89883cf0af8e3664d6a02d55" url: "https://pub.dev" source: hosted - version: "2.2.4" + version: "2.3.2" dio: dependency: "direct main" description: name: dio - sha256: "7d328c4d898a61efc3cd93655a0955858e29a0aa647f0f9e02d59b3bb275e2e8" + sha256: "417e2a6f9d83ab396ec38ff4ea5da6c254da71e4db765ad737a42af6930140b7" url: "https://pub.dev" source: hosted - version: "4.0.6" + version: "5.3.3" equatable: dependency: "direct main" description: @@ -405,18 +406,18 @@ packages: dependency: "direct main" description: name: retrofit - sha256: "9254ec985d5e26a839a9070ae25b98f0781c9c420e4241c5fb8b8965aa1fc7f2" + sha256: "04ed77c82cadb655bb9357e8d0cb9da72ff704749a2d0cfe6540dd1f1f7ca4b9" url: "https://pub.dev" source: hosted - version: "3.3.1" + version: "4.0.3" retrofit_generator: dependency: "direct dev" description: name: retrofit_generator - sha256: f5107e842e77ce71c63b995331b43d4597f71df9031389dd93a1197a00118d83 + sha256: "9499eb46b3657a62192ddbc208ff7e6c6b768b19e83c1ee6f6b119c864b99690" url: "https://pub.dev" source: hosted - version: "4.2.0" + version: "7.0.8" shelf: dependency: transitive description: @@ -453,10 +454,10 @@ packages: dependency: transitive description: name: source_gen - sha256: "2d79738b6bbf38a43920e2b8d189e9a3ce6cc201f4b8fc76be5e4fe377b1c38d" + sha256: fc0da689e5302edb6177fdd964efcb7f58912f43c28c2047a808f5bfff643d16 url: "https://pub.dev" source: hosted - version: "1.2.6" + version: "1.4.0" source_helper: dependency: transitive description: @@ -618,4 +619,4 @@ packages: source: hosted version: "3.1.1" sdks: - dart: ">=2.19.0 <3.0.0" + dart: ">=3.0.0 <4.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index 72fd1ae..a1dfeee 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,6 +4,7 @@ version: 2.0.0-dev.14 homepage: https://www.algorand.com repository: https://github.com/RootSoft/algorand-dart issue_tracker: https://github.com/RootSoft/algorand-dart/issues +publish_to: none environment: sdk: '>=2.17.0 <3.0.0' @@ -34,13 +35,16 @@ dependencies: collection: ^1.17.0 # HTTP & REST - dio: ^4.0.6 - retrofit: ^3.3.1 + dio: ^5.1.1 + retrofit: ^4.0.3 # Messagepack algorand_msgpack: ^1.0.1 - algorand_json: ^0.0.1 + algorand_json: + git: + url: https://github.com/ArunBabu98/algorand-json + ref: dart3 dev_dependencies: # Testing framework @@ -56,4 +60,4 @@ dev_dependencies: json_serializable: ^6.6.1 # Retrofit - retrofit_generator: ^4.2.0 \ No newline at end of file + retrofit_generator: ^7.0.1+1 \ No newline at end of file diff --git a/test/securus/securus_test.dart b/test/securus/securus_test.dart new file mode 100644 index 0000000..e69de29