-
Notifications
You must be signed in to change notification settings - Fork 13
fix wallet restore balance #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe reloadWallet function in src/providers/wallet.tsx was changed from parallel fetching (Promise.all) to sequential awaits: first vtxos, then transaction history, then balance. Corresponding state updates were reordered to align with the new fetch sequence. Error handling and public interfaces were not modified. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant WP as WalletProvider
participant V as VTXO Service
participant T as TxHistory Service
participant B as Balance Service
User->>WP: reloadWallet()
Note over WP: Start sequential fetch
WP->>V: getVtxos()
V-->>WP: vtxos
WP->>WP: setVtxos(vtxos)
WP->>T: getTxHistory()
T-->>WP: txs
WP->>WP: setTxs(txs)
WP->>B: getBalance()
B-->>WP: balance
WP->>WP: setBalance(balance)
Note over WP: Error handling unchanged
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
Deploying wallet-signet with
|
| Latest commit: |
1ce1347
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://2a26e2f3.wallet-23u.pages.dev |
| Branch Preview URL: | https://fix-restore.wallet-23u.pages.dev |
Deploying wallet-mutinynet with
|
| Latest commit: |
1ce1347
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://250f6ba8.arkade-wallet.pages.dev |
| Branch Preview URL: | https://fix-restore.arkade-wallet.pages.dev |
Deploying wallet-bitcoin-v8 with
|
| Latest commit: |
1ce1347
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://75bef00b.wallet-v8.pages.dev |
| Branch Preview URL: | https://fix-restore.wallet-v8.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/providers/wallet.tsx (2)
115-117: Consider aligning state update order with fetch order for clarity.The fetch order is vtxos → txs → balance (lines 112-114), but state updates are balance → vtxos → txs (lines 115-117). While React batches these updates, aligning the order improves code readability and makes the data flow clearer.
const balance = await getBalance(swWallet) -setBalance(balance) setVtxos(vtxos) setTxs(txs) +setBalance(balance)
112-114: Parallelize vtxos and txs fetch, then await balance
Sequential awaits add ~3× latency. Instead, use:const [vtxos, txs] = await Promise.all([ getVtxos(swWallet), getTxHistory(swWallet), ]); const balance = await getBalance(swWallet);This ensures VTXO state is refreshed before
getBalance()without degrading reload performance. Verify this still resolves the balance-restore bug.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/providers/wallet.tsx(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: bordalix
PR: arkade-os/wallet#114
File: src/lib/asp.ts:0-0
Timestamp: 2025-06-30T18:33:29.839Z
Learning: In src/lib/asp.ts, only the collaborativeExit function should accept both IWallet and ServiceWorkerWallet types. Other wallet functions (getBalance, getTxHistory, getReceivingAddresses, redeemNotes, sendOnChain, settleVtxos) should maintain their original IWallet-only signatures and not be updated for consistency.
📚 Learning: 2025-06-30T18:33:29.839Z
Learnt from: bordalix
PR: arkade-os/wallet#114
File: src/lib/asp.ts:0-0
Timestamp: 2025-06-30T18:33:29.839Z
Learning: In src/lib/asp.ts, only the collaborativeExit function should accept both IWallet and ServiceWorkerWallet types. Other wallet functions (getBalance, getTxHistory, getReceivingAddresses, redeemNotes, sendOnChain, settleVtxos) should maintain their original IWallet-only signatures and not be updated for consistency.
Applied to files:
src/providers/wallet.tsx
🧬 Code graph analysis (1)
src/providers/wallet.tsx (1)
src/lib/asp.ts (3)
getVtxos(122-131)getTxHistory(86-120)getBalance(80-84)
Summary by CodeRabbit