mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-22 23:28:53 +00:00
fixes
This commit is contained in:
parent
54463b2ca3
commit
3108c759e0
5 changed files with 13 additions and 10 deletions
|
@ -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_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/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/entities/fiat_currency.dart';
|
||||||
import 'package:cake_wallet/exchange/limits.dart';
|
import 'package:cake_wallet/exchange/limits.dart';
|
||||||
import 'package:cw_core/wallet_base.dart';
|
import 'package:cw_core/wallet_base.dart';
|
||||||
|
@ -13,10 +15,10 @@ import 'package:cake_wallet/.secrets.g.dart' as secrets;
|
||||||
|
|
||||||
class AnonPayApi {
|
class AnonPayApi {
|
||||||
const AnonPayApi({
|
const AnonPayApi({
|
||||||
this.useTorOnly = false,
|
this.apiMode = ExchangeApiMode.enabled,
|
||||||
required this.wallet,
|
required this.wallet,
|
||||||
});
|
});
|
||||||
final bool useTorOnly;
|
final ExchangeApiMode apiMode;
|
||||||
final WalletBase wallet;
|
final WalletBase wallet;
|
||||||
|
|
||||||
static const anonpayRef = secrets.anonPayReferralCode;
|
static const anonpayRef = secrets.anonPayReferralCode;
|
||||||
|
@ -136,7 +138,7 @@ class AnonPayApi {
|
||||||
fiatRate = await FiatConversionService.fetchPrice(
|
fiatRate = await FiatConversionService.fetchPrice(
|
||||||
crypto: cryptoCurrency,
|
crypto: cryptoCurrency,
|
||||||
fiat: fiatCurrency,
|
fiat: fiatCurrency,
|
||||||
torOnly: useTorOnly,
|
apiMode: apiMode,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +202,7 @@ class AnonPayApi {
|
||||||
|
|
||||||
Future<String> _getAuthority() async {
|
Future<String> _getAuthority() async {
|
||||||
try {
|
try {
|
||||||
if (useTorOnly) {
|
if (apiMode == ExchangeApiMode.torOnly) {
|
||||||
return onionApiAuthority;
|
return onionApiAuthority;
|
||||||
}
|
}
|
||||||
final uri = Uri.https(onionApiAuthority, '/anonpay');
|
final uri = Uri.https(onionApiAuthority, '/anonpay');
|
||||||
|
|
|
@ -1125,7 +1125,7 @@ Future<void> setup({
|
||||||
getIt.registerFactory(() => IoniaAccountCardsPage(getIt.get<IoniaAccountViewModel>()));
|
getIt.registerFactory(() => IoniaAccountCardsPage(getIt.get<IoniaAccountViewModel>()));
|
||||||
|
|
||||||
getIt.registerFactory(() => AnonPayApi(
|
getIt.registerFactory(() => AnonPayApi(
|
||||||
useTorOnly: getIt.get<SettingsStore>().exchangeStatus == ExchangeApiMode.torOnly,
|
apiMode: getIt.get<SettingsStore>().exchangeStatus,
|
||||||
wallet: getIt.get<AppStore>().wallet!));
|
wallet: getIt.get<AppStore>().wallet!));
|
||||||
|
|
||||||
getIt.registerFactory(() =>
|
getIt.registerFactory(() =>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:cake_wallet/.secrets.g.dart' as secrets;
|
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/exchange_provider_description.dart';
|
||||||
import 'package:cake_wallet/exchange/limits.dart';
|
import 'package:cake_wallet/exchange/limits.dart';
|
||||||
import 'package:cake_wallet/exchange/provider/exchange_provider.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';
|
import 'package:http/http.dart';
|
||||||
|
|
||||||
class TrocadorExchangeProvider extends ExchangeProvider {
|
class TrocadorExchangeProvider extends ExchangeProvider {
|
||||||
TrocadorExchangeProvider({this.useTorOnly = false, this.providerStates = const {}})
|
TrocadorExchangeProvider({this.apiMode = FiatApiMode.enabled, this.providerStates = const {}})
|
||||||
: _lastUsedRateId = '', _provider = [],
|
: _lastUsedRateId = '', _provider = [],
|
||||||
super(pairList: supportedPairs(_notSupported));
|
super(pairList: supportedPairs(_notSupported));
|
||||||
|
|
||||||
bool useTorOnly;
|
FiatApiMode apiMode;
|
||||||
final Map<String, bool> providerStates;
|
final Map<String, bool> providerStates;
|
||||||
|
|
||||||
static const List<String> availableProviders = [
|
static const List<String> availableProviders = [
|
||||||
|
@ -304,7 +305,7 @@ class TrocadorExchangeProvider extends ExchangeProvider {
|
||||||
Future<Uri> _getUri(String path, Map<String, String> queryParams) async {
|
Future<Uri> _getUri(String path, Map<String, String> queryParams) async {
|
||||||
final uri = Uri.http(onionApiAuthority, path, queryParams);
|
final uri = Uri.http(onionApiAuthority, path, queryParams);
|
||||||
|
|
||||||
if (useTorOnly) return uri;
|
if (apiMode == FiatApiMode.torOnly) return uri;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await get(uri);
|
await get(uri);
|
||||||
|
|
|
@ -32,7 +32,7 @@ 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);
|
apiMode: settingsStore.fiatApiMode == FiatApiMode.torOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterable<Erc20Token>? currencies;
|
Iterable<Erc20Token>? currencies;
|
||||||
|
|
|
@ -147,7 +147,7 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
||||||
ChangeNowExchangeProvider(settingsStore: _settingsStore),
|
ChangeNowExchangeProvider(settingsStore: _settingsStore),
|
||||||
SideShiftExchangeProvider(),
|
SideShiftExchangeProvider(),
|
||||||
SimpleSwapExchangeProvider(),
|
SimpleSwapExchangeProvider(),
|
||||||
TrocadorExchangeProvider(useTorOnly: _useTorOnly,
|
TrocadorExchangeProvider(apiMode: _settingsStore.fiatApiMode,
|
||||||
providerStates: _settingsStore.trocadorProviderStates),
|
providerStates: _settingsStore.trocadorProviderStates),
|
||||||
if (FeatureFlag.isExolixEnabled) ExolixExchangeProvider(),
|
if (FeatureFlag.isExolixEnabled) ExolixExchangeProvider(),
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue