From 47f347edf73508aa4081cb38c2aa51f79ecda33c Mon Sep 17 00:00:00 2001 From: Hwee-Boon Yar Date: Tue, 28 May 2024 17:13:22 +0800 Subject: [PATCH] SwiftFormat --- .../Alerts/Types/PriceAlert.swift | 2 - .../CoinTicker/Types/TickerId.swift | 1 - .../Types/TokenMappedToTicker.swift | 2 - .../Tokens/Types/TokensDataStore.swift | 42 +++++++++---------- 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/modules/AlphaWalletFoundation/AlphaWalletFoundation/Alerts/Types/PriceAlert.swift b/modules/AlphaWalletFoundation/AlphaWalletFoundation/Alerts/Types/PriceAlert.swift index 5fc9f7f0b..827e11024 100644 --- a/modules/AlphaWalletFoundation/AlphaWalletFoundation/Alerts/Types/PriceAlert.swift +++ b/modules/AlphaWalletFoundation/AlphaWalletFoundation/Alerts/Types/PriceAlert.swift @@ -23,7 +23,6 @@ public struct PriceAlert { } extension AlertType: Codable, Hashable { - private enum CodingKeys: String, CodingKey { case priceTarget case value @@ -54,7 +53,6 @@ extension AlertType: Codable, Hashable { } extension PriceAlert: Codable, Hashable, Equatable { - public init(type: AlertType, token: Token, isEnabled: Bool) { self.addressAndRPCServer = token.addressAndRPCServer self.type = type diff --git a/modules/AlphaWalletFoundation/AlphaWalletFoundation/CoinTicker/Types/TickerId.swift b/modules/AlphaWalletFoundation/AlphaWalletFoundation/CoinTicker/Types/TickerId.swift index a403237d9..d71938dad 100644 --- a/modules/AlphaWalletFoundation/AlphaWalletFoundation/CoinTicker/Types/TickerId.swift +++ b/modules/AlphaWalletFoundation/AlphaWalletFoundation/CoinTicker/Types/TickerId.swift @@ -64,7 +64,6 @@ extension TickerId { } extension RPCServer { - init?(coinGeckoPlatform: String) { switch coinGeckoPlatform { case "ethereum": self = .main diff --git a/modules/AlphaWalletFoundation/AlphaWalletFoundation/CoinTicker/Types/TokenMappedToTicker.swift b/modules/AlphaWalletFoundation/AlphaWalletFoundation/CoinTicker/Types/TokenMappedToTicker.swift index 8e22f2335..efaad7938 100644 --- a/modules/AlphaWalletFoundation/AlphaWalletFoundation/CoinTicker/Types/TokenMappedToTicker.swift +++ b/modules/AlphaWalletFoundation/AlphaWalletFoundation/CoinTicker/Types/TokenMappedToTicker.swift @@ -44,7 +44,6 @@ public struct TokenMappedToTicker { } extension TokenMappedToTicker: Hashable, Codable { - public init(token: Token) { symbol = token.symbol name = token.name @@ -55,7 +54,6 @@ extension TokenMappedToTicker: Hashable, Codable { } extension TokenMappedToTicker: Equatable { - /// Checks for matching of ticker id public static func == (lhs: TokenMappedToTicker, rhs: AddressAndRPCServer) -> Bool { return lhs.contractAddress == rhs.address && lhs.server == rhs.server diff --git a/modules/AlphaWalletFoundation/AlphaWalletFoundation/Tokens/Types/TokensDataStore.swift b/modules/AlphaWalletFoundation/AlphaWalletFoundation/Tokens/Types/TokensDataStore.swift index 708332359..ed6b97d00 100644 --- a/modules/AlphaWalletFoundation/AlphaWalletFoundation/Tokens/Types/TokensDataStore.swift +++ b/modules/AlphaWalletFoundation/AlphaWalletFoundation/Tokens/Types/TokensDataStore.swift @@ -1,10 +1,12 @@ // Copyright © 2018 Stormbird PTE. LTD. +import Combine import Foundation + import AlphaWalletOpenSea + import BigInt import RealmSwift -import Combine public enum DataStoreError: Error { case objectTypeMismatch @@ -34,7 +36,6 @@ public protocol TokensDataStore: NSObjectProtocol { } extension TokensDataStore { - @discardableResult func updateToken(addressAndRpcServer: AddressAndRPCServer, action: TokenFieldUpdate) async -> Bool? { let primaryKey = TokenObject.generatePrimaryKey(fromContract: addressAndRpcServer.address, server: addressAndRpcServer.server) return await updateToken(primaryKey: primaryKey, action: action) @@ -56,11 +57,11 @@ extension TokensDataStore { func enabledTokensPublisher(for servers: [RPCServer]) -> AnyPublisher<[Token], Never> { return tokensChangesetPublisher(for: servers, predicate: nil) .map { changeset in - switch changeset { - case .initial(let tokens): return tokens - case .update(let tokens, _, _, _): return tokens - case .error: return [] - } + switch changeset { + case .initial(let tokens): return tokens + case .update(let tokens, _, _, _): return tokens + case .error: return [] + } }.eraseToAnyPublisher() } } @@ -609,7 +610,6 @@ open class MultipleChainsTokensDataStore: NSObject, TokensDataStore { // swiftlint:enable type_body_length extension TokenObject { - convenience init(ercToken token: ErcToken, shouldUpdateBalance: Bool) { self.init(contract: token.contract, server: token.server, name: token.name, symbol: token.symbol, decimals: token.decimals, value: token.value.description, isCustom: true, type: token.type) @@ -663,20 +663,20 @@ extension MultipleChainsTokensDataStore.functional { return NSCompoundPredicate(andPredicateWithSubpredicates: [ contractPredicate(contract: contract), isDisabledPredicate(isDisabled: isDisabled), - chainIdPredicate(servers: [server]) + chainIdPredicate(servers: [server]), ]) } static func tokenPredicate(server: RPCServer, contract: AlphaWallet.Address) -> NSPredicate { return NSCompoundPredicate(andPredicateWithSubpredicates: [ contractPredicate(contract: contract), - chainIdPredicate(servers: [server]) + chainIdPredicate(servers: [server]), ]) } static func tokenPredicate(contract: AlphaWallet.Address) -> NSPredicate { return NSCompoundPredicate(andPredicateWithSubpredicates: [ - contractPredicate(contract: contract) + contractPredicate(contract: contract), ]) } @@ -684,7 +684,7 @@ extension MultipleChainsTokensDataStore.functional { return NSCompoundPredicate(andPredicateWithSubpredicates: [ isDisabledPredicate(isDisabled: isDisabled), chainIdPredicate(servers: servers), - nonEmptyContractPredicate() + nonEmptyContractPredicate(), ]) } @@ -692,26 +692,26 @@ extension MultipleChainsTokensDataStore.functional { return NSCompoundPredicate(andPredicateWithSubpredicates: [ isDisabledPredicate(isDisabled: isDisabled), chainIdPredicate(servers: servers), - nonEmptyContractPredicate() + nonEmptyContractPredicate(), ]) } static func nonEmptyContractTokenPredicate(server: RPCServer) -> NSPredicate { return NSCompoundPredicate(andPredicateWithSubpredicates: [ chainIdPredicate(servers: [server]), - nonEmptyContractPredicate() + nonEmptyContractPredicate(), ]) } public static func etherToken(forServer server: RPCServer) -> Token { return Token( - contract: Constants.nativeCryptoAddressInDatabase, - server: server, - name: server.name, - symbol: server.symbol, - decimals: server.decimals, - value: .zero, - type: .nativeCryptocurrency + contract: Constants.nativeCryptoAddressInDatabase, + server: server, + name: server.name, + symbol: server.symbol, + decimals: server.decimals, + value: .zero, + type: .nativeCryptocurrency ) }