Skip to content

[34] Add a per-course reward configuration replacing the hardcoded BASE_REWARD_AMOUNT #34

Description

@merlik787-droi

Problem Statement

course-registry::complete_module hardcodes let base_reward: i128 = 10_0000000; (line 329). Every course pays the same reward on completion. There's no field on Course to specify its reward amount, despite the constant BASE_REWARD_AMOUNT: i128 = 10_0000000 existing at the crate level.

Why It Matters

  • Every course paying the same amount kills curriculum differentiation.
  • A premium tier of courses cannot pay more without a contract upgrade.

Expected Outcome

  • Add reward_amount: i128 to the Course struct.
  • create_course accepts a reward amount and validates it (> 0, < MAX_*).
  • complete_module reads course.reward_amount instead of constant.
  • New admin-only set_course_reward(env, admin, id, new_reward) (with safeguards).
  • Migration: existing courses get a default zero reward; admin must call set_course_reward to enable.

Acceptance Criteria

  • Different courses can have different reward amounts.
  • Migration is non-destructive.
  • Tests for the new fields and setter.

Implementation Notes

Files / Modules Affected

  • contracts/course-registry/src/types.rs
  • contracts/course-registry/src/lib.rs
  • contracts/course-registry/src/test.rs
  • contracts/course-registry/Cargo.toml (version bump).

Dependencies

Issue #35.

Difficulty

Medium.

Estimated Effort

1–2 days.

Suggested Labels

feature, breaking-change, P2, course-registry


Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions