feat: stream enumeration view functions#1
Open
Bizify1370 wants to merge 1 commit into
Open
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
stream_count(env)andget_stream_ids(env, page, page_size)view functions to thestreampay-streamcontract to enable off-chain indexer enumeration.Changes
storage.rsDataKey::StreamCount→DataKey::NextStreamId(fixes pre-existing mismatch between enum declaration and its usage)get_stream_count(env)helper — count = next_id - 1lib.rsstream_count(env) -> u64view functionget_stream_ids(env, page, page_size) -> Vec<u64>view functiontest.rs8 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
Closes Streampay-Org#445