safeguard calls to coin integration classes (#3534)

malik1004x committed Aug 20, 2026 at 23:14 UTC 517612095ba94f55795ab1a025c44ea510d9a408
2 files changed +28 -12
lib/entities/default_settings_migration.dart
+19 -7
@@ -95,8 +95,12 @@ Future<void> defaultSettingsMigration(
95 case 1:
96 await sharedPreferences.setString(
97 PreferencesKey.currentFiatCurrencyKey, FiatCurrency.usd.toString());
98 - await sharedPreferences.setInt(PreferencesKey.currentTransactionPriorityKeyLegacy,
99 - monero!.getDefaultTransactionPriority().raw);
98 +
99 + if (monero != null) {
100 + await sharedPreferences.setInt(
101 + PreferencesKey.currentTransactionPriorityKeyLegacy,
102 + monero!.getDefaultTransactionPriority().raw);
103 + }
104 await sharedPreferences.setInt(
105 PreferencesKey.currentBalanceDisplayModeKey, BalanceDisplayMode.availableBalance.raw);
106 await sharedPreferences.setBool('save_recipient_address', true);
@@ -791,6 +795,10 @@ Future<void> _backupWowneroSeeds(Box<HavenSeedStore> havenSeedStore) async {
795 }
796
797 Future<void> _updateMoneroPriority(SharedPreferences sharedPreferences) async {
798 + if (monero == null) {
799 + return;
800 + }
801 +
802 final currentPriority =
803 await sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority) ??
804 monero!.getDefaultTransactionPriority().serialize();
@@ -1071,11 +1079,15 @@ Future<void> generateBackupPassword(SecureStorage secureStorage) async {
1079
1080 Future<void> changeTransactionPriorityAndFeeRateKeys(SharedPreferences sharedPreferences) async {
1081 final legacyTransactionPriority =
1074 - sharedPreferences.getInt(PreferencesKey.currentTransactionPriorityKeyLegacy)!;
1075 - await sharedPreferences.setInt(
1076 - PreferencesKey.moneroTransactionPriority, legacyTransactionPriority);
1077 - await sharedPreferences.setInt(PreferencesKey.bitcoinTransactionPriority,
1078 - bitcoin!.getMediumTransactionPriority().serialize());
1082 + sharedPreferences.getInt(PreferencesKey.currentTransactionPriorityKeyLegacy);
1083 + if (legacyTransactionPriority != null) {
1084 + await sharedPreferences.setInt(
1085 + PreferencesKey.moneroTransactionPriority, legacyTransactionPriority);
1086 + }
1087 + if (bitcoin != null) {
1088 + await sharedPreferences.setInt(PreferencesKey.bitcoinTransactionPriority,
1089 + bitcoin!.getMediumTransactionPriority().serialize());
1090 + }
1091 }
1092
1093 Future<void> fixBtcDerivationPaths() async {
lib/store/settings_store.dart
+9 -5
@@ -1777,12 +1777,16 @@ abstract class SettingsStoreBase with Store {
1777 Future<void> reload() async {
1778 final sharedPreferences = await getIt.getAsync<SharedPreferences>();
1779
1780 - fiatCurrency = FiatCurrency.deserialize(
1781 - raw: sharedPreferences.getString(PreferencesKey.currentFiatCurrencyKey)!);
1780 + final savedFiatCurrency = sharedPreferences.getString(PreferencesKey.currentFiatCurrencyKey);
1781 + if (savedFiatCurrency != null) {
1782 + fiatCurrency = FiatCurrency.deserialize(raw: savedFiatCurrency);
1783 + }
1784
1783 - priority[WalletType.monero] = monero?.deserializeMoneroTransactionPriority(
1784 - raw: sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority)!) ??
1785 - priority[WalletType.monero]!;
1785 + if (monero != null &&
1786 + sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority) != null) {
1787 + priority[WalletType.monero] = monero!.deserializeMoneroTransactionPriority(
1788 + raw: sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority)!);
1789 + }
1790
1791 if (wownero != null &&
1792 sharedPreferences.getInt(PreferencesKey.wowneroTransactionPriority) != null) {