// // AccountNodeService.swift // // // Created by Nut.Tech on 16.01.2023. // import Alamofire import Foundation public struct NodeService: NetworkService { let environment: NetworkEnvironment let session: Session public init(environment: NetworkEnvironment) { self.environment = environment if let configuration = environment.configuration { configuration.headers = HTTPHeaders.default self.session = Session(configuration: configuration) } else { self.session = AF } } public func fetchActions(account: String, limit: Int, skip: Int? = nil) async throws -> [NodeAction] { guard let url = URL(string: "https://eos.greymass.com") else { return [] } //self.environment.hyperion.url() guard var components = URLComponents(url: url, resolvingAgainstBaseURL: false) else { return [] } components.path = "/v1/history/get_actions" components.queryItems = [URLQueryItem(name: "account_name", value: account), URLQueryItem(name: "offset", value: "\(-limit)")] if let skip { components.queryItems?.append(URLQueryItem(name: "pos", value: "\(skip)")) } do { let result = try await self.session.request( components, method: .get ).serializingDecodable(NodeResponse.self) .value return result.actions } catch { throw error } } }