Skip to content

Fix ensureSafeNumber throwing on large Soroban Stream IDs - #604

Open
Richkid2 wants to merge 1 commit into
Fundable-Protocol:mainfrom
Richkid2:feature/web-api
Open

Fix ensureSafeNumber throwing on large Soroban Stream IDs#604
Richkid2 wants to merge 1 commit into
Fundable-Protocol:mainfrom
Richkid2:feature/web-api

Conversation

@Richkid2

@Richkid2 Richkid2 commented Jul 30, 2026

Copy link
Copy Markdown

Closes #372


createStream() threw an unhandled error whenever a Soroban stream ID exceeded Number.MAX_SAFE_INTEGER (2^53 - 1). Replaced ensureSafeNumber with serializeStreamId, which serializes the bigint to a string instead of forcing a lossy/unsafe number cast. createStream() now returns Promise.

Confirmed via tsc --noEmit with no downstream type errors. issue #372

Summary by CodeRabbit

  • Bug Fixes
    • Improved stream creation reliability by preserving stream IDs as exact text values.
    • Prevented failures when stream IDs exceed JavaScript’s safe numeric range.

createStream() threw an unhandled error whenever a Soroban stream ID
exceeded Number.MAX_SAFE_INTEGER (2^53 - 1). Replaced ensureSafeNumber
with serializeStreamId, which serializes the bigint to a string instead
of forcing a lossy/unsafe number cast. createStream() now returns
Promise<string>.

Confirmed via tsc --noEmit with no downstream type errors.
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

createStream now serializes contract stream IDs as strings, removing safe-integer bounds enforcement and changing its return type from Promise<number> to Promise<string>.

Changes

Stream ID serialization

Layer / File(s) Summary
Update createStream stream ID contract
apps/web/src/lib/api.ts
Adds serializeStreamId and returns the stream ID as a string instead of applying safe-number conversion.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested reviewers: bashir1738, sofeel

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing unsafe number coercion for large Soroban stream IDs.
✨ 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.

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

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

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): ensureSafeNumber throws exception on BigInt Stream IDs exceeding MAX_SAFE_INTEGER

1 participant