feat(order): show amount limits in fiat in the create order screen#605
Conversation
currency - Convert the node's sats min/max back to whole fiat using the loaded rate - Round min up / max down, floor min at 1 (field is integer-only, no decimals) - Fall back to the sats message when the range collapses below 1 fiat - Add pure fiatAmountLimits helper + unit tests; drop validation debugPrint
currency - Convert the node's sats min/max back to whole fiat using the loaded rate - Round min up / max down, floor min at 1 (field is integer-only, no decimals) - Append the raw sats range in parentheses so users see why the fiat range moves - Fall back to the sats-only message when the range collapses below 1 fiat - Add pure fiatAmountLimits helper + unit tests; drop validation debugPrint
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (4)
WalkthroughAdds a fiat-conversion utility for satoshi bounds, integrates it into order validation to provide range-aware localized errors, passes the selected fiat code into the amount widget, adds unit tests for conversion logic, and updates localization keys/messages in five locale files. ChangesFiat amount range validation for orders
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@test/shared/utils/order_amount_limits_test.dart`:
- Around line 19-27: The explanatory comment in the test for fiatAmountLimits is
wrong: the conversion for minSats=50 with exchangeRate=100000 yields
50/100000000*100000 = 0.05 (not 0.5); update the inline comment in the test case
(the one above the fiatAmountLimits call in order_amount_limits_test.dart) to
show "0.05" so it correctly documents the conversion while keeping the assertion
that the value is clamped to 1.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4bafd724-20a1-44d6-bb52-544739b07021
📒 Files selected for processing (8)
lib/features/order/screens/add_order_screen.dartlib/l10n/intl_de.arblib/l10n/intl_en.arblib/l10n/intl_es.arblib/l10n/intl_fr.arblib/l10n/intl_it.arblib/shared/utils/order_amount_limits.darttest/shared/utils/order_amount_limits_test.dart
There was a problem hiding this comment.
I reviewed the current revision and I do not see a blocking issue here.
What I checked:
- The conversion logic is directionally correct for this UI: min rounds up, max rounds down, and the minimum is floored at 1 because the field only accepts whole fiat values.
- The fallback to the sats-only message when the fiat range collapses below 1 is the right behavior; otherwise the user would see a fake whole-fiat range they cannot actually enter.
- Reusing the already-loaded exchange rate is the right tradeoff here. This improves the message without adding extra fetches or cross-cutting changes.
- The raw sats bounds are still appended in the range message, which is useful context and makes the moving fiat range less surprising.
- The helper extraction and unit tests are good. They cover the important rounding/displayability cases rather than just snapshotting strings.
I only saw a minor doc/comment nit in the tests, not a functional problem. Approving this revision.
- AmountSection takes the selected fiatCode and shows e.g. Enter the amount of USD you want to receive; falls back to fiat when none - Replace the generic enterAmount keys with currency-parameterized ones in en/es/it/de/fr
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Re-reviewed the latest head. I still do not see a blocking issue here.
The new follow-up change also looks fine to me:
- Passing the selected
fiatCodeintoAmountSectionmakes the prompt more explicit without changing validation semantics. - The null/empty fallback to the generic "fiat" label is reasonable, so the UI does not regress when the code is not selected yet.
- The earlier conversion/range behavior still looks correct, and the test-comment nit was fixed.
- CI is green.
Approved on the current revision.



The range error now shows the limits in the fiat currency the user typed, with the sats range in parentheses.
Before: "...allows between 100 and 1000000 sats."
After: "...allows between 1 and 734 USD (100 - 1000000 sats)."
fiatAmountLimitshelper reuses the already-loaded rate (no extra calls)Summary by CodeRabbit