Skip to content

Fix tron transaction status update#9388

Merged
rafaelekol merged 1 commit into
version/0.50from
fix-tron-transaction-state-update
Jul 13, 2026
Merged

Fix tron transaction status update#9388
rafaelekol merged 1 commit into
version/0.50from
fix-tron-transaction-state-update

Conversation

@rafaelekol

@rafaelekol rafaelekol commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

#9379

Summary by CodeRabbit

  • Bug Fixes
    • Improved transaction list updates when new data arrives during an active load.
    • Ensures the latest transaction information is automatically reloaded after the current loading operation completes.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR updates the TronKit version reference and changes transaction record loading to replay reload requests received while a page load is in progress.

Changes

TronKit version update

Layer / File(s) Summary
Update TronKit version
gradle/libs.versions.toml
The tronKit version changes from 2f07e86 to ce966b7.

Transaction reload handling

Layer / File(s) Summary
Replay pending transaction reloads
walletkit/src/main/java/io/horizontalsystems/walletkit/modules/transactions/TransactionRecordRepository.kt
TransactionRecordRepository records reload requests during active loads and invokes a subsequent load after completion.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: abdrasulov

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the Tron transaction status update fix implemented in the repository and dependency changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-tron-transaction-state-update

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@walletkit/src/main/java/io/horizontalsystems/walletkit/modules/transactions/TransactionRecordRepository.kt`:
- Line 38: Update invalidateAdapters() to also reset the reloadRequested
AtomicBoolean when resetting loading and loadedPageNumber, preventing an
in-flight load from scheduling a spurious loadItems(0).
- Around line 235-237: Update the reload-request replay logic in
TransactionRecordRepository so it preserves the caller’s intended page:
handleUpdates must replay the page represented by loadedPageNumber, while
reload() and set() must replay from page 1 when their load is deferred by an
in-flight request. Track this intent with a distinct flag or equivalent
parameter, and have the replay consume it without changing normal pagination
behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ffc8b7c7-3477-4a27-aed8-adadc240eb14

📥 Commits

Reviewing files that changed from the base of the PR and between f44bc6d and 104fdab.

📒 Files selected for processing (2)
  • gradle/libs.versions.toml
  • walletkit/src/main/java/io/horizontalsystems/walletkit/modules/transactions/TransactionRecordRepository.kt

private var loadedPageNumber = 0
private val items = CopyOnWriteArrayList<TransactionRecord>()
private val loading = AtomicBoolean(false)
private val reloadRequested = AtomicBoolean(false)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Clear reloadRequested in invalidateAdapters().

invalidateAdapters() (line 248) sets loading.set(false) but does not clear reloadRequested. If a load is in progress when invalidateAdapters() is called, the in-flight coroutine's finally block may see reloadRequested == true and trigger a spurious loadItems(0) (since invalidateAdapters() resets loadedPageNumber = 0).

🛡️ Proposed fix
 override fun invalidateAdapters() {
     unsubscribeFromUpdates()
     adaptersMap.values.forEach(TransactionAdapterWrapper::clear)
     adaptersMap.clear()
     items.clear()
     loadedPageNumber = 0
     loading.set(false)
+    reloadRequested.set(false)
     allLoaded.set(false)
     selectedWallet = null
     itemsSubject.onNext(emptyList())
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private val reloadRequested = AtomicBoolean(false)
override fun invalidateAdapters() {
unsubscribeFromUpdates()
adaptersMap.values.forEach(TransactionAdapterWrapper::clear)
adaptersMap.clear()
items.clear()
loadedPageNumber = 0
loading.set(false)
reloadRequested.set(false)
allLoaded.set(false)
selectedWallet = null
itemsSubject.onNext(emptyList())
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@walletkit/src/main/java/io/horizontalsystems/walletkit/modules/transactions/TransactionRecordRepository.kt`
at line 38, Update invalidateAdapters() to also reset the reloadRequested
AtomicBoolean when resetting loading and loadedPageNumber, preventing an
in-flight load from scheduling a spurious loadItems(0).

Comment on lines +235 to +237
if (reloadRequested.compareAndSet(true, false)) {
loadItems(loadedPageNumber)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Replay uses loadedPageNumber — wrong page for reload() and set() paths.

The replay calls loadItems(loadedPageNumber), which is correct for handleUpdates (refresh the page just loaded). However, reload() (line 187) and set() (line 170) call loadItems(1) with the intent of starting from page 1. If a load is already in progress when either is called, loadItems(1) returns early and sets reloadRequested = true. When the in-flight load finishes, loadedPageNumber has been set to the in-flight page (e.g., 2 or 3), so the replay loads that page instead of page 1. This causes incorrect pagination — the user sees items from the wrong page after a filter change or explicit reload.

The two call paths have different replay intents: handleUpdates wants the page just loaded (loadedPageNumber at replay time), while reload()/set() want page 1. Consider distinguishing them, e.g., with a fromStart parameter or a separate flag:

🔧 Proposed fix using a `fromStart` parameter
 private val reloadRequested = AtomicBoolean(false)
+private val reloadFromStartRequested = AtomicBoolean(false)

 // ...

 override fun reload() {
     adaptersMap.forEach { (_, transactionAdapterWrapper) ->
         transactionAdapterWrapper.reload()
     }
     unsubscribeFromUpdates()
     allLoaded.set(false)
-    loadItems(1)
+    loadItems(1, fromStart = true)
     subscribeForUpdates()
 }

 // In set():
 if (reload) {
     unsubscribeFromUpdates()
     allLoaded.set(false)
-    loadItems(1)
+    loadItems(1, fromStart = true)
     subscribeForUpdates()
 }

-private fun loadItems(page: Int) {
+private fun loadItems(page: Int, fromStart: Boolean = false) {
     if (!loading.compareAndSet(false, true)) {
-        reloadRequested.set(true)
+        if (fromStart) reloadFromStartRequested.set(true) else reloadRequested.set(true)
         return
     }
     // ...
     } finally {
         loading.set(false)
+        if (reloadFromStartRequested.compareAndSet(true, false)) {
+            loadItems(1, fromStart = true)
+        } else if (reloadRequested.compareAndSet(true, false)) {
-        if (reloadRequested.compareAndSet(true, false)) {
             loadItems(loadedPageNumber)
         }
     }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@walletkit/src/main/java/io/horizontalsystems/walletkit/modules/transactions/TransactionRecordRepository.kt`
around lines 235 - 237, Update the reload-request replay logic in
TransactionRecordRepository so it preserves the caller’s intended page:
handleUpdates must replay the page represented by loadedPageNumber, while
reload() and set() must replay from page 1 when their load is deferred by an
in-flight request. Track this intent with a distinct flag or equivalent
parameter, and have the replay consume it without changing normal pagination
behavior.

@rafaelekol
rafaelekol merged commit 104fdab into version/0.50 Jul 13, 2026
2 checks passed
@rafaelekol
rafaelekol deleted the fix-tron-transaction-state-update branch July 13, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants