Skip to content

fix(stream-validation): add StrKey contract ID format validation - #588

Merged
Idrhas merged 1 commit into
Fundable-Protocol:mainfrom
Fayedamz:fix/stream-validation-strkey-contract-id
Aug 3, 2026
Merged

fix(stream-validation): add StrKey contract ID format validation#588
Idrhas merged 1 commit into
Fundable-Protocol:mainfrom
Fayedamz:fix/stream-validation-strkey-contract-id

Conversation

@Fayedamz

@Fayedamz Fayedamz commented Jul 29, 2026

Copy link
Copy Markdown
Contributor
  • Add validateContractId() to stream-validation.ts using StrKey.isValidContract
  • Apply contract ID validation to token field in paymentStreamSchema (validations.ts)
  • Guard token contract address in CreatePaymentStream handleFormSubmit
  • Native XLM token ('native') is correctly exempted from contract ID check

Closes #379

Summary by CodeRabbit

  • Bug Fixes
    • Improved payment stream validation to reject invalid Stellar token contract IDs.
    • Native XLM payments continue to be supported without a contract ID.
    • Added clearer error messaging when an invalid token is selected.

- Add validateContractId() to stream-validation.ts using StrKey.isValidContract
- Apply contract ID validation to token field in paymentStreamSchema (validations.ts)
- Guard token contract address in CreatePaymentStream handleFormSubmit
- Native XLM token ('native') is correctly exempted from contract ID check

Closes Fundable-Protocol#379
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Fayedamz 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 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Payment stream token validation now accepts native XLM or valid Stellar contract IDs. A reusable validator uses Stellar SDK StrKey.isValidContract, while schema and form submission checks reject invalid token addresses with validation errors.

Changes

Payment stream validation

Layer / File(s) Summary
Contract validation rules
apps/web/src/lib/stream-validation.ts, apps/web/src/lib/validations.ts
Adds validateContractId and restricts the schema token value to native or a valid Stellar contract ID.
Submission-time token validation
apps/web/src/components/modules/payment-stream/CreatePaymentStream.tsx
Validates the selected token address during submission and displays an error toast for invalid contract IDs.

Estimated code review effort: 2 (Simple) | ~10 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: adding StrKey contract ID validation for streams.
Linked Issues check ✅ Passed The PR adds validateContractId with StrKey.isValidContract and applies it in form validation and submission, matching issue #379.
Out of Scope Changes check ✅ Passed The additional validation wiring is directly related to the contract ID validation objective and does not appear out of scope.
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.

🧹 Nitpick comments (1)
apps/web/src/lib/stream-validation.ts (1)

12-19: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add focused regression tests for the shared validator.

Cover valid contract IDs, invalid checksum/prefix/length, empty input, and confirm that "native" remains handled by the schema/form layer rather than this helper.

🤖 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/lib/stream-validation.ts` around lines 12 - 19, Add focused
regression tests for validateContractId covering valid contract IDs, invalid
checksum, prefix, and length cases, plus empty input. Also verify that "native"
is not accepted or specially handled by validateContractId, leaving that
behavior to the schema/form layer.
🤖 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.

Nitpick comments:
In `@apps/web/src/lib/stream-validation.ts`:
- Around line 12-19: Add focused regression tests for validateContractId
covering valid contract IDs, invalid checksum, prefix, and length cases, plus
empty input. Also verify that "native" is not accepted or specially handled by
validateContractId, leaving that behavior to the schema/form layer.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 299fcd7a-0c2c-49e1-8c3f-faf5f0105efc

📥 Commits

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

📒 Files selected for processing (3)
  • apps/web/src/components/modules/payment-stream/CreatePaymentStream.tsx
  • apps/web/src/lib/stream-validation.ts
  • apps/web/src/lib/validations.ts

@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 4a0340e 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(stream-validation): add StrKey contract ID format validation

2 participants