SwiftFormat

pull/7097/merge
Hwee-Boon Yar 5 months ago
parent 3f3ec0697a
commit 47f347edf7
  1. 2
      modules/AlphaWalletFoundation/AlphaWalletFoundation/Alerts/Types/PriceAlert.swift
  2. 1
      modules/AlphaWalletFoundation/AlphaWalletFoundation/CoinTicker/Types/TickerId.swift
  3. 2
      modules/AlphaWalletFoundation/AlphaWalletFoundation/CoinTicker/Types/TokenMappedToTicker.swift
  4. 42
      modules/AlphaWalletFoundation/AlphaWalletFoundation/Tokens/Types/TokensDataStore.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

@ -64,7 +64,6 @@ extension TickerId {
}
extension RPCServer {
init?(coinGeckoPlatform: String) {
switch coinGeckoPlatform {
case "ethereum": self = .main

@ -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

@ -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
)
}

Loading…
Cancel
Save