MettaChain/PropChain-contract

Replace manual `unwrap`/`expect` in production contracts with graceful error propagation

Geschlossen

#742 geöffnet am 23.07.2026

 (4 Kommentare) (0 Reaktionen) (1 zugewiesene Person)Rust (151 Forks)auto 404
High ComplexityRustStellar Waveenhancementhelp wanted

Repository-Metriken

Stars
 (1 Stern)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

Problem Statement

60+ instances of .unwrap()/.expect() in production code paths across governance, property-management, sanctions, prediction-market, etc.

Why it matters

An unwrap in a paid user path is a denial-of-service vector and a gas bomb on bug-fix deployments.

Technical Context

Replace each unwrap() with ? or a typed error variant. Reserve unwraps for #[cfg(test)].

Expected Outcome

grep -rE '\.unwrap\(\)|\.expect\(' contracts/*/src/lib.rs returns 0 lines outside #[cfg(test)].

Acceptance Criteria

  1. Production unwraps removed.
  2. Tests unchanged in count.
  3. Kani harness prove_no_panic_in_storage_round_trip.
  4. Stack-overflow review: deep recursion removed.

Implementation Notes

Branch-by-branch, smallest to largest. Add safe_unwrap! macro in propchain-traits.

Files or modules likely to be affected

Every contracts/**/src/lib.rs.

Dependencies

None.

Difficulty level

MEDIUM.

Estimated effort

L (~1–2 engineer-weeks).

Contributor Guide