diff --git a/lib/models/exchange/exchange_form_state.dart b/lib/models/exchange/exchange_form_state.dart index 72d84e2a9..645642b9d 100644 --- a/lib/models/exchange/exchange_form_state.dart +++ b/lib/models/exchange/exchange_form_state.dart @@ -115,18 +115,18 @@ class ExchangeFormState extends ChangeNotifier { String get toAmountString => toAmount?.toStringAsFixed(8) ?? ""; bool get canExchange { - switch (exchangeType) { - case ExchangeRateType.estimated: - return fromAmount != null && - fromAmount != Decimal.zero && - toAmount != null && - rate != null && - warning.isEmpty; - case ExchangeRateType.fixed: - return _market != null && - fromAmount != null && - toAmount != null && - warning.isEmpty; + if (exchange?.name == ChangeNowExchange.exchangeName && + exchangeType == ExchangeRateType.fixed) { + return _market != null && + fromAmount != null && + toAmount != null && + warning.isEmpty; + } else { + return fromAmount != null && + fromAmount != Decimal.zero && + toAmount != null && + rate != null && + warning.isEmpty; } } diff --git a/lib/pages/exchange_view/exchange_form.dart b/lib/pages/exchange_view/exchange_form.dart index 045170952..d5fa29b62 100644 --- a/lib/pages/exchange_view/exchange_form.dart +++ b/lib/pages/exchange_view/exchange_form.dart @@ -24,6 +24,7 @@ import 'package:stackwallet/services/exchange/simpleswap/simpleswap_exchange.dar import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/flush_bar_type.dart'; +import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/widgets/custom_loading_overlay.dart'; @@ -308,6 +309,11 @@ class _ExchangeFormState extends ConsumerState { if (markets.isNotEmpty) { await ref.read(exchangeFormStateProvider).swap(market: markets.first); + } else { + Logging.instance.log( + "swap to fixed rate market failed", + level: LogLevel.Warning, + ); } } } else { diff --git a/lib/services/exchange/simpleswap/simpleswap_api.dart b/lib/services/exchange/simpleswap/simpleswap_api.dart index addf732de..3d626b2eb 100644 --- a/lib/services/exchange/simpleswap/simpleswap_api.dart +++ b/lib/services/exchange/simpleswap/simpleswap_api.dart @@ -32,17 +32,22 @@ class SimpleSwapAPI { Future _makeGetRequest(Uri uri) async { final client = this.client ?? http.Client(); + int code = -1; try { final response = await client.get( uri, ); + code = response.statusCode; + final parsed = jsonDecode(response.body); return parsed; } catch (e, s) { - Logging.instance - .log("_makeRequest($uri) threw: $e\n$s", level: LogLevel.Error); + Logging.instance.log( + "_makeRequest($uri) HTTP:$code threw: $e\n$s", + level: LogLevel.Error, + ); rethrow; } }