Update fiat API version

Enable Tor support for Fiat
This commit is contained in:
OmarHatem
2023-02-28 18:23:21 +02:00
parent c307e055ea
commit ce4b1cd4ae
8 changed files with 97 additions and 51 deletions
+2
View File
@@ -1,5 +1,6 @@
import 'dart:async';
import 'package:cake_wallet/reactions/fiat_rate_update.dart';
import 'package:cake_wallet/reactions/on_current_fiat_api_mode_change.dart';
import 'package:cake_wallet/reactions/on_current_node_change.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/widgets.dart';
@@ -31,6 +32,7 @@ Future<void> bootstrap(GlobalKey<NavigatorState> navigatorKey) async {
startCurrentWalletChangeReaction(
appStore, settingsStore, fiatConversionStore);
startCurrentFiatChangeReaction(appStore, settingsStore, fiatConversionStore);
startCurrentFiatApiModeChangeReaction(appStore, settingsStore, fiatConversionStore);
startOnCurrentNodeChangeReaction(appStore);
startFiatRateUpdate(appStore, settingsStore, fiatConversionStore);
}
+3 -1
View File
@@ -26,7 +26,9 @@ Future<void> startFiatRateUpdate(
} else {
fiatConversionStore.prices[appStore.wallet!.currency] =
await FiatConversionService.fetchPrice(
appStore.wallet!.currency, settingsStore.fiatCurrency);
crypto: appStore.wallet!.currency,
fiat: settingsStore.fiatCurrency,
torOnly: settingsStore.fiatApiMode == FiatApiMode.torOnly);
}
} catch (e) {
print(e);
@@ -0,0 +1,25 @@
import 'package:cake_wallet/entities/fiat_api_mode.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/core/fiat_conversion_service.dart';
import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart';
import 'package:cake_wallet/store/settings_store.dart';
import 'package:cake_wallet/store/app_store.dart';
ReactionDisposer? _onCurrentFiatCurrencyChangeDisposer;
void startCurrentFiatApiModeChangeReaction(AppStore appStore,
SettingsStore settingsStore, FiatConversionStore fiatConversionStore) {
_onCurrentFiatCurrencyChangeDisposer?.reaction.dispose();
_onCurrentFiatCurrencyChangeDisposer = reaction(
(_) => settingsStore.fiatApiMode, (FiatApiMode fiatApiMode) async {
if (appStore.wallet == null || fiatApiMode == FiatApiMode.disabled) {
return;
}
fiatConversionStore.prices[appStore.wallet!.currency] =
await FiatConversionService.fetchPrice(
crypto: appStore.wallet!.currency,
fiat: settingsStore.fiatCurrency,
torOnly: fiatApiMode == FiatApiMode.torOnly);
});
}
+5 -2
View File
@@ -18,7 +18,10 @@ void startCurrentFiatChangeReaction(AppStore appStore,
}
final cryptoCurrency = appStore.wallet!.currency;
fiatConversionStore.prices[appStore.wallet!.currency] =
await FiatConversionService.fetchPrice(cryptoCurrency, fiatCurrency);
fiatConversionStore.prices[cryptoCurrency] =
await FiatConversionService.fetchPrice(
crypto: cryptoCurrency,
fiat: fiatCurrency,
torOnly: settingsStore.fiatApiMode == FiatApiMode.torOnly);
});
}
+4 -2
View File
@@ -71,7 +71,7 @@ void startCurrentWalletChangeReaction(AppStore appStore,
await updateHavenRate(fiatConversionStore);
}
if (wallet.walletInfo.address?.isEmpty ?? true) {
if (wallet.walletInfo.address.isEmpty) {
wallet.walletInfo.address = wallet.walletAddresses.address;
if (wallet.walletInfo.isInBox) {
@@ -95,7 +95,9 @@ void startCurrentWalletChangeReaction(AppStore appStore,
fiatConversionStore.prices[wallet.currency] = 0;
fiatConversionStore.prices[wallet.currency] =
await FiatConversionService.fetchPrice(
wallet.currency, settingsStore.fiatCurrency);
crypto: wallet.currency,
fiat: settingsStore.fiatCurrency,
torOnly: settingsStore.fiatApiMode == FiatApiMode.torOnly);
} catch (e) {
print(e.toString());
}