Skip to content

Commit bbf6e11

Browse files
authored
Merge pull request #1662 from MixinNetwork/bugfix/web3
Fix solana dapp operations
2 parents b1273c8 + d0925f2 commit bbf6e11

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

Mixin/Service/Web3/SolanaTransferOperation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class SolanaTransferOperation: Web3TransferOperation {
4343
}
4444

4545
func fee(for transaction: Solana.Transaction) async throws -> Fee? {
46-
let lamportsPerSignature = try await client.getRecentBlockhash().lamportsPerSignature
46+
let lamportsPerSignature: UInt64 = 5000
4747
guard let tokenCount = transaction.fee(lamportsPerSignature: lamportsPerSignature) else {
4848
return nil
4949
}
@@ -57,7 +57,7 @@ class SolanaTransferOperation: Web3TransferOperation {
5757
do {
5858
Logger.web3.info(category: "SolanaTransfer", message: "Start")
5959
let priv = try await TIP.deriveSolanaPrivateKey(pin: pin)
60-
let recentBlockhash = try await client.getRecentBlockhash().blockhash
60+
let recentBlockhash = try await client.getLatestBlockhash()
6161
Logger.web3.info(category: "SolanaTransfer", message: "Using blockhash: \(recentBlockhash)")
6262
guard let blockhash = Data(base58EncodedString: recentBlockhash) else {
6363
throw SigningError.invalidBlockhash

Mixin/UserInterface/Controllers/Web3/Model/SolanaRPCClient.swift

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ import Alamofire
33

44
struct SolanaRPCClient {
55

6-
struct RecentBlockhash {
7-
let blockhash: String
8-
let lamportsPerSignature: UInt64
9-
}
10-
116
struct ResponseError: Error, Decodable, CustomStringConvertible {
127

138
struct Data: Decodable {
@@ -66,32 +61,24 @@ struct SolanaRPCClient {
6661
return value != nil
6762
}
6863

69-
func getRecentBlockhash() async throws -> RecentBlockhash {
64+
func getLatestBlockhash() async throws -> String {
7065

7166
struct Result: Decodable {
7267

7368
struct Value: Decodable {
74-
75-
struct FeeCalculator: Decodable {
76-
let lamportsPerSignature: UInt64
77-
}
78-
7969
let blockhash: String
80-
let feeCalculator: FeeCalculator
81-
8270
}
8371

8472
let value: Value
8573

8674
}
8775

8876
let response: Response<Result> = try await post(
89-
method: "getRecentBlockhash",
77+
method: "getLatestBlockhash",
9078
params: nil
9179
)
9280
let value = try response.getResult().value
93-
return RecentBlockhash(blockhash: value.blockhash,
94-
lamportsPerSignature: value.feeCalculator.lamportsPerSignature)
81+
return value.blockhash
9582
}
9683

9784
func sendTransaction(signedTransaction: String) async throws -> String {

0 commit comments

Comments
 (0)