mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-26 04:05:53 +00:00
simpleswap impl
This commit is contained in:
parent
28d41cc5ab
commit
65cedbac02
2 changed files with 40 additions and 7 deletions
|
@ -138,4 +138,35 @@ class Trade {
|
||||||
status: status ?? this.status,
|
status: status ?? this.status,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, dynamic> toMap() {
|
||||||
|
return {
|
||||||
|
"uuid,": uuid,
|
||||||
|
"tradeId,": tradeId,
|
||||||
|
"rateType,": rateType,
|
||||||
|
"direction,": direction,
|
||||||
|
"timestamp,": timestamp,
|
||||||
|
"updatedAt,": updatedAt,
|
||||||
|
"from,": from,
|
||||||
|
"fromAmount,": fromAmount,
|
||||||
|
"fromAddress,": fromAddress,
|
||||||
|
"fromNetwork,": fromNetwork,
|
||||||
|
"fromExtraId,": fromExtraId,
|
||||||
|
"fromTxid,": fromTxid,
|
||||||
|
"to,": to,
|
||||||
|
"toAmount,": toAmount,
|
||||||
|
"toAddress,": toAddress,
|
||||||
|
"toNetwork,": toNetwork,
|
||||||
|
"toExtraId,": toExtraId,
|
||||||
|
"toTxid,": toTxid,
|
||||||
|
"refundAddress,": refundAddress,
|
||||||
|
"refundExtraId,": refundExtraId,
|
||||||
|
"status,": status,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString() {
|
||||||
|
return toMap().toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ class SimpleSwapAPI {
|
||||||
);
|
);
|
||||||
|
|
||||||
final parsed = jsonDecode(response.body);
|
final parsed = jsonDecode(response.body);
|
||||||
|
print("PARSED: $parsed");
|
||||||
|
|
||||||
return parsed;
|
return parsed;
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
|
@ -81,14 +82,14 @@ class SimpleSwapAPI {
|
||||||
String? extraIdTo,
|
String? extraIdTo,
|
||||||
String? apiKey,
|
String? apiKey,
|
||||||
}) async {
|
}) async {
|
||||||
Map<String, String> body = {
|
Map<String, dynamic> body = {
|
||||||
"fixed": isFixedRate.toString(),
|
"fixed": isFixedRate,
|
||||||
"currency_from": currencyFrom,
|
"currency_from": currencyFrom,
|
||||||
"currency_to": currencyTo,
|
"currency_to": currencyTo,
|
||||||
"addressTo": addressTo,
|
"addressTo": addressTo,
|
||||||
"userRefundAddress": userRefundAddress,
|
"userRefundAddress": userRefundAddress,
|
||||||
"userRefundExtraId": userRefundExtraId,
|
"userRefundExtraId": userRefundExtraId,
|
||||||
"amount": amount,
|
"amount": double.parse(amount),
|
||||||
};
|
};
|
||||||
|
|
||||||
final uri =
|
final uri =
|
||||||
|
@ -118,7 +119,7 @@ class SimpleSwapAPI {
|
||||||
toAmount: json["amount_to"] as String,
|
toAmount: json["amount_to"] as String,
|
||||||
toAddress: json["address_to"] as String,
|
toAddress: json["address_to"] as String,
|
||||||
toNetwork: "",
|
toNetwork: "",
|
||||||
toExtraId: json["extra_id_to"] as String,
|
toExtraId: json["extra_id_to"] as String? ?? "",
|
||||||
toTxid: json["tx_to"] as String,
|
toTxid: json["tx_to"] as String,
|
||||||
refundAddress: json["user_refund_address"] as String,
|
refundAddress: json["user_refund_address"] as String,
|
||||||
refundExtraId: json["user_refund_extra_id"] as String,
|
refundExtraId: json["user_refund_extra_id"] as String,
|
||||||
|
@ -346,13 +347,14 @@ class SimpleSwapAPI {
|
||||||
final jsonObject = await _makeGetRequest(uri);
|
final jsonObject = await _makeGetRequest(uri);
|
||||||
|
|
||||||
final json = Map<String, dynamic>.from(jsonObject as Map);
|
final json = Map<String, dynamic>.from(jsonObject as Map);
|
||||||
|
final ts = DateTime.parse(json["timestamp"] as String);
|
||||||
final trade = Trade(
|
final trade = Trade(
|
||||||
uuid: const Uuid().v1(),
|
uuid: const Uuid().v1(),
|
||||||
tradeId: json["id"] as String,
|
tradeId: json["id"] as String,
|
||||||
rateType: json["type"] as String,
|
rateType: json["type"] as String,
|
||||||
direction: "direct",
|
direction: "direct",
|
||||||
timestamp: DateTime.parse(json["timestamp"] as String),
|
timestamp: ts,
|
||||||
updatedAt: DateTime.parse(json["updated_at"] as String),
|
updatedAt: DateTime.tryParse(json["updated_at"] as String? ?? "") ?? ts,
|
||||||
from: json["currency_from"] as String,
|
from: json["currency_from"] as String,
|
||||||
fromAmount: json["amount_from"] as String,
|
fromAmount: json["amount_from"] as String,
|
||||||
fromAddress: json["address_from"] as String,
|
fromAddress: json["address_from"] as String,
|
||||||
|
@ -363,7 +365,7 @@ class SimpleSwapAPI {
|
||||||
toAmount: json["amount_to"] as String,
|
toAmount: json["amount_to"] as String,
|
||||||
toAddress: json["address_to"] as String,
|
toAddress: json["address_to"] as String,
|
||||||
toNetwork: "",
|
toNetwork: "",
|
||||||
toExtraId: json["extra_id_to"] as String,
|
toExtraId: json["extra_id_to"] as String? ?? "",
|
||||||
toTxid: json["tx_to"] as String,
|
toTxid: json["tx_to"] as String,
|
||||||
refundAddress: json["user_refund_address"] as String,
|
refundAddress: json["user_refund_address"] as String,
|
||||||
refundExtraId: json["user_refund_extra_id"] as String,
|
refundExtraId: json["user_refund_extra_id"] as String,
|
||||||
|
|
Loading…
Reference in a new issue