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

Commit

Permalink
update SolanaTxManagerProxyExtensions to fetch estimated tx fee using…
Browse files Browse the repository at this point in the history
… TransactionInfo
  • Loading branch information
nuo-xu committed May 15, 2023
1 parent 3d5dff6 commit 036ba67
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 36 deletions.
5 changes: 1 addition & 4 deletions Sources/BraveWallet/Crypto/Stores/AssetDetailStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,7 @@ class AssetDetailStore: ObservableObject {
}
var solEstimatedTxFees: [String: UInt64] = [:]
if token.coin == .sol {
solEstimatedTxFees = await solTxManagerProxy.estimatedTxFees(
chainId: network.chainId,
for: allTransactions.map(\.id)
)
solEstimatedTxFees = await solTxManagerProxy.estimatedTxFees(for: allTransactions)
}
return allTransactions
.filter { tx in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,6 @@ import BraveCore

extension BraveWalletSolanaTxManagerProxy {

/// Fetches the estimatedTxFee for an array of transaction meta ids.
func estimatedTxFees(
chainId: String,
for transactionMetaIds: [String],
completion: @escaping ([String: UInt64]) -> Void
) {
var estimatedTxFees: [String: UInt64] = [:]
let dispatchGroup = DispatchGroup()
transactionMetaIds.forEach { txMetaId in
dispatchGroup.enter()
estimatedTxFee(chainId, txMetaId: txMetaId) { fee, _, _ in
defer { dispatchGroup.leave() }
estimatedTxFees[txMetaId] = fee
}
}
dispatchGroup.notify(queue: .main) {
completion(estimatedTxFees)
}
}

/// Fetches the estimatedTxFee for an array of transaction meta ids.
@MainActor func estimatedTxFees(
chainId: String,
for transactionMetaIds: [String]
) async -> [String: UInt64] {
await withCheckedContinuation { continuation in
estimatedTxFees(chainId: chainId, for: transactionMetaIds) { fees in
continuation.resume(returning: fees)
}
}
}

/// Fetches the estimatedTxFee for an array of transactions
@MainActor func estimatedTxFees(for transactions: [BraveWallet.TransactionInfo]
) async -> [String: UInt64] {
Expand Down

0 comments on commit 036ba67

Please sign in to comment.