From d2c146d448f01b630f2c53178450c099e342b146 Mon Sep 17 00:00:00 2001 From: Alexander Osokin <4981841+tureck1y@users.noreply.github.com> Date: Mon, 21 Oct 2024 18:31:44 +0100 Subject: [PATCH] IOS-8287 Update quicknode resolving (#868) --- .../xcshareddata/swiftpm/Package.resolved | 4 ++-- .../APIResolvers/QuickNodeAPIResolver.swift | 20 +++++++++++++------ BlockchainSdkExample/config | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/BlockchainSdk.xcworkspace/xcshareddata/swiftpm/Package.resolved b/BlockchainSdk.xcworkspace/xcshareddata/swiftpm/Package.resolved index e7e1850ae..273705505 100644 --- a/BlockchainSdk.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/BlockchainSdk.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -240,8 +240,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/tangem/ton-swift.git", "state" : { - "revision" : "9b34ec1c46dff7d2d5ee9e3ee0893886d3ceceae", - "version" : "1.0.10-tangem2" + "revision" : "723cfeb8da0ea024158b4274fced8a1891bff88e", + "version" : "1.0.10-tangem3" } }, { diff --git a/BlockchainSdk/Common/API/APIResolvers/QuickNodeAPIResolver.swift b/BlockchainSdk/Common/API/APIResolvers/QuickNodeAPIResolver.swift index 6c2bd3914..152ac45c0 100644 --- a/BlockchainSdk/Common/API/APIResolvers/QuickNodeAPIResolver.swift +++ b/BlockchainSdk/Common/API/APIResolvers/QuickNodeAPIResolver.swift @@ -12,15 +12,23 @@ struct QuickNodeAPIResolver { let config: BlockchainSdkConfig func resolve(for blockchain: Blockchain) -> NodeInfo? { + guard let credentials = resolveCredentials(for: blockchain) else { + return nil + } + + guard let url = URL(string: "https://\(credentials.subdomain)/\(credentials.apiKey)") else { + return nil + } + + return NodeInfo(url: url) + } + + private func resolveCredentials(for blockchain: Blockchain) -> BlockchainSdkConfig.QuickNodeCredentials? { switch blockchain { case .bsc: - let subdomain = config.quickNodeBscCredentials.subdomain - let key = config.quickNodeBscCredentials.apiKey - return .init(url: URL(string: "https://\(subdomain).bsc.discover.quiknode.pro/\(key)")!) + return config.quickNodeBscCredentials case .solana: - let subdomain = config.quickNodeSolanaCredentials.subdomain - let key = config.quickNodeSolanaCredentials.apiKey - return .init(url: URL(string: "https://\(subdomain).solana-mainnet.discover.quiknode.pro/\(key)")!) + return config.quickNodeSolanaCredentials default: return nil } diff --git a/BlockchainSdkExample/config b/BlockchainSdkExample/config index d52c8382e..cf01c9162 160000 --- a/BlockchainSdkExample/config +++ b/BlockchainSdkExample/config @@ -1 +1 @@ -Subproject commit d52c8382e9e94b2b44ceecd7cb7bd897e091073c +Subproject commit cf01c91626bf58bdf6895c59a706b83c37a9e345