review fixes

This commit is contained in:
fosse 2024-01-17 20:37:10 -05:00
parent e2413be087
commit 3ae3753e22
16 changed files with 54 additions and 92 deletions

View file

@ -4,19 +4,19 @@ import 'package:cake_wallet/anonpay/anonpay_invoice_info.dart';
import 'package:cake_wallet/anonpay/anonpay_request.dart'; import 'package:cake_wallet/anonpay/anonpay_request.dart';
import 'package:cake_wallet/anonpay/anonpay_status_response.dart'; import 'package:cake_wallet/anonpay/anonpay_status_response.dart';
import 'package:cake_wallet/core/fiat_conversion_service.dart'; import 'package:cake_wallet/core/fiat_conversion_service.dart';
import 'package:cake_wallet/di.dart';
import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/entities/fiat_currency.dart';
import 'package:cake_wallet/exchange/limits.dart'; import 'package:cake_wallet/exchange/limits.dart';
import 'package:cake_wallet/utils/proxy_wrapper.dart';
import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_base.dart';
import 'package:http/http.dart'; import 'package:flutter/foundation.dart';
import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/crypto_currency.dart';
import 'package:cake_wallet/.secrets.g.dart' as secrets; import 'package:cake_wallet/.secrets.g.dart' as secrets;
class AnonPayApi { class AnonPayApi {
const AnonPayApi({ const AnonPayApi({
this.useTorOnly = false,
required this.wallet, required this.wallet,
}); });
final bool useTorOnly;
final WalletBase wallet; final WalletBase wallet;
static const anonpayRef = secrets.anonPayReferralCode; static const anonpayRef = secrets.anonPayReferralCode;
@ -29,9 +29,9 @@ class AnonPayApi {
static const apiKey = secrets.trocadorApiKey; static const apiKey = secrets.trocadorApiKey;
Future<AnonpayStatusResponse> paymentStatus(String id) async { Future<AnonpayStatusResponse> paymentStatus(String id) async {
final authority = await _getAuthority(); final response = await proxyGet("$anonPayStatus/$id", {});
final response = await get(Uri.https(authority, "$anonPayStatus/$id")); final responseBody = await utf8.decodeStream(response);
final responseJSON = json.decode(response.body) as Map<String, dynamic>; final responseJSON = json.decode(responseBody) as Map<String, dynamic>;
final status = responseJSON['Status'] as String; final status = responseJSON['Status'] as String;
final fiatAmount = responseJSON['Fiat_Amount'] as double?; final fiatAmount = responseJSON['Fiat_Amount'] as double?;
final fiatEquiv = responseJSON['Fiat_Equiv'] as String?; final fiatEquiv = responseJSON['Fiat_Equiv'] as String?;
@ -69,11 +69,10 @@ class AnonPayApi {
if (request.fiatEquivalent != null) { if (request.fiatEquivalent != null) {
body['fiat_equiv'] = request.fiatEquivalent; body['fiat_equiv'] = request.fiatEquivalent;
} }
final authority = await _getAuthority();
final response = await get(Uri.https(authority, anonPayPath, body)); final response = await proxyGet(anonPayPath, body);
final responseBody = await utf8.decodeStream(response);
final responseJSON = json.decode(response.body) as Map<String, dynamic>; final responseJSON = json.decode(responseBody) as Map<String, dynamic>;
final id = responseJSON['ID'] as String; final id = responseJSON['ID'] as String;
final url = responseJSON['url'] as String; final url = responseJSON['url'] as String;
final urlOnion = responseJSON['url_onion'] as String; final urlOnion = responseJSON['url_onion'] as String;
@ -136,8 +135,6 @@ class AnonPayApi {
fiatRate = await FiatConversionService.fetchPrice( fiatRate = await FiatConversionService.fetchPrice(
crypto: cryptoCurrency, crypto: cryptoCurrency,
fiat: fiatCurrency, fiat: fiatCurrency,
torOnly: useTorOnly,
onionOnly: false,// TODO: CW-519
); );
} }
@ -147,16 +144,14 @@ class AnonPayApi {
'name': cryptoCurrency.name, 'name': cryptoCurrency.name,
}; };
final String apiAuthority = await _getAuthority(); final response = await proxyGet(coinPath, params);
final uri = Uri.https(apiAuthority, coinPath, params);
final response = await get(uri);
if (response.statusCode != 200) { if (response.statusCode != 200) {
throw Exception('Unexpected http status: ${response.statusCode}'); throw Exception('Unexpected http status: ${response.statusCode}');
} }
final responseJSON = json.decode(response.body) as List<dynamic>; final responseBody = await utf8.decodeStream(response);
final responseJSON = json.decode(responseBody) as List<dynamic>;
if (responseJSON.isEmpty) { if (responseJSON.isEmpty) {
throw Exception('No data'); throw Exception('No data');
@ -199,16 +194,14 @@ class AnonPayApi {
} }
} }
Future<String> _getAuthority() async { Future<HttpClientResponse> proxyGet(String path, Map<String, dynamic> queryParams) async {
try { ProxyWrapper proxy = await getIt.get<ProxyWrapper>();
if (useTorOnly) { Uri onionUri = Uri.http(onionApiAuthority, path, queryParams);
return onionApiAuthority; Uri clearnetUri = Uri.https(clearNetAuthority, path, queryParams);
} return await proxy.get(
final uri = Uri.https(onionApiAuthority, '/anonpay'); onionUri: onionUri,
await get(uri); clearnetUri: clearnetUri,
return onionApiAuthority; torOnly: false,
} catch (e) { );
return clearNetAuthority;
}
} }
} }

View file

@ -15,7 +15,6 @@ const _fiatApiPath = '/v2/rates';
Future<double> _fetchPrice(Map<String, dynamic> args) async { Future<double> _fetchPrice(Map<String, dynamic> args) async {
final crypto = args['crypto'] as String; final crypto = args['crypto'] as String;
final fiat = args['fiat'] as String; final fiat = args['fiat'] as String;
final torOnly = args['torOnly'] as bool;
final mainThreadProxyPort = args['port'] as int; final mainThreadProxyPort = args['port'] as int;
final Map<String, String> queryParams = { final Map<String, String> queryParams = {
@ -43,7 +42,7 @@ Future<double> _fetchPrice(Map<String, dynamic> args) async {
onionUri: onionUri, onionUri: onionUri,
clearnetUri: clearnetUri, clearnetUri: clearnetUri,
portOverride: mainThreadProxyPort, portOverride: mainThreadProxyPort,
torOnly: torOnly, torOnly: false,
); );
responseBody = await utf8.decodeStream(httpResponse); responseBody = await utf8.decodeStream(httpResponse);
statusCode = httpResponse.statusCode; statusCode = httpResponse.statusCode;
@ -70,30 +69,17 @@ Future<double> _fetchPrice(Map<String, dynamic> args) async {
} }
Future<double> _fetchPriceAsync( Future<double> _fetchPriceAsync(
CryptoCurrency crypto, FiatCurrency fiat, bool torOnly, bool onionOnly) async => CryptoCurrency crypto, FiatCurrency fiat) async =>
// compute(_fetchPrice, { compute(_fetchPrice, {
// 'fiat': fiat.toString(),
// 'crypto': crypto.toString(),
// 'torOnly': torOnly,
// 'onionOnly': onionOnly,
// 'port': ProxyWrapper.port,
// 'torEnabled': ProxyWrapper.enabled,
// });
_fetchPrice({
'fiat': fiat.toString(), 'fiat': fiat.toString(),
'crypto': crypto.toString(), 'crypto': crypto.toString(),
'torOnly': torOnly,
'onionOnly': onionOnly,
'port': ProxyWrapper.port, 'port': ProxyWrapper.port,
'torEnabled': ProxyWrapper.enabled,
}); });
class FiatConversionService { class FiatConversionService {
static Future<double> fetchPrice({ static Future<double> fetchPrice({
required CryptoCurrency crypto, required CryptoCurrency crypto,
required FiatCurrency fiat, required FiatCurrency fiat,
required bool torOnly,
required bool onionOnly,
}) async => }) async =>
await _fetchPriceAsync(crypto, fiat, torOnly, onionOnly); await _fetchPriceAsync(crypto, fiat);
} }

View file

@ -14,14 +14,12 @@ class WalletLoadingService {
this.sharedPreferences, this.sharedPreferences,
this.keyService, this.keyService,
this.walletServiceFactory, this.walletServiceFactory,
this.settingsStore,
this.torViewModel, this.torViewModel,
); );
final SharedPreferences sharedPreferences; final SharedPreferences sharedPreferences;
final KeyService keyService; final KeyService keyService;
final WalletService Function(WalletType type) walletServiceFactory; final WalletService Function(WalletType type) walletServiceFactory;
final SettingsStore settingsStore;
final TorViewModel torViewModel; final TorViewModel torViewModel;
Future<void> renameWallet(WalletType type, String name, String newName) async { Future<void> renameWallet(WalletType type, String name, String newName) async {

View file

@ -352,7 +352,6 @@ Future<void> setup({
getIt.get<SharedPreferences>(), getIt.get<SharedPreferences>(),
getIt.get<KeyService>(), getIt.get<KeyService>(),
(WalletType type) => getIt.get<WalletService>(param1: type), (WalletType type) => getIt.get<WalletService>(param1: type),
getIt.get<SettingsStore>(),
getIt.get<TorViewModel>(), getIt.get<TorViewModel>(),
)); ));
@ -1144,9 +1143,7 @@ Future<void> setup({
getIt.registerFactory(() => IoniaAccountCardsPage(getIt.get<IoniaAccountViewModel>())); getIt.registerFactory(() => IoniaAccountCardsPage(getIt.get<IoniaAccountViewModel>()));
getIt.registerFactory(() => AnonPayApi( getIt.registerFactory(() => AnonPayApi(wallet: getIt.get<AppStore>().wallet!));
useTorOnly: getIt.get<SettingsStore>().exchangeStatus == ExchangeApiMode.torOnly,
wallet: getIt.get<AppStore>().wallet!));
getIt.registerFactory(() => getIt.registerFactory(() =>
DesktopWalletSelectionDropDown(getIt.get<WalletListViewModel>(), getIt.get<AuthService>())); DesktopWalletSelectionDropDown(getIt.get<WalletListViewModel>(), getIt.get<AuthService>()));

View file

@ -185,6 +185,9 @@ Future<void> defaultSettingsMigration(
case 25: case 25:
await rewriteSecureStoragePin(secureStorage: secureStorage); await rewriteSecureStoragePin(secureStorage: secureStorage);
break; break;
case 26:
await migrateTorPreferences(sharedPreferences: sharedPreferences);
break;
default: default:
break; break;
} }
@ -378,6 +381,18 @@ Node getMoneroDefaultNode({required Box<Node> nodes}) {
} }
} }
Future<void> migrateTorPreferences({required SharedPreferences sharedPreferences}) async {
if (sharedPreferences.getInt(PreferencesKey.currentFiatApiModeKey) == 1) {
await sharedPreferences.setInt(PreferencesKey.currentFiatApiModeKey, 0);
}
if (sharedPreferences.getInt(PreferencesKey.exchangeStatusKey) == 1) {
await sharedPreferences.setInt(PreferencesKey.currentFiatApiModeKey, 0);
}
}
Future<void> rewriteSecureStoragePin({required FlutterSecureStorage secureStorage}) async { Future<void> rewriteSecureStoragePin({required FlutterSecureStorage secureStorage}) async {
// the bug only affects ios/mac: // the bug only affects ios/mac:
if (!Platform.isIOS && !Platform.isMacOS) { if (!Platform.isIOS && !Platform.isMacOS) {

View file

@ -4,18 +4,15 @@ import 'package:cw_core/enumerable_item.dart';
class ExchangeApiMode extends EnumerableItem<int> with Serializable<int> { class ExchangeApiMode extends EnumerableItem<int> with Serializable<int> {
const ExchangeApiMode({required String title, required int raw}) : super(title: title, raw: raw); const ExchangeApiMode({required String title, required int raw}) : super(title: title, raw: raw);
static const all = [ExchangeApiMode.enabled, ExchangeApiMode.torOnly, ExchangeApiMode.disabled]; static const all = [ExchangeApiMode.enabled, ExchangeApiMode.disabled];
static const enabled = ExchangeApiMode(raw: 0, title: 'Enabled'); static const enabled = ExchangeApiMode(raw: 0, title: 'Enabled');
static const torOnly = ExchangeApiMode(raw: 1, title: 'Tor only'); static const disabled = ExchangeApiMode(raw: 1, title: 'Disabled');
static const disabled = ExchangeApiMode(raw: 2, title: 'Disabled');
static ExchangeApiMode deserialize({required int raw}) { static ExchangeApiMode deserialize({required int raw}) {
switch (raw) { switch (raw) {
case 0: case 0:
return enabled; return enabled;
case 1:
return torOnly;
case 2: case 2:
return disabled; return disabled;
default: default:
@ -28,8 +25,6 @@ class ExchangeApiMode extends EnumerableItem<int> with Serializable<int> {
switch (this) { switch (this) {
case ExchangeApiMode.enabled: case ExchangeApiMode.enabled:
return S.current.enabled; return S.current.enabled;
case ExchangeApiMode.torOnly:
return S.current.tor_only;
case ExchangeApiMode.disabled: case ExchangeApiMode.disabled:
return S.current.disabled; return S.current.disabled;
default: default:

View file

@ -4,19 +4,16 @@ import 'package:cw_core/enumerable_item.dart';
class FiatApiMode extends EnumerableItem<int> with Serializable<int> { class FiatApiMode extends EnumerableItem<int> with Serializable<int> {
const FiatApiMode({required String title, required int raw}) : super(title: title, raw: raw); const FiatApiMode({required String title, required int raw}) : super(title: title, raw: raw);
static const all = [FiatApiMode.enabled, FiatApiMode.torOnly, FiatApiMode.disabled]; static const all = [FiatApiMode.enabled, FiatApiMode.disabled];
static const enabled = FiatApiMode(raw: 0, title: 'Enabled'); static const enabled = FiatApiMode(raw: 0, title: 'Enabled');
static const torOnly = FiatApiMode(raw: 1, title: 'Tor only'); static const disabled = FiatApiMode(raw: 1, title: 'Disabled');
static const disabled = FiatApiMode(raw: 2, title: 'Disabled');
static FiatApiMode deserialize({required int raw}) { static FiatApiMode deserialize({required int raw}) {
switch (raw) { switch (raw) {
case 0: case 0:
return enabled; return enabled;
case 1: case 1:
return torOnly;
case 2:
return disabled; return disabled;
default: default:
throw Exception('Unexpected token: $raw for FiatApiMode deserialize'); throw Exception('Unexpected token: $raw for FiatApiMode deserialize');
@ -28,8 +25,6 @@ class FiatApiMode extends EnumerableItem<int> with Serializable<int> {
switch (this) { switch (this) {
case FiatApiMode.enabled: case FiatApiMode.enabled:
return S.current.enabled; return S.current.enabled;
case FiatApiMode.torOnly:
return S.current.tor_only;
case FiatApiMode.disabled: case FiatApiMode.disabled:
return S.current.disabled; return S.current.disabled;
default: default:

View file

@ -14,12 +14,11 @@ import 'package:cake_wallet/utils/proxy_wrapper.dart';
import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/crypto_currency.dart';
class TrocadorExchangeProvider extends ExchangeProvider { class TrocadorExchangeProvider extends ExchangeProvider {
TrocadorExchangeProvider({this.useTorOnly = false, this.providerStates = const {}}) TrocadorExchangeProvider({this.providerStates = const {}})
: _lastUsedRateId = '', : _lastUsedRateId = '',
_provider = [], _provider = [],
super(pairList: supportedPairs(_notSupported)); super(pairList: supportedPairs(_notSupported));
bool useTorOnly;
final Map<String, bool> providerStates; final Map<String, bool> providerStates;
static const List<String> availableProviders = [ static const List<String> availableProviders = [
@ -308,11 +307,11 @@ class TrocadorExchangeProvider extends ExchangeProvider {
Future<HttpClientResponse> proxyGet(String path, Map<String, String> queryParams) async { Future<HttpClientResponse> proxyGet(String path, Map<String, String> queryParams) async {
ProxyWrapper proxy = await getIt.get<ProxyWrapper>(); ProxyWrapper proxy = await getIt.get<ProxyWrapper>();
Uri onionUri = Uri.http(onionApiAuthority, path, queryParams); Uri onionUri = Uri.http(onionApiAuthority, path, queryParams);
Uri clearnetUri = Uri.http(onionApiAuthority, path, queryParams); Uri clearnetUri = Uri.http(clearNetAuthority, path, queryParams);
return await proxy.get( return await proxy.get(
onionUri: onionUri, onionUri: onionUri,
clearnetUri: clearnetUri, clearnetUri: clearnetUri,
torOnly: useTorOnly, torOnly: false,
); );
} }
} }

View file

@ -163,7 +163,7 @@ Future<void> initializeAppConfigs() async {
transactionDescriptions: transactionDescriptions, transactionDescriptions: transactionDescriptions,
secureStorage: secureStorage, secureStorage: secureStorage,
anonpayInvoiceInfo: anonpayInvoiceInfo, anonpayInvoiceInfo: anonpayInvoiceInfo,
initialMigrationVersion: 25); initialMigrationVersion: 26);
} }
Future<void> initialSetup( Future<void> initialSetup(

View file

@ -33,8 +33,6 @@ Future<void> startFiatRateUpdate(
await FiatConversionService.fetchPrice( await FiatConversionService.fetchPrice(
crypto: appStore.wallet!.currency, crypto: appStore.wallet!.currency,
fiat: settingsStore.fiatCurrency, fiat: settingsStore.fiatCurrency,
torOnly: settingsStore.fiatApiMode == FiatApiMode.torOnly,
onionOnly: settingsStore.torConnectionMode == TorConnectionMode.onionOnly,
); );
} }
@ -55,8 +53,6 @@ Future<void> startFiatRateUpdate(
fiatConversionStore.prices[currency] = await FiatConversionService.fetchPrice( fiatConversionStore.prices[currency] = await FiatConversionService.fetchPrice(
crypto: currency, crypto: currency,
fiat: settingsStore.fiatCurrency, fiat: settingsStore.fiatCurrency,
torOnly: settingsStore.fiatApiMode == FiatApiMode.torOnly,
onionOnly: settingsStore.torConnectionMode == TorConnectionMode.onionOnly,
); );
}.call(); }.call();
} }

View file

@ -20,8 +20,6 @@ void startCurrentFiatApiModeChangeReaction(
fiatConversionStore.prices[appStore.wallet!.currency] = await FiatConversionService.fetchPrice( fiatConversionStore.prices[appStore.wallet!.currency] = await FiatConversionService.fetchPrice(
crypto: appStore.wallet!.currency, crypto: appStore.wallet!.currency,
fiat: settingsStore.fiatCurrency, fiat: settingsStore.fiatCurrency,
torOnly: fiatApiMode == FiatApiMode.torOnly,
onionOnly: settingsStore.torConnectionMode == TorConnectionMode.onionOnly,
); );
}); });
} }

View file

@ -22,8 +22,6 @@ void startCurrentFiatChangeReaction(
fiatConversionStore.prices[cryptoCurrency] = await FiatConversionService.fetchPrice( fiatConversionStore.prices[cryptoCurrency] = await FiatConversionService.fetchPrice(
crypto: cryptoCurrency, crypto: cryptoCurrency,
fiat: fiatCurrency, fiat: fiatCurrency,
torOnly: settingsStore.fiatApiMode == FiatApiMode.torOnly,
onionOnly: settingsStore.torConnectionMode == TorConnectionMode.onionOnly,
); );
}); });
} }

View file

@ -95,8 +95,6 @@ void startCurrentWalletChangeReaction(
fiatConversionStore.prices[wallet.currency] = await FiatConversionService.fetchPrice( fiatConversionStore.prices[wallet.currency] = await FiatConversionService.fetchPrice(
crypto: wallet.currency, crypto: wallet.currency,
fiat: settingsStore.fiatCurrency, fiat: settingsStore.fiatCurrency,
torOnly: settingsStore.fiatApiMode == FiatApiMode.torOnly,
onionOnly: settingsStore.torConnectionMode == TorConnectionMode.onionOnly,
); );
Iterable<Erc20Token>? currencies; Iterable<Erc20Token>? currencies;
@ -114,8 +112,6 @@ void startCurrentWalletChangeReaction(
fiatConversionStore.prices[currency] = await FiatConversionService.fetchPrice( fiatConversionStore.prices[currency] = await FiatConversionService.fetchPrice(
crypto: currency, crypto: currency,
fiat: settingsStore.fiatCurrency, fiat: settingsStore.fiatCurrency,
torOnly: settingsStore.fiatApiMode == FiatApiMode.torOnly,
onionOnly: settingsStore.torConnectionMode == TorConnectionMode.onionOnly,
); );
}.call(); }.call();
} }

View file

@ -92,7 +92,7 @@ class ConnectionSyncPage extends BasePage {
), ),
const StandardListSeparator(padding: EdgeInsets.symmetric(horizontal: 24)), const StandardListSeparator(padding: EdgeInsets.symmetric(horizontal: 24)),
], ],
if (FeatureFlag.isInAppTorEnabled) ...[ if (FeatureFlag.isInAppTorEnabled && !DeviceInfo.instance.isMobile) ...[
Container( Container(
padding: EdgeInsets.symmetric(horizontal: 12, vertical: 10), padding: EdgeInsets.symmetric(horizontal: 12, vertical: 10),
child: Column(children: [ child: Column(children: [

View file

@ -89,8 +89,6 @@ abstract class HomeSettingsViewModelBase with Store {
await FiatConversionService.fetchPrice( await FiatConversionService.fetchPrice(
crypto: token, crypto: token,
fiat: _settingsStore.fiatCurrency, fiat: _settingsStore.fiatCurrency,
torOnly: _settingsStore.fiatApiMode == FiatApiMode.torOnly,
onionOnly: _settingsStore.torConnectionMode == TorConnectionMode.onionOnly,
); );
} catch (_) {} } catch (_) {}
} }

View file

@ -30,6 +30,8 @@ import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/store/templates/exchange_template_store.dart'; import 'package:cake_wallet/store/templates/exchange_template_store.dart';
import 'package:cake_wallet/utils/feature_flag.dart'; import 'package:cake_wallet/utils/feature_flag.dart';
import 'package:cake_wallet/view_model/contact_list/contact_list_view_model.dart'; import 'package:cake_wallet/view_model/contact_list/contact_list_view_model.dart';
import 'package:cake_wallet/view_model/settings/tor_connection.dart';
import 'package:cake_wallet/view_model/settings/tor_view_model.dart';
import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/crypto_currency.dart';
import 'package:cw_core/sync_status.dart'; import 'package:cw_core/sync_status.dart';
import 'package:cw_core/transaction_priority.dart'; import 'package:cw_core/transaction_priority.dart';
@ -67,7 +69,6 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
depositAddress = '', depositAddress = '',
isDepositAddressEnabled = false, isDepositAddressEnabled = false,
isReceiveAmountEditable = false, isReceiveAmountEditable = false,
_useTorOnly = false,
receiveCurrencies = <CryptoCurrency>[], receiveCurrencies = <CryptoCurrency>[],
depositCurrencies = <CryptoCurrency>[], depositCurrencies = <CryptoCurrency>[],
limits = Limits(min: 0, max: 0), limits = Limits(min: 0, max: 0),
@ -78,7 +79,6 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
providerList = [], providerList = [],
selectedProviders = ObservableList<ExchangeProvider>(), selectedProviders = ObservableList<ExchangeProvider>(),
super(appStore: appStore) { super(appStore: appStore) {
_useTorOnly = _settingsStore.exchangeStatus == ExchangeApiMode.torOnly;
_setProviders(); _setProviders();
const excludeDepositCurrencies = [CryptoCurrency.btt]; const excludeDepositCurrencies = [CryptoCurrency.btt];
const excludeReceiveCurrencies = [ const excludeReceiveCurrencies = [
@ -135,7 +135,6 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
}); });
} }
bool _useTorOnly;
final Box<Trade> trades; final Box<Trade> trades;
final ExchangeTemplateStore _exchangeTemplateStore; final ExchangeTemplateStore _exchangeTemplateStore;
final TradesStore tradesStore; final TradesStore tradesStore;
@ -145,8 +144,7 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
ChangeNowExchangeProvider(settingsStore: _settingsStore), ChangeNowExchangeProvider(settingsStore: _settingsStore),
SideShiftExchangeProvider(), SideShiftExchangeProvider(),
SimpleSwapExchangeProvider(), SimpleSwapExchangeProvider(),
TrocadorExchangeProvider( TrocadorExchangeProvider(providerStates: _settingsStore.trocadorProviderStates),
useTorOnly: _useTorOnly, providerStates: _settingsStore.trocadorProviderStates),
if (FeatureFlag.isExolixEnabled) ExolixExchangeProvider(), if (FeatureFlag.isExolixEnabled) ExolixExchangeProvider(),
]; ];
@ -721,7 +719,7 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
} }
void _setProviders() { void _setProviders() {
if (_settingsStore.exchangeStatus == ExchangeApiMode.torOnly) if (_settingsStore.torConnectionMode == TorConnectionMode.onionOnly)
providerList = _allProviders.where((provider) => provider.supportsOnionAddress).toList(); providerList = _allProviders.where((provider) => provider.supportsOnionAddress).toList();
else else
providerList = _allProviders; providerList = _allProviders;