Skip to content

fix: synchronize errors.rs with missing enum variants#335

Merged
hman38705 merged 1 commit intosolutions-plug:mainfrom
maztah1:fix/issue-5-error-codes
Mar 27, 2026
Merged

fix: synchronize errors.rs with missing enum variants#335
hman38705 merged 1 commit intosolutions-plug:mainfrom
maztah1:fix/issue-5-error-codes

Conversation

@maztah1
Copy link
Copy Markdown
Contributor

@maztah1 maztah1 commented Mar 27, 2026

Closes #113 (issue #5 — Define Missing SAC and Oracle Error Codes)

Problem

The contract referenced ErrorCode::AssetClawedBack and ErrorCode::StalePrice that were either missing or the enum exceeded Soroban SDK's 50-variant limit for #[contracterror], causing compilation failures.

Changes

Core Fix

  • errors.rs: Consolidated ErrorCode enum to exactly 50 variants (Soroban SDK contracterror limit). StalePrice (31) and AssetClawedBack (32) are now properly defined.

SAC Module

  • sac.rs: detect_clawback now correctly returns ErrorCode::AssetClawedBack instead of ErrorCode::InsufficientBalance.

Oracle Module

  • oracles.rs: Removed duplicate function bodies, publish_time is now u64, added abs_price_to_u64 helper for safe i64::MIN handling. StalePrice and ConfidenceTooLow propagate correctly through validate_price.

Supporting Fixes

  • types.rs: Added UpgradeStats, PendingGuardianRemoval, winner_counts, total_claimed; ConfigKey::UpgradeRejectedAt now uses BytesN<32>
  • markets.rs: Added get_outcome_stake/set_outcome_stake helpers, fixed Market struct initialization
  • governance.rs: Updated wasm_hash type to BytesN<32>, added set_timelock_duration
  • events.rs: Shortened symbol strings to Soroban's 9-char max
  • circuit_breaker.rs / fees.rs: Replaced non-existent try_require_auth with correct auth patterns
  • resolution.rs: Fixed get_oracle_result call signature mismatch
  • All test files: Removed duplicate use statements and struct field initializations

Verification

cargo build --manifest-path contracts/predict-iq/Cargo.toml

Finished dev profile — no errors

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Mar 27, 2026

@maztah1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

- Deduplicate ErrorCode enum  main had 150+ duplicate variants causing
  the Soroban contracterror 50-variant limit to be exceeded
- Add StalePrice = 29 and AssetClawedBack = 32 as canonical definitions
- Add TransferFailed = 33 for SAC programmatic transfer failures
- All 50 variants are unique, sequential, and cover every ErrorCode
  reference used across the module suite (sac.rs, oracles.rs, etc.)

Closes solutions-plug#113 / issue-5
@maztah1 maztah1 force-pushed the fix/issue-5-error-codes branch from e7f10a2 to b392a83 Compare March 27, 2026 16:01
@hman38705 hman38705 merged commit daf4be2 into solutions-plug:main Mar 27, 2026
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.

Define Missing SAC and Oracle Error Codes

2 participants