Skip to content

feat: stream enumeration view functions#1

Open
Bizify1370 wants to merge 1 commit into
mainfrom
feat/stream-enumeration
Open

feat: stream enumeration view functions#1
Bizify1370 wants to merge 1 commit into
mainfrom
feat/stream-enumeration

Conversation

@Bizify1370

Copy link
Copy Markdown
Owner

Summary

Adds stream_count(env) and get_stream_ids(env, page, page_size) view functions to the streampay-stream contract to enable off-chain indexer enumeration.

Changes

storage.rs

  • Renamed DataKey::StreamCountDataKey::NextStreamId (fixes pre-existing mismatch between enum declaration and its usage)
  • Added get_stream_count(env) helper — count = next_id - 1

lib.rs

  • Added stream_count(env) -> u64 view function
  • Added get_stream_ids(env, page, page_size) -> Vec<u64> view function
    • Page size capped at 50; zero-based pagination; 1-based IDs; no auth required

test.rs

8 new enumeration tests: zero count, count increments, empty/first/second pages, page-size cap, page-beyond-end, partial last page, zero page size.

Acceptance Criteria

  • View functions return correct data
  • Page cap enforced (50 max)
  • Tests pass for all pagination edges

Closes Streampay-Org#445

Add stream_count(env) and get_stream_ids(env, page, page_size) view functions
to the streampay-stream contract for off-chain indexer enumeration.

Changes:
- storage.rs: rename DataKey::StreamCount → NextStreamId (fixes pre-existing
  mismatch between enum declaration and actual usage); add get_stream_count()
  helper that derives count from the next-id counter (count = next_id - 1)
- lib.rs: add stream_count() and get_stream_ids() view functions; page size
  capped at 50, IDs are 1-based, pagination is zero-based
- test.rs: 8 new enumeration tests covering zero count, count increments,
  empty/first/second pages, page-size cap at 50, page-beyond-end, partial
  last page, and zero page size

Closes Streampay-Org#445
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.

Add stream_count and get_stream_ids view functions to streampay-stream

1 participant