Skip to content

feat(hamplard): add instructor registry and token decimal validation - #276

Open
Shredder401k wants to merge 1 commit into
Hamplard-Hub:mainfrom
Shredder401k:wave8
Open

feat(hamplard): add instructor registry and token decimal validation#276
Shredder401k wants to merge 1 commit into
Hamplard-Hub:mainfrom
Shredder401k:wave8

Conversation

@Shredder401k

Copy link
Copy Markdown
Contributor

Feature Enhancements and Security Fixes

Closes #148
Closes #149
Closes #151

Issue #148: Global instructor registry for efficient instructor-level operations

Problem: No global tracking of instructor addresses prevented efficient on-chain
instructor-level operations like freeze queries, earnings aggregation, and instructor listing.

Changes:

  • Added InstructorRegistry key to DataKey enum to maintain global set of instructor addresses
  • Updated register_course() to automatically add instructors to registry on first course registration
  • Implemented get_all_instructors() admin function returning complete list of registered instructors
  • Implemented get_instructor_count() admin function for platform analytics
  • Registry is append-only and persists across course status changes
  • Functions are admin-only to prevent privacy concerns

Code additions:

// In DataKey enum
InstructorRegistry,

// In register_course()
let mut registry: Vec<Address> = env
    .storage()
    .persistent()
    .get(&DataKey::InstructorRegistry)
    .unwrap_or_else(|| Vec::new(&env));

let mut exists = false;
for i in 0..registry.len() {
    if registry.get(i).unwrap() == instructor {
        exists = true;
        break;
    }
}

if !exists {
    registry.push_back(instructor.clone());
    env.storage()
        .persistent()
        .set(&DataKey::InstructorRegistry, &registry);
}

// New functions
pub fn get_all_instructors(env: Env, admin: Address) -> Vec<Address>
pub fn get_instructor_count(env: Env, admin: Address) -> u32

@drips-wave

drips-wave Bot commented Aug 27, 2026

Copy link
Copy Markdown

@Shredder401k Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment