fix(DepositStreamModal): enforce positive amount validation for token deposits - #599
Conversation
… deposits Prevent submitting zero or negative deposit amounts into existing payment streams by adding an explicit front-end guard in the onSubmit handler and a `min="0"` HTML attribute on the number input. This provides defense-in-depth alongside the existing Zod schema and StellarService validation. Closes Fundable-Protocol#419
|
@Adeyinka0123 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
📝 WalkthroughWalkthrough
ChangesDeposit amount validation
Estimated code review effort: 2 (Simple) | ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
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 `@apps/web/src/components/modules/payment-stream/DepositStreamModal.tsx`:
- Around line 120-124: Update the deposit amount Input in DepositStreamModal to
use the smallest supported positive token unit as its min value, matching the
existing positive-amount validation; alternatively remove the min attribute
rather than retaining min="0".
🪄 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 Plus
Run ID: 7632ef22-8774-4d80-8886-00fd4c02d991
📒 Files selected for processing (1)
apps/web/src/components/modules/payment-stream/DepositStreamModal.tsx
| <Input | ||
| id="deposit-amount" | ||
| type="number" | ||
| min="0" | ||
| step="0.0000001" |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "Files:"
fd -a 'DepositStreamModal\.tsx|.*payment.*|.*Deposit.*|.*Stream.*' . | sed 's#^\./##' | head -200
echo
echo "Target file outline:"
if [ -f apps/web/src/components/modules/payment-stream/DepositStreamModal.tsx ]; then
wc -l apps/web/src/components/modules/payment-stream/DepositStreamModal.tsx
ast-grep outline apps/web/src/components/modules/payment-stream/DepositStreamModal.tsx || true
echo
echo "Relevant sections:"
sed -n '1,240p' apps/web/src/components/modules/payment-stream/DepositStreamModal.tsx | cat -n
fi
echo
echo "Search for deposit amount guard/schema:"
rg -n "deposit.*amount|depositAmount|amount|greater than zero|> 0|schema|z\\.number|validate|allowZero|zero" apps/web/src -S | head -300Repository: Fundable-Protocol/stellar_client_os
Length of output: 39139
Use a consistent minimum value.
min="0" still represents the value 0 in this context, so it conflicts with the existing positive-amount enforcement. Since zero is already blocked by the submit guard, set min to the smallest supported positive token unit or remove it as a UI hint.
🤖 Prompt for 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.
In `@apps/web/src/components/modules/payment-stream/DepositStreamModal.tsx` around
lines 120 - 124, Update the deposit amount Input in DepositStreamModal to use
the smallest supported positive token unit as its min value, matching the
existing positive-amount validation; alternatively remove the min attribute
rather than retaining min="0".
|
dont forget to offramp using https://stellar.fundable.finance/offramp its fast, free and p2p rates |
Overview
This PR enforces positive amount validation for token deposits in the DepositStreamModal to prevent users from submitting zero or negative deposit amounts into existing payment streams.
Related Issue
Closes #419
Changes
onSubmithandler — checks thatparseFloat(data.amount) > 0and shows an error notification before proceeding with the depositmin="0"HTML attribute on the number input element to prevent browsers from allowing negative values via the stepper/spinnerDefense-in-depth validation layers
min="0"attributevalidations.ts→depositStreamSchema.refine()checksparseFloat(val) > 0onSubmithandlerstellar.ts→depositToStream()ErrorVerification Results
TypeScript compiles without new errors. All 4 pre-existing test failures are unrelated (sanitize-error regex patterns, app-provider offline notification, stellar-service edge cases).
Summary by CodeRabbit