Files
raspberry/iOS/Wallet/Sources/CCCP/Service/CCCPServiceSwaps.swift
2022-05-27 20:21:01 +03:00

37 lines
1022 B
Swift

//
// CCCPServiceSwaps.swift
// PayCash
//
// Created by Saveliy Stavitsky on 9/21/20.
// Copyright © 2020 List. All rights reserved.
//
extension CCCP.Service {
class Swaps {
static let shared = Swaps()
private init() { }
var collection = [Network.Model.TokenSmall]()
func fetch(_ completition: (([Network.Model.TokenSmall]) -> Void)?) {
if collection.count > 0 {
completition?(collection)
return
}
Network.table.fetch(code: Network.servers.current.contract(.cash),
table: "swap",
scope: Network.servers.current.contract(.cash),
type: Income.self) { rows in
self.collection = rows.map({ $0.income })
completition?(self.collection)
}
}
private struct Income: Codable {
let income: Network.Model.TokenSmall
}
}
}