From b81eeebc6f698f5cd34bca0492ac107f1b4a295e Mon Sep 17 00:00:00 2001 From: ivan grachev Date: Tue, 7 Nov 2023 21:05:45 +0300 Subject: [PATCH] use infura if key is available --- Shared/Ethereum/Nodes.swift | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Shared/Ethereum/Nodes.swift b/Shared/Ethereum/Nodes.swift index 6563b0d5..9289a3be 100644 --- a/Shared/Ethereum/Nodes.swift +++ b/Shared/Ethereum/Nodes.swift @@ -4,7 +4,7 @@ import Foundation struct Nodes { - private static let infuraKey: String = { + private static let infuraKey: String? = { if let latest = ExtensionBridge.defaultInfuraKeys?.first, !latest.isEmpty { return latest } else if let path = Bundle.main.path(forResource: "shared", ofType: "plist"), @@ -12,18 +12,16 @@ struct Nodes { let infuraKey = dict["InfuraKey"] as? String, !infuraKey.isEmpty { return infuraKey } else { - return "" // TODO: return nil instead + return nil } }() static func getNode(chainId: Int) -> String? { - if let domain = BundledNodes.dict[chainId] { - let https = "https://" + domain - if domain.hasSuffix(".infura.io/v3/") { - return https + infuraKey - } else { - return https - } + let https = "https://" + if let infura = BundledNodes.infura[chainId], let infuraKey = infuraKey { + return https + infura + ".infura.io/v3/" + infuraKey + } else if let domain = BundledNodes.dict[chainId] { + return https + domain } else { return nil }