From 0125d88bb914d26b72105c85b8b7ac7e1b17a1fd Mon Sep 17 00:00:00 2001 From: NIK Date: Thu, 7 Sep 2023 20:23:20 +0800 Subject: [PATCH 1/6] remove throw error --- lib/core/logging/log_helper.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/core/logging/log_helper.dart b/lib/core/logging/log_helper.dart index c6f954b6..865588ea 100644 --- a/lib/core/logging/log_helper.dart +++ b/lib/core/logging/log_helper.dart @@ -1,6 +1,5 @@ import 'package:fimber/fimber.dart'; import 'package:firebase_crashlytics/firebase_crashlytics.dart'; -import 'package:flutter/foundation.dart'; const kLogQuietMode = false; const kIsDebugNetworking = true; @@ -36,6 +35,8 @@ class LogHelper { static void e(String message, {dynamic error, StackTrace? stacktrace}) { Fimber.e(message, ex: error, stacktrace: stacktrace); FirebaseCrashlytics.instance.log('Error message $message \nStackTrace: $stacktrace'); - if (error != null && kDebugMode) throw error; + // Nik: I commented out below. A log should never throw an error! + // It should log things. Not throw errors. + // if (error != null && kDebugMode) throw error; } } From 424deed6361039d8a0d165f5b750aff65ff6a44d Mon Sep 17 00:00:00 2001 From: NIK Date: Thu, 7 Sep 2023 20:23:28 +0800 Subject: [PATCH 2/6] update endpoints --- lib/core/network/api/services/remote_config_service.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/core/network/api/services/remote_config_service.dart b/lib/core/network/api/services/remote_config_service.dart index 2bb356cb..24874910 100644 --- a/lib/core/network/api/services/remote_config_service.dart +++ b/lib/core/network/api/services/remote_config_service.dart @@ -161,8 +161,8 @@ class RemoteConfigService { }, "eosTestnet": { "name": "Jungle4 Testnet", - "endpoint": "https://jungle4.dfuse.eosnation.io", - "fastEndpoint": "https://jungle4.dfuse.eosnation.io", + "endpoint": "http://jungle.eosusa.io/", + "fastEndpoint": "http://jungle.eosusa.io/", "loginContract": "logintohypha", "loginAction": "loginuser", "logoutAction": "logoutuser", @@ -207,6 +207,7 @@ class RemoteConfigService { 'walletEnabled': false, }); FirebaseRemoteConfig.instance.onConfigUpdated.listen((event) async { + // Side note: This does not seem to work reliably on simulator but it works in the app. await FirebaseRemoteConfig.instance.activate(); }); } From 5985f7009bd9154f902796194f54f5f6ac1109a7 Mon Sep 17 00:00:00 2001 From: NIK Date: Thu, 7 Sep 2023 20:24:11 +0800 Subject: [PATCH 3/6] changed from e level to w these can happen on any network error and also happen at 404 - not found - that's not an error, just means no profile exists for the account --- lib/core/network/repository/profile_repository.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/core/network/repository/profile_repository.dart b/lib/core/network/repository/profile_repository.dart index 19d8d65f..b784abb1 100644 --- a/lib/core/network/repository/profile_repository.dart +++ b/lib/core/network/repository/profile_repository.dart @@ -22,12 +22,13 @@ class ProfileService { final map = Map.from(response.data); return Result.value(ProfileData.fromJson(map, user.network, [])); } else { - LogHelper.e('get profile status error', stacktrace: StackTrace.current); + LogHelper.i('get profile status error'); return Result.error(HyphaError(type: HyphaErrorType.api, message: 'server error ${response.statusMessage}')); } } catch (error, stackTrace) { // note: 500 status on get throws an error - LogHelper.e('get profile error', stacktrace: stackTrace, error: error); + // this happens when the profile doesn't exist, which is valid + LogHelper.i('get profile error', stacktrace: stackTrace, error: error); return Result.error(HyphaError(type: HyphaErrorType.api, message: 'server error $error')); } } From ca64e87f60ab3f238b753fd5e026d987a8562c3e Mon Sep 17 00:00:00 2001 From: NIK Date: Thu, 7 Sep 2023 20:24:29 +0800 Subject: [PATCH 4/6] dart update is smarter now --- lib/core/network/repository/transaction_history_repository.dart | 1 - lib/ui/home_page/components/scanner_widget.dart | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/core/network/repository/transaction_history_repository.dart b/lib/core/network/repository/transaction_history_repository.dart index 83585ef0..bcae1430 100644 --- a/lib/core/network/repository/transaction_history_repository.dart +++ b/lib/core/network/repository/transaction_history_repository.dart @@ -3,7 +3,6 @@ import 'package:hypha_wallet/core/error_handler/model/hypha_error.dart'; import 'package:hypha_wallet/core/logging/log_helper.dart'; import 'package:hypha_wallet/core/network/api/services/transaction_history_service.dart'; import 'package:hypha_wallet/core/network/dio_exception.dart'; -import 'package:hypha_wallet/core/network/models/network.dart'; import 'package:hypha_wallet/core/network/models/transaction_model.dart'; import 'package:hypha_wallet/core/network/models/user_profile_data.dart'; import 'package:hypha_wallet/ui/architecture/result/result.dart'; diff --git a/lib/ui/home_page/components/scanner_widget.dart b/lib/ui/home_page/components/scanner_widget.dart index 77d19c7a..0d532189 100644 --- a/lib/ui/home_page/components/scanner_widget.dart +++ b/lib/ui/home_page/components/scanner_widget.dart @@ -99,7 +99,7 @@ class _ScannerWidgetState extends State { ), ); } else { - final String code = barcodes.first!.rawValue!; + final String code = barcodes.first.rawValue!; LogHelper.d('Barcode found! $code'); hideScanner(); context.read().add(HomeEvent.onQRCodeScanned(code)); From 23092e51c7190cb6bb2a7e6a14927706765c69c6 Mon Sep 17 00:00:00 2001 From: NIK Date: Thu, 7 Sep 2023 20:24:45 +0800 Subject: [PATCH 5/6] better api for import account --- lib/core/crypto/eosdart/src/client.dart | 13 ++++++++----- .../usecases/find_account_use_case.dart | 8 ++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/core/crypto/eosdart/src/client.dart b/lib/core/crypto/eosdart/src/client.dart index 4e80e4a1..a0799543 100644 --- a/lib/core/crypto/eosdart/src/client.dart +++ b/lib/core/crypto/eosdart/src/client.dart @@ -203,12 +203,15 @@ class EOSClient extends NetworkingManager { }); } - /// Get Key Accounts - Future> getKeyAccounts(String pubKey) async { + /// Get accounts by key - uses /chain/get_accounts_by_authorizers + Future> getAccountsByKey(String pubKey) async { try { - return Result.capture( - _post('/history/get_key_accounts', {'public_key': pubKey}).then((dio.Response accountNames) { - return AccountNames.fromJson(accountNames.data as Map); + return Result.capture(_post('/chain/get_accounts_by_authorizers', { + 'accounts': [], + 'keys': [pubKey] + }).then((dio.Response response) { + final List accountNames = List.from(response.data['accounts'].map((e) => e['account_name'])); + return AccountNames(accountNames.toSet().toList()); })); } catch (e) { LogHelper.e(e.toString()); diff --git a/lib/ui/onboarding/import_account/usecases/find_account_use_case.dart b/lib/ui/onboarding/import_account/usecases/find_account_use_case.dart index 76be44bb..c65836eb 100644 --- a/lib/ui/onboarding/import_account/usecases/find_account_use_case.dart +++ b/lib/ui/onboarding/import_account/usecases/find_account_use_case.dart @@ -40,10 +40,10 @@ class FindAccountsUseCase extends InputUseCase, ); final results = await Future.wait([ - eosClient.getKeyAccounts(input), - telosClient.getKeyAccounts(input), - telosTestnetClient.getKeyAccounts(input), - eosTestnetClient.getKeyAccounts(input) + eosClient.getAccountsByKey(input), + telosClient.getAccountsByKey(input), + telosTestnetClient.getAccountsByKey(input), + eosTestnetClient.getAccountsByKey(input) ]); final eosResult = results[0]; final telosResult = results[1]; From 30abed2edc0666b6ca37ae48b852d5d68d9cedbc Mon Sep 17 00:00:00 2001 From: NIK Date: Thu, 7 Sep 2023 23:50:51 +0800 Subject: [PATCH 6/6] pass status message --- lib/core/network/repository/profile_repository.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/network/repository/profile_repository.dart b/lib/core/network/repository/profile_repository.dart index b784abb1..b3594d13 100644 --- a/lib/core/network/repository/profile_repository.dart +++ b/lib/core/network/repository/profile_repository.dart @@ -22,7 +22,7 @@ class ProfileService { final map = Map.from(response.data); return Result.value(ProfileData.fromJson(map, user.network, [])); } else { - LogHelper.i('get profile status error'); + LogHelper.i('get profile error status code: ${response.statusMessage}'); return Result.error(HyphaError(type: HyphaErrorType.api, message: 'server error ${response.statusMessage}')); } } catch (error, stackTrace) {