From 9acdf9cfc442f9ba89d31e49ce7c7b71e138300c Mon Sep 17 00:00:00 2001 From: julian Date: Tue, 4 Oct 2022 18:57:01 -0600 Subject: [PATCH] remove unused files --- .../estimated_rate_exchange_form_state.dart | 282 ------------------ .../fixed_rate_exchange_form_state.dart | 179 ----------- 2 files changed, 461 deletions(-) delete mode 100644 lib/models/exchange/estimated_rate_exchange_form_state.dart delete mode 100644 lib/models/exchange/fixed_rate_exchange_form_state.dart diff --git a/lib/models/exchange/estimated_rate_exchange_form_state.dart b/lib/models/exchange/estimated_rate_exchange_form_state.dart deleted file mode 100644 index 2a465c3ef..000000000 --- a/lib/models/exchange/estimated_rate_exchange_form_state.dart +++ /dev/null @@ -1,282 +0,0 @@ -// import 'package:decimal/decimal.dart'; -// import 'package:flutter/cupertino.dart'; -// import 'package:flutter/material.dart'; -// import 'package:stackwallet/models/exchange/response_objects/currency.dart'; -// import 'package:stackwallet/services/exchange/change_now/change_now_api.dart'; -// import 'package:stackwallet/utilities/logger.dart'; -// -// class EstimatedRateExchangeFormState extends ChangeNotifier { -// /// used in testing to inject mock -// ChangeNowAPI? cnTesting; -// -// Decimal? _fromAmount; -// Decimal? _toAmount; -// -// Decimal? _minFromAmount; -// Decimal? _minToAmount; -// -// Decimal? rate; -// -// Currency? _from; -// Currency? _to; -// -// void Function(String)? _onError; -// -// Currency? get from => _from; -// Currency? get to => _to; -// -// String get fromAmountString => -// _fromAmount == null ? "" : _fromAmount!.toStringAsFixed(8); -// String get toAmountString => -// _toAmount == null ? "" : _toAmount!.toStringAsFixed(8); -// -// String get rateDisplayString { -// if (rate == null || from == null || to == null) { -// return "N/A"; -// } else { -// return "1 ${from!.ticker.toUpperCase()} ~${rate!.toStringAsFixed(8)} ${to!.ticker.toUpperCase()}"; -// } -// } -// -// bool get canExchange { -// return _fromAmount != null && -// _fromAmount != Decimal.zero && -// _toAmount != null && -// rate != null && -// minimumSendWarning.isEmpty; -// } -// -// String get minimumSendWarning { -// if (_from != null && -// _fromAmount != null && -// _minFromAmount != null && -// _fromAmount! < _minFromAmount!) { -// return "Minimum amount ${_minFromAmount!.toString()} ${from!.ticker.toUpperCase()}"; -// } -// -// return ""; -// } -// -// Future init(Currency? from, Currency? to) async { -// _from = from; -// _to = to; -// } -// -// void clearAmounts(bool shouldNotifyListeners) { -// _fromAmount = null; -// _toAmount = null; -// _minFromAmount = null; -// _minToAmount = null; -// rate = null; -// -// if (shouldNotifyListeners) { -// notifyListeners(); -// } -// } -// -// Future swap() async { -// final Decimal? newToAmount = _fromAmount; -// final Decimal? newFromAmount = _toAmount; -// -// final Decimal? newMinFromAmount = _minToAmount; -// final Decimal? newMinToAmount = _minFromAmount; -// -// final Currency? newTo = from; -// final Currency? newFrom = to; -// -// _fromAmount = newFromAmount; -// _toAmount = newToAmount; -// -// _minToAmount = newMinToAmount; -// _minFromAmount = newMinFromAmount; -// -// // rate = newRate; -// -// _to = newTo; -// _from = newFrom; -// -// await _updateMinFromAmount(shouldNotifyListeners: false); -// -// await updateRate(); -// -// notifyListeners(); -// } -// -// Future updateTo(Currency to, bool shouldNotifyListeners) async { -// try { -// _to = to; -// if (_from == null) { -// rate = null; -// notifyListeners(); -// return; -// } -// -// await _updateMinFromAmount(shouldNotifyListeners: shouldNotifyListeners); -// -// await updateRate(shouldNotifyListeners: shouldNotifyListeners); -// -// debugPrint( -// "_updated TO: _from=${_from!.ticker} _to=${_to!.ticker} _fromAmount=$_fromAmount _toAmount=$_toAmount rate:$rate"); -// -// if (shouldNotifyListeners) { -// notifyListeners(); -// } -// } catch (e, s) { -// Logging.instance.log("$e\n$s", level: LogLevel.Error); -// } -// } -// -// Future updateFrom(Currency from, bool shouldNotifyListeners) async { -// try { -// _from = from; -// -// if (_to == null) { -// rate = null; -// notifyListeners(); -// return; -// } -// -// await _updateMinFromAmount(shouldNotifyListeners: shouldNotifyListeners); -// -// await updateRate(shouldNotifyListeners: shouldNotifyListeners); -// -// debugPrint( -// "_updated FROM: _from=${_from!.ticker} _to=${_to!.ticker} _fromAmount=$_fromAmount _toAmount=$_toAmount rate:$rate"); -// if (shouldNotifyListeners) { -// notifyListeners(); -// } -// } catch (e, s) { -// Logging.instance.log("$e\n$s", level: LogLevel.Error); -// } -// } -// -// Future _updateMinFromAmount( -// {required bool shouldNotifyListeners}) async { -// _minFromAmount = await getStandardMinExchangeAmount(from: from!, to: to!); -// if (shouldNotifyListeners) { -// notifyListeners(); -// } -// } -// -// // Future setToAmountAndCalculateFromAmount( -// // Decimal newToAmount, -// // bool shouldNotifyListeners, -// // ) async { -// // if (newToAmount == Decimal.zero) { -// // _fromAmount = Decimal.zero; -// // } -// // -// // _toAmount = newToAmount; -// // await updateRate(); -// // if (shouldNotifyListeners) { -// // notifyListeners(); -// // } -// // } -// -// Future setFromAmountAndCalculateToAmount( -// Decimal newFromAmount, -// bool shouldNotifyListeners, -// ) async { -// if (newFromAmount == Decimal.zero) { -// _toAmount = Decimal.zero; -// } -// -// _fromAmount = newFromAmount; -// await updateRate(shouldNotifyListeners: shouldNotifyListeners); -// -// if (shouldNotifyListeners) { -// notifyListeners(); -// } -// } -// -// Future getStandardEstimatedToAmount({ -// required Decimal fromAmount, -// required Currency from, -// required Currency to, -// }) async { -// final response = -// await (cnTesting ?? ChangeNowAPI.instance).getEstimatedExchangeAmount( -// fromTicker: from.ticker, -// toTicker: to.ticker, -// fromAmount: fromAmount, -// ); -// -// if (response.value != null) { -// return response.value!.estimatedAmount; -// } else { -// _onError?.call( -// "Failed to fetch estimated amount: ${response.exception?.toString()}"); -// return null; -// } -// } -// -// // Future getStandardEstimatedFromAmount({ -// // required Decimal toAmount, -// // required Currency from, -// // required Currency to, -// // }) async { -// // final response = await (cnTesting ?? ChangeNow.instance) -// // .getEstimatedExchangeAmount( -// // fromTicker: from.ticker, -// // toTicker: to.ticker, -// // fromAmount: toAmount, ); -// // -// // if (response.value != null) { -// // return response.value!.fromAmount; -// // } else { -// // _onError?.call( -// // "Failed to fetch estimated amount: ${response.exception?.toString()}"); -// // return null; -// // } -// // } -// -// Future getStandardMinExchangeAmount({ -// required Currency from, -// required Currency to, -// }) async { -// final response = await (cnTesting ?? ChangeNowAPI.instance) -// .getMinimalExchangeAmount(fromTicker: from.ticker, toTicker: to.ticker); -// -// if (response.value != null) { -// return response.value!; -// } else { -// _onError?.call( -// "Could not update minimal exchange amounts: ${response.exception?.toString()}"); -// return null; -// } -// } -// -// void setOnError({ -// required void Function(String)? onError, -// bool shouldNotifyListeners = false, -// }) { -// _onError = onError; -// if (shouldNotifyListeners) { -// notifyListeners(); -// } -// } -// -// Future updateRate({bool shouldNotifyListeners = false}) async { -// rate = null; -// final amount = _fromAmount; -// final minAmount = _minFromAmount; -// if (amount != null && amount > Decimal.zero) { -// Decimal? amt; -// if (minAmount != null) { -// if (minAmount <= amount) { -// amt = await getStandardEstimatedToAmount( -// fromAmount: amount, from: _from!, to: _to!); -// if (amt != null) { -// rate = (amt / amount).toDecimal(scaleOnInfinitePrecision: 12); -// } -// } -// } -// if (rate != null && amt != null) { -// _toAmount = amt; -// } -// } -// if (shouldNotifyListeners) { -// notifyListeners(); -// } -// } -// } diff --git a/lib/models/exchange/fixed_rate_exchange_form_state.dart b/lib/models/exchange/fixed_rate_exchange_form_state.dart deleted file mode 100644 index fcb686a73..000000000 --- a/lib/models/exchange/fixed_rate_exchange_form_state.dart +++ /dev/null @@ -1,179 +0,0 @@ -// import 'package:decimal/decimal.dart'; -// import 'package:flutter/cupertino.dart'; -// import 'package:stackwallet/models/exchange/change_now/cn_exchange_estimate.dart'; -// import 'package:stackwallet/models/exchange/response_objects/fixed_rate_market.dart'; -// import 'package:stackwallet/services/exchange/change_now/change_now_api.dart'; -// import 'package:stackwallet/utilities/logger.dart'; -// -// class FixedRateExchangeFormState extends ChangeNotifier { -// Decimal? _fromAmount; -// Decimal? _toAmount; -// -// FixedRateMarket? _market; -// FixedRateMarket? get market => _market; -// -// CNExchangeEstimate? _estimate; -// CNExchangeEstimate? get estimate => _estimate; -// -// Decimal? get rate { -// if (_estimate == null) { -// return null; -// } else { -// return (_estimate!.toAmount / _estimate!.fromAmount) -// .toDecimal(scaleOnInfinitePrecision: 12); -// } -// } -// -// Future swap(FixedRateMarket reverseFixedRateMarket) async { -// final Decimal? tmp = _fromAmount; -// _fromAmount = _toAmount; -// _toAmount = tmp; -// -// await updateMarket(reverseFixedRateMarket, false); -// await updateRateEstimate(CNEstimateType.direct); -// _toAmount = _estimate?.toAmount ?? Decimal.zero; -// notifyListeners(); -// } -// -// String get fromAmountString => -// _fromAmount == null ? "" : _fromAmount!.toStringAsFixed(8); -// String get toAmountString => -// _toAmount == null ? "" : _toAmount!.toStringAsFixed(8); -// -// Future updateMarket( -// FixedRateMarket? market, -// bool shouldNotifyListeners, -// ) async { -// _market = market; -// -// if (_market == null) { -// _fromAmount = null; -// _toAmount = null; -// } else { -// if (_fromAmount != null) { -// if (_fromAmount! <= Decimal.zero) { -// _toAmount = Decimal.zero; -// } else { -// await updateRateEstimate(CNEstimateType.direct); -// } -// } -// } -// -// if (shouldNotifyListeners) { -// notifyListeners(); -// } -// } -// -// String get rateDisplayString { -// if (_market == null || _estimate == null) { -// return "N/A"; -// } else { -// return "1 ${_estimate!.fromCurrency.toUpperCase()} ~${rate!.toStringAsFixed(8)} ${_estimate!.toCurrency.toUpperCase()}"; -// } -// } -// -// bool get canExchange { -// return _market != null && -// _fromAmount != null && -// _toAmount != null && -// sendAmountWarning.isEmpty; -// } -// -// String get sendAmountWarning { -// if (_market != null && _fromAmount != null) { -// if (_fromAmount! < _market!.min) { -// return "Minimum amount ${_market!.min.toString()} ${_market!.from.toUpperCase()}"; -// } else if (_fromAmount! > _market!.max) { -// return "Maximum amount ${_market!.max.toString()} ${_market!.from.toUpperCase()}"; -// } -// } -// -// return ""; -// } -// -// Future setToAmountAndCalculateFromAmount( -// Decimal newToAmount, -// bool shouldNotifyListeners, -// ) async { -// _toAmount = newToAmount; -// -// if (shouldNotifyListeners) { -// await updateRateEstimate(CNEstimateType.reverse); -// notifyListeners(); -// } -// } -// -// Future setFromAmountAndCalculateToAmount( -// Decimal newFromAmount, -// bool shouldNotifyListeners, -// ) async { -// _fromAmount = newFromAmount; -// -// if (shouldNotifyListeners) { -// await updateRateEstimate(CNEstimateType.direct); -// notifyListeners(); -// } -// } -// -// void Function(String)? _onError; -// -// void setOnError({ -// required void Function(String)? onError, -// bool shouldNotifyListeners = false, -// }) { -// _onError = onError; -// if (shouldNotifyListeners) { -// notifyListeners(); -// } -// } -// -// Future updateRateEstimate(CNEstimateType direction) async { -// if (market != null) { -// Decimal? amount; -// // set amount based on trade estimate direction -// switch (direction) { -// case CNEstimateType.direct: -// if (_fromAmount != null -// // && -// // market!.min >= _fromAmount! && -// // _fromAmount! <= market!.max -// ) { -// amount = _fromAmount!; -// } -// break; -// case CNEstimateType.reverse: -// if (_toAmount != null -// // && -// // market!.min >= _toAmount! && -// // _toAmount! <= market!.max -// ) { -// amount = _toAmount!; -// } -// break; -// } -// -// if (amount != null && market != null && amount > Decimal.zero) { -// final response = -// await ChangeNowAPI.instance.getEstimatedExchangeAmountV2( -// fromTicker: market!.from, -// toTicker: market!.to, -// fromOrTo: direction, -// flow: CNFlowType.fixedRate, -// amount: amount, -// ); -// -// if (response.value != null) { -// // update estimate if response succeeded -// _estimate = response.value; -// -// _toAmount = _estimate?.toAmount; -// _fromAmount = _estimate?.fromAmount; -// notifyListeners(); -// } else if (response.exception != null) { -// Logging.instance.log("updateRateEstimate(): ${response.exception}", -// level: LogLevel.Warning); -// } -// } -// } -// } -// }