mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-05-04 03:32:23 +00:00
- Rename calculateAmount to fetchRate to be more descriptive
- Add Disable Exchange change reaction to save in shared prefs [skip ci]
This commit is contained in:
parent
d0c22aa082
commit
4b1e9a10eb
8 changed files with 13 additions and 8 deletions
lib
|
@ -114,7 +114,7 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
|
||||||
if (isFixedRateMode) {
|
if (isFixedRateMode) {
|
||||||
// since we schedule to calculate the rate every 5 seconds we need to ensure that
|
// since we schedule to calculate the rate every 5 seconds we need to ensure that
|
||||||
// we have the latest rate id with the given inputs before creating the trade
|
// we have the latest rate id with the given inputs before creating the trade
|
||||||
await calculateAmount(
|
await fetchRate(
|
||||||
from: _request.from,
|
from: _request.from,
|
||||||
to: _request.to,
|
to: _request.to,
|
||||||
amount: double.tryParse(_request.toAmount) ?? 0,
|
amount: double.tryParse(_request.toAmount) ?? 0,
|
||||||
|
@ -208,7 +208,7 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<double> calculateAmount(
|
Future<double> fetchRate(
|
||||||
{required CryptoCurrency from,
|
{required CryptoCurrency from,
|
||||||
required CryptoCurrency to,
|
required CryptoCurrency to,
|
||||||
required double amount,
|
required double amount,
|
||||||
|
|
|
@ -26,7 +26,7 @@ abstract class ExchangeProvider {
|
||||||
required TradeRequest request,
|
required TradeRequest request,
|
||||||
required bool isFixedRateMode});
|
required bool isFixedRateMode});
|
||||||
Future<Trade> findTradeById({required String id});
|
Future<Trade> findTradeById({required String id});
|
||||||
Future<double> calculateAmount({
|
Future<double> fetchRate({
|
||||||
required CryptoCurrency from,
|
required CryptoCurrency from,
|
||||||
required CryptoCurrency to,
|
required CryptoCurrency to,
|
||||||
required double amount,
|
required double amount,
|
||||||
|
|
|
@ -203,7 +203,7 @@ class MorphTokenExchangeProvider extends ExchangeProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<double> calculateAmount(
|
Future<double> fetchRate(
|
||||||
{required CryptoCurrency from,
|
{required CryptoCurrency from,
|
||||||
required CryptoCurrency to,
|
required CryptoCurrency to,
|
||||||
required double amount,
|
required double amount,
|
||||||
|
|
|
@ -57,7 +57,7 @@ class SideShiftExchangeProvider extends ExchangeProvider {
|
||||||
ExchangeProviderDescription.sideShift;
|
ExchangeProviderDescription.sideShift;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<double> calculateAmount(
|
Future<double> fetchRate(
|
||||||
{required CryptoCurrency from,
|
{required CryptoCurrency from,
|
||||||
required CryptoCurrency to,
|
required CryptoCurrency to,
|
||||||
required double amount,
|
required double amount,
|
||||||
|
|
|
@ -36,7 +36,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
|
||||||
ExchangeProviderDescription.simpleSwap;
|
ExchangeProviderDescription.simpleSwap;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<double> calculateAmount(
|
Future<double> fetchRate(
|
||||||
{required CryptoCurrency from,
|
{required CryptoCurrency from,
|
||||||
required CryptoCurrency to,
|
required CryptoCurrency to,
|
||||||
required double amount,
|
required double amount,
|
||||||
|
|
|
@ -194,7 +194,7 @@ class XMRTOExchangeProvider extends ExchangeProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<double> calculateAmount(
|
Future<double> fetchRate(
|
||||||
{required CryptoCurrency from,
|
{required CryptoCurrency from,
|
||||||
required CryptoCurrency to,
|
required CryptoCurrency to,
|
||||||
required double amount,
|
required double amount,
|
||||||
|
|
|
@ -115,6 +115,11 @@ abstract class SettingsStoreBase with Store {
|
||||||
(BalanceDisplayMode mode) => sharedPreferences.setInt(
|
(BalanceDisplayMode mode) => sharedPreferences.setInt(
|
||||||
PreferencesKey.currentBalanceDisplayModeKey, mode.serialize()));
|
PreferencesKey.currentBalanceDisplayModeKey, mode.serialize()));
|
||||||
|
|
||||||
|
reaction(
|
||||||
|
(_) => disableExchange,
|
||||||
|
(bool disableExchange) => sharedPreferences.setBool(
|
||||||
|
PreferencesKey.disableExchangeKey, disableExchange));
|
||||||
|
|
||||||
this
|
this
|
||||||
.nodes
|
.nodes
|
||||||
.observe((change) {
|
.observe((change) {
|
||||||
|
|
|
@ -311,7 +311,7 @@ abstract class ExchangeViewModelBase with Store {
|
||||||
final result = await Future.wait<double>(
|
final result = await Future.wait<double>(
|
||||||
_tradeAvailableProviders
|
_tradeAvailableProviders
|
||||||
.where((element) => !isFixedRateMode || element.supportsFixedRate)
|
.where((element) => !isFixedRateMode || element.supportsFixedRate)
|
||||||
.map((element) => element.calculateAmount(
|
.map((element) => element.fetchRate(
|
||||||
from: depositCurrency,
|
from: depositCurrency,
|
||||||
to: receiveCurrency,
|
to: receiveCurrency,
|
||||||
amount: amount,
|
amount: amount,
|
||||||
|
|
Loading…
Reference in a new issue