commit 17e0e92b012c3fe08c6bb58b3f3044fe0df93d58
parent 2f0716816f4c25cbd52111eefaba4b69e9e3e8d8
Author: Marc Stibane <marc@taler.net>
Date: Thu, 8 Feb 2024 17:46:38 +0100
static func <
Diffstat:
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/TalerWallet1/Backend/WalletBackendRequest.swift b/TalerWallet1/Backend/WalletBackendRequest.swift
@@ -34,6 +34,30 @@ struct ScopeInfo: Codable, Hashable {
var url: String? // only for "exchange"
var currency: String // 3-char ISO 4217 code for global currency. Regional MUST be >= 4 letters
+ public static func < (lhs: ScopeInfo, rhs: ScopeInfo) -> Bool {
+ if lhs.type == .global {
+ if rhs.type == .global { // both global ==> alphabetic currency
+ return lhs.currency < rhs.currency
+ }
+ return true // global comes first
+ }
+ if rhs.type == .global {
+ return false // global comes first
+ }
+ if lhs.currency == rhs.currency {
+ if let lhsBaseURL = lhs.url {
+ if let rhsBaseURL = rhs.url {
+ return lhsBaseURL < rhsBaseURL
+ }
+ return true
+ }
+ if let rhsBaseURL = rhs.url {
+ return false
+ }
+ // fall thru
+ }
+ return lhs.currency < rhs.currency
+ }
public static func == (lhs: ScopeInfo, rhs: ScopeInfo) -> Bool {
if let lhsBaseURL = lhs.url {
if let rhsBaseURL = rhs.url {
diff --git a/TalerWallet1/Model/Model+Exchange.swift b/TalerWallet1/Model/Model+Exchange.swift
@@ -29,6 +29,15 @@ enum ExchangeUpdateStatus: String, Codable {
// MARK: -
/// The result from wallet-core's ListExchanges
struct Exchange: Codable, Hashable, Identifiable {
+ static func < (lhs: Exchange, rhs: Exchange) -> Bool {
+ if let leftScope = lhs.scopeInfo {
+ if let rightScope = rhs.scopeInfo {
+ return leftScope < rightScope
+ }
+ return true // scopeInfo comes first
+ }
+ return false
+ }
static func == (lhs: Exchange, rhs: Exchange) -> Bool {
return lhs.exchangeBaseUrl == rhs.exchangeBaseUrl
&& lhs.tosStatus == rhs.tosStatus