flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[Contracts] Key position metadata by (stream_id, role) instead of a single slot

Open blurbeast opened this issue 1 week ago • 4 comments

Overview & Background

The position metadata API pretends to support per-role storage, but only one slot exists per stream. try_load_position_metadata(env, stream_id, _role) ignores the role parameter and keys only on DataKey::StreamPosition(stream_id); save_position_metadata likewise keys by stream_id alone, so mint_stream_position's two saves (sender then recipient) overwrite each other — the sender position is silently destroyed. get_position_metadata(stream_id, role) returns the same single record regardless of requested role (so role: Sender yields a record whose own role field says Recipient). The doc promises PositionNotFound but the code returns StreamNotFound, and no PositionNotFound variant exists.


Technical Specification & Architecture

  1. In contracts/stream_contract/src/storage.rs:442-483, key positions by (stream_id, role) (e.g. DataKey::StreamPosition(u64, PositionRole)).
  2. Add the missing PositionNotFound error variant in errors.rs and return it as documented.
  3. Assert in tests that both roles persist independently and that role lookups return the correct record.

Target Files

  • contracts/stream_contract/src/storage.rs
  • contracts/stream_contract/src/errors.rs
  • contracts/stream_contract/src/lib.rs

Acceptance Criteria

  • [ ] Sender and recipient positions coexist for the same stream.
  • [ ] Role-scoped lookups return the record for that role only.
  • [ ] PositionNotFound is returned for missing positions, per the documented contract.

blurbeast avatar Nov 18 '26 19:11 blurbeast

@Michael997glitch has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

Hi, I’m a smart contractor and a full-stack web developer, I have read through the issue and it’s something I’m capable of doing. Please assign me this work.

ℹ️ Repo Maintainers: To accept this application, review their application or assign @Michael997glitch to this issue.

Michael997glitch avatar Nov 20 '26 23:11 Michael997glitch

@wagmiiii has applied to work on this issue as part of the Stellar Wave Program's 11th wave.

i have experience doing this

ℹ️ Repo Maintainers: To accept this application, review their application or assign @wagmiiii to this issue.

wagmiiii avatar Nov 21 '26 07:11 wagmiiii

Congratulations, @wagmiiii! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.

🧑‍💻 @wagmiiii: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

🌊 Happy Wave 🌊

drips-wave[bot] avatar Nov 21 '26 07:11 drips-wave[bot]

This issue has been completed by @wagmiiii as part of the Stellar Wave Program's 11th Wave 🥳

😎 @wagmiiii: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

drips-wave[bot] avatar Nov 21 '26 17:11 drips-wave[bot]