-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
difficulty: mediumStandard features across multiple codebase sectionsStandard features across multiple codebase sections
Description
Context
The amount validation utilities (utils/amount-validation.ts) validate that inputs are positive numbers with correct decimal precision, but they don't check whether the entered amount exceeds the user's actual token balance. Users can fill in amounts larger than what they hold and only discover the problem when the transaction fails during signing. This wastes time and creates confusion.
What Success Looks Like
- Amount inputs on the Distribution and Payment Stream forms validate against the user's real token balance
- If the entered amount exceeds the available balance, an inline error message appears immediately (e.g., "Insufficient balance. You have 500 USDC")
- The validation is debounced to avoid excessive balance queries
- Balance is fetched once and cached, then re-validated when the amount input changes
- The submit button is disabled when the amount exceeds the balance
Implementation Guidance
apps/web/src/utils/amount-validation.ts— existing validation to extend with a balance checkapps/web/src/app/(overview)/distribution/page.tsx— total amount input for equal distributionapps/web/src/components/modules/payment-stream/PaymentStreamForm.tsx— stream amount inputapps/web/src/services/stellar.service.ts— balance fetching methods- Fetch the balance for the selected token using the existing service layer
- Add a
maxAmountparameter to the validation function that compares against the fetched balance - Use TanStack Query for caching the balance (it's already in the project)
- Show the user's current balance near the amount input as a helpful reference
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
difficulty: mediumStandard features across multiple codebase sectionsStandard features across multiple codebase sections