Cw 181 simple swap extra id fix (#532)

* extra id for simple swap

Godwin Asuquo committed Oct 25, 2022 at 23:36 UTC 95ecf4ef56b3b49a2ea1a570df6865bfb7027a88
1 file changed +6 -4
lib/exchange/simpleswap/simpleswap_exchange_provider.dart
+6 -4
@@ -35,7 +35,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
35 @override
36 ExchangeProviderDescription get description =>
37 ExchangeProviderDescription.simpleSwap;
38 -
38 +
39 @override
40 Future<double> calculateAmount(
41 {required CryptoCurrency from,
@@ -61,7 +61,6 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
61
62 if (response.body == null || response.body == "null") return 0.00;
63 final data = json.decode(response.body) as String;
64 -
64 return double.parse(data);
65 } catch (_) {
66 return 0.00;
@@ -79,7 +78,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
78 @override
79 Future<Trade> createTrade({required TradeRequest request, required bool isFixedRateMode}) async {
80 final _request = request as SimpleSwapRequest;
82 - final headers = {
81 + final headers = {
82 'Content-Type': 'application/json'};
83 final params = <String, String>{
84 'api_key': apiKey,
@@ -111,7 +110,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
110 final id = responseJSON['id'] as String;
111 final inputAddress = responseJSON['address_from'] as String;
112 final settleAddress = responseJSON['user_refund_address'] as String;
114 -
113 + final extraId = responseJSON['extra_id_from'] as String?;
114 return Trade(
115 id: id,
116 provider: description,
@@ -119,6 +118,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
118 to: _request.to,
119 inputAddress: inputAddress,
120 refundAddress: settleAddress,
121 + extraId: extraId,
122 state: TradeState.created,
123 amount: _request.amount,
124 createdAt: DateTime.now(),
@@ -188,6 +188,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
188 final to = CryptoCurrency.fromString(toCurrency);
189 final inputAddress = responseJSON['address_from'] as String;
190 final expectedSendAmount = responseJSON['expected_amount'].toString();
191 + final extraId = responseJSON['extra_id_from'] as String?;
192 final status = responseJSON['status'] as String;
193 final state = TradeState.deserialize(raw: status);
194
@@ -195,6 +196,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
196 id: id,
197 from: from,
198 to: to,
199 + extraId: extraId,
200 provider: description,
201 inputAddress: inputAddress,
202 amount: expectedSendAmount,