improve Soroban stream ID extraction in createStream - #501
Conversation
|
@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! 🚀 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesStream ID handling
Estimated code review effort: 2 (Simple) | ~10 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.
🧹 Nitpick comments (1)
apps/web/src/lib/api.ts (1)
128-130: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd 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
📒 Files selected for processing (1)
apps/web/src/lib/api.ts
|
dont forget to offramp using https://stellar.fundable.finance/offramp its fast, free and p2p rates |
2 similar comments
|
dont forget to offramp using https://stellar.fundable.finance/offramp its fast, free and p2p rates |
|
dont forget to offramp using https://stellar.fundable.finance/offramp its fast, free and p2p rates |
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