feat: new currency input#2320
Conversation
|
Warning Review limit reached
More reviews will be available in 5 minutes and 31 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR introduces ChangesCurrency Input Component & Wallet Integration
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
* feat: use currency input in send flows * feat: use currency input in swap flows (#2322) * feat: use currency input in swap flows * feat: add BTC denomination toggle to currency input (#2367) * feat: add BTC denomination toggle to currency input * fix: auto switch decimal bitcoin input to BTC * chore: address feedback on currency input field (#2371) * chore: address feedback on currency input field * feat: make currency input units clickable * fix: separate currency and unit click targets * fix: remove persistent unit toggle highlight * fix: tighten currency input unit spacing * fix: make alternate bitcoin amount clickable * fix: align context amount unit spacing --------- Co-authored-by: saunter <68239231+stackingsaunter@users.noreply.github.com> --------- Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com> --------- Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com> --------- Co-authored-by: Roland <33993199+rolznz@users.noreply.github.com>
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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 `@frontend/src/components/CurrencyInputField.tsx`:
- Around line 381-386: The code currently forces 2 decimal places for fiat
output by using .toFixed(2); change this to derive the decimal precision from
the active fiat currency instead of hardcoding 2: determine the number of
fraction digits (e.g., via a helper like getCurrencyDecimals(selectedCurrency)
or Intl.NumberFormat(selectedCurrency).resolvedOptions().maximumFractionDigits)
and use that value in place of 2 when formatting the converted amount in the
function that returns ((amountSat / SATS_PER_BTC) * rate).toFixed(...), with a
sensible fallback (e.g., 2) if the currency information is unavailable.
- Around line 451-454: In CurrencyInputField.tsx remove the Tailwind !important
modifier from the InputGroupAddon class (the className value on the
InputGroupAddon element) and replace it by composing normal utilities or wrapper
classes — e.g., remove "!mr-0" and use an equivalent combination such as "mr-0"
applied via a parent wrapper or add a specific component-level class (e.g.,
"addon-no-margin") and define the margin rule in the component's
stylesheet/JS-in-CSS so the addon styling is enforced without using !important;
update any tests or snapshots that depend on the previous rendering.
In `@frontend/src/screens/wallet/receive/ReceiveOnchain.tsx`:
- Around line 135-146: The maxSat calculation uses
balances.lightning.totalReceivableSat directly, which when 0 blocks valid
receives; update the logic in the maxSat expression (the ternary handling
swapFrom, hasChannelManagement, swapInfo.maxAmountSat,
balances.lightning.totalReceivableSat) to treat a zero or falsy
totalReceivableSat as "unknown" by falling back to swapInfo.maxAmountSat (for
bitcoin) or undefined (for non-bitcoin) — i.e., compute an effectiveReceivable =
balances.lightning.totalReceivableSat > 0 ?
balances.lightning.totalReceivableSat * 0.99 : undefined and then use
Math.min(swapInfo.maxAmountSat, effectiveReceivable) when appropriate so valid
amounts aren’t blocked; apply the same change to the similar block using the
same identifiers.
In `@frontend/src/screens/wallet/swap/index.tsx`:
- Around line 198-206: The maxSat calculation currently applies the receivable
cap even when balances.lightning.totalReceivableSat is zero, which can force
maxSat to 0; update the logic in the maxSat computation (the expression using
hasChannelManagement, balances.lightning.totalReceivableSat * 0.99,
swapInfo.maxAmountSat, isInternalSwap, and spendableOnchainBalance) to only
include the receivable bound when balances.lightning.totalReceivableSat > 0
(e.g., conditionally push balances.lightning.totalReceivableSat * 0.99 into the
Math.min arguments only if it is positive), and apply the same change to the
analogous block around lines 219-226 so missing/unreported receivable capacity
does not zero out the limit.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4bba7373-449c-4c1d-9926-280fff58c721
📒 Files selected for processing (9)
frontend/src/components/AnchorReserveAlert.tsxfrontend/src/components/CurrencyInputField.tsxfrontend/src/screens/wallet/receive/ReceiveInvoice.tsxfrontend/src/screens/wallet/receive/ReceiveOnchain.tsxfrontend/src/screens/wallet/send/LnurlPay.tsxfrontend/src/screens/wallet/send/Onchain.tsxfrontend/src/screens/wallet/send/ZeroAmount.tsxfrontend/src/screens/wallet/swap/AutoSwap.tsxfrontend/src/screens/wallet/swap/index.tsx



Summary
Part of #2319.
Fixes #2379
Adds a reusable
CurrencyInputFieldcomposed from the existing shadcnFieldandInputGroupprimitives, then adopts it in receive flows. The field supports bitcoin/sats display, fiat entry through the configured currency, opposite-currency preview, and context rows.Scope
CurrencyInputFieldReceive limitcontext from existing balance dataValidation
yarn tsc:compileyarn lintbefore splitting the PR stackSummary by CodeRabbit
Release Notes
New Features
Improvements