Skip to content

fix: use cached account for fetch accounts#82

Merged
jaymengxy merged 1 commit into
mainfrom
fix-provider-wallet
Feb 27, 2026
Merged

fix: use cached account for fetch accounts#82
jaymengxy merged 1 commit into
mainfrom
fix-provider-wallet

Conversation

@jaymengxy
Copy link
Copy Markdown
Contributor

No description provided.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 27, 2026

PR Summary

Modified the wallet account fetching logic to preserve cached accounts when network requests return empty results, preventing account loss due to potential indexer latency issues. Added comprehensive logging to track cache loading and network fetch results across different blockchain networks.

Changes

File Summary
Android/wallet/src/main/java/com/flow/wallet/wallet/BaseWallet.kt Modified fetchAllNetworkAccounts() to preserve existing cached accounts instead of starting fresh. Added logic to keep cached accounts when network returns empty results, preventing data loss from indexer latency. Enhanced logging to track cache loading and network fetch results.
Android/wallet/src/main/java/com/flow/wallet/wallet/KeyWallet.kt Enhanced debug logging in fetchAccountsForNetwork() to include network information when fetching accounts for both P256 and SECP256k1 public keys, improving debugging capabilities for network-specific operations.

autogenerated by presubmit.ai

@jaymengxy jaymengxy merged commit 8c6cac0 into main Feb 27, 2026
1 of 2 checks passed
@jaymengxy jaymengxy deleted the fix-provider-wallet branch February 27, 2026 15:12
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

🚨 Pull request needs attention.

Review Summary

Commits Considered (1)
  • df862a2: fix: use cached account for fetch accounts
Files Processed (2)
  • Android/wallet/src/main/java/com/flow/wallet/wallet/BaseWallet.kt (3 hunks)
  • Android/wallet/src/main/java/com/flow/wallet/wallet/KeyWallet.kt (2 hunks)
Actionable Comments (2)
  • Android/wallet/src/main/java/com/flow/wallet/wallet/BaseWallet.kt [196-197]

    possible bug: "Cached accounts may not be preserved in new maps initialization."

  • Android/wallet/src/main/java/com/flow/wallet/wallet/BaseWallet.kt [211-216]

    possible bug: "Cache preservation logic is incomplete."

Skipped Comments (0)

Comment on lines +196 to +197
val newAccounts = _accounts.toMutableMap()
val newFlowAccounts = flowAccounts.toMutableMap()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The initialization of newAccounts and newFlowAccounts creates mutable copies of the current state, but when network fetches return empty results, these copies won't contain the cached data. Consider initializing these maps with the existing cached data to ensure cached accounts are preserved.

Comment on lines +211 to 216
} else {
val cached = flowAccounts[network]
if (!cached.isNullOrEmpty()) {
Log.w("BaseWallet", "Network returned 0 accounts for $network, but cache has ${cached.size}. KEEPING CACHE due to potential indexer latency.")
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The logic logs a warning about keeping cache but doesn't actually preserve the cached accounts in the newFlowAccounts and newAccounts maps. The cached data should be explicitly added to these maps to prevent account loss.

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.

1 participant