Skip to content

Latest commit

 

History

History
49 lines (42 loc) · 4.89 KB

File metadata and controls

49 lines (42 loc) · 4.89 KB

Anchored Summary — Remitwise-Contracts Fix Session

Goal

Fix compilation errors blocking cargo build --release --target wasm32-unknown-unknown --workspace

Constraints & Preferences

  • WASM target (wasm32-unknown-unknown) with #![no_std] constraint
  • panic = "abort" in release profile (no panic catching)
  • #![cfg_attr(not(test), deny(clippy::unwrap_used, clippy::expect_used))] in remitwise-common

Progress

Done

  • Generated Cargo.lock via cargo generate-lockfile (fixes check_ci.sh step 1)
  • Fixed remitwise-common/Cargo.toml: removed duplicate [features] section (lines 13–14, 20–21)
  • remitwise-common/src/lib.rs: replaced Vec::with_capacity / extend_from_slice with soroban_sdk::Bytes::new + extend_from_slice
  • remitwise-common/src/lib.rs: replaced soroban_sdk::crypto::ed25519_verify(...) free-function call with env.crypto().ed25519_verify(...) using BytesN::from_array
  • remitwise-common/src/tests.rs: rewrote ed25519::generate / ed25519::sign helpers with ed25519-dalek::SigningKey / Signer (dev-dependency only)
  • remitwise-common/src/tests.rs: updated verify_signature tests — invalid signature tests changed from assert_eq!(..., Err(SignatureError::VerificationFailed)) to #[should_panic]
  • bill_payments/src/lib.rs: fixed &envenv type mismatch (line 1722), fixed next_bill use-after-move (line 1772)
  • This session (Type-Safe Percent Conversion): Implemented BPS_PER_PERCENT / BASIS_POINTS_PER_PERCENT constants, Percent newtype, TryFrom<Percent> for Rate, Rate::from_percent, Rate::to_percent, and Rate::has_fractional_percent in remitwise-common. Added 4 unit tests + 1 proptest in remitwise-common/src/tests.rs and created docs/type-safe-percent-conversion.md.
  • remitwise-common/Cargo.toml: moved ed25519-dalek from dev-deps to regular deps (version "2") to prevent CI resolving to v3.0.0 (incompatible with soroban-env-host-21.2.1).
  • insurance/src/lib.rs: fixed symbol_short!("reactivated") (too long, 11 > 9) → Symbol::new(&env, "reactivated"); fixed PolicyAlreadyInactive duplicate discriminant 1252; added clamp_limit to import; removed mut from let mut active (no mutation needed); fixed Vec::new(&env)Vec::new(env) in remove_active_policy.
  • data_migration/src/lib.rs: fixed manual_range_contains clippy lint (version < MIN || version > MAX!range.contains); gated ENCRYPTED_PAYLOAD_PREFIX_V2 with #[cfg(test)] (only used in tests).
  • reporting/src/utils.rs: removed invalid #![no_std] (not at crate root).
  • remittance_split/src/lib.rs: added #[allow(dead_code)] to unused STORAGE_OWNER_SCHED_IDS.

Verified

  • cargo check --workspace — clean.
  • remitwise-common unit tests & proptest for Percent and Rate — clean.

Remaining / Untested

  • CI (check_ci.sh) not yet run on CI runner — needs push and PR re-trigger.
  • 6 pre-existing emit_tests / assert_event_tests failures in remitwise-common — not introduced by this PR.

Key Decisions

  • verify_signature uses env.crypto().ed25519_verify(...) which panics on verification failure (standard Soroban behavior); the SignatureError::VerificationFailed variant becomes unreachable
  • Invalid signature tests use #[should_panic] instead of asserting Err(VerificationFailed)
  • Pre-checks (signature length == 64, public key length == 32) still return Err variants
  • ed25519-dalek = "2" added as regular dep (not dev-dep) to remitwise-common to constrain transitive resolution.
  • Cargo.lock committed (force-added, bypassing .gitignore). CI regenerates a fresh lockfile each run, but cargo generate-lockfile without --workspace constraints doesn't consider all workspace members' dep specs, allowing ed25519-dalek v3.0.0 to be picked for targets outside the root package graph (e.g., --package testutils). Committed lockfile ensures every CI job uses v2.2.0 regardless of which target or feature set is built.
  • Pre-existing warnings in insurance, data_migration, reporting, remittance_split fixed prophylactically to avoid CI clippy failures with -D warnings.
  • BPS_PER_PERCENT: u32 = 100 and Percent(u32) newtype centralize whole percentage → basis points conversion to prevent ad-hoc arithmetic and potential integer overflow.

File Changes

  • /remitwise-common/src/lib.rs: BPS_PER_PERCENT, BASIS_POINTS_PER_PERCENT, Percent struct, Rate::from_percent, Rate::to_percent, Rate::has_fractional_percent
  • /remitwise-common/src/tests.rs: test_bps_per_percent_constants, test_rate_from_percent, test_rate_to_percent_and_fractional, test_percent_type_conversions, proptest_percent_rate_roundtrip
  • /docs/type-safe-percent-conversion.md: New documentation page
  • /remitwise-common/README.md: Updated documentation for Percent, Rate, and constants
  • /README.md: Linked docs/type-safe-percent-conversion.md in workspace documentation index