From 69886372660be5e204083e9e05e2dbb789a4c597 Mon Sep 17 00:00:00 2001 From: Serhii Date: Sun, 13 Nov 2022 20:06:45 +0200 Subject: [PATCH 1/4] fix fetching trade state for SideShift --- lib/exchange/sideshift/sideshift_exchange_provider.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/exchange/sideshift/sideshift_exchange_provider.dart b/lib/exchange/sideshift/sideshift_exchange_provider.dart index a732f7ef2..8cd4593c1 100644 --- a/lib/exchange/sideshift/sideshift_exchange_provider.dart +++ b/lib/exchange/sideshift/sideshift_exchange_provider.dart @@ -250,8 +250,10 @@ class SideShiftExchangeProvider extends ExchangeProvider { final deposits = responseJSON['deposits'] as List?; TradeState? state; - if (deposits != null && deposits.isNotEmpty) { - final status = deposits[0]['status'] as String; + if (deposits != null && deposits.isEmpty) { + state = TradeState.deserialize(raw: 'created'); + } else { + final status = deposits?[0]['status'] as String; state = TradeState.deserialize(raw: status); } From 35b7c05bc1650d41b25c3cc67385cd7b5a8caf95 Mon Sep 17 00:00:00 2001 From: Serhii Date: Tue, 6 Dec 2022 11:41:25 +0200 Subject: [PATCH 2/4] fix null check --- .../sideshift/sideshift_exchange_provider.dart | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/exchange/sideshift/sideshift_exchange_provider.dart b/lib/exchange/sideshift/sideshift_exchange_provider.dart index 8cd4593c1..23e506858 100644 --- a/lib/exchange/sideshift/sideshift_exchange_provider.dart +++ b/lib/exchange/sideshift/sideshift_exchange_provider.dart @@ -249,12 +249,14 @@ class SideShiftExchangeProvider extends ExchangeProvider { final expectedSendAmount = responseJSON['depositAmount'].toString(); final deposits = responseJSON['deposits'] as List?; TradeState? state; - - if (deposits != null && deposits.isEmpty) { - state = TradeState.deserialize(raw: 'created'); - } else { - final status = deposits?[0]['status'] as String; - state = TradeState.deserialize(raw: status); + + if (deposits != null) { + if (deposits.isEmpty) { + state = TradeState.deserialize(raw: 'created'); + } else { + final status = deposits[0]['status'] as String; + state = TradeState.deserialize(raw: status); + } } final expiredAtRaw = responseJSON['expiresAtISO'] as String; From f29f17476c0faf16dfc169067841c9b937511d66 Mon Sep 17 00:00:00 2001 From: Serhii Date: Tue, 6 Dec 2022 17:14:07 +0200 Subject: [PATCH 3/4] add null check [skip ci] --- .../sideshift/sideshift_exchange_provider.dart | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/exchange/sideshift/sideshift_exchange_provider.dart b/lib/exchange/sideshift/sideshift_exchange_provider.dart index 23e506858..0cd74061f 100644 --- a/lib/exchange/sideshift/sideshift_exchange_provider.dart +++ b/lib/exchange/sideshift/sideshift_exchange_provider.dart @@ -249,15 +249,12 @@ class SideShiftExchangeProvider extends ExchangeProvider { final expectedSendAmount = responseJSON['depositAmount'].toString(); final deposits = responseJSON['deposits'] as List?; TradeState? state; - - if (deposits != null) { - if (deposits.isEmpty) { - state = TradeState.deserialize(raw: 'created'); - } else { - final status = deposits[0]['status'] as String; - state = TradeState.deserialize(raw: status); - } + String? status; + + if (deposits?.isNotEmpty ?? false) { + status = deposits![0]['status'] as String; } + state = TradeState.deserialize(raw: status ?? 'created'); final expiredAtRaw = responseJSON['expiresAtISO'] as String; final expiredAt = From fa5c705bc888abea53703ca06589e344a63d7ee8 Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Tue, 6 Dec 2022 17:29:44 +0200 Subject: [PATCH 4/4] Add nullability to `status` String [skip ci] --- lib/exchange/sideshift/sideshift_exchange_provider.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/exchange/sideshift/sideshift_exchange_provider.dart b/lib/exchange/sideshift/sideshift_exchange_provider.dart index 0cd74061f..920dc9907 100644 --- a/lib/exchange/sideshift/sideshift_exchange_provider.dart +++ b/lib/exchange/sideshift/sideshift_exchange_provider.dart @@ -252,7 +252,7 @@ class SideShiftExchangeProvider extends ExchangeProvider { String? status; if (deposits?.isNotEmpty ?? false) { - status = deposits![0]['status'] as String; + status = deposits![0]['status'] as String?; } state = TradeState.deserialize(raw: status ?? 'created');