Code-quality items from internal review
Each subitem is small. Group into a single PR or several small PRs.
Magic numbers → named constants
const BPS_SCALE: u32 = 10_000;
const FIRST_PLACE_REP_POINTS: u32 = 100;
const SECOND_PLACE_REP_POINTS: u32 = 50;
const PARTICIPATION_REP_POINTS: u32 = 25;
const SECONDS_PER_DAY: u64 = 86_400;
const TRACK_ID_PER_HACKATHON_CAP: u32 = 1_000;
Inconsistent TTL extensions
Some functions extend TTL after storage writes, others don't. Apply uniformly. Consider a helper macro or wrap storage writes.
Add get_version() query
Returns a constant string (e.g., "hackathon_registry/0.4.0"). Indexers and frontends need to know which version they're talking to. Bump on every breaking change.
Missing events
Add and emit:
JudgeAdded { hackathon_id, judge }
JudgeRemoved { hackathon_id, judge }
HackathonStatusChanged { hackathon_id, old: HackathonStatus, new: HackathonStatus }
SubmissionDisqualified { hackathon_id, team_lead }
DeadlineExtended { hackathon_id, field, old, new } (paired with #extension issue)
Rename submission_count → registration_count
The field tracks registrations, not submitted projects. Confusing for indexers and integrators. Plan as storage migration.
Reentrancy discipline: CEI pattern uniformly
Refactor older fns (cancel_hackathon, distribute_track_prizes) to set state changes BEFORE cross-contract calls. Audit every existing fn for this.
Inline doc comments
Functions are self-explanatory by name but pre/post conditions and invariants are undocumented. Add /// doc comments to each public fn with: auth required, state precondition, side effects, error cases.
Code-quality items from internal review
Each subitem is small. Group into a single PR or several small PRs.
Magic numbers → named constants
Inconsistent TTL extensions
Some functions extend TTL after storage writes, others don't. Apply uniformly. Consider a helper macro or wrap storage writes.
Add
get_version()queryReturns a constant string (e.g., "hackathon_registry/0.4.0"). Indexers and frontends need to know which version they're talking to. Bump on every breaking change.
Missing events
Add and emit:
JudgeAdded { hackathon_id, judge }JudgeRemoved { hackathon_id, judge }HackathonStatusChanged { hackathon_id, old: HackathonStatus, new: HackathonStatus }SubmissionDisqualified { hackathon_id, team_lead }DeadlineExtended { hackathon_id, field, old, new }(paired with #extension issue)Rename
submission_count→registration_countThe field tracks registrations, not submitted projects. Confusing for indexers and integrators. Plan as storage migration.
Reentrancy discipline: CEI pattern uniformly
Refactor older fns (
cancel_hackathon,distribute_track_prizes) to set state changes BEFORE cross-contract calls. Audit every existing fn for this.Inline doc comments
Functions are self-explanatory by name but pre/post conditions and invariants are undocumented. Add
///doc comments to each public fn with: auth required, state precondition, side effects, error cases.