diff --git a/lib/core/backup_service.dart b/lib/core/backup_service.dart index 509f7f80d..a4593aceb 100644 --- a/lib/core/backup_service.dart +++ b/lib/core/backup_service.dart @@ -219,7 +219,6 @@ class BackupService { final displayActionListMode = data[PreferencesKey.displayActionListModeKey] as int?; final fiatApiMode = data[PreferencesKey.currentFiatApiModeKey] as int?; final torConnectionMode = data[PreferencesKey.currentTorConnectionModeKey] as int?; - final shouldStartTorOnLaunch = data[PreferencesKey.shouldStartTorOnLaunch] as bool?; final currentPinLength = data[PreferencesKey.currentPinLength] as int?; final currentTheme = data[PreferencesKey.currentTheme] as int?; final exchangeStatus = data[PreferencesKey.exchangeStatusKey] as int?; @@ -295,10 +294,6 @@ class BackupService { if (torConnectionMode != null) await _sharedPreferences.setInt(PreferencesKey.currentTorConnectionModeKey, torConnectionMode); - if (shouldStartTorOnLaunch != null) - await _sharedPreferences.setBool( - PreferencesKey.shouldStartTorOnLaunch, shouldStartTorOnLaunch); - if (autoGenerateSubaddressStatus != null) await _sharedPreferences.setInt( PreferencesKey.autoGenerateSubaddressStatusKey, autoGenerateSubaddressStatus); @@ -495,8 +490,6 @@ class BackupService { _sharedPreferences.getInt(PreferencesKey.currentFiatApiModeKey), PreferencesKey.currentTorConnectionModeKey: _sharedPreferences.getInt(PreferencesKey.currentTorConnectionModeKey), - PreferencesKey.shouldStartTorOnLaunch: - _sharedPreferences.getBool(PreferencesKey.shouldStartTorOnLaunch), PreferencesKey.sortBalanceBy: _sharedPreferences.getInt(PreferencesKey.sortBalanceBy), PreferencesKey.pinNativeTokenAtTop: _sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop), diff --git a/lib/di.dart b/lib/di.dart index 17e26c89e..d489b94ee 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -13,6 +13,7 @@ import 'package:cake_wallet/core/yat_service.dart'; import 'package:cake_wallet/entities/background_tasks.dart'; import 'package:cake_wallet/entities/exchange_api_mode.dart'; import 'package:cake_wallet/entities/parse_address_from_domain.dart'; +import 'package:cake_wallet/view_model/settings/tor_connection.dart'; import 'package:cw_core/receive_page_option.dart'; import 'package:cake_wallet/ethereum/ethereum.dart'; import 'package:cake_wallet/nano/nano.dart'; @@ -730,7 +731,9 @@ Future setup({ torViewModel: getIt.get(), )); - if (DeviceInfo.instance.isMobile && settingsStore.shouldStartTorOnLaunch) { + if (DeviceInfo.instance.isMobile && + (settingsStore.torConnectionMode == TorConnectionMode.enabled || + settingsStore.torConnectionMode == TorConnectionMode.torOnly)) { getIt.get().startTor(); } diff --git a/lib/entities/preferences_key.dart b/lib/entities/preferences_key.dart index daf7beb08..5179bfda4 100644 --- a/lib/entities/preferences_key.dart +++ b/lib/entities/preferences_key.dart @@ -24,7 +24,6 @@ class PreferencesKey { static const walletListOrder = 'wallet_list_order'; static const walletListAscending = 'wallet_list_ascending'; static const currentFiatApiModeKey = 'current_fiat_api_mode'; - static const shouldStartTorOnLaunch = 'start_tor_on_launch'; static const currentTorConnectionModeKey = 'current_tor_connection_mode'; static const failedTotpTokenTrials = 'failed_token_trials'; static const disableExchangeKey = 'disable_exchange'; diff --git a/lib/store/settings_store.dart b/lib/store/settings_store.dart index af459c209..97e9be6d9 100644 --- a/lib/store/settings_store.dart +++ b/lib/store/settings_store.dart @@ -64,7 +64,6 @@ abstract class SettingsStoreBase with Store { required bool initialWalletListAscending, required FiatApiMode initialFiatMode, required TorConnectionMode initialTorConnectionMode, - required bool initialShouldStartTorOnLaunch, required bool initialAllowBiometricalAuthentication, required String initialTotpSecretKey, required bool initialUseTOTP2FA, @@ -126,7 +125,6 @@ abstract class SettingsStoreBase with Store { moneroSeedType = initialMoneroSeedType, fiatApiMode = initialFiatMode, torConnectionMode = initialTorConnectionMode, - shouldStartTorOnLaunch = initialShouldStartTorOnLaunch, allowBiometricalAuthentication = initialAllowBiometricalAuthentication, selectedCake2FAPreset = initialCake2FAPresetOptions, totpSecretKey = initialTotpSecretKey, @@ -325,9 +323,6 @@ abstract class SettingsStoreBase with Store { await sharedPreferences.setInt(PreferencesKey.currentTorConnectionModeKey, mode.serialize()); }); - reaction((_) => shouldStartTorOnLaunch, - (bool value) => sharedPreferences.setBool(PreferencesKey.shouldStartTorOnLaunch, value)); - reaction((_) => currentTheme, (ThemeBase theme) => sharedPreferences.setInt(PreferencesKey.currentTheme, theme.raw)); @@ -550,9 +545,6 @@ abstract class SettingsStoreBase with Store { @observable TorConnectionMode torConnectionMode; - @observable - bool shouldStartTorOnLaunch; - @observable bool shouldSaveRecipientAddress; @@ -805,8 +797,6 @@ abstract class SettingsStoreBase with Store { final currentTorConnectionMode = TorConnectionMode.deserialize( raw: sharedPreferences.getInt(PreferencesKey.currentTorConnectionModeKey) ?? TorConnectionMode.disabled.raw); - final shouldStartTorOnLaunch = - sharedPreferences.getBool(PreferencesKey.shouldStartTorOnLaunch) ?? false; final tokenTrialNumber = sharedPreferences.getInt(PreferencesKey.failedTotpTokenTrials) ?? 0; final shouldShowMarketPlaceInDashboard = sharedPreferences.getBool(PreferencesKey.shouldShowMarketPlaceInDashboard) ?? true; @@ -1049,7 +1039,6 @@ abstract class SettingsStoreBase with Store { initialWalletListAscending: walletListAscending, initialFiatMode: currentFiatApiMode, initialTorConnectionMode: currentTorConnectionMode, - initialShouldStartTorOnLaunch: shouldStartTorOnLaunch, initialAllowBiometricalAuthentication: allowBiometricalAuthentication, initialCake2FAPresetOptions: selectedCake2FAPreset, initialUseTOTP2FA: useTOTP2FA, diff --git a/lib/view_model/settings/privacy_settings_view_model.dart b/lib/view_model/settings/privacy_settings_view_model.dart index b2c6c4d00..65375b3e7 100644 --- a/lib/view_model/settings/privacy_settings_view_model.dart +++ b/lib/view_model/settings/privacy_settings_view_model.dart @@ -83,9 +83,6 @@ abstract class PrivacySettingsViewModelBase with Store { @computed bool get looksUpENS => _settingsStore.lookupsENS; - @computed - bool get shouldStartTorOnLaunch => _settingsStore.shouldStartTorOnLaunch; - bool get canUseEtherscan => _wallet.type == WalletType.ethereum; bool get canUsePolygonScan => _wallet.type == WalletType.polygon; @@ -127,9 +124,6 @@ abstract class PrivacySettingsViewModelBase with Store { @action void setLookupsOpenAlias(bool value) => _settingsStore.lookupsOpenAlias = value; - @action - void setShouldStartTorOnLaunch(bool value) => _settingsStore.shouldStartTorOnLaunch = value; - @action void setUseEtherscan(bool value) { _settingsStore.useEtherscan = value; diff --git a/lib/view_model/settings/tor_view_model.dart b/lib/view_model/settings/tor_view_model.dart index 5fb661305..4282e799d 100644 --- a/lib/view_model/settings/tor_view_model.dart +++ b/lib/view_model/settings/tor_view_model.dart @@ -33,11 +33,6 @@ abstract class TorViewModelBase with Store { final SettingsStore _settingsStore; Tor torInstance = Tor.instance; - @action - Future updateStartOnLaunch(bool value) async { - _settingsStore.shouldStartTorOnLaunch = value; - } - @computed TorConnectionMode get torConnectionMode => _settingsStore.torConnectionMode; @@ -86,8 +81,6 @@ abstract class TorViewModelBase with Store { await torInstance.enable(); - _settingsStore.shouldStartTorOnLaunch = true; - SocksTCPClient.setProxy(proxies: [ ProxySettings( InternetAddress.loopbackIPv4, @@ -108,8 +101,6 @@ abstract class TorViewModelBase with Store { @action Future stopTor() async { torInstance.disable(); - // setting the torConnectionMode to disabled will prevent anything from actually using the proxy - _settingsStore.shouldStartTorOnLaunch = false; torConnectionStatus = TorConnectionStatus.disconnected; SocksTCPClient.removeProxy(); await connectOrDisconnectNodeToProxy(connect: false);