Skip to content

feat: Add get_streams_by_sender with paginated index - #911

Open
Miraclechukwuemeka wants to merge 1 commit into
ritik4ever:mainfrom
Miraclechukwuemeka:feat/get-streams-by-sender
Open

feat: Add get_streams_by_sender with paginated index#911
Miraclechukwuemeka wants to merge 1 commit into
ritik4ever:mainfrom
Miraclechukwuemeka:feat/get-streams-by-sender

Conversation

@Miraclechukwuemeka

Copy link
Copy Markdown

Summary

Closes #686

Adds get_streams_by_sender(sender: Address, page: u32, page_size: u32) -> Vec<u64> to the Soroban smart contract, enabling paginated queries for all streams created by a given sender.

Changes

  • contracts/src/lib.rs:

    • Added SenderStreams(Address) variant to DataKey enum for the ledger index
    • Updated create_stream to maintain the sender streams index on stream creation
    • Updated create_split_stream to maintain the index (parent + all children)
    • Added get_streams_by_sender function with:
      • Zero-based pagination (page, page_size)
      • Max page size clamped to 100 to avoid storage read limits
      • Returns Vec<u64> of stream IDs in creation order
      • Returns empty vec for unknown senders
  • contracts/src/test.rs — 6 new tests:

    • test_get_streams_by_sender_returns_all_stream_ids — verifies IDs returned in creation order
    • test_get_streams_by_sender_empty_for_unknown_sender — empty vec for unknown sender
    • test_get_streams_by_sender_pagination — correct slicing across 5 streams with page_size=2
    • test_get_streams_by_sender_includes_split_stream_children — split streams index parent + children
    • test_get_streams_by_sender_does_not_mix_senders — sender isolation
    • test_get_streams_by_sender_page_size_clamped_to_100 — oversized page_size is clamped

Acceptance Criteria

  • Returns stream IDs in creation order
  • Pagination correct for senders with 100+ streams (clamped to 100 per page)
  • Empty vec for unknown sender

Add a SenderStreams(Address) ledger key index that maintains a Vec<u64>
of stream IDs per sender in creation order. The new
get_streams_by_sender(sender, page, page_size) query function returns a
paginated slice (max 100 per page), enabling efficient lookups for
senders with 100+ streams without scanning all storage.

Index is maintained on both create_stream and create_split_stream
(including parent + children). Empty vec returned for unknown senders.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

@Miraclechukwuemeka is attempting to deploy a commit to the ritik4ever's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

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

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e6e53fd9-429a-485c-8adc-12ff9b4bde46


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.

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.

[FEATURE] Add contract function to get all streams for a sender

1 participant