Skip to content

[CT-15] Implement on-chain Booking Conflict Detector for double-booking prevention in Rust #1032

@devwums

Description

@devwums

Problem

Double-booking is prevented only in the NestJS backend. There is no on-chain validation, meaning a malicious actor can bypass the backend and submit duplicate booking transactions directly to the contract.

Proposed Solution

Create contracts/cntr/booking_conflict.rs defining pub struct BookingSlot { pub booking_id: String, pub start_ts: u64, pub end_ts: u64 } and implementing pub fn find_conflicts(new_slot: &BookingSlot, existing_slots: &[BookingSlot]) -> Vec<String> returning the booking_id of each conflicting slot. Overlap condition: new.start_ts < existing.end_ts && new.end_ts > existing.start_ts. Adjacent slots (touching endpoints) are NOT conflicts. All implementation must live inside contracts/cntr/.

Acceptance Criteria

  • File at contracts/cntr/booking_conflict.rs
  • Returns empty Vec when no conflicts exist
  • Detects full overlap, partial overlap (start inside), and containment
  • Adjacent bookings (one ends exactly when other starts) are not flagged
  • Returns only the booking_id strings of conflicting slots
  • At least 7 unit tests
  • Compiles with cargo test

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions