mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-24 19:25:52 +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,
|
||||
);
|
||||
}
|
||||
|
||||
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);
|
||||
print("PARSED: $parsed");
|
||||
|
||||
return parsed;
|
||||
} catch (e, s) {
|
||||
|
@ -81,14 +82,14 @@ class SimpleSwapAPI {
|
|||
String? extraIdTo,
|
||||
String? apiKey,
|
||||
}) async {
|
||||
Map<String, String> body = {
|
||||
"fixed": isFixedRate.toString(),
|
||||
Map<String, dynamic> body = {
|
||||
"fixed": isFixedRate,
|
||||
"currency_from": currencyFrom,
|
||||
"currency_to": currencyTo,
|
||||
"addressTo": addressTo,
|
||||
"userRefundAddress": userRefundAddress,
|
||||
"userRefundExtraId": userRefundExtraId,
|
||||
"amount": amount,
|
||||
"amount": double.parse(amount),
|
||||
};
|
||||
|
||||
final uri =
|
||||
|
@ -118,7 +119,7 @@ class SimpleSwapAPI {
|
|||
toAmount: json["amount_to"] as String,
|
||||
toAddress: json["address_to"] as String,
|
||||
toNetwork: "",
|
||||
toExtraId: json["extra_id_to"] as String,
|
||||
toExtraId: json["extra_id_to"] as String? ?? "",
|
||||
toTxid: json["tx_to"] as String,
|
||||
refundAddress: json["user_refund_address"] as String,
|
||||
refundExtraId: json["user_refund_extra_id"] as String,
|
||||
|
@ -346,13 +347,14 @@ class SimpleSwapAPI {
|
|||
final jsonObject = await _makeGetRequest(uri);
|
||||
|
||||
final json = Map<String, dynamic>.from(jsonObject as Map);
|
||||
final ts = DateTime.parse(json["timestamp"] as String);
|
||||
final trade = Trade(
|
||||
uuid: const Uuid().v1(),
|
||||
tradeId: json["id"] as String,
|
||||
rateType: json["type"] as String,
|
||||
direction: "direct",
|
||||
timestamp: DateTime.parse(json["timestamp"] as String),
|
||||
updatedAt: DateTime.parse(json["updated_at"] as String),
|
||||
timestamp: ts,
|
||||
updatedAt: DateTime.tryParse(json["updated_at"] as String? ?? "") ?? ts,
|
||||
from: json["currency_from"] as String,
|
||||
fromAmount: json["amount_from"] as String,
|
||||
fromAddress: json["address_from"] as String,
|
||||
|
@ -363,7 +365,7 @@ class SimpleSwapAPI {
|
|||
toAmount: json["amount_to"] as String,
|
||||
toAddress: json["address_to"] as String,
|
||||
toNetwork: "",
|
||||
toExtraId: json["extra_id_to"] as String,
|
||||
toExtraId: json["extra_id_to"] as String? ?? "",
|
||||
toTxid: json["tx_to"] as String,
|
||||
refundAddress: json["user_refund_address"] as String,
|
||||
refundExtraId: json["user_refund_extra_id"] as String,
|
||||
|
|
Loading…
Reference in a new issue