@@ -28,6 +28,7 @@ pub mod payout;
2828pub mod payout_executor;
2929pub mod penalty;
3030pub mod pool;
31+ pub mod rating;
3132pub mod status;
3233pub mod storage;
3334pub mod token;
@@ -51,6 +52,7 @@ pub use events::*;
5152pub use group:: { Group , GroupStatus } ;
5253pub use payout:: PayoutRecord ;
5354pub use pool:: { PoolCalculator , PoolInfo } ;
55+ pub use rating:: { GroupRating , RatingAggregate , RatingEntry } ;
5456#[ cfg( test) ]
5557use soroban_sdk:: testutils:: { Events , Ledger } ;
5658use soroban_sdk:: { contract, contractimpl, contracttype, Address , Env , String , Symbol , Vec } ;
@@ -2659,6 +2661,51 @@ impl StellarSaveContract {
26592661 env. storage ( ) . persistent ( ) . get ( & key) . unwrap_or ( 0 )
26602662 }
26612663
2664+ /// Submits a 1–5 star rating (with optional comment) for a completed or cancelled group.
2665+ ///
2666+ /// # Rules
2667+ /// - Group must be in a terminal state (Completed or Cancelled).
2668+ /// - Caller must be a member of the group.
2669+ /// - Each member may only rate once per group.
2670+ /// - `stars` must be 1–5.
2671+ /// - `comment` must be ≤ 280 characters (pass an empty string for no comment).
2672+ ///
2673+ /// # Errors
2674+ /// - `GroupNotFound` – group does not exist
2675+ /// - `InvalidState` – group is not yet in a terminal state
2676+ /// - `NotMember` – caller is not a member of the group
2677+ /// - `InvalidAmount` – stars is 0 or > 5
2678+ /// - `InvalidMetadata` – comment exceeds 280 characters
2679+ /// - `AlreadyContributed` – member has already rated this group
2680+ pub fn rate_group (
2681+ env : Env ,
2682+ caller : Address ,
2683+ group_id : u64 ,
2684+ stars : u32 ,
2685+ comment : String ,
2686+ ) -> Result < ( ) , StellarSaveError > {
2687+ rating:: rate_group ( & env, caller, group_id, stars, comment)
2688+ }
2689+
2690+ /// Returns the aggregated rating summary for a group.
2691+ ///
2692+ /// Returns a [`GroupRating`] with `rating_count`, `total_stars`, and
2693+ /// `average_scaled` (average × 100, e.g. 450 = 4.50 stars).
2694+ /// Returns zeroed counts if no ratings have been submitted yet.
2695+ pub fn get_group_rating ( env : Env , group_id : u64 ) -> Result < GroupRating , StellarSaveError > {
2696+ rating:: get_group_rating ( & env, group_id)
2697+ }
2698+
2699+ /// Returns the individual rating submitted by a specific member for a group.
2700+ /// Returns `None` if the member has not yet rated the group.
2701+ pub fn get_member_rating (
2702+ env : Env ,
2703+ group_id : u64 ,
2704+ member : Address ,
2705+ ) -> Result < Option < RatingEntry > , StellarSaveError > {
2706+ rating:: get_member_rating ( & env, group_id, member)
2707+ }
2708+
26622709 /// Gets the total XLM balance held by the contract.
26632710 ///
26642711 /// # Arguments
0 commit comments