Skip to content

Commit

Permalink
- bump library to get 3route abstraction fix
Browse files Browse the repository at this point in the history
- make sure no uniqueness collisions with other pending items
- sort based on counter so newest is always top
  • Loading branch information
simonmcl committed Feb 16, 2024
1 parent 6c0ba47 commit aaf9ec7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"location" : "https://github.com/kukai-wallet/kukai-core-swift",
"state" : {
"branch" : "develop",
"revision" : "da94dc790fce0ce2228bb7930303f4670bd9cef0"
"revision" : "4e775b2632f44b24fee55de769aa438e0e5eb6d5"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Kukai Mobile/Modules/Activity/ActivityViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class ActivityViewModel: ViewModel, UITableViewDiffableDataSourceHandler {
var full = DependencyManager.shared.activityService.pendingTransactionGroups.filter({ $0.transactions.first?.sender.address == currentAddress })
full.append(contentsOf: DependencyManager.shared.activityService.transactionGroups)

full.sort(by: { ($0.transactions.first?.id) ?? 0 > ($1.transactions.first?.id) ?? 0 })
full.sort(by: { ($0.transactions.first?.counter) ?? 0 > ($1.transactions.first?.counter) ?? 0 })

self.groups = full
self.loadGroups(animate: animate)
Expand Down
6 changes: 3 additions & 3 deletions Kukai Mobile/Services/ActivityService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public class ActivityService {

public func addPending(opHash: String, type: TzKTTransaction.TransactionType, counter: Decimal, fromWallet: WalletMetadata, destinationAddress: String, destinationAlias: String?, xtzAmount: TokenAmount, parameters: [String: String]?, primaryToken: Token?) -> Bool {
let destination = TzKTAddress(alias: destinationAlias, address: destinationAddress)
let previousId = transactionGroups.first?.transactions.first?.id ?? 0
let previousId = pendingTransactionGroups.count == 0 ? (transactionGroups.first?.transactions.first?.id ?? 0) : (pendingTransactionGroups.first?.id ?? 0)
var transaction = TzKTTransaction.placeholder(withStatus: .unconfirmed, id: previousId + 1, opHash: opHash, type: type, counter: counter, fromWallet: fromWallet, destination: destination, xtzAmount: xtzAmount, parameters: parameters, primaryToken: primaryToken)
transaction.processAdditionalData(withCurrentWalletAddress: fromWallet.address)

Expand All @@ -126,7 +126,7 @@ public class ActivityService {
}

public func addPendingBatch(opHash: String, counter: Decimal, fromWallet: WalletMetadata, batchInfo: [PendingBatchInfo]) -> Bool {
var previousId = transactionGroups.first?.transactions.first?.id ?? 0
var previousId = pendingTransactionGroups.count == 0 ? (transactionGroups.first?.transactions.first?.id ?? 0) : (pendingTransactionGroups.first?.id ?? 0)

var transactions: [TzKTTransaction] = []
for info in batchInfo {
Expand All @@ -150,7 +150,7 @@ public class ActivityService {
}

public func addPending(opHash: String, type: TzKTTransaction.TransactionType, counter: Decimal, fromWallet: WalletMetadata, newDelegate: TzKTAddress?) -> Bool {
let previousId = transactionGroups.first?.transactions.first?.id ?? 0
let previousId = pendingTransactionGroups.count == 0 ? (transactionGroups.first?.transactions.first?.id ?? 0) : (pendingTransactionGroups.first?.id ?? 0)
let transaction = TzKTTransaction.placeholder(withStatus: .unconfirmed, id: previousId + 1, opHash: opHash, type: type, counter: counter, fromWallet: fromWallet, newDelegate: newDelegate)

if let group = TzKTTransactionGroup(withTransactions: [transaction], currentWalletAddress: fromWallet.address) {
Expand Down

0 comments on commit aaf9ec7

Please sign in to comment.