Skip to content

fix(contracts): add stream_count view fn and fix resume_stream status…#988

Open
Anthony-19 wants to merge 2 commits into
LabsCrypt:mainfrom
Anthony-19:anthony_flowfi
Open

fix(contracts): add stream_count view fn and fix resume_stream status…#988
Anthony-19 wants to merge 2 commits into
LabsCrypt:mainfrom
Anthony-19:anthony_flowfi

Conversation

@Anthony-19

Copy link
Copy Markdown
Contributor

… guard

Closes #421 — stream_count() -> u64

  • Add stream_count() read-only function that returns the global StreamCounter value (monotonically increasing, equals the highest stream ID ever issued, never decrements on cancel/complete).
  • Returns 0 on a freshly-deployed contract with no streams.
  • Add TypeScript binding fetchStreamCount() in frontend/src/lib/soroban.ts that simulates the view call without wallet auth.
  • Unit tests: stream_count_returns_zero_on_fresh_contract, stream_count_increments_by_one_per_create, stream_count_is_not_decremented_by_cancel, stream_count_matches_last_stream_id.

Closes #787 — resume_stream status guard

  • resume_stream now checks stream.status == Paused (not just stream.paused), so a stream cancelled while paused (status=Cancelled, paused=true) correctly returns StreamInactive instead of being resurrected to Active.
  • cancel_stream now explicitly clears stream.paused = false and stream.paused_at = None when settling a cancellation, ensuring no stale pause state survives into the Cancelled record.
  • Unit tests: resume_after_cancel_while_paused_returns_stream_inactive, cancel_while_paused_clears_pause_fields, cancel_normal_stream_also_clears_pause_fields.

Description

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test addition or update

Related Issues

Closes #

Changes Made

Testing

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed

Test Steps

Breaking Changes

Breaking Changes:

Migration Guide:

Screenshots/Demo

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have checked for breaking changes and documented them if applicable

Additional Notes

… guard

Closes LabsCrypt#421 — stream_count() -> u64
- Add stream_count() read-only function that returns the global
  StreamCounter value (monotonically increasing, equals the highest
  stream ID ever issued, never decrements on cancel/complete).
- Returns 0 on a freshly-deployed contract with no streams.
- Add TypeScript binding fetchStreamCount() in frontend/src/lib/soroban.ts
  that simulates the view call without wallet auth.
- Unit tests: stream_count_returns_zero_on_fresh_contract,
  stream_count_increments_by_one_per_create,
  stream_count_is_not_decremented_by_cancel,
  stream_count_matches_last_stream_id.

Closes LabsCrypt#787 — resume_stream status guard
- resume_stream now checks stream.status == Paused (not just stream.paused),
  so a stream cancelled while paused (status=Cancelled, paused=true) correctly
  returns StreamInactive instead of being resurrected to Active.
- cancel_stream now explicitly clears stream.paused = false and
  stream.paused_at = None when settling a cancellation, ensuring no stale
  pause state survives into the Cancelled record.
- Unit tests: resume_after_cancel_while_paused_returns_stream_inactive,
  cancel_while_paused_clears_pause_fields,
  cancel_normal_stream_also_clears_pause_fields.
…tream

The pause state clearance (paused=false, paused_at=None) was placed after
the CEI-refactored save_stream call, putting it inside the interactions block
where token_client/contract_address are in scope but stream state mutations
should not happen. Move the two lines up into the effects block, before
save_stream, consistent with the existing is_active/status/last_update_time
assignments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant