From c4698576a3fc8c2d1da51ebdb82267e456b9d014 Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Wed, 13 Nov 2024 01:19:50 +0200 Subject: [PATCH 1/3] add xmr to unstoppable domain (#1800) --- lib/entities/parse_address_from_domain.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/entities/parse_address_from_domain.dart b/lib/entities/parse_address_from_domain.dart index 481db5620..11ba4724c 100644 --- a/lib/entities/parse_address_from_domain.dart +++ b/lib/entities/parse_address_from_domain.dart @@ -41,7 +41,8 @@ class AddressResolver { 'kresus', 'anime', 'manga', - 'binanceus' + 'binanceus', + 'xmr', ]; static String? extractAddressByType({required String raw, required CryptoCurrency type}) { From 0adb69d095a80526c02101877b2141ac20e133ab Mon Sep 17 00:00:00 2001 From: Konstantin Ullrich Date: Wed, 13 Nov 2024 10:44:43 +0100 Subject: [PATCH 2/3] Better Ledger Connection handling (#1802) --- cw_monero/lib/ledger.dart | 6 +----- cw_monero/lib/monero_wallet_service.dart | 5 +++++ lib/monero/cw_monero.dart | 4 ++++ lib/view_model/hardware_wallet/ledger_view_model.dart | 4 +++- tool/configure.dart | 1 + 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cw_monero/lib/ledger.dart b/cw_monero/lib/ledger.dart index 074975df3..c947d0944 100644 --- a/cw_monero/lib/ledger.dart +++ b/cw_monero/lib/ledger.dart @@ -47,10 +47,6 @@ void enableLedgerExchange(monero.wallet ptr, LedgerConnection connection) { void keepAlive(LedgerConnection connection) { if (connection.connectionType == ConnectionType.ble) { - UniversalBle.onConnectionChange = (String deviceId, bool isConnected) { - print("[Monero] Ledger Disconnected"); - _ledgerKeepAlive?.cancel(); - }; _ledgerKeepAlive = Timer.periodic(Duration(seconds: 10), (_) async { try { UniversalBle.setNotifiable( @@ -59,7 +55,7 @@ void keepAlive(LedgerConnection connection) { connection.device.deviceInfo.notifyCharacteristicKey, BleInputProperty.notification, ); - } catch (_){} + } catch (_) {} }); } } diff --git a/cw_monero/lib/monero_wallet_service.dart b/cw_monero/lib/monero_wallet_service.dart index b2089dfc7..6f49640be 100644 --- a/cw_monero/lib/monero_wallet_service.dart +++ b/cw_monero/lib/monero_wallet_service.dart @@ -146,6 +146,11 @@ class MoneroWalletService extends WalletService< password: password); final isValid = wallet.walletAddresses.validate(); + if (wallet.isHardwareWallet) { + wallet.setLedgerConnection(gLedger!); + gLedger = null; + } + if (!isValid) { await restoreOrResetWalletFiles(name); wallet.close(shouldCleanup: false); diff --git a/lib/monero/cw_monero.dart b/lib/monero/cw_monero.dart index 09d9889c5..89b1579fc 100644 --- a/lib/monero/cw_monero.dart +++ b/lib/monero/cw_monero.dart @@ -402,6 +402,10 @@ class CWMonero extends Monero { moneroWallet.setLedgerConnection(connection); } + void resetLedgerConnection() { + disableLedgerExchange(); + } + @override void setGlobalLedgerConnection(ledger.LedgerConnection connection) { gLedger = connection; diff --git a/lib/view_model/hardware_wallet/ledger_view_model.dart b/lib/view_model/hardware_wallet/ledger_view_model.dart index 96f5930c0..3cd131efa 100644 --- a/lib/view_model/hardware_wallet/ledger_view_model.dart +++ b/lib/view_model/hardware_wallet/ledger_view_model.dart @@ -98,7 +98,9 @@ abstract class LedgerViewModelBase with Store { print('Ledger Device State Changed: $event'); if (event == sdk.BleConnectionState.disconnected) { _connection = null; - _connectionChangeListener?.cancel(); + if (type == WalletType.monero) { + monero!.resetLedgerConnection(); + } } }); } diff --git a/tool/configure.dart b/tool/configure.dart index fb8291385..f0f79cfb1 100644 --- a/tool/configure.dart +++ b/tool/configure.dart @@ -415,6 +415,7 @@ abstract class Monero { WalletService createMoneroWalletService(Box walletInfoSource, Box unspentCoinSource); Map pendingTransactionInfo(Object transaction); void setLedgerConnection(Object wallet, ledger.LedgerConnection connection); + void resetLedgerConnection(); void setGlobalLedgerConnection(ledger.LedgerConnection connection); } From ed5e701d801cd88d4905a06a6f9e2b3aa6dca510 Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Wed, 13 Nov 2024 11:55:46 +0200 Subject: [PATCH 3/3] Potential fix for the race condition of loading a wallet while the name in the shared prefs hasn't updated yet (#1801) --- lib/reactions/on_current_wallet_change.dart | 7 ------- lib/store/app_store.dart | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/reactions/on_current_wallet_change.dart b/lib/reactions/on_current_wallet_change.dart index 6630f1dfc..d7e6f90c0 100644 --- a/lib/reactions/on_current_wallet_change.dart +++ b/lib/reactions/on_current_wallet_change.dart @@ -10,9 +10,6 @@ import 'package:cw_core/transaction_history.dart'; import 'package:cw_core/balance.dart'; import 'package:cw_core/transaction_info.dart'; import 'package:mobx/mobx.dart'; -import 'package:shared_preferences/shared_preferences.dart'; -import 'package:cake_wallet/di.dart'; -import 'package:cake_wallet/entities/preferences_key.dart'; import 'package:cake_wallet/reactions/check_connection.dart'; import 'package:cake_wallet/reactions/on_wallet_sync_status_change.dart'; import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart'; @@ -65,10 +62,6 @@ void startCurrentWalletChangeReaction( startWalletSyncStatusChangeReaction(wallet, fiatConversionStore); startCheckConnectionReaction(wallet, settingsStore); - await getIt.get().setString(PreferencesKey.currentWalletName, wallet.name); - await getIt - .get() - .setInt(PreferencesKey.currentWalletType, serializeToInt(wallet.type)); if (wallet.type == WalletType.monero || wallet.type == WalletType.wownero || diff --git a/lib/store/app_store.dart b/lib/store/app_store.dart index cd8881633..24d5dc6a4 100644 --- a/lib/store/app_store.dart +++ b/lib/store/app_store.dart @@ -1,8 +1,10 @@ import 'package:cake_wallet/core/wallet_connect/web3wallet_service.dart'; import 'package:cake_wallet/di.dart'; +import 'package:cake_wallet/entities/preferences_key.dart'; import 'package:cake_wallet/reactions/wallet_connect.dart'; import 'package:cake_wallet/utils/exception_handler.dart'; import 'package:cw_core/transaction_info.dart'; +import 'package:cw_core/wallet_type.dart'; import 'package:mobx/mobx.dart'; import 'package:cw_core/balance.dart'; import 'package:cw_core/wallet_base.dart'; @@ -11,6 +13,7 @@ import 'package:cake_wallet/store/wallet_list_store.dart'; import 'package:cake_wallet/store/authentication_store.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/store/node_list_store.dart'; +import 'package:shared_preferences/shared_preferences.dart'; part 'app_store.g.dart'; @@ -47,5 +50,9 @@ abstract class AppStoreBase with Store { getIt.get().create(); await getIt.get().init(); } + await getIt.get().setString(PreferencesKey.currentWalletName, wallet.name); + await getIt + .get() + .setInt(PreferencesKey.currentWalletType, serializeToInt(wallet.type)); } }