[Contracts] Implement TryFrom<u32> and code() helper for ContractError in errors.rs
Overview
contracts/stream_contract/src/errors.rs defines ContractError with #[repr(u32)], but lacks a helper method to convert a numeric error code back into a ContractError variant during off-chain testing and log decoding.
Problem
- Test helpers and Rust SDK consumers parsing
Error(Contract, #N)must manually match integer literals instead of usingContractError::try_from(code).
Proposed Changes
- Implement
pub const fn code(self) -> u32andTryFrom<u32> for ContractErrorincontracts/stream_contract/src/errors.rs. - Add a unit test verifying round-trip conversion for every
ContractErrorvariant.
Acceptance Criteria
- [ ]
ContractError::try_from(u32)returnsOk(variant)for all valid error codes andErr(())for unknown codes. - [ ] Round-trip unit test covers all enum variants.
- [ ]
cargo testandcargo clippypass.
@Dev-dave01 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
Hello Maintainer, I have reviewed this issue and I have relevant experience in solving it. Please assign to me.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Dev-dave01 to this issue.
@Yemmy88 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
Hi maintainer please I will appreciate it if I'm given this issue to work on. Please assign me I'm ready to get started Thank you
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Yemmy88 to this issue.
@Alosnireda has applied to work on this issue as part of the Stellar Wave Program's 10th wave.
Assign to me
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Alosnireda to this issue.
Congratulations, @Alosnireda! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.
🧑💻 @Alosnireda: 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 @Alosnireda as part of the Stellar Wave Program's 10th Wave 🥳
😎 @Alosnireda: 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.