From 00d43f88224964f5b30c31ea91fef63343006c3b Mon Sep 17 00:00:00 2001 From: ivanzeng Date: Wed, 11 Dec 2024 14:48:35 +0800 Subject: [PATCH] fix: optional try for the getFees --- Sources/SolanaSwift/BlockchainClient/BlockchainClient.swift | 6 ++---- .../BlockchainClientWithNativeSOLTests.swift | 6 ++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Sources/SolanaSwift/BlockchainClient/BlockchainClient.swift b/Sources/SolanaSwift/BlockchainClient/BlockchainClient.swift index c68ed38..e3cfadf 100644 --- a/Sources/SolanaSwift/BlockchainClient/BlockchainClient.swift +++ b/Sources/SolanaSwift/BlockchainClient/BlockchainClient.swift @@ -34,10 +34,8 @@ public class BlockchainClient: SolanaBlockchainClient { if let fc = fc { feeCalculator = fc } else { - let (lps, minRentExemption) = try await( - apiClient.getFees(commitment: nil).feeCalculator?.lamportsPerSignature, - apiClient.getMinimumBalanceForRentExemption(span: 165) - ) + let lps = try? await apiClient.getFees(commitment: nil).feeCalculator?.lamportsPerSignature + let minRentExemption = try await apiClient.getMinimumBalanceForRentExemption(span: 165) let lamportsPerSignature = lps ?? 5000 feeCalculator = DefaultFeeCalculator( lamportsPerSignature: lamportsPerSignature, diff --git a/Tests/SolanaSwiftUnitTests/BlockchainClient/BlockchainClientWithNativeSOLTests.swift b/Tests/SolanaSwiftUnitTests/BlockchainClient/BlockchainClientWithNativeSOLTests.swift index acea5e3..ae043ed 100644 --- a/Tests/SolanaSwiftUnitTests/BlockchainClient/BlockchainClientWithNativeSOLTests.swift +++ b/Tests/SolanaSwiftUnitTests/BlockchainClient/BlockchainClientWithNativeSOLTests.swift @@ -72,6 +72,7 @@ class BlockchainClientWithNativeSOLTests: XCTestCase { } private class MockAPIClient: SolanaAPIClient { + let testCase: String init(testCase: String) { @@ -204,6 +205,11 @@ private class MockAPIClient: SolanaAPIClient { fatalError() } } + + func getLatestBlockhash(commitment: SolanaSwift.Commitment?) async throws -> String { + return "" + } + func getMinimumBalanceForRentExemption(dataLength _: UInt64, commitment _: Commitment?) async throws -> UInt64 { 2_039_280