Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
IOS-8287 Update quicknode resolving (#868)
Browse files Browse the repository at this point in the history
  • Loading branch information
tureck1y authored Oct 21, 2024
1 parent b6d5daf commit d2c146d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down
20 changes: 14 additions & 6 deletions BlockchainSdk/Common/API/APIResolvers/QuickNodeAPIResolver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion BlockchainSdkExample/config

0 comments on commit d2c146d

Please sign in to comment.