Merge branch 'main' of https://github.com/cake-tech/cake_wallet into new-fiat-currencies

 Conflicts:
	lib/reactions/on_current_wallet_change.dart
This commit is contained in:
OmarHatem
2023-03-03 01:53:23 +02:00
57 changed files with 2992 additions and 322 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);
@@ -1,4 +1,5 @@
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/utils/exception_handler.dart';
import 'package:flutter/widgets.dart';
import 'package:mobx/mobx.dart';
import 'package:cake_wallet/entities/load_current_wallet.dart';
@@ -16,8 +17,9 @@ void startAuthenticationStateChange(AuthenticationStore authenticationStore,
if (state == AuthenticationState.installed) {
try {
await loadCurrentWallet();
} catch (e) {
loginError = e;
} catch (error, stack) {
loginError = error;
ExceptionHandler.onError(FlutterErrorDetails(exception: error, stack: stack));
}
return;
}
@@ -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);
});
}
+5 -3
View File
@@ -69,8 +69,8 @@ void startCurrentWalletChangeReaction(AppStore appStore,
if (wallet.type == WalletType.haven) {
await updateHavenRate(fiatConversionStore);
}
if (wallet.walletInfo.address?.isEmpty ?? true) {
if (wallet.walletInfo.address.isEmpty) {
wallet.walletInfo.address = wallet.walletAddresses.address;
if (wallet.walletInfo.isInBox) {
@@ -94,7 +94,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());
}