- Fix Change now request missing type - Only send either to or from amount depending on fixed rate - take the trade amount from the response

- Fix Change now request missing type - Only send either to or from amount depending on fixed rate - take the trade amount from the response

OmarHatem committed Dec 8, 2022 at 01:21 UTC d0c22aa082b5f61ad534544afd0ecf33b286aebc
1 file changed +5 -3
lib/exchange/changenow/changenow_exchange_provider.dart
+5 -3
@@ -97,15 +97,17 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
97 apiHeaderKey: apiKey,
98 'Content-Type': 'application/json'};
99 final flow = getFlow(isFixedRateMode);
100 + final type = isFixedRateMode ? 'reverse' : 'direct';
101 final body = <String, String>{
102 'fromCurrency': normalizeCryptoCurrency(_request.from),
103 'toCurrency': normalizeCryptoCurrency(_request.to),
104 'fromNetwork': networkFor(_request.from),
105 'toNetwork': networkFor(_request.to),
105 - 'fromAmount': _request.fromAmount,
106 - 'toAmount': _request.toAmount,
106 + if (!isFixedRateMode) 'fromAmount': _request.fromAmount,
107 + if (isFixedRateMode) 'toAmount': _request.toAmount,
108 'address': _request.address,
109 'flow': flow,
110 + 'type': type,
111 'refundAddress': _request.refundAddress
112 };
113
@@ -151,7 +153,7 @@ class ChangeNowExchangeProvider extends ExchangeProvider {
153 refundAddress: refundAddress,
154 extraId: extraId,
155 createdAt: DateTime.now(),
154 - amount: _request.fromAmount,
156 + amount: responseJSON['fromAmount']?.toString() ?? _request.fromAmount,
157 state: TradeState.created);
158 }
159