Cw 181 simple swap extra id fix (#532)

* extra id for simple swap
This commit is contained in:
Godwin Asuquo 2022-10-25 23:36:28 +03:00 committed by GitHub
parent ed1dc75a3d
commit 95ecf4ef56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -35,7 +35,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
@override
ExchangeProviderDescription get description =>
ExchangeProviderDescription.simpleSwap;
@override
Future<double> calculateAmount(
{required CryptoCurrency from,
@ -61,7 +61,6 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
if (response.body == null || response.body == "null") return 0.00;
final data = json.decode(response.body) as String;
return double.parse(data);
} catch (_) {
return 0.00;
@ -79,7 +78,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
@override
Future<Trade> createTrade({required TradeRequest request, required bool isFixedRateMode}) async {
final _request = request as SimpleSwapRequest;
final headers = {
final headers = {
'Content-Type': 'application/json'};
final params = <String, String>{
'api_key': apiKey,
@ -111,7 +110,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
final id = responseJSON['id'] as String;
final inputAddress = responseJSON['address_from'] as String;
final settleAddress = responseJSON['user_refund_address'] as String;
final extraId = responseJSON['extra_id_from'] as String?;
return Trade(
id: id,
provider: description,
@ -119,6 +118,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
to: _request.to,
inputAddress: inputAddress,
refundAddress: settleAddress,
extraId: extraId,
state: TradeState.created,
amount: _request.amount,
createdAt: DateTime.now(),
@ -188,6 +188,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
final to = CryptoCurrency.fromString(toCurrency);
final inputAddress = responseJSON['address_from'] as String;
final expectedSendAmount = responseJSON['expected_amount'].toString();
final extraId = responseJSON['extra_id_from'] as String?;
final status = responseJSON['status'] as String;
final state = TradeState.deserialize(raw: status);
@ -195,6 +196,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
id: id,
from: from,
to: to,
extraId: extraId,
provider: description,
inputAddress: inputAddress,
amount: expectedSendAmount,