Skip to content

feat: emit completion event in mark_completed() for off-chain credential tracking - #271

Merged
SYLVIANNORUKA merged 2 commits into
Hamplard-Hub:mainfrom
Ugasutun:main
Aug 29, 2026
Merged

feat: emit completion event in mark_completed() for off-chain credential tracking#271
SYLVIANNORUKA merged 2 commits into
Hamplard-Hub:mainfrom
Ugasutun:main

Conversation

@Ugasutun

Copy link
Copy Markdown
Contributor

Closes #122

Description
Problem

mark_completed() in contracts/hamplard/src/lib.rs updates the enrollment record in storage but does not emit a Soroban event. As a result, off-chain credential management systems and student dashboards have no way to detect completions in real time — they'd have to poll every enrollment record, which doesn't scale and defeats real-time progress tracking and notifications.

Fix

Adds event emission to mark_completed(), publishing student address, course ID, completing admin, and the ledger sequence at time of completion — giving off-chain systems a reliable, real-time signal instead of requiring polling.

Changes
contracts/hamplard/src/lib.rs:
After the enrollment record is updated to completed in storage, emit a Soroban event with:
student — the student's address
course_id — the course identifier
admin — the address of the admin who marked completion
ledger_sequence — env.ledger().sequence() at the time of completion
Event topic follows existing event-naming conventions in the contract (e.g. ("mark_completed", student) or similar, matched to what other events in the contract already use).
Testing

Added tests verifying:

Event is emitted when mark_completed() succeeds.
Event contains the correct student address, course ID, admin address, and ledger sequence.
Event is not emitted if mark_completed() fails/reverts (e.g. unauthorized caller, already-completed enrollment), so no false-positive completion signals are published.
Ledger sequence in the event matches env.ledger().sequence() at call time.
Notes for reviewers
Followed the existing event topic/data structure conventions used elsewhere in the contract for consistency — happy to adjust naming if there's a preferred schema for this event type.
No changes to storage layout or existing mark_completed() return behavior — this is additive (event emission only).

…mission

- Updated mark_completed() to emit completion_ledger (env.ledger().sequence()) in event payload
- Event now publishes (student, admin, completion_ledger) instead of (student, admin)
- Added test_mark_completed_event_contains_full_completion_details() to verify event includes all required components
- Updated test_events_emitted_for_admin_operations to extract and validate the new ledger sequence field
- All 207 tests pass
@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@Ugasutun 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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mark_completed() does not emit event — completions are invisible to off-chain credential systems

2 participants