Skip to content

Commit

Permalink
Merge pull request #3436 from safe-global/GH-3435/limit-order-type
Browse files Browse the repository at this point in the history
GH-3435 changed display strings for order types
  • Loading branch information
DmitryBespalov authored Jul 2, 2024
2 parents f0d31c8 + 15b424a commit 09f8f0f
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 22 deletions.
33 changes: 33 additions & 0 deletions Multisig/Data/Services/Safe Client Gateway Service/SCGModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,44 @@ 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 {
var kind: String
var status: String
var displayName: String { "Twap order" }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,13 @@ 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)
case .twapOrder(let order):
text(order.displayName, title: "Contract Interaction", expandableTitle: nil, copyText: nil)
case .creation(_):
// ignore
fallthrough
Expand Down Expand Up @@ -666,14 +666,14 @@ 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"
case .twapOrder(let order):
type = order.displayName
icon = UIImage(named: "ico-custom-tx")
case .unknown:
type = "Unknown operation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,15 @@ 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"
case .twapOrder(_):
title = order.swapTransferDisplayName
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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ 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"
case .twapOrder(_):
name = order.swapTransferDisplayName
case .twapOrder(let order):
imageName = "ico-custom-tx"
name = "Twap transfer"
name = order.displayName
case .unknown:
imageName = "ico-custom-tx"
name = "Unknown operation"
Expand Down

0 comments on commit 09f8f0f

Please sign in to comment.