Skip to content

[CT-10] Add service provider rating system in asset-maintenance in opsce crate #809

@yusuftomilola

Description

@yusuftomilola

Problem

contracts/asset-maintenance/src/lib.rs defines ProviderProfile but has no reputation or rating mechanism. There is no way to track provider performance across maintenance jobs on-chain.

Proposed Solution

Create contracts/opsce/src/provider_rating.rs. Implement a 1-5 star rating system where asset owners can rate a provider after a maintenance record is marked complete.

Acceptance Criteria

  • rate_provider(env, record_id, rating, comment) — caller must be the asset owner; rating must be 1-5
  • Calculates and updates a running average rating stored on the ProviderProfile
  • Each record can only be rated once — returns Err(ContractError::AlreadyRated) on duplicate
  • get_provider_rating(env, provider_address) returns { average_rating, total_reviews }
  • Emits a provider_rated event with rating value and record ID
  • Unit tests cover: valid rating, duplicate rating, rating bounds (0 and 6 should fail)

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