mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-29 04:49:51 +00:00
CW-949 backup error messages (#2059)
* [skip-ci] minor * dont initialize with restore button enabled + error handling updates
This commit is contained in:
parent
c2996ac303
commit
6cc9f4f757
2 changed files with 26 additions and 8 deletions
|
@ -13,8 +13,7 @@ import 'package:cake_wallet/store/authentication_store.dart';
|
||||||
|
|
||||||
part 'restore_from_backup_view_model.g.dart';
|
part 'restore_from_backup_view_model.g.dart';
|
||||||
|
|
||||||
class RestoreFromBackupViewModel = RestoreFromBackupViewModelBase
|
class RestoreFromBackupViewModel = RestoreFromBackupViewModelBase with _$RestoreFromBackupViewModel;
|
||||||
with _$RestoreFromBackupViewModel;
|
|
||||||
|
|
||||||
abstract class RestoreFromBackupViewModelBase with Store {
|
abstract class RestoreFromBackupViewModelBase with Store {
|
||||||
RestoreFromBackupViewModelBase(this.backupService)
|
RestoreFromBackupViewModelBase(this.backupService)
|
||||||
|
@ -45,8 +44,14 @@ abstract class RestoreFromBackupViewModelBase with Store {
|
||||||
final file = File(filePath);
|
final file = File(filePath);
|
||||||
final data = await file.readAsBytes();
|
final data = await file.readAsBytes();
|
||||||
|
|
||||||
|
|
||||||
await backupService.importBackup(data, password);
|
await backupService.importBackup(data, password);
|
||||||
|
|
||||||
|
try {
|
||||||
await initializeAppAtRoot(reInitializing: true);
|
await initializeAppAtRoot(reInitializing: true);
|
||||||
|
} catch (e, s) {
|
||||||
|
throw Exception('failed_app_initialization: $e $s');
|
||||||
|
}
|
||||||
|
|
||||||
final store = getIt.get<AppStore>();
|
final store = getIt.get<AppStore>();
|
||||||
ReactionDisposer? reaction;
|
ReactionDisposer? reaction;
|
||||||
|
@ -63,11 +68,25 @@ abstract class RestoreFromBackupViewModelBase with Store {
|
||||||
|
|
||||||
state = ExecutedSuccessfullyState();
|
state = ExecutedSuccessfullyState();
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
var msg = e.toString();
|
var msg = e.toString().toLowerCase();
|
||||||
|
|
||||||
if (msg.toLowerCase().contains("message authentication code (mac)")) {
|
// can't use a switch here because of .contains() / not an exact match
|
||||||
|
bool shouldBeMadeAware = false;
|
||||||
|
if (msg.contains("message authentication code (mac)")) {
|
||||||
msg = 'Incorrect backup password';
|
msg = 'Incorrect backup password';
|
||||||
|
} else if (msg.contains("faileddecryption")) {
|
||||||
|
msg = 'Failed to decrypt backup file, please check you entered the right password';
|
||||||
|
} else if (msg.contains("failed_to_decode")) {
|
||||||
|
msg = 'Failed to decode backup file, please try again';
|
||||||
|
shouldBeMadeAware = true;
|
||||||
|
} else if (msg.contains("failed_app_initialization")) {
|
||||||
|
msg = 'Failed to initialize app, please try again';
|
||||||
|
shouldBeMadeAware = true;
|
||||||
} else {
|
} else {
|
||||||
|
shouldBeMadeAware = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldBeMadeAware) {
|
||||||
await ExceptionHandler.onError(FlutterErrorDetails(
|
await ExceptionHandler.onError(FlutterErrorDetails(
|
||||||
exception: e,
|
exception: e,
|
||||||
stack: s,
|
stack: s,
|
||||||
|
|
|
@ -67,7 +67,6 @@ abstract class WalletRestoreViewModelBase extends WalletCreationVM with Store {
|
||||||
availableModes = [WalletRestoreMode.seed];
|
availableModes = [WalletRestoreMode.seed];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
isButtonEnabled = !hasSeedLanguageSelector && !hasBlockchainHeightLanguageSelector;
|
|
||||||
walletCreationService.changeWalletType(type: type);
|
walletCreationService.changeWalletType(type: type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue