Repository navigation
fix available sats in keyboard - #224
Conversation
Deploying wallet-signet with
|
| Latest commit: |
8fc7db6
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://aecac845.wallet-23u.pages.dev |
| Branch Preview URL: | https://fix-available-sats-mobile.wallet-23u.pages.dev |
Deploying wallet-mutinynet with
|
| Latest commit: |
8fc7db6
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6c969478.arkade-wallet.pages.dev |
| Branch Preview URL: | https://fix-available-sats-mobile.arkade-wallet.pages.dev |
WalkthroughChanges introduce available balance state management in the Keyboard component, fetching balance via wallet service and using it for max button functionality and balance displays. A type annotation is simplified in the Send form component. Changes
Sequence DiagramsequenceDiagram
participant Keyboard as Keyboard Component
participant Effect as useEffect Hook
participant Wallet as svcWallet Service
participant State as availableBalance State
Keyboard->>Keyboard: balance updates
Keyboard->>Effect: trigger effect (dependency: balance)
Effect->>Effect: check svcWallet exists
alt svcWallet available
Effect->>Wallet: getBalance()
Wallet-->>Effect: available balance
Effect->>State: update availableBalance
else svcWallet missing
Effect->>Effect: guard exits, no action
end
Keyboard->>State: read availableBalance
Keyboard->>Keyboard: handleMaxPress uses availableBalance
Keyboard->>Keyboard: display uses availableBalance
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 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-bitcoin with
|
| Latest commit: |
8fc7db6
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://66ad3c4f.wallet-bitcoin.pages.dev |
| Branch Preview URL: | https://fix-available-sats-mobile.wallet-bitcoin.pages.dev |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/screens/Wallet/Send/Form.tsx (1)
88-91: Add error handling for the balance fetch.The promise from
svcWallet.getBalance()lacks error handling, which could result in unhandled promise rejections if the call fails.Apply this diff to add error handling:
useEffect(() => { if (!svcWallet) return - svcWallet.getBalance().then((bal) => setAvailableBalance(bal.available)) + svcWallet.getBalance() + .then((bal) => setAvailableBalance(bal.available)) + .catch((err) => consoleError(err, 'error fetching available balance')) }, [balance])src/components/Keyboard.tsx (1)
36-39: Add error handling for the balance fetch.The promise from
svcWallet.getBalance()lacks error handling, which could result in unhandled promise rejections if the call fails.Apply this diff to add error handling:
useEffect(() => { if (!svcWallet) return - svcWallet.getBalance().then((bal) => setAvailableBalance(bal.available)) + svcWallet.getBalance() + .then((bal) => setAvailableBalance(bal.available)) + .catch((err) => console.error('error fetching available balance:', err)) }, [balance])
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/components/Keyboard.tsx(3 hunks)src/screens/Wallet/Send/Form.tsx(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: bordalix
Repo: arkade-os/wallet PR: 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
Repo: arkade-os/wallet PR: 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/components/Keyboard.tsxsrc/screens/Wallet/Send/Form.tsx
📚 Learning: 2025-07-21T18:25:36.391Z
Learnt from: bordalix
Repo: arkade-os/wallet PR: 121
File: src/screens/Init/Restore.tsx:58-58
Timestamp: 2025-07-21T18:25:36.391Z
Learning: In src/screens/Init/Restore.tsx, the Input component for private key restoration intentionally omits the `value` prop to make it uncontrolled. This is a security feature to prevent the private key from being displayed if users navigate away and return to the screen, avoiding potential exposure of sensitive data in the UI.
Applied to files:
src/components/Keyboard.tsx
🧬 Code graph analysis (1)
src/components/Keyboard.tsx (3)
src/providers/wallet.tsx (1)
WalletContext(41-55)src/lib/constants.ts (1)
defaultFee(2-2)src/lib/format.ts (1)
prettyAmount(27-34)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test
🔇 Additional comments (3)
src/screens/Wallet/Send/Form.tsx (1)
56-56: LGTM! Type inference handles this.Removing the explicit type annotation is fine since TypeScript correctly infers
numberfrom the initial value.src/components/Keyboard.tsx (2)
26-26: Good addition of available balance tracking.Adding
svcWalletfrom context and introducing theavailableBalancestate improves accuracy by tracking the actual spendable balance.Also applies to: 29-29
49-50: Correct use of available balance for max amount and display.The logic now correctly uses
availableBalanceinstead of the totalbalance, which accurately reflects what users can actually spend and prevents confusion.Also applies to: 60-60
Summary by CodeRabbit