Skip to content

[CT-07] Implement maintenance record creation in asset-maintenance in opsce crate #806

@yusuftomilola

Description

@yusuftomilola

Problem

contracts/asset-maintenance/src/lib.rs defines the MaintenanceRecord type and related enums but the function to actually create and store a maintenance record on-chain is missing or incomplete.

Proposed Solution

Create contracts/opsce/src/maintenance_record.rs. Implement create_maintenance_record(env, asset_id, record_type, provider, scheduled_date, cost, notes) that stores a MaintenanceRecord in the ledger.

Acceptance Criteria

  • create_maintenance_record() validates that asset_id is non-empty and cost is non-negative
  • Generates a unique record_id (hash of asset_id + timestamp)
  • Stores the record under key DataKey::MaintenanceRecord(record_id)
  • get_maintenance_records(env, asset_id) returns all records for a given asset as a Vec
  • MaintenanceStatus enum: Scheduled, InProgress, Completed, Cancelled
  • Emits a maintenance_scheduled event on creation
  • Unit tests cover: create, retrieve, and duplicate prevention

Metadata

Metadata

Assignees

Labels

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