feat(events): add notification priority levels (#131)#148
Merged
Abd-Standard merged 1 commit intoJun 22, 2026
Merged
Conversation
…ore-Foundry#131) Add a NotificationPriority enum (Low/Medium/High/Critical) as a trailing topic on every emitted event, alongside the existing NotificationCategory. Off-chain consumers (alerting, dashboards, paging) can now route by priority — or page on Critical (admin transfer, authorization failure) without decoding the payload. Backward compatibility: priority is added as the LAST topic. Existing listeners keyed off category or the event name keep working unchanged. - Add NotificationPriority contracttype enum to base/events.rs - Append priority as trailing #[topic] on every event struct - Update autoshare_logic.rs publish sites with semantic priority: * Low: GroupActivated/GroupDeactivated (routine lifecycle) * Medium: AutoshareCreated/AutoshareUpdated (operator awareness) * High: ContractPaused/ContractUnpaused (operator review) * Critical: AdminTransferred/AuthorizationFailure (urgent) - Migrate topic helpers from topics.last() to topics.get(n-2) for category (pitfall Core-Foundry#69 prevention); add priority_of helper - Update existing tests with priority assertions; add backward-compat shape test verifying category_topic index remains stable All 105 tests pass (cargo test --workspace). Signed-off-by: zeroknowledge0x <zeroknowledge0x@users.noreply.github.com>
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 #131
Summary
Adds a
NotificationPriorityenum (Low / Medium / High / Critical) as a trailing topic on every emitted event alongside the existingNotificationCategory. Off-chain consumers (alerting, dashboards, paging) can now route notifications by priority — or page onCritical(admin transfer, authorization failure) without decoding the payload.Why a trailing topic
Soroban events are positional — the topic at the last index is what consumers read as the most recent routing signal. By appending
priorityaftercategory, existing listeners keyed off the event name or category keep working unchanged (the extra trailing topic is simply ignored). New consumers can opt in to priority-based routing.Semantic priority mapping
AutoshareCreated,AutoshareUpdatedMediumGroupActivated,GroupDeactivatedLowContractPaused,ContractUnpausedHighAdminTransferred,AuthorizationFailureCriticalBackward compatibility
category_of/latest_categorymigrated fromtopics.last()totopics.get(n - 2)so they keep reading the category from its (now second-to-last) position.priority_ofhelper added for priority assertions.Test evidence
Run:
cargo test --workspacefromcontract/.Files changed
contract/contracts/hello-world/src/base/events.rs— addNotificationPriorityenum, append trailing#[topic] priorityto every event struct (+46)contract/contracts/hello-world/src/autoshare_logic.rs— set semantic priority at every publish site (+12)contract/contracts/hello-world/src/tests/notification_test.rs— migrate topic helpers fromtopics.last()→topics.get(n-2), addpriority_ofhelper, add priority assertions (+77)Signed-off-by: zeroknowledge0x zeroknowledge0x@users.noreply.github.com