From 3108c759e0ea99be850b5e35f234594c2678badc Mon Sep 17 00:00:00 2001 From: Matthew Fosse Date: Mon, 11 Dec 2023 08:56:10 -0800 Subject: [PATCH] fixes --- lib/anonpay/anonpay_api.dart | 10 ++++++---- lib/di.dart | 2 +- lib/exchange/provider/trocador_exchange_provider.dart | 7 ++++--- lib/reactions/fiat_rate_update.dart | 2 +- lib/view_model/exchange/exchange_view_model.dart | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/anonpay/anonpay_api.dart b/lib/anonpay/anonpay_api.dart index e46499407..c39447c03 100644 --- a/lib/anonpay/anonpay_api.dart +++ b/lib/anonpay/anonpay_api.dart @@ -4,6 +4,8 @@ import 'package:cake_wallet/anonpay/anonpay_invoice_info.dart'; import 'package:cake_wallet/anonpay/anonpay_request.dart'; import 'package:cake_wallet/anonpay/anonpay_status_response.dart'; import 'package:cake_wallet/core/fiat_conversion_service.dart'; +import 'package:cake_wallet/entities/exchange_api_mode.dart'; +import 'package:cake_wallet/entities/fiat_api_mode.dart'; import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/exchange/limits.dart'; import 'package:cw_core/wallet_base.dart'; @@ -13,10 +15,10 @@ import 'package:cake_wallet/.secrets.g.dart' as secrets; class AnonPayApi { const AnonPayApi({ - this.useTorOnly = false, + this.apiMode = ExchangeApiMode.enabled, required this.wallet, }); - final bool useTorOnly; + final ExchangeApiMode apiMode; final WalletBase wallet; static const anonpayRef = secrets.anonPayReferralCode; @@ -136,7 +138,7 @@ class AnonPayApi { fiatRate = await FiatConversionService.fetchPrice( crypto: cryptoCurrency, fiat: fiatCurrency, - torOnly: useTorOnly, + apiMode: apiMode, ); } @@ -200,7 +202,7 @@ class AnonPayApi { Future _getAuthority() async { try { - if (useTorOnly) { + if (apiMode == ExchangeApiMode.torOnly) { return onionApiAuthority; } final uri = Uri.https(onionApiAuthority, '/anonpay'); diff --git a/lib/di.dart b/lib/di.dart index 15d008dca..d2988b574 100644 --- a/lib/di.dart +++ b/lib/di.dart @@ -1125,7 +1125,7 @@ Future setup({ getIt.registerFactory(() => IoniaAccountCardsPage(getIt.get())); getIt.registerFactory(() => AnonPayApi( - useTorOnly: getIt.get().exchangeStatus == ExchangeApiMode.torOnly, + apiMode: getIt.get().exchangeStatus, wallet: getIt.get().wallet!)); getIt.registerFactory(() => diff --git a/lib/exchange/provider/trocador_exchange_provider.dart b/lib/exchange/provider/trocador_exchange_provider.dart index 52e38ecc8..c235e8ce7 100644 --- a/lib/exchange/provider/trocador_exchange_provider.dart +++ b/lib/exchange/provider/trocador_exchange_provider.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:cake_wallet/.secrets.g.dart' as secrets; +import 'package:cake_wallet/entities/fiat_api_mode.dart'; import 'package:cake_wallet/exchange/exchange_provider_description.dart'; import 'package:cake_wallet/exchange/limits.dart'; import 'package:cake_wallet/exchange/provider/exchange_provider.dart'; @@ -12,11 +13,11 @@ import 'package:cw_core/crypto_currency.dart'; import 'package:http/http.dart'; class TrocadorExchangeProvider extends ExchangeProvider { - TrocadorExchangeProvider({this.useTorOnly = false, this.providerStates = const {}}) + TrocadorExchangeProvider({this.apiMode = FiatApiMode.enabled, this.providerStates = const {}}) : _lastUsedRateId = '', _provider = [], super(pairList: supportedPairs(_notSupported)); - bool useTorOnly; + FiatApiMode apiMode; final Map providerStates; static const List availableProviders = [ @@ -304,7 +305,7 @@ class TrocadorExchangeProvider extends ExchangeProvider { Future _getUri(String path, Map queryParams) async { final uri = Uri.http(onionApiAuthority, path, queryParams); - if (useTorOnly) return uri; + if (apiMode == FiatApiMode.torOnly) return uri; try { await get(uri); diff --git a/lib/reactions/fiat_rate_update.dart b/lib/reactions/fiat_rate_update.dart index 67f621d68..05d233b6f 100644 --- a/lib/reactions/fiat_rate_update.dart +++ b/lib/reactions/fiat_rate_update.dart @@ -32,7 +32,7 @@ Future startFiatRateUpdate( await FiatConversionService.fetchPrice( crypto: appStore.wallet!.currency, fiat: settingsStore.fiatCurrency, - torOnly: settingsStore.fiatApiMode == FiatApiMode.torOnly); + apiMode: settingsStore.fiatApiMode == FiatApiMode.torOnly); } Iterable? currencies; diff --git a/lib/view_model/exchange/exchange_view_model.dart b/lib/view_model/exchange/exchange_view_model.dart index fb7019885..0aee33da2 100644 --- a/lib/view_model/exchange/exchange_view_model.dart +++ b/lib/view_model/exchange/exchange_view_model.dart @@ -147,7 +147,7 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with ChangeNowExchangeProvider(settingsStore: _settingsStore), SideShiftExchangeProvider(), SimpleSwapExchangeProvider(), - TrocadorExchangeProvider(useTorOnly: _useTorOnly, + TrocadorExchangeProvider(apiMode: _settingsStore.fiatApiMode, providerStates: _settingsStore.trocadorProviderStates), if (FeatureFlag.isExolixEnabled) ExolixExchangeProvider(), ];