Skip to content

improve Soroban stream ID extraction in createStream - #501

Open
canicefavour wants to merge 3 commits into
Fundable-Protocol:mainfrom
canicefavour:client
Open

improve Soroban stream ID extraction in createStream#501
canicefavour wants to merge 3 commits into
Fundable-Protocol:mainfrom
canicefavour:client

Conversation

@canicefavour

@canicefavour canicefavour commented Jul 29, 2026

Copy link
Copy Markdown

Enhanced the createStream API to reliably extract the stream ID from Soroban contract execution results across multiple return formats. Previously, the implementation only accepted primitive bigint values, causing successful transactions to fail whenever the contract returned an SCVal object or emitted the stream ID through contract events. This update introduces a more resilient parsing strategy that first handles native bigint results, then attempts conversion from SCVal using the Stellar SDK, and finally falls back to extracting the stream ID from contract events via SorobanEventParser when necessary.

The improved implementation ensures compatibility with different Soroban response formats, reduces false-negative transaction failures, and provides clearer error handling when a valid stream ID cannot be determined.

Highlights
Added support for direct bigint stream ID responses.
Implemented SCVal to native value conversion using Stellar SDK utilities.
Added fallback extraction of stream IDs from contract execution events using SorobanEventParser.
Improved compatibility with Soroban return types, including SCVal integer variants.
Enhanced error handling by distinguishing invalid or missing stream IDs from successful contract executions.
Eliminated false "Contract did not return a stream id" errors for valid on-chain transactions.
Increased the robustness and reliability of the createStream API across different contract response formats.

Closes #374

Summary by CodeRabbit

  • Bug Fixes
    • Improved stream creation reliability by supporting stream IDs returned through transaction events.
    • Added clearer error handling when a valid stream ID cannot be retrieved.

@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@canicefavour 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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1e88c6ec-4826-40fb-bccf-f8da233404b4

📥 Commits

Reviewing files that changed from the base of the PR and between ae56c3b and 4a3e2e9.

📒 Files selected for processing (1)
  • apps/web/src/lib/api.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/lib/api.ts

📝 Walkthrough

Walkthrough

createStream now parses stream IDs from transaction results and falls back to transaction events when needed. It throws an updated error only when neither source provides a valid ID.

Changes

Stream ID handling

Layer / File(s) Summary
Stream ID extraction and event fallback
apps/web/src/lib/api.ts
createStream extracts the stream ID from tx.result or transaction events. It throws Contract did not return a valid stream id when both sources fail.

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 directly describes the main change: improving Soroban stream ID extraction logic in the createStream function.
Linked Issues check ✅ Passed The PR implements the fix specified in issue #374: extracting stream IDs from both SCVal primitives and contract event logs using fallback logic.
Out of Scope Changes check ✅ Passed All changes are scoped to stream ID extraction logic in createStream, directly addressing the bug described in issue #374.
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/api.ts (1)

128-130: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add regression coverage for every extraction path.

Cover raw bigint, SCVal-wrapped results, event-emitted IDs, and the error path where neither source yields a valid ID. This change affects transaction success detection and should guard against regressions across Soroban result formats.

🤖 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/api.ts` around lines 128 - 130, Add regression tests for the
stream ID extraction flow around extractBigInt and extractStreamIdFromTxEvents:
cover raw bigint results, SCVal-wrapped results, event-emitted IDs, and
transactions where both sources are invalid, verifying the latter throws
“Contract did not return a valid stream id.”
🤖 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/api.ts`:
- Around line 128-130: Add regression tests for the stream ID extraction flow
around extractBigInt and extractStreamIdFromTxEvents: cover raw bigint results,
SCVal-wrapped results, event-emitted IDs, and transactions where both sources
are invalid, verifying the latter throws “Contract did not return a valid stream
id.”

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b23e8ece-f657-47ce-8e0f-cca86cc88676

📥 Commits

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

📒 Files selected for processing (1)
  • apps/web/src/lib/api.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

2 similar comments
@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 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

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(api): createStream fails to parse SCVal-wrapped return value from Soroban events

2 participants