From 85263a937ed23a711305973c9417cc0ec9837d20 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Tue, 19 Nov 2024 09:09:24 -0500 Subject: [PATCH 1/3] fix: Error when loading application after deleting wallet (closes #8) --- lib/coins/abstract.dart | 2 ++ lib/coins/monero/coin.dart | 3 +++ lib/views/home_screen.dart | 1 + 3 files changed, 6 insertions(+) diff --git a/lib/coins/abstract.dart b/lib/coins/abstract.dart index d9c5866..0305ad5 100644 --- a/lib/coins/abstract.dart +++ b/lib/coins/abstract.dart @@ -61,6 +61,8 @@ abstract class CoinWalletInfo { Future checkWalletPassword(String password); + bool exists(); + Future openWallet(BuildContext context, {required String password}); diff --git a/lib/coins/monero/coin.dart b/lib/coins/monero/coin.dart index bee3653..b7d43aa 100644 --- a/lib/coins/monero/coin.dart +++ b/lib/coins/monero/coin.dart @@ -400,4 +400,7 @@ class MoneroWalletInfo extends CoinWalletInfo { File("$walletName.keys").rename(p.join(basePath, "$newName.keys")); _walletName = newName; } + + @override + bool exists() => File("$walletName.keys").existsSync(); } diff --git a/lib/views/home_screen.dart b/lib/views/home_screen.dart index 193837a..5db331b 100644 --- a/lib/views/home_screen.dart +++ b/lib/views/home_screen.dart @@ -161,6 +161,7 @@ class HomeScreen extends AbstractView { if (config.lastWallet == null) return; if (!context.mounted) return; if (!viewModel.openLastWallet) return; + if (config.lastWallet?.exists() != true) return; config.lastWallet!.openUI(context); } } From ac7133a8f925424679457b8844394b3115b203a2 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Tue, 19 Nov 2024 09:22:33 -0500 Subject: [PATCH 2/3] fix: Password screen disappears (closes #9) --- lib/view_model/create_wallet_view_model.dart | 2 +- lib/view_model/open_wallet_view_model.dart | 4 ++++ lib/view_model/security_backup_view_model.dart | 7 +++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/view_model/create_wallet_view_model.dart b/lib/view_model/create_wallet_view_model.dart index ffe9ee3..465418e 100644 --- a/lib/view_model/create_wallet_view_model.dart +++ b/lib/view_model/create_wallet_view_model.dart @@ -512,8 +512,8 @@ class PinFormElement extends FormElement { Future Function(BuildContext context)? onChanged; Future Function(BuildContext context)? onConfirm; Future onConfirmInternal(BuildContext context) async { - isConfirmed = true; await valueOutcome.encode(ctrl.text); + isConfirmed = true; } bool isConfirmed = false; diff --git a/lib/view_model/open_wallet_view_model.dart b/lib/view_model/open_wallet_view_model.dart index 0850423..691312e 100644 --- a/lib/view_model/open_wallet_view_model.dart +++ b/lib/view_model/open_wallet_view_model.dart @@ -50,7 +50,11 @@ class OpenWalletViewModel extends ViewModel { } Future checkWalletPassword() async { + try { return coinInfo.checkWalletPassword(await walletPassword.value); + } catch (e) { + return false; + } } Future openWalletIfPasswordCorrect(BuildContext context) async { diff --git a/lib/view_model/security_backup_view_model.dart b/lib/view_model/security_backup_view_model.dart index 2f0d566..4d503f0 100644 --- a/lib/view_model/security_backup_view_model.dart +++ b/lib/view_model/security_backup_view_model.dart @@ -31,8 +31,11 @@ class SecurityBackupViewModel extends ViewModel { }, showNumboard: true, onConfirm: (BuildContext context) async { - await form.first.value; - + try { + await form.first.value; + } catch (e) { + print(e); + } isLocked = false; markNeedsBuild(); }) From 8475a7d622e6534592425767d4a3b4b67d4b5bab Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Tue, 19 Nov 2024 09:23:39 -0500 Subject: [PATCH 3/3] format code --- lib/coins/monero/coin.dart | 2 +- lib/view_model/open_wallet_view_model.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/coins/monero/coin.dart b/lib/coins/monero/coin.dart index b7d43aa..0f4c112 100644 --- a/lib/coins/monero/coin.dart +++ b/lib/coins/monero/coin.dart @@ -400,7 +400,7 @@ class MoneroWalletInfo extends CoinWalletInfo { File("$walletName.keys").rename(p.join(basePath, "$newName.keys")); _walletName = newName; } - + @override bool exists() => File("$walletName.keys").existsSync(); } diff --git a/lib/view_model/open_wallet_view_model.dart b/lib/view_model/open_wallet_view_model.dart index 691312e..da3efdc 100644 --- a/lib/view_model/open_wallet_view_model.dart +++ b/lib/view_model/open_wallet_view_model.dart @@ -51,7 +51,7 @@ class OpenWalletViewModel extends ViewModel { Future checkWalletPassword() async { try { - return coinInfo.checkWalletPassword(await walletPassword.value); + return coinInfo.checkWalletPassword(await walletPassword.value); } catch (e) { return false; }