Skip to content

Commit

Permalink
fix: optional try for the getFees
Browse files Browse the repository at this point in the history
  • Loading branch information
zanyfly committed Dec 11, 2024
1 parent 3362295 commit 00d43f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Sources/SolanaSwift/BlockchainClient/BlockchainClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class BlockchainClientWithNativeSOLTests: XCTestCase {
}

private class MockAPIClient: SolanaAPIClient {

let testCase: String

init(testCase: String) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 00d43f8

Please sign in to comment.