[Contracts] Key position metadata by (stream_id, role) instead of a single slot
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
- In
contracts/stream_contract/src/storage.rs:442-483, key positions by(stream_id, role)(e.g.DataKey::StreamPosition(u64, PositionRole)). - Add the missing
PositionNotFounderror variant inerrors.rsand return it as documented. - Assert in tests that both roles persist independently and that role lookups return the correct record.
Target Files
contracts/stream_contract/src/storage.rscontracts/stream_contract/src/errors.rscontracts/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.
- [ ]
PositionNotFoundis returned for missing positions, per the documented contract.
@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.
@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.
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 🌊
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.