63 lines
1.7 KiB
Swift
63 lines
1.7 KiB
Swift
//
|
|
// ApplicationEnvironmentRecord.swift
|
|
// Malinka
|
|
//
|
|
// Created by Juraldinio on 10/23/22.
|
|
// Copyright © 2022 NUT.Tech. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import WalletFoundation
|
|
|
|
final class ApplicationEnvironmentRecord {
|
|
|
|
typealias UrlPath = String
|
|
|
|
struct Malinka {
|
|
let name: String
|
|
let graphQL: UrlPath // malinkaGraphQL
|
|
}
|
|
|
|
struct PayCash {
|
|
let name: String
|
|
let listSite: UrlPath // listFamilySite
|
|
let listGraphQL: UrlPath // graphql
|
|
let paycashGraphQl: UrlPath
|
|
let paycashSwap: UrlPath
|
|
let paycashSwapSite: UrlPath
|
|
let freecpu: UrlPath
|
|
let webSocket: UrlPath
|
|
let contracts: [EOSContract: String]
|
|
}
|
|
|
|
private(set) var malinka: Malinka
|
|
private(set) var paycash: PayCash
|
|
|
|
private(set) var nodes = [UrlPath]()
|
|
private(set) var hyperions = [UrlPath]()
|
|
|
|
init(malinka: Malinka, paycash: PayCash, nodes: [UrlPath], hyperions: [UrlPath]) {
|
|
self.malinka = malinka
|
|
self.paycash = paycash
|
|
self.nodes = nodes
|
|
self.hyperions = hyperions
|
|
}
|
|
|
|
// MARK: -
|
|
|
|
var node: UrlPath? { self.nodes.first }
|
|
|
|
var hyperion: UrlPath? { self.hyperions.first }
|
|
|
|
var useScatter: Bool { false }
|
|
|
|
func update(nodes: [UrlPath]) { self.nodes = nodes.map { $0 } }
|
|
|
|
func update(hyperions: [UrlPath]) { self.hyperions = hyperions.map { $0 } }
|
|
|
|
// TODO: - NEED USE Optional!
|
|
func contract(_ name: EOSContract) -> String { self.paycash.contracts[name] ?? "" }
|
|
|
|
func contract(_ name: String) -> EOSContract? { self.paycash.contracts.filter { $0.value == name }.first?.key }
|
|
}
|