mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-24 11:36:21 +00:00
parent
ed1dc75a3d
commit
95ecf4ef56
1 changed files with 6 additions and 4 deletions
|
@ -35,7 +35,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
|
||||||
@override
|
@override
|
||||||
ExchangeProviderDescription get description =>
|
ExchangeProviderDescription get description =>
|
||||||
ExchangeProviderDescription.simpleSwap;
|
ExchangeProviderDescription.simpleSwap;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<double> calculateAmount(
|
Future<double> calculateAmount(
|
||||||
{required CryptoCurrency from,
|
{required CryptoCurrency from,
|
||||||
|
@ -61,7 +61,6 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
|
||||||
|
|
||||||
if (response.body == null || response.body == "null") return 0.00;
|
if (response.body == null || response.body == "null") return 0.00;
|
||||||
final data = json.decode(response.body) as String;
|
final data = json.decode(response.body) as String;
|
||||||
|
|
||||||
return double.parse(data);
|
return double.parse(data);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
return 0.00;
|
return 0.00;
|
||||||
|
@ -79,7 +78,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
|
||||||
@override
|
@override
|
||||||
Future<Trade> createTrade({required TradeRequest request, required bool isFixedRateMode}) async {
|
Future<Trade> createTrade({required TradeRequest request, required bool isFixedRateMode}) async {
|
||||||
final _request = request as SimpleSwapRequest;
|
final _request = request as SimpleSwapRequest;
|
||||||
final headers = {
|
final headers = {
|
||||||
'Content-Type': 'application/json'};
|
'Content-Type': 'application/json'};
|
||||||
final params = <String, String>{
|
final params = <String, String>{
|
||||||
'api_key': apiKey,
|
'api_key': apiKey,
|
||||||
|
@ -111,7 +110,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
|
||||||
final id = responseJSON['id'] as String;
|
final id = responseJSON['id'] as String;
|
||||||
final inputAddress = responseJSON['address_from'] as String;
|
final inputAddress = responseJSON['address_from'] as String;
|
||||||
final settleAddress = responseJSON['user_refund_address'] as String;
|
final settleAddress = responseJSON['user_refund_address'] as String;
|
||||||
|
final extraId = responseJSON['extra_id_from'] as String?;
|
||||||
return Trade(
|
return Trade(
|
||||||
id: id,
|
id: id,
|
||||||
provider: description,
|
provider: description,
|
||||||
|
@ -119,6 +118,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
|
||||||
to: _request.to,
|
to: _request.to,
|
||||||
inputAddress: inputAddress,
|
inputAddress: inputAddress,
|
||||||
refundAddress: settleAddress,
|
refundAddress: settleAddress,
|
||||||
|
extraId: extraId,
|
||||||
state: TradeState.created,
|
state: TradeState.created,
|
||||||
amount: _request.amount,
|
amount: _request.amount,
|
||||||
createdAt: DateTime.now(),
|
createdAt: DateTime.now(),
|
||||||
|
@ -188,6 +188,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
|
||||||
final to = CryptoCurrency.fromString(toCurrency);
|
final to = CryptoCurrency.fromString(toCurrency);
|
||||||
final inputAddress = responseJSON['address_from'] as String;
|
final inputAddress = responseJSON['address_from'] as String;
|
||||||
final expectedSendAmount = responseJSON['expected_amount'].toString();
|
final expectedSendAmount = responseJSON['expected_amount'].toString();
|
||||||
|
final extraId = responseJSON['extra_id_from'] as String?;
|
||||||
final status = responseJSON['status'] as String;
|
final status = responseJSON['status'] as String;
|
||||||
final state = TradeState.deserialize(raw: status);
|
final state = TradeState.deserialize(raw: status);
|
||||||
|
|
||||||
|
@ -195,6 +196,7 @@ class SimpleSwapExchangeProvider extends ExchangeProvider {
|
||||||
id: id,
|
id: id,
|
||||||
from: from,
|
from: from,
|
||||||
to: to,
|
to: to,
|
||||||
|
extraId: extraId,
|
||||||
provider: description,
|
provider: description,
|
||||||
inputAddress: inputAddress,
|
inputAddress: inputAddress,
|
||||||
amount: expectedSendAmount,
|
amount: expectedSendAmount,
|
||||||
|
|
Loading…
Reference in a new issue