show testnets in a different list

This commit is contained in:
ivan grachev 2023-11-02 19:06:18 +03:00
parent 4cc8280954
commit 5c8ecf9708
2 changed files with 5 additions and 4 deletions

View File

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

View File

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