flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[Contracts] Implement TryFrom<u32> and code() helper for ContractError in errors.rs

Open blurbeast opened this issue 1 month ago • 5 comments

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 using ContractError::try_from(code).

Proposed Changes

  1. Implement pub const fn code(self) -> u32 and TryFrom<u32> for ContractError in contracts/stream_contract/src/errors.rs.
  2. Add a unit test verifying round-trip conversion for every ContractError variant.

Acceptance Criteria

  • [ ] ContractError::try_from(u32) returns Ok(variant) for all valid error codes and Err(()) for unknown codes.
  • [ ] Round-trip unit test covers all enum variants.
  • [ ] cargo test and cargo clippy pass.

blurbeast avatar Oct 18 '26 05:10 blurbeast

@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.

Dev-dave01 avatar Oct 18 '26 12:10 Dev-dave01

@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.

Yemmy88 avatar Oct 18 '26 12:10 Yemmy88

@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.

Alosnireda avatar Oct 18 '26 12:10 Alosnireda

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 🌊

drips-wave[bot] avatar Oct 18 '26 12:10 drips-wave[bot]

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.

drips-wave[bot] avatar Oct 18 '26 18:10 drips-wave[bot]