Skip to content

Implemented Soroban stream storage, events, and errors#168

Merged
ogazboiz merged 3 commits intoLabsCrypt:mainfrom
Arowolokehinde:feat/issue-124-stream-storage-events-errors
Feb 24, 2026
Merged

Implemented Soroban stream storage, events, and errors#168
ogazboiz merged 3 commits intoLabsCrypt:mainfrom
Arowolokehinde:feat/issue-124-stream-storage-events-errors

Conversation

@Arowolokehinde
Copy link
Copy Markdown
Contributor

Description

Closes #124

Type of Change

This PR strengthens how StreamContract stores data, defines keys, emits events, and surfaces errors so that off-chain indexers and clients can reliably interpret stream state. The implementation follows a clean modular architecture with no redundant code and strict separation of concerns.

  • 🐛 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

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

Additional Notes

…, and errors

- Extract DataKey, Stream, ProtocolConfig into types.rs
- Extract StreamError (9 variants) into errors.rs
- Extract typed event structs into events.rs (StreamCreatedEvent,
  StreamToppedUpEvent, TokensWithdrawnEvent, StreamCancelledEvent,
  FeeCollectedEvent)
- Introduce storage.rs as the single centralized storage access layer;
  all reads/writes go through load_stream, save_stream, load_config,
  save_config, next_stream_id — no ad-hoc storage calls elsewhere
- Fix create_stream: returns Result<u64> guarding InvalidAmount and
  new InvalidDuration (= 9) error variant
- Fix cancel_stream: refunds unspent balance (deposited - withdrawn)
  back to sender; includes refunded_amount in StreamCancelledEvent
- All four public mutating methods emit indexer-filterable events with
  two-element topic tuple (event_name_symbol, stream_id)
- Remove dangling references to is_emergency_mode / EmergencyStopEnabled
  that prevented compilation
- 36 tests: every StreamError variant covered, every event payload
  asserted, DataKey deterministic serialization verified

Closes LabsCrypt#124
Auto-generated by the Soroban test runner — should never be committed.
Added **/test_snapshots/ to .gitignore to prevent re-addition.
Copy link
Copy Markdown
Contributor

@ogazboiz ogazboiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hey, thanks for implementing the Soroban stream storage, events, and error handling! this looks like a huge and important milestone.

the CI didn't trigger for your branch, probably because it's slightly out of sync with main. could you run git fetch origin && git rebase origin/main and force push? that will trigger our test runner.

once the tests run and pass, i'll get this merged!

@Arowolokehinde
Copy link
Copy Markdown
Contributor Author

@ogazboiz you can merge now

Copy link
Copy Markdown
Contributor

@ogazboiz ogazboiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great, merging this in! thanks for the contribution

@ogazboiz ogazboiz merged commit 891b117 into LabsCrypt:main Feb 24, 2026
4 checks passed
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.

Epic: Soroban stream storage, events, and errors

2 participants