Skip to content

fix(DepositStreamModal): enforce positive amount validation for token deposits - #599

Merged
Idrhas merged 1 commit into
Fundable-Protocol:mainfrom
Adeyinka0123:fix/positive-amount-deposit-stream
Aug 3, 2026
Merged

fix(DepositStreamModal): enforce positive amount validation for token deposits#599
Idrhas merged 1 commit into
Fundable-Protocol:mainfrom
Adeyinka0123:fix/positive-amount-deposit-stream

Conversation

@Adeyinka0123

@Adeyinka0123 Adeyinka0123 commented Jul 30, 2026

Copy link
Copy Markdown

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

  • [ADD] Explicit front-end guard in onSubmit handler — checks that parseFloat(data.amount) > 0 and shows an error notification before proceeding with the deposit
  • [ADD] min="0" HTML attribute on the number input element to prevent browsers from allowing negative values via the stepper/spinner

Defense-in-depth validation layers

Layer Location Validation
Browser Input min="0" attribute Prevents negative/spinner values
Zod schema validations.tsdepositStreamSchema .refine() checks parseFloat(val) > 0
Component onSubmit handler Explicit guard with user-facing notification
Service stellar.tsdepositToStream() Rejects non-positive amounts with Error

Verification 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).

Acceptance Criteria Status
Zero deposits are rejected with a clear message
Negative deposits are rejected with a clear message
Valid positive deposits proceed as expected
No regression in existing test suites

Summary by CodeRabbit

  • Bug Fixes
    • Deposit amounts are now validated before submission.
    • Invalid or non-positive amounts display an error notification and cannot be submitted.
    • The amount field now enforces a minimum value of zero.

… 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
@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

DepositStreamModal now rejects invalid or non-positive deposit amounts before calling the Stellar deposit flow and adds a minimum constraint to the amount input.

Changes

Deposit amount validation

Layer / File(s) Summary
Enforce positive deposit amounts
apps/web/src/components/modules/payment-stream/DepositStreamModal.tsx
The submit handler rejects NaN and values less than or equal to zero with an error notification, while the numeric input declares a minimum of zero.

Estimated code review effort: 2 (Simple) | ~5 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: enforcing positive deposit validation in DepositStreamModal.
Linked Issues check ✅ Passed The change addresses #419 by blocking zero or negative deposits in DepositStreamModal as required.
Out of Scope Changes check ✅ Passed The patch is narrowly scoped to DepositStreamModal validation and input constraints, with no obvious unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 375c936 and a3c166d.

📒 Files selected for processing (1)
  • apps/web/src/components/modules/payment-stream/DepositStreamModal.tsx

Comment on lines 120 to 124
<Input
id="deposit-amount"
type="number"
min="0"
step="0.0000001"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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 -300

Repository: 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".

@Idrhas

Idrhas commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

dont forget to offramp using https://stellar.fundable.finance/offramp its fast, free and p2p rates

@Idrhas
Idrhas merged commit 3eef081 into Fundable-Protocol:main Aug 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web(DepositStreamModal): enforce positive amount validation for token deposits

2 participants