From 03690ba20e52d681853d59fc81635cca39b76abd Mon Sep 17 00:00:00 2001 From: Alexander Cyon <116169792+CyonAlexRDX@users.noreply.github.com> Date: Wed, 21 Feb 2024 22:16:47 +0100 Subject: [PATCH] fix broken Swift (#12) --- apple/Sources/Sargon/Address.swift | 91 ++++ .../Methods/Addresses+Wrap+Functions.swift | 457 +----------------- .../AccessControllerAddress+Swiftified.swift | 38 ++ .../Swiftified/Account+Swiftified.swift | 4 +- .../AccountAddress+Swiftified.swift | 42 +- .../Swiftified/AppearanceID+Swiftified.swift | 2 +- .../ComponentAddress+Swiftified.swift | 37 ++ .../Swiftified/Decimal192+Swiftified.swift | 3 +- .../Swiftified/DisplayName+Swiftified.swift | 10 +- .../IdentityAddress+Swiftified.swift | 42 ++ .../Swiftified/LocaleConfig+Swiftified.swift | 2 +- .../Swiftified/Mnemonic+Swiftified.swift | 2 +- .../Swiftified/NetworkID+Swiftified.swift | 2 +- .../PackageAddress+Swiftified.swift | 34 ++ .../Swiftified/PoolAddress+Swiftified.swift | 39 ++ .../Swiftified/Profile+Swiftified.swift | 2 +- .../ResourceAddress+Swiftified.swift | 53 ++ .../Swiftified/SargonError+Swiftified.swift | 4 +- .../ValidatorAddress+Swiftified.swift | 46 ++ .../Swiftified/VaultAddress+Swiftified.swift | 46 ++ .../Swiftified/Wallet+Swiftified.swift | 2 +- 21 files changed, 487 insertions(+), 471 deletions(-) create mode 100644 apple/Sources/Sargon/Address.swift create mode 100644 apple/Sources/Sargon/Extensions/Swiftified/AccessControllerAddress+Swiftified.swift create mode 100644 apple/Sources/Sargon/Extensions/Swiftified/ComponentAddress+Swiftified.swift create mode 100644 apple/Sources/Sargon/Extensions/Swiftified/IdentityAddress+Swiftified.swift create mode 100644 apple/Sources/Sargon/Extensions/Swiftified/PackageAddress+Swiftified.swift create mode 100644 apple/Sources/Sargon/Extensions/Swiftified/PoolAddress+Swiftified.swift create mode 100644 apple/Sources/Sargon/Extensions/Swiftified/ResourceAddress+Swiftified.swift create mode 100644 apple/Sources/Sargon/Extensions/Swiftified/ValidatorAddress+Swiftified.swift create mode 100644 apple/Sources/Sargon/Extensions/Swiftified/VaultAddress+Swiftified.swift diff --git a/apple/Sources/Sargon/Address.swift b/apple/Sources/Sargon/Address.swift new file mode 100644 index 000000000..b0dcc320c --- /dev/null +++ b/apple/Sources/Sargon/Address.swift @@ -0,0 +1,91 @@ + +#if DEBUG + /// TODO: Declare in Rust land? Make non-DEBUG? + public enum Address: Hashable, Equatable, Sendable { + case accesscontroller(AccessControllerAddress) + case account(AccountAddress) + case component(ComponentAddress) + case identity(IdentityAddress) + case package(PackageAddress) + case pool(PoolAddress) + case resource(ResourceAddress) + case validator(ValidatorAddress) + case vault(VaultAddress) + } + extension Address: AddressProtocol { + public init(validatingAddress bech32String: String) throws { + if let address = try? AccessControllerAddress( + validatingAddress: bech32String) + { + self = .accesscontroller(address) + } else if let address = try? AccountAddress(validatingAddress: bech32String) + { + self = .account(address) + } else if let address = try? ComponentAddress( + validatingAddress: bech32String) + { + self = .component(address) + } else if let address = try? IdentityAddress( + validatingAddress: bech32String) + { + self = .identity(address) + } else if let address = try? PackageAddress(validatingAddress: bech32String) + { + self = .package(address) + } else if let address = try? PoolAddress(validatingAddress: bech32String) { + self = .pool(address) + } else if let address = try? ResourceAddress( + validatingAddress: bech32String) + { + self = .resource(address) + } else if let address = try? ValidatorAddress( + validatingAddress: bech32String) + { + self = .validator(address) + } else if let address = try? VaultAddress(validatingAddress: bech32String) { + self = .vault(address) + } else { + struct UnknownAddressType: Swift.Error {} + throw UnknownAddressType() + } + } + + public var networkID: NetworkID { + property(\.networkID) + } + + public var address: String { + property(\.address) + } + + private func property(_ keyPath: KeyPath) + -> Property + { + switch self { + case let .accesscontroller(address): address[keyPath: keyPath] + case let .account(address): address[keyPath: keyPath] + case let .component(address): address[keyPath: keyPath] + case let .identity(address): address[keyPath: keyPath] + case let .package(address): address[keyPath: keyPath] + case let .pool(address): address[keyPath: keyPath] + case let .resource(address): address[keyPath: keyPath] + case let .validator(address): address[keyPath: keyPath] + case let .vault(address): address[keyPath: keyPath] + } + } + } + extension Address: CaseIterable { + public typealias AllCases = [Self] + public static var allCases: AllCases { + AccountAddress.allCases.map(Self.account) + + AccessControllerAddress.allCases.map(Self.accesscontroller) + + ComponentAddress.allCases.map(Self.component) + + IdentityAddress.allCases.map(Self.identity) + + PackageAddress.allCases.map(Self.package) + + PoolAddress.allCases.map(Self.pool) + + ResourceAddress.allCases.map(Self.resource) + + ValidatorAddress.allCases.map(Self.validator) + + VaultAddress.allCases.map(Self.vault) + } + } +#endif diff --git a/apple/Sources/Sargon/Extensions/Methods/Addresses+Wrap+Functions.swift b/apple/Sources/Sargon/Extensions/Methods/Addresses+Wrap+Functions.swift index 142532e1f..81377d7de 100644 --- a/apple/Sources/Sargon/Extensions/Methods/Addresses+Wrap+Functions.swift +++ b/apple/Sources/Sargon/Extensions/Methods/Addresses+Wrap+Functions.swift @@ -1,4 +1,4 @@ -public protocol AddressProtocol: Sendable, CustomStringConvertible { +public protocol AddressProtocol: CustomStringConvertible { init(validatingAddress bech32String: String) throws var networkID: NetworkID { get } var address: String { get } @@ -58,45 +58,6 @@ extension AccountAddress: EntityAddressProtocol { accountAddressToShort(address: self) } } -#if DEBUG - extension AccountAddress { - /// Namespace for preview values of `AccountAddress` - public struct Preview { - fileprivate init() {} - public static let of = Self() - - public let mainnet: AccountAddress = newAccountAddressPlaceholderMainnet() - public let mainnetOther: AccountAddress = - newAccountAddressPlaceholderMainnetOther() - - public let stokenet: AccountAddress = newAccountAddressPlaceholderStokenet() - public let stokenetOther: AccountAddress = - newAccountAddressPlaceholderStokenetOther() - } - - /// Preview values for `AccountAddress`, e.g.: - /// `AccountAddress.preview.mainnet` - /// or - /// `AccountAddress.preview.stokenetOther` - public static let preview = Preview.of - } -#endif - -#if DEBUG - extension AccountAddress: CaseIterable { - public typealias AllCases = [Self] - public static var allCases: AllCases { - let of = Preview.of - return [ - of.mainnet, - of.mainnetOther, - of.stokenet, - of.stokenetOther, - ] - } - } -#endif - extension IdentityAddress: EntityAddressProtocol { public init(validatingAddress bech32String: String) throws { self = try newIdentityAddress(bech32: bech32String) @@ -119,46 +80,6 @@ extension IdentityAddress: EntityAddressProtocol { } } -#if DEBUG - extension IdentityAddress { - /// Namespace for preview values of `IdentityAddress` - public struct Preview { - fileprivate init() {} - public static let of = Self() - - public let mainnet: IdentityAddress = newIdentityAddressPlaceholderMainnet() - public let mainnetOther: IdentityAddress = - newIdentityAddressPlaceholderMainnetOther() - - public let stokenet: IdentityAddress = - newIdentityAddressPlaceholderStokenet() - public let stokenetOther: IdentityAddress = - newIdentityAddressPlaceholderStokenetOther() - } - - /// Preview values for `IdentityAddress`, e.g.: - /// `IdentityAddress.preview.mainnet` - /// or - /// `IdentityAddress.preview.stokenetOther` - public static let preview = Preview.of - } -#endif - -#if DEBUG - extension IdentityAddress: CaseIterable { - public typealias AllCases = [Self] - public static var allCases: AllCases { - let of = Preview.of - return [ - of.mainnet, - of.mainnetOther, - of.stokenet, - of.stokenetOther, - ] - } - } -#endif - extension PackageAddress: AddressProtocol { public init(validatingAddress bech32String: String) throws { self = try newPackageAddress(bech32: bech32String) @@ -174,40 +95,6 @@ extension PackageAddress: AddressProtocol { } } - -#if DEBUG - extension PackageAddress { - /// Namespace for preview values of `PackageAddress` - public struct Preview { - fileprivate init() {} - public static let of = Self() - - public let first: PackageAddress = newPackageAddressPlaceholder() - public let second: PackageAddress = newPackageAddressPlaceholderOther() - } - - /// Preview values for `PackageAddress`, e.g.: - /// `PackageAddress.preview.first` - /// or - /// `PackageAddress.preview.second` - public static let preview = Preview.of - } -#endif - -#if DEBUG - extension PackageAddress: CaseIterable { - public typealias AllCases = [Self] - public static var allCases: AllCases { - let of = Preview.of - return [ - of.first, - of.second, - ] - } - } -#endif - - extension ResourceAddress: AddressProtocol { public init(validatingAddress bech32String: String) throws { self = try newResourceAddress(bech32: bech32String) @@ -233,148 +120,6 @@ extension ResourceAddress: AddressProtocol { } } -#if DEBUG - extension ResourceAddress { - /// Namespace for preview values of `ResourceAddress` - public struct Preview { - fileprivate init() {} - public static let of = Self() - - public let mainnetXRD: ResourceAddress = - newResourceAddressPlaceholderMainnetXrd() - public let mainnetCandy: ResourceAddress = - newResourceAddressPlaceholderMainnetCandy() - /// Gumball Club membership NFT resource address - public let mainnetNonFungbleGCMembership: ResourceAddress = - newResourceAddressPlaceholderMainnetNftGcMembership() - - public let stokenetXRD: ResourceAddress = - newResourceAddressPlaceholderStokenetXrd() - public let stokenetGum: ResourceAddress = - newResourceAddressPlaceholderStokenetGum() - public let stokenetGC: ResourceAddress = - newResourceAddressPlaceholderStokenetGcTokens() - public let stokenetCandy: ResourceAddress = - newResourceAddressPlaceholderStokenetCandy() - } - - /// Preview values for `ResourceAddress`, e.g.: - /// `ResourceAddress.preview.mainnetXRD` - /// or - /// `ResourceAddress.preview.stokenetCandy` - public static let preview = Preview.of - } -#endif - -#if DEBUG - extension ResourceAddress: CaseIterable { - public typealias AllCases = [Self] - public static var allCases: AllCases { - let of = Preview.of - return [ - of.mainnetXRD, - of.mainnetCandy, - of.mainnetNonFungbleGCMembership, - of.stokenetXRD, - of.stokenetGum, - of.stokenetGC, - of.stokenetCandy, - ] - } - } -#endif - -#if DEBUG - /// TODO: Declare in Rust land? Make non-DEBUG? - public enum Address: Hashable, Equatable, Sendable { - case accesscontroller(AccessControllerAddress) - case account(AccountAddress) - case component(ComponentAddress) - case identity(IdentityAddress) - case package(PackageAddress) - case pool(PoolAddress) - case resource(ResourceAddress) - case validator(ValidatorAddress) - case vault(VaultAddress) - } - extension Address: AddressProtocol { - public init(validatingAddress bech32String: String) throws { - if let address = try? AccessControllerAddress( - validatingAddress: bech32String) - { - self = .accesscontroller(address) - } else if let address = try? AccountAddress(validatingAddress: bech32String) - { - self = .account(address) - } else if let address = try? ComponentAddress( - validatingAddress: bech32String) - { - self = .component(address) - } else if let address = try? IdentityAddress( - validatingAddress: bech32String) - { - self = .identity(address) - } else if let address = try? PackageAddress(validatingAddress: bech32String) - { - self = .package(address) - } else if let address = try? PoolAddress(validatingAddress: bech32String) { - self = .pool(address) - } else if let address = try? ResourceAddress( - validatingAddress: bech32String) - { - self = .resource(address) - } else if let address = try? ValidatorAddress( - validatingAddress: bech32String) - { - self = .validator(address) - } else if let address = try? VaultAddress(validatingAddress: bech32String) { - self = .vault(address) - } else { - struct UnknownAddressType: Swift.Error {} - throw UnknownAddressType() - } - } - - public var networkID: NetworkID { - property(\.networkID) - } - - public var address: String { - property(\.address) - } - - private func property(_ keyPath: KeyPath) - -> Property - { - switch self { - case let .accesscontroller(address): address[keyPath: keyPath] - case let .account(address): address[keyPath: keyPath] - case let .component(address): address[keyPath: keyPath] - case let .identity(address): address[keyPath: keyPath] - case let .package(address): address[keyPath: keyPath] - case let .pool(address): address[keyPath: keyPath] - case let .resource(address): address[keyPath: keyPath] - case let .validator(address): address[keyPath: keyPath] - case let .vault(address): address[keyPath: keyPath] - } - } - } - extension Address: CaseIterable { - public typealias AllCases = [Self] - public static var allCases: AllCases { - AccountAddress.allCases.map(Self.account) - + AccessControllerAddress.allCases.map(Self.accesscontroller) - + ComponentAddress.allCases.map(Self.component) - + IdentityAddress.allCases.map(Self.identity) - + PackageAddress.allCases.map(Self.package) - + PoolAddress.allCases.map(Self.pool) - + ResourceAddress.allCases.map(Self.resource) - + ValidatorAddress.allCases.map(Self.validator) - + VaultAddress.allCases.map(Self.vault) - } - } -#endif - extension VaultAddress: AddressProtocol { public init(validatingAddress bech32String: String) throws { self = try newVaultAddress(bech32: bech32String) @@ -400,50 +145,6 @@ extension VaultAddress: AddressProtocol { } } -#if DEBUG - extension VaultAddress { - /// Namespace for preview values of `VaultAddress` - public struct Preview { - fileprivate init() {} - public static let of = Self() - - public let mainnetFungible: VaultAddress = - newVaultAddressPlaceholderMainnetFungible() - - public let mainnetNonFungible: VaultAddress = - newVaultAddressPlaceholderMainnetNonFungible() - - public let stokenetFungible: VaultAddress = - newVaultAddressPlaceholderStokenetFungible() - - public let stokenetNonFungible: VaultAddress = - newVaultAddressPlaceholderStokenetNonFungible() - - } - - /// Preview values for `VaultAddress`, e.g.: - /// `VaultAddress.preview.mainnetFungible` - /// or - /// `VaultAddress.preview.stokenetNonFungible` - public static let preview = Preview.of - } -#endif - -#if DEBUG - extension VaultAddress: CaseIterable { - public typealias AllCases = [Self] - public static var allCases: AllCases { - let of = Preview.of - return [ - of.mainnetFungible, - of.mainnetNonFungible, - of.stokenetFungible, - of.stokenetNonFungible, - ] - } - } -#endif - extension PoolAddress: AddressProtocol { public init(validatingAddress bech32String: String) throws { self = try newPoolAddress(bech32: bech32String) @@ -464,42 +165,6 @@ extension PoolAddress: AddressProtocol { } } -#if DEBUG - extension PoolAddress { - /// Namespace for preview values of `PoolAddress` - public struct Preview { - fileprivate init() {} - public static let of = Self() - - public let mainnetSingle: PoolAddress = newPoolAddressPlaceholderSingle() - - public let mainnetTwo: PoolAddress = newPoolAddressPlaceholderTwo() - - public let mainnetMulti: PoolAddress = newPoolAddressPlaceholderMulti() - - } - - /// Preview values for `PoolAddress`, e.g.: - /// `PoolAddress.preview.mainnetSingle` - /// or - /// `PoolAddress.preview.mainnetMulti` - public static let preview = Preview.of - } -#endif - -#if DEBUG - extension PoolAddress: CaseIterable { - public typealias AllCases = [Self] - public static var allCases: AllCases { - let of = Preview.of - return [ - of.mainnetSingle, - of.mainnetTwo, - of.mainnetMulti, - ] - } - } -#endif extension ValidatorAddress: AddressProtocol { public init(validatingAddress bech32String: String) throws { @@ -516,49 +181,6 @@ extension ValidatorAddress: AddressProtocol { } } -#if DEBUG - extension ValidatorAddress { - /// Namespace for preview values of `ValidatorAddress` - public struct Preview { - fileprivate init() {} - public static let of = Self() - - public let mainnet: ValidatorAddress = - newValidatorAddressPlaceholderMainnet() - - public let mainnetOther: ValidatorAddress = - newValidatorAddressPlaceholderMainnetOther() - - public let stokenet: ValidatorAddress = - newValidatorAddressPlaceholderStokenet() - - public let stokenetOther: ValidatorAddress = - newValidatorAddressPlaceholderStokenetOther() - - } - - /// Preview values for `ValidatorAddress`, e.g.: - /// `ValidatorAddress.preview.mainnet` - /// or - /// `ValidatorAddress.preview.stokenetOther` - public static let preview = Preview.of - } -#endif - -#if DEBUG - extension ValidatorAddress: CaseIterable { - public typealias AllCases = [Self] - public static var allCases: AllCases { - let of = Preview.of - return [ - of.mainnet, - of.mainnetOther, - of.stokenet, - of.stokenetOther, - ] - } - } -#endif extension ComponentAddress: AddressProtocol { public init(validatingAddress bech32String: String) throws { @@ -575,88 +197,17 @@ extension ComponentAddress: AddressProtocol { } } -#if DEBUG - extension ComponentAddress { - /// Namespace for preview values of `ComponentAddress` - public struct Preview { - fileprivate init() {} - public static let of = Self() - - public let mainnet: ComponentAddress = newComponentAddressPlaceholder() - - public let mainnetOther: ComponentAddress = - newComponentAddressPlaceholderOther() - - } - - /// Preview values for `ComponentAddress`, e.g.: - /// `ComponentAddress.preview.mainnet` - /// or - /// `ComponentAddress.preview.mainnetOther` - public static let preview = Preview.of - } -#endif - -#if DEBUG - extension ComponentAddress: CaseIterable { - public typealias AllCases = [Self] - public static var allCases: AllCases { - let of = Preview.of - return [ - of.mainnet, - of.mainnetOther, - ] - } - } -#endif - extension AccessControllerAddress: AddressProtocol { public init(validatingAddress bech32String: String) throws { - self = try newAccesscontrollerAddress(bech32: bech32String) + self = try newAccessControllerAddress(bech32: bech32String) } /// The bech32 encoded string for this address. public var address: String { - accesscontrollerAddressBech32Address(address: self) + accessControllerAddressBech32Address(address: self) } public var networkID: NetworkId { - accesscontrollerAddressNetworkId(address: self) + accessControllerAddressNetworkId(address: self) } } - -#if DEBUG - extension AccessControllerAddress { - /// Namespace for preview values of `AccessControllerAddress` - public struct Preview { - fileprivate init() {} - public static let of = Self() - - public let first: AccessControllerAddress = - newAccesscontrollerAddressPlaceholder() - - public let second: AccessControllerAddress = - newAccesscontrollerAddressPlaceholderOther() - - } - - /// Preview values for `AccessControllerAddress`, e.g.: - /// `AccessControllerAddress.preview.first` - /// or - /// `AccessControllerAddress.preview.second` - public static let preview = Preview.of - } -#endif - -#if DEBUG - extension AccessControllerAddress: CaseIterable { - public typealias AllCases = [Self] - public static var allCases: AllCases { - let of = Preview.of - return [ - of.first, - of.second, - ] - } - } -#endif diff --git a/apple/Sources/Sargon/Extensions/Swiftified/AccessControllerAddress+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/AccessControllerAddress+Swiftified.swift new file mode 100644 index 000000000..428ff190c --- /dev/null +++ b/apple/Sources/Sargon/Extensions/Swiftified/AccessControllerAddress+Swiftified.swift @@ -0,0 +1,38 @@ +extension AccessControllerAddress: @unchecked Sendable {} + + +#if DEBUG + extension AccessControllerAddress { + /// Namespace for preview values of `AccessControllerAddress` + public struct Preview { + fileprivate init() {} + public static let of = Self() + + public let first: AccessControllerAddress = + newAccessControllerAddressPlaceholder() + + public let second: AccessControllerAddress = + newAccessControllerAddressPlaceholderOther() + + } + + /// Preview values for `AccessControllerAddress`, e.g.: + /// `AccessControllerAddress.preview.first` + /// or + /// `AccessControllerAddress.preview.second` + public static let preview = Preview.of + } +#endif + +#if DEBUG + extension AccessControllerAddress: CaseIterable { + public typealias AllCases = [Self] + public static var allCases: AllCases { + let of = Preview.of + return [ + of.first, + of.second, + ] + } + } +#endif diff --git a/apple/Sources/Sargon/Extensions/Swiftified/Account+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/Account+Swiftified.swift index f3c15d7e8..7d2753059 100644 --- a/apple/Sources/Sargon/Extensions/Swiftified/Account+Swiftified.swift +++ b/apple/Sources/Sargon/Extensions/Swiftified/Account+Swiftified.swift @@ -1,13 +1,13 @@ // // Account+Swiftified.swift -// +// // // Created by Alexander Cyon on 2024-02-16. // import Foundation -extension Account: Sendable {} +extension Account: @unchecked Sendable {} extension Account: Identifiable { public typealias ID = AccountAddress public var id: ID { diff --git a/apple/Sources/Sargon/Extensions/Swiftified/AccountAddress+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/AccountAddress+Swiftified.swift index 329c1f406..6b44deb50 100644 --- a/apple/Sources/Sargon/Extensions/Swiftified/AccountAddress+Swiftified.swift +++ b/apple/Sources/Sargon/Extensions/Swiftified/AccountAddress+Swiftified.swift @@ -1 +1,41 @@ -extension AccountAddress: Sendable {} +extension AccountAddress: @unchecked Sendable {} + + +#if DEBUG + extension AccountAddress { + /// Namespace for preview values of `AccountAddress` + public struct Preview { + fileprivate init() {} + public static let of = Self() + + public let mainnet: AccountAddress = newAccountAddressPlaceholderMainnet() + public let mainnetOther: AccountAddress = + newAccountAddressPlaceholderMainnetOther() + + public let stokenet: AccountAddress = newAccountAddressPlaceholderStokenet() + public let stokenetOther: AccountAddress = + newAccountAddressPlaceholderStokenetOther() + } + + /// Preview values for `AccountAddress`, e.g.: + /// `AccountAddress.preview.mainnet` + /// or + /// `AccountAddress.preview.stokenetOther` + public static let preview = Preview.of + } +#endif + +#if DEBUG + extension AccountAddress: CaseIterable { + public typealias AllCases = [Self] + public static var allCases: AllCases { + let of = Preview.of + return [ + of.mainnet, + of.mainnetOther, + of.stokenet, + of.stokenetOther, + ] + } + } +#endif diff --git a/apple/Sources/Sargon/Extensions/Swiftified/AppearanceID+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/AppearanceID+Swiftified.swift index d4deaca59..6798f74ec 100644 --- a/apple/Sources/Sargon/Extensions/Swiftified/AppearanceID+Swiftified.swift +++ b/apple/Sources/Sargon/Extensions/Swiftified/AppearanceID+Swiftified.swift @@ -1,6 +1,6 @@ public typealias AppearanceID = AppearanceId -extension AppearanceID: Sendable {} +extension AppearanceID: @unchecked Sendable {} extension AppearanceID: Identifiable { public typealias ID = UInt8 public var id: ID { diff --git a/apple/Sources/Sargon/Extensions/Swiftified/ComponentAddress+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/ComponentAddress+Swiftified.swift new file mode 100644 index 000000000..aead2429e --- /dev/null +++ b/apple/Sources/Sargon/Extensions/Swiftified/ComponentAddress+Swiftified.swift @@ -0,0 +1,37 @@ +extension ComponentAddress: @unchecked Sendable {} + + +#if DEBUG + extension ComponentAddress { + /// Namespace for preview values of `ComponentAddress` + public struct Preview { + fileprivate init() {} + public static let of = Self() + + public let mainnet: ComponentAddress = newComponentAddressPlaceholder() + + public let mainnetOther: ComponentAddress = + newComponentAddressPlaceholderOther() + + } + + /// Preview values for `ComponentAddress`, e.g.: + /// `ComponentAddress.preview.mainnet` + /// or + /// `ComponentAddress.preview.mainnetOther` + public static let preview = Preview.of + } +#endif + +#if DEBUG + extension ComponentAddress: CaseIterable { + public typealias AllCases = [Self] + public static var allCases: AllCases { + let of = Preview.of + return [ + of.mainnet, + of.mainnetOther, + ] + } + } +#endif diff --git a/apple/Sources/Sargon/Extensions/Swiftified/Decimal192+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/Decimal192+Swiftified.swift index 12687e79c..e6f6f1edd 100644 --- a/apple/Sources/Sargon/Extensions/Swiftified/Decimal192+Swiftified.swift +++ b/apple/Sources/Sargon/Extensions/Swiftified/Decimal192+Swiftified.swift @@ -1,4 +1,4 @@ -extension Decimal192: Sendable {} +extension Decimal192: @unchecked Sendable {} extension Decimal192: ExpressibleByStringLiteral { public init(stringLiteral string: String) { @@ -11,7 +11,6 @@ extension Decimal192: ExpressibleByIntegerLiteral { } } - extension Decimal192: AdditiveArithmetic { public static var zero: Self { newDecimalFromU64(value: 0) diff --git a/apple/Sources/Sargon/Extensions/Swiftified/DisplayName+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/DisplayName+Swiftified.swift index 830bd0373..44725a055 100644 --- a/apple/Sources/Sargon/Extensions/Swiftified/DisplayName+Swiftified.swift +++ b/apple/Sources/Sargon/Extensions/Swiftified/DisplayName+Swiftified.swift @@ -1,9 +1,9 @@ -extension DisplayName: Sendable {} +extension DisplayName: @unchecked Sendable {} #if DEBUG -extension DisplayName: ExpressibleByStringLiteral { - public init(stringLiteral name: String) { - try! self.init(validating: name) + extension DisplayName: ExpressibleByStringLiteral { + public init(stringLiteral name: String) { + try! self.init(validating: name) + } } -} #endif diff --git a/apple/Sources/Sargon/Extensions/Swiftified/IdentityAddress+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/IdentityAddress+Swiftified.swift new file mode 100644 index 000000000..cd5080c4f --- /dev/null +++ b/apple/Sources/Sargon/Extensions/Swiftified/IdentityAddress+Swiftified.swift @@ -0,0 +1,42 @@ +extension IdentityAddress: @unchecked Sendable {} + + +#if DEBUG + extension IdentityAddress { + /// Namespace for preview values of `IdentityAddress` + public struct Preview { + fileprivate init() {} + public static let of = Self() + + public let mainnet: IdentityAddress = newIdentityAddressPlaceholderMainnet() + public let mainnetOther: IdentityAddress = + newIdentityAddressPlaceholderMainnetOther() + + public let stokenet: IdentityAddress = + newIdentityAddressPlaceholderStokenet() + public let stokenetOther: IdentityAddress = + newIdentityAddressPlaceholderStokenetOther() + } + + /// Preview values for `IdentityAddress`, e.g.: + /// `IdentityAddress.preview.mainnet` + /// or + /// `IdentityAddress.preview.stokenetOther` + public static let preview = Preview.of + } +#endif + +#if DEBUG + extension IdentityAddress: CaseIterable { + public typealias AllCases = [Self] + public static var allCases: AllCases { + let of = Preview.of + return [ + of.mainnet, + of.mainnetOther, + of.stokenet, + of.stokenetOther, + ] + } + } +#endif diff --git a/apple/Sources/Sargon/Extensions/Swiftified/LocaleConfig+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/LocaleConfig+Swiftified.swift index 3eae8b7ca..a0ac2a2c2 100644 --- a/apple/Sources/Sargon/Extensions/Swiftified/LocaleConfig+Swiftified.swift +++ b/apple/Sources/Sargon/Extensions/Swiftified/LocaleConfig+Swiftified.swift @@ -1,4 +1,4 @@ -extension LocaleConfig: Sendable {} +extension LocaleConfig: @unchecked Sendable {} extension LocaleConfig { public init(locale: Locale) { self.init( diff --git a/apple/Sources/Sargon/Extensions/Swiftified/Mnemonic+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/Mnemonic+Swiftified.swift index e360de9b2..4094e2ff1 100644 --- a/apple/Sources/Sargon/Extensions/Swiftified/Mnemonic+Swiftified.swift +++ b/apple/Sources/Sargon/Extensions/Swiftified/Mnemonic+Swiftified.swift @@ -1 +1 @@ -extension Mnemonic: Sendable {} +extension Mnemonic: @unchecked Sendable {} diff --git a/apple/Sources/Sargon/Extensions/Swiftified/NetworkID+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/NetworkID+Swiftified.swift index ec44ff696..855624921 100644 --- a/apple/Sources/Sargon/Extensions/Swiftified/NetworkID+Swiftified.swift +++ b/apple/Sources/Sargon/Extensions/Swiftified/NetworkID+Swiftified.swift @@ -1,3 +1,3 @@ public typealias NetworkID = NetworkId -extension NetworkID: Sendable {} +extension NetworkID: @unchecked Sendable {} diff --git a/apple/Sources/Sargon/Extensions/Swiftified/PackageAddress+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/PackageAddress+Swiftified.swift new file mode 100644 index 000000000..5307a74f6 --- /dev/null +++ b/apple/Sources/Sargon/Extensions/Swiftified/PackageAddress+Swiftified.swift @@ -0,0 +1,34 @@ +extension PackageAddress: @unchecked Sendable {} + + +#if DEBUG + extension PackageAddress { + /// Namespace for preview values of `PackageAddress` + public struct Preview { + fileprivate init() {} + public static let of = Self() + + public let first: PackageAddress = newPackageAddressPlaceholder() + public let second: PackageAddress = newPackageAddressPlaceholderOther() + } + + /// Preview values for `PackageAddress`, e.g.: + /// `PackageAddress.preview.first` + /// or + /// `PackageAddress.preview.second` + public static let preview = Preview.of + } +#endif + +#if DEBUG + extension PackageAddress: CaseIterable { + public typealias AllCases = [Self] + public static var allCases: AllCases { + let of = Preview.of + return [ + of.first, + of.second, + ] + } + } +#endif diff --git a/apple/Sources/Sargon/Extensions/Swiftified/PoolAddress+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/PoolAddress+Swiftified.swift new file mode 100644 index 000000000..6cbf193bb --- /dev/null +++ b/apple/Sources/Sargon/Extensions/Swiftified/PoolAddress+Swiftified.swift @@ -0,0 +1,39 @@ +extension PoolAddress: @unchecked Sendable {} + + +#if DEBUG + extension PoolAddress { + /// Namespace for preview values of `PoolAddress` + public struct Preview { + fileprivate init() {} + public static let of = Self() + + public let mainnetSingle: PoolAddress = newPoolAddressPlaceholderSingle() + + public let mainnetTwo: PoolAddress = newPoolAddressPlaceholderTwo() + + public let mainnetMulti: PoolAddress = newPoolAddressPlaceholderMulti() + + } + + /// Preview values for `PoolAddress`, e.g.: + /// `PoolAddress.preview.mainnetSingle` + /// or + /// `PoolAddress.preview.mainnetMulti` + public static let preview = Preview.of + } +#endif + +#if DEBUG + extension PoolAddress: CaseIterable { + public typealias AllCases = [Self] + public static var allCases: AllCases { + let of = Preview.of + return [ + of.mainnetSingle, + of.mainnetTwo, + of.mainnetMulti, + ] + } + } +#endif \ No newline at end of file diff --git a/apple/Sources/Sargon/Extensions/Swiftified/Profile+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/Profile+Swiftified.swift index 66cee306b..2c6a53cf0 100644 --- a/apple/Sources/Sargon/Extensions/Swiftified/Profile+Swiftified.swift +++ b/apple/Sources/Sargon/Extensions/Swiftified/Profile+Swiftified.swift @@ -1,4 +1,4 @@ -extension Profile: Sendable {} +extension Profile: @unchecked Sendable {} extension Profile: Identifiable { public typealias ID = ProfileID public var id: ID { diff --git a/apple/Sources/Sargon/Extensions/Swiftified/ResourceAddress+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/ResourceAddress+Swiftified.swift new file mode 100644 index 000000000..416747485 --- /dev/null +++ b/apple/Sources/Sargon/Extensions/Swiftified/ResourceAddress+Swiftified.swift @@ -0,0 +1,53 @@ +extension ResourceAddress: @unchecked Sendable {} + + +#if DEBUG + extension ResourceAddress { + /// Namespace for preview values of `ResourceAddress` + public struct Preview { + fileprivate init() {} + public static let of = Self() + + public let mainnetXRD: ResourceAddress = + newResourceAddressPlaceholderMainnetXrd() + public let mainnetCandy: ResourceAddress = + newResourceAddressPlaceholderMainnetCandy() + /// Gumball Club membership NFT resource address + public let mainnetNonFungbleGCMembership: ResourceAddress = + newResourceAddressPlaceholderMainnetNftGcMembership() + + public let stokenetXRD: ResourceAddress = + newResourceAddressPlaceholderStokenetXrd() + public let stokenetGum: ResourceAddress = + newResourceAddressPlaceholderStokenetGum() + public let stokenetGC: ResourceAddress = + newResourceAddressPlaceholderStokenetGcTokens() + public let stokenetCandy: ResourceAddress = + newResourceAddressPlaceholderStokenetCandy() + } + + /// Preview values for `ResourceAddress`, e.g.: + /// `ResourceAddress.preview.mainnetXRD` + /// or + /// `ResourceAddress.preview.stokenetCandy` + public static let preview = Preview.of + } +#endif + +#if DEBUG + extension ResourceAddress: CaseIterable { + public typealias AllCases = [Self] + public static var allCases: AllCases { + let of = Preview.of + return [ + of.mainnetXRD, + of.mainnetCandy, + of.mainnetNonFungbleGCMembership, + of.stokenetXRD, + of.stokenetGum, + of.stokenetGC, + of.stokenetCandy, + ] + } + } +#endif diff --git a/apple/Sources/Sargon/Extensions/Swiftified/SargonError+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/SargonError+Swiftified.swift index 5d1353cf5..ebe407185 100644 --- a/apple/Sources/Sargon/Extensions/Swiftified/SargonError+Swiftified.swift +++ b/apple/Sources/Sargon/Extensions/Swiftified/SargonError+Swiftified.swift @@ -1,6 +1,6 @@ // // SargonError+Swiftified.swift -// +// // // Created by Alexander Cyon on 2024-02-16. // @@ -8,4 +8,4 @@ import Foundation public typealias SargonError = CommonError -extension SargonError: Sendable {} +extension SargonError: @unchecked Sendable {} diff --git a/apple/Sources/Sargon/Extensions/Swiftified/ValidatorAddress+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/ValidatorAddress+Swiftified.swift new file mode 100644 index 000000000..6c745a482 --- /dev/null +++ b/apple/Sources/Sargon/Extensions/Swiftified/ValidatorAddress+Swiftified.swift @@ -0,0 +1,46 @@ +extension ValidatorAddress: @unchecked Sendable {} + + +#if DEBUG + extension ValidatorAddress { + /// Namespace for preview values of `ValidatorAddress` + public struct Preview { + fileprivate init() {} + public static let of = Self() + + public let mainnet: ValidatorAddress = + newValidatorAddressPlaceholderMainnet() + + public let mainnetOther: ValidatorAddress = + newValidatorAddressPlaceholderMainnetOther() + + public let stokenet: ValidatorAddress = + newValidatorAddressPlaceholderStokenet() + + public let stokenetOther: ValidatorAddress = + newValidatorAddressPlaceholderStokenetOther() + + } + + /// Preview values for `ValidatorAddress`, e.g.: + /// `ValidatorAddress.preview.mainnet` + /// or + /// `ValidatorAddress.preview.stokenetOther` + public static let preview = Preview.of + } +#endif + +#if DEBUG + extension ValidatorAddress: CaseIterable { + public typealias AllCases = [Self] + public static var allCases: AllCases { + let of = Preview.of + return [ + of.mainnet, + of.mainnetOther, + of.stokenet, + of.stokenetOther, + ] + } + } +#endif \ No newline at end of file diff --git a/apple/Sources/Sargon/Extensions/Swiftified/VaultAddress+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/VaultAddress+Swiftified.swift new file mode 100644 index 000000000..e66ec6b59 --- /dev/null +++ b/apple/Sources/Sargon/Extensions/Swiftified/VaultAddress+Swiftified.swift @@ -0,0 +1,46 @@ +extension VaultAddress: @unchecked Sendable {} + + +#if DEBUG + extension VaultAddress { + /// Namespace for preview values of `VaultAddress` + public struct Preview { + fileprivate init() {} + public static let of = Self() + + public let mainnetFungible: VaultAddress = + newVaultAddressPlaceholderMainnetFungible() + + public let mainnetNonFungible: VaultAddress = + newVaultAddressPlaceholderMainnetNonFungible() + + public let stokenetFungible: VaultAddress = + newVaultAddressPlaceholderStokenetFungible() + + public let stokenetNonFungible: VaultAddress = + newVaultAddressPlaceholderStokenetNonFungible() + + } + + /// Preview values for `VaultAddress`, e.g.: + /// `VaultAddress.preview.mainnetFungible` + /// or + /// `VaultAddress.preview.stokenetNonFungible` + public static let preview = Preview.of + } +#endif + +#if DEBUG + extension VaultAddress: CaseIterable { + public typealias AllCases = [Self] + public static var allCases: AllCases { + let of = Preview.of + return [ + of.mainnetFungible, + of.mainnetNonFungible, + of.stokenetFungible, + of.stokenetNonFungible, + ] + } + } +#endif diff --git a/apple/Sources/Sargon/Extensions/Swiftified/Wallet+Swiftified.swift b/apple/Sources/Sargon/Extensions/Swiftified/Wallet+Swiftified.swift index b82bd791c..abfe3ff0f 100644 --- a/apple/Sources/Sargon/Extensions/Swiftified/Wallet+Swiftified.swift +++ b/apple/Sources/Sargon/Extensions/Swiftified/Wallet+Swiftified.swift @@ -1 +1 @@ -extension Wallet: Sendable {} +extension Wallet: @unchecked Sendable {}