From ae96213aadcc209b851a5f3ab37c42e8ca9762c6 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Mon, 22 Feb 2021 18:04:37 +0200 Subject: [PATCH] CAKE-278 | added expireAt to Trade() for exchange with fixed rate --- .../changenow_exchange_provider.dart | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/lib/exchange/changenow/changenow_exchange_provider.dart b/lib/exchange/changenow/changenow_exchange_provider.dart index 832eee88f..02e6d9f7c 100644 --- a/lib/exchange/changenow/changenow_exchange_provider.dart +++ b/lib/exchange/changenow/changenow_exchange_provider.dart @@ -153,17 +153,35 @@ class ChangeNowExchangeProvider extends ExchangeProvider { final state = TradeState.deserialize(raw: status); final extraId = responseJSON['payinExtraId'] as String; final outputTransaction = responseJSON['payoutHash'] as String; + final expiredAtRaw = responseJSON['validUntil'] as String; + final expiredAt = expiredAtRaw != null + ? DateTime.parse(expiredAtRaw).toLocal() + : null; - return Trade( - id: id, - from: from, - to: to, - provider: description, - inputAddress: inputAddress, - amount: expectedSendAmount, - state: state, - extraId: extraId, - outputTransaction: outputTransaction); + if (expiredAt != null) { + return Trade( + id: id, + from: from, + to: to, + provider: description, + inputAddress: inputAddress, + amount: expectedSendAmount, + state: state, + extraId: extraId, + expiredAt: expiredAt, + outputTransaction: outputTransaction); + } else { + return Trade( + id: id, + from: from, + to: to, + provider: description, + inputAddress: inputAddress, + amount: expectedSendAmount, + state: state, + extraId: extraId, + outputTransaction: outputTransaction); + } } @override