From 58227c40be613f8e423bf61bea9babbd89d06390 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 3 Mar 2023 11:56:21 -0600 Subject: [PATCH 1/2] mb order status fixes --- lib/pages/exchange_view/trade_details_view.dart | 13 ++++++++++--- .../desktop_exchange/desktop_all_trades_view.dart | 14 ++++++++++++-- lib/utilities/theme/stack_colors.dart | 1 + lib/widgets/trade_card.dart | 14 ++++++++++++-- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/lib/pages/exchange_view/trade_details_view.dart b/lib/pages/exchange_view/trade_details_view.dart index 662ed6922..2e9c3d112 100644 --- a/lib/pages/exchange_view/trade_details_view.dart +++ b/lib/pages/exchange_view/trade_details_view.dart @@ -116,9 +116,16 @@ class _TradeDetailsViewState extends ConsumerState { } status = changeNowTransactionStatusFromStringIgnoreCase(statusString); } on ArgumentError catch (_) { - status = ChangeNowTransactionStatus.Failed; - if (statusString == "Processing payment") { - status = ChangeNowTransactionStatus.Sending; + switch (statusString.toLowerCase()) { + case "funds confirming": + case "processing payment": + return Assets.svg.txExchangePending(context); + + case "completed": + return Assets.svg.txExchange(context); + + default: + status = ChangeNowTransactionStatus.Failed; } } diff --git a/lib/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart b/lib/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart index 7dd6578c3..d4e79c42a 100644 --- a/lib/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart +++ b/lib/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart @@ -290,11 +290,21 @@ class _DesktopTradeRowCardState extends ConsumerState { ChangeNowTransactionStatus? status; try { if (statusString.toLowerCase().startsWith("waiting")) { - statusString = "waiting"; + statusString = "Waiting"; } status = changeNowTransactionStatusFromStringIgnoreCase(statusString); } on ArgumentError catch (_) { - status = ChangeNowTransactionStatus.Failed; + switch (statusString.toLowerCase()) { + case "funds confirming": + case "processing payment": + return Assets.svg.txExchangePending(context); + + case "completed": + return Assets.svg.txExchange(context); + + default: + status = ChangeNowTransactionStatus.Failed; + } } switch (status) { diff --git a/lib/utilities/theme/stack_colors.dart b/lib/utilities/theme/stack_colors.dart index bc26c3f80..d0ba2cd40 100644 --- a/lib/utilities/theme/stack_colors.dart +++ b/lib/utilities/theme/stack_colors.dart @@ -1603,6 +1603,7 @@ class StackColors extends ThemeExtension { return const Color(0xFFD3A90F); case "Finished": case "finished": + case "Completed": return accentColorGreen; case "Failed": case "failed": diff --git a/lib/widgets/trade_card.dart b/lib/widgets/trade_card.dart index 5a14a0777..f4162fc5e 100644 --- a/lib/widgets/trade_card.dart +++ b/lib/widgets/trade_card.dart @@ -25,11 +25,21 @@ class TradeCard extends ConsumerWidget { ChangeNowTransactionStatus? status; try { if (statusString.toLowerCase().startsWith("waiting")) { - statusString = "waiting"; + statusString = "Waiting"; } status = changeNowTransactionStatusFromStringIgnoreCase(statusString); } on ArgumentError catch (_) { - status = ChangeNowTransactionStatus.Failed; + switch (statusString.toLowerCase()) { + case "funds confirming": + case "processing payment": + return Assets.svg.txExchangePending(context); + + case "completed": + return Assets.svg.txExchange(context); + + default: + status = ChangeNowTransactionStatus.Failed; + } } switch (status) { From 40ca565d54c3bf66b10f4a3460162624cbd2a7ff Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 3 Mar 2023 14:46:53 -0600 Subject: [PATCH 2/2] mb order status util and extra logging --- .../exchange/majestic_bank/mb_order_status.dart | 17 +++++++++++++---- .../majestic_bank/majestic_bank_api.dart | 6 ++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/models/exchange/majestic_bank/mb_order_status.dart b/lib/models/exchange/majestic_bank/mb_order_status.dart index 5496aa5e2..030fe1ddf 100644 --- a/lib/models/exchange/majestic_bank/mb_order_status.dart +++ b/lib/models/exchange/majestic_bank/mb_order_status.dart @@ -24,9 +24,18 @@ class MBOrderStatus extends MBObject { final Decimal received; final Decimal confirmed; + Map toMap() => { + "orderId": orderId, + "status": status, + "fromCurrency": fromCurrency, + "fromAmount": fromAmount, + "receiveCurrency": receiveCurrency, + "receiveAmount": receiveAmount, + "address": address, + "received": received, + "confirmed": confirmed, + }; + @override - String toString() { - // todo: full toString - return status; - } + String toString() => toMap().toString(); } diff --git a/lib/services/exchange/majestic_bank/majestic_bank_api.dart b/lib/services/exchange/majestic_bank/majestic_bank_api.dart index 1aa2394c9..e2445e2e1 100644 --- a/lib/services/exchange/majestic_bank/majestic_bank_api.dart +++ b/lib/services/exchange/majestic_bank/majestic_bank_api.dart @@ -349,8 +349,10 @@ class MajesticBankAPI { return ExchangeResponse(value: status); } catch (e, s) { - Logging.instance - .log("createOrder exception: $e\n$s", level: LogLevel.Error); + Logging.instance.log( + "trackOrder exception when trying to parse $json: $e\n$s", + level: LogLevel.Error, + ); return ExchangeResponse( exception: ExchangeException( e.toString(),