Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update account import #250

Merged
merged 6 commits into from
Sep 7, 2023
Merged
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
13 changes: 8 additions & 5 deletions lib/core/crypto/eosdart/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,15 @@ class EOSClient extends NetworkingManager {
});
}

/// Get Key Accounts
Future<Result<AccountNames>> getKeyAccounts(String pubKey) async {
/// Get accounts by key - uses /chain/get_accounts_by_authorizers
Future<Result<AccountNames>> 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<String, dynamic>);
return Result.capture(_post('/chain/get_accounts_by_authorizers', {
'accounts': [],
'keys': [pubKey]
}).then((dio.Response response) {
final List<String> accountNames = List.from(response.data['accounts'].map((e) => e['account_name']));
return AccountNames(accountNames.toSet().toList());
}));
} catch (e) {
LogHelper.e(e.toString());
Expand Down
5 changes: 3 additions & 2 deletions lib/core/logging/log_helper.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}
}
5 changes: 3 additions & 2 deletions lib/core/network/api/services/remote_config_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be changing these endpoints in firebase and not locally?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was changing them in firebase, but the local app doesn't update for whatever reason.

The mobile phones were updating correctly

"fastEndpoint": "http://jungle.eosusa.io/",
"loginContract": "logintohypha",
"loginAction": "loginuser",
"logoutAction": "logoutuser",
Expand Down Expand Up @@ -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();
});
}
Expand Down
5 changes: 3 additions & 2 deletions lib/core/network/repository/profile_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ class ProfileService {
final map = Map<String, dynamic>.from(response.data);
return Result.value(ProfileData.fromJson(map, user.network, []));
} else {
LogHelper.e('get profile status error', stacktrace: StackTrace.current);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't happen - a 404 ends in the catch block of this try/catch because dio throws

LogHelper.i('get profile error status code: ${response.statusMessage}');
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'));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/home_page/components/scanner_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class _ScannerWidgetState extends State<ScannerWidget> {
),
);
} else {
final String code = barcodes.first!.rawValue!;
final String code = barcodes.first.rawValue!;
LogHelper.d('Barcode found! $code');
hideScanner();
context.read<HomeBloc>().add(HomeEvent.onQRCodeScanned(code));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class FindAccountsUseCase extends InputUseCase<Result<Iterable<UserProfileData>,
);

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];
Expand Down