Repository navigation
fix(app): reject non-finite usd in amountForUsd - #28
Conversation
…er becomes "Infinity" amountForUsd(Infinity, 1, 18) returned the literal string "Infinity", which viem parseUnits rejects downstream in suggestFirstBuy. Guard the usd input with Number.isFinite like quoteUsd already was, and cover Infinity/NaN for both inputs.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthrough
ChangesAmount validation
Priority: ⬇️ Low Estimated code review effort: 1 (Trivial) | ~5 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to Non-finite amount inputs are now rejected before formatting, preventing invalid purchase suggestions. No merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
amountForUsd(Infinity, 1, 18) returned the literal string "Infinity", which viem parseUnits rejects downstream in suggestFirstBuy.
Before: `if (!(usd > 0) || !(quoteUsd > 0) || !Number.isFinite(quoteUsd))` — Infinity passes `usd > 0`, divides to Infinity, toFixed(2) is "Infinity", trimZeros is a no-op, places=0 passes, returns "Infinity".
After: also require `Number.isFinite(usd)`, matching the quoteUsd guard. Adds regression coverage for Infinity/NaN on both inputs.
Verified locally on upstream/main base:
Summary by CodeRabbit
InfinityandNaNare now safely rejected instead of causing invalid amount conversion errors.