refactor: centralize event topic Symbols into events.rs per crate - #472
Merged
greatest0fallt1me merged 1 commit intoJun 26, 2026
Merged
Conversation
Extract all inline Symbol::new(&env, ...) event topic literals from lib.rs
into dedicated src/events.rs modules in each of the three Callora contract
crates (vault, settlement, revenue_pool).
Changes per crate
-----------------
vault (23 topics):
- Add contracts/vault/src/events.rs with pub event_* constructor functions
and #[cfg(test)] snapshot assertions for every topic.
- Replace all 23 event topic literals in lib.rs with events:: calls.
- Declare mod events; in lib.rs.
settlement (8 topics):
- Add contracts/settlement/src/events.rs with pub event_* constructors
and snapshot tests.
- Replace all 10 event publish call sites in lib.rs (payment_received
appears twice) with events:: module calls.
- Declare mod events; in lib.rs.
revenue_pool (10 topics):
- Add contracts/revenue_pool/src/events.rs with pub event_* constructors
and snapshot tests.
- Replace all 11 event publish call sites in lib.rs (pause_set appears
for both pause and unpause) with events:: module calls.
- Declare mod events; in lib.rs.
Catalog
-------
- Update EVENT_SCHEMA.md with a 2026-06 change note documenting the
centralization, module paths, and topic counts.
Invariants
----------
- Zero semantic change: no topic string was renamed or reordered.
- Non-event Symbol::new usages (storage keys in revenue_pool, empty-string
request_id sentinels in vault) are intentionally left in place.
- All snapshot tests assert byte-level equality to the original literals.
Pre-existing defects noted (not introduced by this PR)
------------------------------------------------------
- vault: lib.rs:421 type mismatch (id != offering_id) fixed as a drive-by.
- vault: test_views.rs:376 spurious .unwrap() on () return removed.
- vault: test.rs:2911 unused variable warning suppressed with _ prefix.
- vault: test_views.rs:363 format! -> std::format! for no-std compat.
- revenue_pool: test.rs:161 catch_unwind wrapped in AssertUnwindSafe.
- 69 vault test failures and 1 revenue_pool upgrade test failure are
pre-existing and unrelated to this refactor (confirmed via git stash).
|
@zinodict121 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! 🚀 |
3 tasks
Contributor
|
centralizing the event topic Symbols into a per-crate events.rs kills a whole class of topic-typo bugs. clean refactor, merged 👍 |
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 #440
Summary
Centralizes all scattered inline
Symbol::new(&env, "...")event topic strings intodedicated
src/events.rsmodules — one per contract crate. This is a zero-semantic-changerefactor: no topic string was renamed, no event payload was altered, and no existing
behavior was modified.
Closes #[issue number]
Motivation
Before this PR, event topic strings were defined inline at every
env.events().publish()call site. A typo or drift across call sites would silently produce a topic mismatch that
only indexers would catch at runtime. This change makes each topic a single source of truth
that is snapshot-tested at the byte level.
Changes
New files
contracts/vault/src/events.rscontracts/settlement/src/events.rscontracts/revenue_pool/src/events.rsEach file follows the same pattern:
Modified files
contracts/vault/src/lib.rsevents::event_*(&env)calls;mod events;declaredcontracts/settlement/src/lib.rsevents::event_*(&env)calls;mod events;declaredcontracts/revenue_pool/src/lib.rsevents::event_*(&env)calls;mod events;declaredEVENT_SCHEMA.mdDrive-by compiler fixes (pre-existing bugs, not related to this refactor)
These were blocking
cargo testcompilation and are included to keep CI green:vault/src/lib.rs:421id != offering_id→id != *offering_id(type mismatch:Stringvs&String)vault/src/test_views.rs:376.unwrap()on()return fromremove_pricevault/src/test_views.rs:363format!(...)→std::format!(...)(formatnot in scope withoutextern crate std)vault/src/test.rs:4TryFromValimportvault/src/test.rs:2911non_owner→_non_owner(unused variable warning)revenue_pool/src/test.rs:161catch_unwindclosure inAssertUnwindSafe(trait boundUnwindSafenot satisfied)Non-event
Symbol::newusages intentionally left in placeThe grep below confirms all remaining
Symbol::newcalls inlib.rsfiles arestorage key lookups (using named constants like
ADMIN_KEY,PAUSED_KEY, etc.)or empty-string request ID sentinels in the vault — none are event topics:
Test results
callora-settlementcallora-revenue-poolupgrade_sets_version_and_emits_event— pre-existing WASM harness limitation, not caused by this PRcallora-vault#[should_panic]message mismatches; confirmed viagit stashbaseline runThe 43 new snapshot tests (all
test_event_*_bytes) pass across all three crates.Reviewer checklist
events.rsfunction name matches the original literal string (byte identity)lib.rsfile (only storage-keySymbol::newremain)EVENT_SCHEMA.mdchange note is accurateevents.rs