Standardize versioned event schema for payment, enrollment, governance, and role actions - #1053
Merged
ayomideadeniran merged 2 commits intoAug 2, 2026
Conversation
…e, and role actions (StellarDevHub#918) Events across these domains were previously ad hoc: raw Address/Symbol values stuffed directly into topics, no schema version, no timestamps, and no test ever asserted on event contents. There was also an existing, well-built versioned EventPublisher module (events.rs) that nothing in the codebase actually called. Every event now follows one shape: topics carry (event_name, schema_version, ...indexed fields), and the payload is a single documented #[contracttype] struct with a full field list (actors, amounts, timestamps). schema_version only bumps on breaking payload changes, so indexers can detect incompatible changes instead of guessing from shape. The convention is documented at the top of events.rs. Wired up: - payment_gateway.rs (root crate module): payment_processed/released/ refunded/disputed, dispute_resolved - enrollment.rs: student_enrolled/enrollment_completed/ enrollment_dropped - governance.rs: gov_initialized/credits_deposited/proposal_created/ vote_cast/proposal_finalized/proposal_executed - rbac.rs: rbac_role_granted (previously not emitted at all for init_rbac or grant_role) and rbac_role_revoked Also fixes two pre-existing bugs found while adding coverage: - get_default_roles() in rbac.rs built role data with its own internal Env::default() instead of the contract's real Env, so init_rbac() failed on every call. - governance_test.rs (18 tests) existed on disk but was never wired into the module tree, so it silently never compiled or ran. Added event-content assertion tests (env.events().all()) for each domain, since none existed before. Known gap, left out of scope: certificate-lifecycle events already have a complete, well-designed schema in events.rs (Minted/Revoked/ Renewed/BatchMinted/etc.), but the certificate-minting contract that would call it could not be located as compiled/reachable code in this snapshot — the only reference is contracts/src/tests.rs, which is itself unwired and references functions (e.g. batch_issue) that don't exist anywhere in the crate. Wiring that up is a separate, larger undertaking and is flagged here rather than guessed at.
|
@Junirezz is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Junirezz 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! 🚀 |
Contributor
|
Pr under review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #918
Summary
Events across the payment, enrollment, governance, and role-management domains were ad hoc: raw
Address/Symbolvalues stuffed directly into topics, no schema version, no timestamps, and no test ever asserted on event contents. There was also an existing, well-built versionedEventPublishermodule (contracts/src/events.rs) that nothing in the codebase actually called.Every event now follows one shape, documented at the top of
events.rs:schema_versiononly bumps on a breaking payload change (field removed/renamed/retyped) — adding a field is non-breaking. This lets indexers detect incompatible changes instead of guessing from payload shape.Wired up:
payment_gateway.rs:payment_processed/payment_released/payment_refunded/payment_disputed/dispute_resolvedenrollment.rs:student_enrolled/enrollment_completed/enrollment_droppedgovernance.rs:gov_initialized/credits_deposited/proposal_created/vote_cast/proposal_finalized/proposal_executedrbac.rs:rbac_role_granted(previously not emitted at all forinit_rbacorgrant_role) /rbac_role_revokedAlso fixes two pre-existing bugs found while adding coverage:
get_default_roles()inrbac.rsbuilt role data with its own internalEnv::default()instead of the contract's realEnv, soinit_rbac()failed on every call.governance_test.rs(18 tests) existed on disk but was never wired into the module tree, so it silently never compiled or ran.Known gap, explicitly left out of scope: certificate-lifecycle events already have a complete, well-designed schema in
events.rs(Minted/Revoked/Renewed/BatchMinted/etc.), but the certificate-minting contract that would call it could not be located as compiled/reachable code in this snapshot — the only reference iscontracts/src/tests.rs, which is itself unwired and references functions (e.g.batch_issue) that don't exist anywhere in the crate. Wiring that up is a separate, larger undertaking and is flagged here rather than guessed at.Test plan
env.events().all()) added for each domain — none existed beforecargo testincontracts/— all 277 tests passcargo fmt --check/cargo clippyclean