commit cb080273b802e82f683c0616ccd6835875234a3b
parent f54e0f8551db654c7ed4b064840755209ce5fece
Author: Marc Stibane <marc@taler.net>
Date: Mon, 18 Sep 2023 08:43:58 +0200
Sendable for Swift 6
Diffstat:
5 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/TalerWallet.xcodeproj/project.pbxproj b/TalerWallet.xcodeproj/project.pbxproj
@@ -1376,6 +1376,7 @@
SDKROOT = iphoneos;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
};
name = Debug;
@@ -1430,6 +1431,7 @@
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
+ SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
VALIDATE_PRODUCT = YES;
};
diff --git a/TalerWallet1/Backend/Transaction.swift b/TalerWallet1/Backend/Transaction.swift
@@ -142,7 +142,7 @@ enum TransactionType: String, Codable {
var isIncoming : Bool { isP2pIncoming || isWithdrawal || isRefund || isReward }
}
-struct TransactionCommon: Decodable {
+struct TransactionCommon: Decodable, Sendable {
var type: TransactionType
var txState: TransactionState
var amountEffective: Amount
@@ -222,7 +222,7 @@ struct WithdrawalTransactionDetails: Decodable {
var withdrawalDetails: WithdrawalDetails
}
-struct WithdrawalTransaction {
+struct WithdrawalTransaction : Sendable{
var common: TransactionCommon
var details: WithdrawalTransactionDetails
}
@@ -237,7 +237,7 @@ struct PaymentTransactionDetails: Decodable {
var info: OrderShortInfo
}
-struct PaymentTransaction {
+struct PaymentTransaction : Sendable{
var common: TransactionCommon
var details: PaymentTransactionDetails
}
@@ -250,7 +250,7 @@ struct RefundTransactionDetails: Decodable {
var info: OrderShortInfo? // TODO: is this still here?
}
-struct RefundTransaction {
+struct RefundTransaction : Sendable{
var common: TransactionCommon
var details: RefundTransactionDetails
}
@@ -260,7 +260,7 @@ struct RewardTransactionDetails: Decodable {
var exchangeBaseUrl: String
}
-struct RewardTransaction {
+struct RewardTransaction : Sendable{
var common: TransactionCommon
var details: RewardTransactionDetails
}
@@ -285,32 +285,32 @@ struct RefreshTransactionDetails: Decodable {
var refreshOutputAmount: Amount
}
-struct RefreshTransaction {
+struct RefreshTransaction : Sendable{
var common: TransactionCommon
var details: RefreshTransactionDetails
}
-struct P2pShortInfo: Codable {
+struct P2pShortInfo: Codable, Sendable {
var summary: String
var expiration: Timestamp
}
-struct P2PTransactionDetails: Codable {
+struct P2PTransactionDetails: Codable, Sendable {
var exchangeBaseUrl: String
var talerUri: String? // only if we initiated the transaction
var info: P2pShortInfo
}
-struct P2PTransaction {
+struct P2PTransaction : Sendable{
var common: TransactionCommon
var details: P2PTransactionDetails
}
-struct DummyTransaction {
+struct DummyTransaction : Sendable{
var common: TransactionCommon
}
-enum Transaction: Decodable, Hashable, Identifiable {
+enum Transaction: Decodable, Hashable, Identifiable, Sendable {
case dummy (DummyTransaction)
case withdrawal (WithdrawalTransaction)
case payment (PaymentTransaction)
diff --git a/TalerWallet1/Model/Model+Balances.swift b/TalerWallet1/Model/Model+Balances.swift
@@ -8,7 +8,7 @@ fileprivate let ASYNCDELAY: UInt = 0 //set e.g to 6 or 9 seconds for debugging
// MARK: -
/// A currency balance
-struct Balance: Decodable, Hashable {
+struct Balance: Decodable, Hashable, Sendable {
var available: Amount
var scopeInfo: ScopeInfo
var requiresUserInput: Bool
@@ -36,7 +36,7 @@ fileprivate struct Balances: WalletBackendFormattedRequest {
struct Args: Encodable {} // no arguments needed
- struct Response: Decodable { // list of balances
+ struct Response: Decodable, Sendable { // list of balances
var balances: [Balance]
}
}
diff --git a/taler-swift/Sources/taler-swift/Amount.swift b/taler-swift/Sources/taler-swift/Amount.swift
@@ -38,15 +38,15 @@ enum AmountError: Error {
case divideByZero
}
-public struct ScopedCurrencyInfo: Codable {
- var decimalSeparator: String
- var numFractionalDigits: Int // 0 Yen, 2 €,$, 3 arabic
- var numTinyDigits: Int // SuperScriptDigits
- var isCurrencyNameLeading: Bool
+public struct ScopedCurrencyInfo: Codable, Sendable {
+ let decimalSeparator: String
+ let numFractionalDigits: Int // 0 Yen, 2 €,$, 3 arabic
+ let numTinyDigits: Int // SuperScriptDigits
+ let isCurrencyNameLeading: Bool
}
/// A value of some currency.
-public class Amount: Codable, Hashable, CustomStringConvertible {
+public final class Amount: Codable, Hashable, @unchecked Sendable, CustomStringConvertible { // TODO: @unchecked
/// Format that a currency must match.
private static let currencyRegex = #"^[-_*A-Za-z0-9]{1,12}$"#
diff --git a/taler-swift/Sources/taler-swift/Time.swift b/taler-swift/Sources/taler-swift/Time.swift
@@ -17,7 +17,7 @@ enum TimestampError: Error {
}
/// A point in time, represented by milliseconds from January 1, 1970..
-public enum Timestamp: Codable, Hashable {
+public enum Timestamp: Codable, Hashable, Sendable {
case milliseconds(UInt64)
case never