mirror of
https://github.com/lil-org/tokenary.git
synced 2024-12-02 09:33:49 +03:00
show testnets in a different list
This commit is contained in:
parent
4cc8280954
commit
5c8ecf9708
@ -8,6 +8,7 @@ struct EthereumNetwork: Codable, Equatable {
|
||||
let name: String
|
||||
let symbol: String
|
||||
let nodeURLString: String
|
||||
let isTestnet: Bool
|
||||
|
||||
var symbolIsETH: Bool { return symbol == "ETH" }
|
||||
var hasUSDPrice: Bool { return chainId == EthereumNetwork.ethMainnetChainId } // TODO: list more chains with usd price
|
||||
|
@ -19,15 +19,15 @@ struct Networks {
|
||||
}
|
||||
|
||||
static let allMainnets: [EthereumNetwork] = {
|
||||
return allBundled // TODO: filter mainnets
|
||||
return allBundled.filter { !$0.isTestnet }
|
||||
}()
|
||||
|
||||
static let allTestnets: [EthereumNetwork] = {
|
||||
return allBundled // TODO: filter testnets
|
||||
return allBundled.filter { $0.isTestnet }
|
||||
}()
|
||||
|
||||
private static let allBundled: [EthereumNetwork] = {
|
||||
return Array(allBundledDict.values.sorted(by: { $0.chainId < $1.chainId }))
|
||||
return Array(allBundledDict.values.sorted(by: { $0.name < $1.name }))
|
||||
}()
|
||||
|
||||
private static let allBundledDict: [Int: EthereumNetwork] = {
|
||||
@ -36,7 +36,7 @@ struct Networks {
|
||||
let bundledNetworks = try? JSONDecoder().decode([Int: BundledNetwork].self, from: data) {
|
||||
let mapped = bundledNetworks.compactMap { (key, value) -> (Int, EthereumNetwork)? in
|
||||
guard let node = Nodes.getNode(chainId: key) else { return nil }
|
||||
let network = EthereumNetwork(chainId: key, name: value.name, symbol: value.symbol, nodeURLString: node)
|
||||
let network = EthereumNetwork(chainId: key, name: value.name, symbol: value.symbol, nodeURLString: node, isTestnet: value.isTest)
|
||||
return (key, network)
|
||||
}
|
||||
let dict = [Int: EthereumNetwork](uniqueKeysWithValues: mapped)
|
||||
|
Loading…
Reference in New Issue
Block a user