Skip to content

[Contracts] Add stream_count view function #421

@ogazboiz

Description

@ogazboiz

https://t.me/+DOylgFv1jyJlNzM0

Description

The contract has no way to report how many streams exist, making cursor-based or offset pagination impossible without a full DB scan on the backend. A simple stream_count() -> u64 view function that returns the global stream counter enables the backend (and any external indexer) to implement correct pagination without an extra DB roundtrip.

Acceptance Criteria

  • stream_count(env: Env) -> u64 read-only function is implemented
  • The value returned is the monotonically-increasing stream ID counter (i.e. total streams ever created, not just active ones)
  • Function does not panic on a freshly-deployed contract (returns 0)
  • Unit test: assert count increments by 1 after each create_stream call
  • TypeScript bindings regenerated

Files to Touch

  • contracts/flowfi/src/lib.rs — add stream_count function
  • contracts/flowfi/src/test.rs — unit test
  • packages/sdk/src/index.ts — regenerated bindings

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programcontractsSmart contract related tasksgood first issueGood for newcomerssmart-contractSoroban smart contract

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions