From 79e38dfb93079c95347a8e87d0cd78ff836c6540 Mon Sep 17 00:00:00 2001 From: Dmitry Bespalov Date: Tue, 2 Jul 2024 11:12:52 +0200 Subject: [PATCH 1/2] GH-3435 changed display strings for order types --- .../SCGModels.swift | 32 +++++++++++++++++++ .../TransactionDetailCellBuilder.swift | 12 +++---- .../TransactionListViewController.swift | 8 ++--- ...mingTransactionRequestViewController.swift | 8 ++--- 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/Multisig/Data/Services/Safe Client Gateway Service/SCGModels.swift b/Multisig/Data/Services/Safe Client Gateway Service/SCGModels.swift index 295ca32c2..87efb306d 100644 --- a/Multisig/Data/Services/Safe Client Gateway Service/SCGModels.swift +++ b/Multisig/Data/Services/Safe Client Gateway Service/SCGModels.swift @@ -386,6 +386,38 @@ extension SCGModels { struct SwapOrder: Decodable { var uid: String var explorerUrl: URL + var fullAppData: AppData? + + // limit, twap, market + var orderType: String { + fullAppData?.metadata?.orderClass?.orderClass ?? "market" + } + + var swapOrderDisplayName: String { + orderType == "limit" ? "Limit order" : "Swap order" + } + + var swapTransferDisplayName: String { + switch orderType { + case "limit": return "Limit order settlement" + case "twap": return "TWAP order settlement" + case "liquidity": return "Liquidity order settlement" + case "market": return "Swap order settlement" + default: return "Swap order settlement" + } + } + + struct AppData: Codable { + var metadata: Metadata? + } + + struct Metadata: Codable { + var orderClass: OrderClass? + } + + struct OrderClass: Codable { + var orderClass: String? + } } struct TwapOrder: Codable { diff --git a/Multisig/UI/Transaction/TransactionDetailsViewController/TransactionDetailCellBuilder.swift b/Multisig/UI/Transaction/TransactionDetailsViewController/TransactionDetailCellBuilder.swift index 9b5ae70e5..14e3becaf 100644 --- a/Multisig/UI/Transaction/TransactionDetailsViewController/TransactionDetailCellBuilder.swift +++ b/Multisig/UI/Transaction/TransactionDetailsViewController/TransactionDetailCellBuilder.swift @@ -375,10 +375,10 @@ class TransactionDetailCellBuilder { rejectionHeader(nonce: nil, isQueued: tx.txStatus.isInQueue) } case .swapOrder(let orderInfo): - text("Swap order", title: "Contract Interaction", expandableTitle: nil, copyText: nil) + text(orderInfo.swapOrderDisplayName, title: "Contract Interaction", expandableTitle: nil, copyText: nil) externalURL(text: "Order details", url: orderInfo.explorerUrl) case .swapTransfer(let orderInfo): - text("Swap transfer", title: "Contract Interaction", expandableTitle: nil, copyText: nil) + text(orderInfo.swapTransferDisplayName, title: "Contract Interaction", expandableTitle: nil, copyText: nil) externalURL(text: "Order details", url: orderInfo.explorerUrl) case .twapOrder(_): text("Twap order", title: "Contract Interaction", expandableTitle: nil, copyText: nil) @@ -666,11 +666,11 @@ class TransactionDetailCellBuilder { case .creation(_): type = "Safe Account created" icon = UIImage(named: "ico-settings-tx") - case .swapOrder(_): - type = "Swap order" + case .swapOrder(let order): + type = order.swapOrderDisplayName icon = UIImage(named: "ico-custom-tx") - case .swapTransfer(_): - type = "Swap transfer" + case .swapTransfer(let order): + type = order.swapTransferDisplayName icon = UIImage(named: "ico-custom-tx") case .twapOrder(_): type = "Twap order" diff --git a/Multisig/UI/Transaction/TransactionListViewController/TransactionListViewController.swift b/Multisig/UI/Transaction/TransactionListViewController/TransactionListViewController.swift index 57896820f..776e0ab8f 100644 --- a/Multisig/UI/Transaction/TransactionListViewController/TransactionListViewController.swift +++ b/Multisig/UI/Transaction/TransactionListViewController/TransactionListViewController.swift @@ -365,12 +365,12 @@ class TransactionListViewController: LoadableViewController, UITableViewDelegate case .creation(_): image = UIImage(named: "ico-settings-tx") title = "Safe Account created" - case .swapOrder(_): + case .swapOrder(let order): image = UIImage(named: "ico-custom-tx") - title = "Swap order" - case .swapTransfer(_): + title = order.swapOrderDisplayName + case .swapTransfer(let order): image = UIImage(named: "ico-custom-tx") - title = "Swap transfer" + title = order.swapTransferDisplayName case .twapOrder(_): image = UIImage(named: "ico-custom-tx") title = "Twap order" diff --git a/Multisig/UI/WalletConnect/Server/Safes/Incoming Transaction/WCIncomingTransactionRequestViewController.swift b/Multisig/UI/WalletConnect/Server/Safes/Incoming Transaction/WCIncomingTransactionRequestViewController.swift index 85845f395..ccaa1c828 100644 --- a/Multisig/UI/WalletConnect/Server/Safes/Incoming Transaction/WCIncomingTransactionRequestViewController.swift +++ b/Multisig/UI/WalletConnect/Server/Safes/Incoming Transaction/WCIncomingTransactionRequestViewController.swift @@ -137,12 +137,12 @@ class WCIncomingTransactionRequestViewController: ReviewSafeTransactionViewContr case .creation(_): imageName = "ico-settings-tx" name = "Safe Account created" - case .swapOrder(_): + case .swapOrder(let order): imageName = "ico-custom-tx" - name = "Swap order" - case .swapTransfer(_): + name = order.swapOrderDisplayName + case .swapTransfer(let order): imageName = "ico-custom-tx" - name = "Swap transfer" + name = order.swapTransferDisplayName case .twapOrder(_): imageName = "ico-custom-tx" name = "Twap transfer" From 15b424a4f212d51e3bf2fc46ebc5fddc70376fe6 Mon Sep 17 00:00:00 2001 From: Dmitry Bespalov Date: Tue, 2 Jul 2024 11:18:19 +0200 Subject: [PATCH 2/2] GH-3435 move string to a property --- .../Services/Safe Client Gateway Service/SCGModels.swift | 1 + .../TransactionDetailCellBuilder.swift | 8 ++++---- .../TransactionListViewController.swift | 4 ++-- .../WCIncomingTransactionRequestViewController.swift | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Multisig/Data/Services/Safe Client Gateway Service/SCGModels.swift b/Multisig/Data/Services/Safe Client Gateway Service/SCGModels.swift index 87efb306d..c9504fb24 100644 --- a/Multisig/Data/Services/Safe Client Gateway Service/SCGModels.swift +++ b/Multisig/Data/Services/Safe Client Gateway Service/SCGModels.swift @@ -423,6 +423,7 @@ extension SCGModels { struct TwapOrder: Codable { var kind: String var status: String + var displayName: String { "Twap order" } } } diff --git a/Multisig/UI/Transaction/TransactionDetailsViewController/TransactionDetailCellBuilder.swift b/Multisig/UI/Transaction/TransactionDetailsViewController/TransactionDetailCellBuilder.swift index 14e3becaf..91515250e 100644 --- a/Multisig/UI/Transaction/TransactionDetailsViewController/TransactionDetailCellBuilder.swift +++ b/Multisig/UI/Transaction/TransactionDetailsViewController/TransactionDetailCellBuilder.swift @@ -380,8 +380,8 @@ class TransactionDetailCellBuilder { case .swapTransfer(let orderInfo): text(orderInfo.swapTransferDisplayName, title: "Contract Interaction", expandableTitle: nil, copyText: nil) externalURL(text: "Order details", url: orderInfo.explorerUrl) - case .twapOrder(_): - text("Twap order", title: "Contract Interaction", expandableTitle: nil, copyText: nil) + case .twapOrder(let order): + text(order.displayName, title: "Contract Interaction", expandableTitle: nil, copyText: nil) case .creation(_): // ignore fallthrough @@ -672,8 +672,8 @@ class TransactionDetailCellBuilder { case .swapTransfer(let order): type = order.swapTransferDisplayName icon = UIImage(named: "ico-custom-tx") - case .twapOrder(_): - type = "Twap order" + case .twapOrder(let order): + type = order.displayName icon = UIImage(named: "ico-custom-tx") case .unknown: type = "Unknown operation" diff --git a/Multisig/UI/Transaction/TransactionListViewController/TransactionListViewController.swift b/Multisig/UI/Transaction/TransactionListViewController/TransactionListViewController.swift index 776e0ab8f..edd619609 100644 --- a/Multisig/UI/Transaction/TransactionListViewController/TransactionListViewController.swift +++ b/Multisig/UI/Transaction/TransactionListViewController/TransactionListViewController.swift @@ -371,9 +371,9 @@ class TransactionListViewController: LoadableViewController, UITableViewDelegate case .swapTransfer(let order): image = UIImage(named: "ico-custom-tx") title = order.swapTransferDisplayName - case .twapOrder(_): + case .twapOrder(let order): image = UIImage(named: "ico-custom-tx") - title = "Twap order" + title = order.displayName case .unknown: image = UIImage(named: "ico-custom-tx") title = "Unknown operation" diff --git a/Multisig/UI/WalletConnect/Server/Safes/Incoming Transaction/WCIncomingTransactionRequestViewController.swift b/Multisig/UI/WalletConnect/Server/Safes/Incoming Transaction/WCIncomingTransactionRequestViewController.swift index ccaa1c828..d72957f08 100644 --- a/Multisig/UI/WalletConnect/Server/Safes/Incoming Transaction/WCIncomingTransactionRequestViewController.swift +++ b/Multisig/UI/WalletConnect/Server/Safes/Incoming Transaction/WCIncomingTransactionRequestViewController.swift @@ -143,9 +143,9 @@ class WCIncomingTransactionRequestViewController: ReviewSafeTransactionViewContr case .swapTransfer(let order): imageName = "ico-custom-tx" name = order.swapTransferDisplayName - case .twapOrder(_): + case .twapOrder(let order): imageName = "ico-custom-tx" - name = "Twap transfer" + name = order.displayName case .unknown: imageName = "ico-custom-tx" name = "Unknown operation"