CW-782: Show error report popup without cooldown (#1739)

* improve exception throwing on broken wallets
- put _lastOpenedWallet to avoid issues on windows (file is currently open by)
- don't throw corruptedWalletsSeed - instead store it inside of secureStorage
- await ExceptionHandler.onError calls where possible to makse sure that popup won't be canceled by some UI element
- adjust BaseAlertDialog to be scrollable if the text is too long
- add ExceptionHandler.resetLastPopupDate - that can be called when we want to show error report screen (bypassing cooldown)

* fix: HiveError: Box has already been closed.

* await the alerts to be sure that each one of them is being shown
fix typo in secure storage

* Update lib/core/backup_service.dart

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>

* address comments on github

* don't store seeds in secure storage

* fix wallet password

* update monero_c
update corrupted seeds UI
prevent app from crashing when wallet is corrupted

* show alert with seeds

* Update corrupted wallet UI
Fix wallet opening cache

* remove unused code

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
cyan
2024-11-28 21:28:31 +02:00
committed by GitHub
co-authored by Omar Hatem
parent d8d4190608
commit 17d34beae9
51 changed files with 205 additions and 87 deletions
+21 -2
View File
@@ -1,5 +1,6 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:mobx/mobx.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
@@ -9,6 +10,8 @@ import 'package:cake_wallet/view_model/auth_view_model.dart';
import 'package:cake_wallet/src/screens/pin_code/pin_code.dart';
import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart';
import 'package:cake_wallet/core/execution_state.dart';
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:flutter/services.dart';
typedef OnAuthenticationFinished = void Function(bool, AuthPageState);
@@ -66,7 +69,6 @@ class AuthPagePinCodeStateImpl extends AuthPageState<AuthPage> {
dismissFlushBar(_authBar);
showBar<void>(
context, S.of(context).failed_authentication(state.error));
widget.onAuthenticationFinished(false, this);
});
}
@@ -77,12 +79,12 @@ class AuthPagePinCodeStateImpl extends AuthPageState<AuthPage> {
dismissFlushBar(_authBar);
showBar<void>(
context, S.of(context).failed_authentication(state.error));
widget.onAuthenticationFinished(false, this);
});
}
});
if (widget.authViewModel.isBiometricalAuthenticationAllowed) {
WidgetsBinding.instance.addPostFrameCallback((_) async {
await Future<void>.delayed(Duration(milliseconds: 100));
@@ -93,6 +95,23 @@ class AuthPagePinCodeStateImpl extends AuthPageState<AuthPage> {
super.initState();
}
Future<void> _showSeedsPopup(BuildContext context, String message) async {
await showPopUp<void>(
context: context,
builder: (BuildContext context) {
return AlertWithTwoActions(
alertTitle: "Corrupted seeds",
alertContent: message,
leftButtonText: S.of(context).copy,
rightButtonText: S.of(context).ok,
actionLeftButton: () async {
await Clipboard.setData(ClipboardData(text: message));
},
actionRightButton: () => Navigator.of(context).pop(),
);
});
}
@override
void dispose() {
_reaction?.reaction.dispose();
+1 -1
View File
@@ -154,7 +154,7 @@ class BackupPage extends BasePage {
File returnedFile = File(outputFile!);
await returnedFile.writeAsBytes(backup.content);
} catch (exception, stackTrace) {
ExceptionHandler.onError(FlutterErrorDetails(
await ExceptionHandler.onError(FlutterErrorDetails(
exception: exception,
stack: stackTrace,
library: "Export Backup",
@@ -11,6 +11,7 @@ import 'package:cake_wallet/src/screens/wallet_unlock/wallet_unlock_arguments.da
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/themes/extensions/menu_theme.dart';
import 'package:cake_wallet/utils/exception_handler.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart';
@@ -1,6 +1,7 @@
import 'package:another_flushbar/flushbar.dart';
import 'package:cake_wallet/core/auth_service.dart';
import 'package:cake_wallet/core/new_wallet_arguments.dart';
import 'package:cake_wallet/core/secure_storage.dart';
import 'package:cake_wallet/entities/wallet_edit_page_arguments.dart';
import 'package:cake_wallet/entities/wallet_list_order_types.dart';
import 'package:cake_wallet/generated/i18n.dart';
@@ -20,6 +21,7 @@ import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/themes/extensions/cake_text_theme.dart';
import 'package:cake_wallet/themes/extensions/filter_theme.dart';
import 'package:cake_wallet/themes/extensions/wallet_list_theme.dart';
import 'package:cake_wallet/utils/exception_handler.dart';
import 'package:cake_wallet/utils/responsive_layout_util.dart';
import 'package:cake_wallet/utils/show_bar.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
@@ -459,6 +461,9 @@ class WalletListBodyState extends State<WalletListBody> {
});
}
} catch (e) {
await ExceptionHandler.resetLastPopupDate();
final err = e.toString();
await ExceptionHandler.onError(FlutterErrorDetails(exception: err));
if (this.mounted) {
changeProcessText(S
.of(context)
+16 -9
View File
@@ -73,15 +73,22 @@ class BaseAlertDialog extends StatelessWidget {
}
Widget content(BuildContext context) {
return Text(
contentText,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.normal,
fontFamily: 'Lato',
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
decoration: TextDecoration.none,
return SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Text(
contentText,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.normal,
fontFamily: 'Lato',
color: Theme.of(context).extension<CakeTextTheme>()!.titleColor,
decoration: TextDecoration.none,
),
),
],
),
);
}