From 517612095ba94f55795ab1a025c44ea510d9a408 Mon Sep 17 00:00:00 2001 From: malik1004x Date: Thu, 20 Aug 2026 23:14:12 +0200 Subject: [PATCH] safeguard calls to coin integration classes (#3534) --- lib/entities/default_settings_migration.dart | 26 ++++++++++++++------ lib/store/settings_store.dart | 14 +++++++---- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/lib/entities/default_settings_migration.dart b/lib/entities/default_settings_migration.dart index ae94b47e1..4696fab40 100644 --- a/lib/entities/default_settings_migration.dart +++ b/lib/entities/default_settings_migration.dart @@ -95,8 +95,12 @@ Future defaultSettingsMigration( case 1: await sharedPreferences.setString( PreferencesKey.currentFiatCurrencyKey, FiatCurrency.usd.toString()); - await sharedPreferences.setInt(PreferencesKey.currentTransactionPriorityKeyLegacy, - monero!.getDefaultTransactionPriority().raw); + + if (monero != null) { + await sharedPreferences.setInt( + PreferencesKey.currentTransactionPriorityKeyLegacy, + monero!.getDefaultTransactionPriority().raw); + } await sharedPreferences.setInt( PreferencesKey.currentBalanceDisplayModeKey, BalanceDisplayMode.availableBalance.raw); await sharedPreferences.setBool('save_recipient_address', true); @@ -791,6 +795,10 @@ Future _backupWowneroSeeds(Box havenSeedStore) async { } Future _updateMoneroPriority(SharedPreferences sharedPreferences) async { + if (monero == null) { + return; + } + final currentPriority = await sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority) ?? monero!.getDefaultTransactionPriority().serialize(); @@ -1071,11 +1079,15 @@ Future generateBackupPassword(SecureStorage secureStorage) async { Future changeTransactionPriorityAndFeeRateKeys(SharedPreferences sharedPreferences) async { final legacyTransactionPriority = - sharedPreferences.getInt(PreferencesKey.currentTransactionPriorityKeyLegacy)!; - await sharedPreferences.setInt( - PreferencesKey.moneroTransactionPriority, legacyTransactionPriority); - await sharedPreferences.setInt(PreferencesKey.bitcoinTransactionPriority, - bitcoin!.getMediumTransactionPriority().serialize()); + sharedPreferences.getInt(PreferencesKey.currentTransactionPriorityKeyLegacy); + if (legacyTransactionPriority != null) { + await sharedPreferences.setInt( + PreferencesKey.moneroTransactionPriority, legacyTransactionPriority); + } + if (bitcoin != null) { + await sharedPreferences.setInt(PreferencesKey.bitcoinTransactionPriority, + bitcoin!.getMediumTransactionPriority().serialize()); + } } Future fixBtcDerivationPaths() async { diff --git a/lib/store/settings_store.dart b/lib/store/settings_store.dart index 95ab5d52c..f699640e7 100644 --- a/lib/store/settings_store.dart +++ b/lib/store/settings_store.dart @@ -1777,12 +1777,16 @@ abstract class SettingsStoreBase with Store { Future reload() async { final sharedPreferences = await getIt.getAsync(); - fiatCurrency = FiatCurrency.deserialize( - raw: sharedPreferences.getString(PreferencesKey.currentFiatCurrencyKey)!); + final savedFiatCurrency = sharedPreferences.getString(PreferencesKey.currentFiatCurrencyKey); + if (savedFiatCurrency != null) { + fiatCurrency = FiatCurrency.deserialize(raw: savedFiatCurrency); + } - priority[WalletType.monero] = monero?.deserializeMoneroTransactionPriority( - raw: sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority)!) ?? - priority[WalletType.monero]!; + if (monero != null && + sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority) != null) { + priority[WalletType.monero] = monero!.deserializeMoneroTransactionPriority( + raw: sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority)!); + } if (wownero != null && sharedPreferences.getInt(PreferencesKey.wowneroTransactionPriority) != null) {