diff --git a/lib/models/exchange/incomplete_exchange.dart b/lib/models/exchange/incomplete_exchange.dart index 864a25490..2680b24e0 100644 --- a/lib/models/exchange/incomplete_exchange.dart +++ b/lib/models/exchange/incomplete_exchange.dart @@ -1,5 +1,6 @@ import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; +import 'package:stackwallet/models/exchange/response_objects/estimate.dart'; import 'package:stackwallet/models/exchange/response_objects/trade.dart'; import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart'; @@ -39,13 +40,13 @@ class IncompleteExchangeModel extends ChangeNotifier { } } - String? _rateId; + Estimate? _estimate; - String? get rateId => _rateId; + Estimate? get estimate => _estimate; - set rateId(String? rateId) { - if (_rateId != rateId) { - _rateId = rateId; + set estimate(Estimate? estimate) { + if (_estimate != estimate) { + _estimate = estimate; notifyListeners(); } } @@ -70,6 +71,6 @@ class IncompleteExchangeModel extends ChangeNotifier { required this.rateType, required this.reversed, required this.walletInitiated, - String? rateId, - }) : _rateId = rateId; + Estimate? estimate, + }) : _estimate = estimate; } diff --git a/lib/models/exchange/response_objects/estimate.dart b/lib/models/exchange/response_objects/estimate.dart index 7df490079..d93fcb560 100644 --- a/lib/models/exchange/response_objects/estimate.dart +++ b/lib/models/exchange/response_objects/estimate.dart @@ -7,6 +7,7 @@ class Estimate { final bool reversed; final String? warningMessage; final String? rateId; + final String? exchangeProvider; Estimate({ required this.estimatedAmount, @@ -14,6 +15,7 @@ class Estimate { required this.reversed, this.warningMessage, this.rateId, + this.exchangeProvider, }); factory Estimate.fromMap(Map map) { @@ -38,6 +40,7 @@ class Estimate { "reversed": reversed, "warningMessage": warningMessage, "rateId": rateId, + "exchangeProvider": exchangeProvider, }; } diff --git a/lib/pages/exchange_view/exchange_form.dart b/lib/pages/exchange_view/exchange_form.dart index 11b4f4e51..3ecee0994 100644 --- a/lib/pages/exchange_view/exchange_form.dart +++ b/lib/pages/exchange_view/exchange_form.dart @@ -554,7 +554,7 @@ class _ExchangeFormState extends ConsumerState { ? ref.read(exchangeFormStateProvider).receiveAmount! : estimate.estimatedAmount, rateType: rateType, - rateId: estimate.rateId, + estimate: estimate, reversed: estimate.reversed, walletInitiated: walletInitiated, ); diff --git a/lib/pages/exchange_view/exchange_step_views/step_3_view.dart b/lib/pages/exchange_view/exchange_step_views/step_3_view.dart index 22c356b5d..a7c954c59 100644 --- a/lib/pages/exchange_view/exchange_step_views/step_3_view.dart +++ b/lib/pages/exchange_view/exchange_step_views/step_3_view.dart @@ -271,24 +271,26 @@ class _Step3ViewState extends ConsumerState { ? model.refundAddress! : "", refundExtraId: "", - rateId: model.rateId, + estimate: model.estimate, reversed: model.reversed, ); if (response.value == null) { if (mounted) { Navigator.of(context).pop(); - } - unawaited(showDialog( - context: context, - barrierDismissible: true, - builder: (_) => StackDialog( - title: "Failed to create trade", - message: - response.exception?.toString(), - ), - )); + unawaited( + showDialog( + context: context, + barrierDismissible: true, + builder: (_) => StackDialog( + title: "Failed to create trade", + message: response.exception + ?.toString(), + ), + ), + ); + } return; } diff --git a/lib/services/exchange/change_now/change_now_exchange.dart b/lib/services/exchange/change_now/change_now_exchange.dart index 3189ff84e..f5b68d300 100644 --- a/lib/services/exchange/change_now/change_now_exchange.dart +++ b/lib/services/exchange/change_now/change_now_exchange.dart @@ -31,7 +31,7 @@ class ChangeNowExchange extends Exchange { String? extraId, required String addressRefund, required String refundExtraId, - String? rateId, + Estimate? estimate, required bool reversed, }) async { late final ExchangeResponse response; @@ -41,7 +41,7 @@ class ChangeNowExchange extends Exchange { toTicker: to, receivingAddress: addressTo, amount: amount, - rateId: rateId!, + rateId: estimate!.rateId!, extraId: extraId ?? "", refundAddress: addressRefund, refundExtraId: refundExtraId, diff --git a/lib/services/exchange/exchange.dart b/lib/services/exchange/exchange.dart index e4f5ce8d5..4aae5a0b8 100644 --- a/lib/services/exchange/exchange.dart +++ b/lib/services/exchange/exchange.dart @@ -69,7 +69,7 @@ abstract class Exchange { String? extraId, required String addressRefund, required String refundExtraId, - String? rateId, + Estimate? estimate, required bool reversed, }); } diff --git a/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart b/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart index dcc63c68b..0980abc62 100644 --- a/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart +++ b/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart @@ -44,7 +44,7 @@ class MajesticBankExchange extends Exchange { String? extraId, required String addressRefund, required String refundExtraId, - String? rateId, + Estimate? estimate, required bool reversed, }) async { ExchangeResponse? response; diff --git a/lib/services/exchange/simpleswap/simpleswap_exchange.dart b/lib/services/exchange/simpleswap/simpleswap_exchange.dart index 1157bd09e..2822d4a1e 100644 --- a/lib/services/exchange/simpleswap/simpleswap_exchange.dart +++ b/lib/services/exchange/simpleswap/simpleswap_exchange.dart @@ -30,7 +30,7 @@ class SimpleSwapExchange extends Exchange { String? extraId, required String addressRefund, required String refundExtraId, - String? rateId, + Estimate? estimate, required bool reversed, }) async { return await SimpleSwapAPI.instance.createNewExchange(