feat: add notification template registry (#352)#419
Open
MAN7A-afk wants to merge 1 commit into
Open
Conversation
|
@MAN7A-afk 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! 🚀 |
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.
Description:
Closes #352
Adds an on-chain registry for reusable notification templates so senders can reference a stored template instead of repeating identical notification data each time.
Changes:
types.rs — added NotificationTemplate struct (id, owner, name, content, created_at, updated_at: Option)
events.rs — added TemplateRegistered and TemplateUpdated events, both emitting template_id with owner, category, and priority as topics
errors.rs — added three new error variants (TemplateNotFound, TemplateNameTooLong, TemplateContentEmpty), starting at discriminant 31 to avoid colliding with existing duplicate discriminants already present in the file
template_registry_logic.rs (new) — implements:
register_template — auth-checks the creator, rejects duplicate IDs, validates name/content, stores the template, emits TemplateRegistered
update_template — auth-checks the caller, enforces owner-only updates, rejects missing IDs, validates input, emits TemplateUpdated
get_template — returns the stored template or TemplateNotFound
template_exists — pure view function, never reverts
lib.rs — wired the four entry points into the contract impl block and registered the new test module
template_registry_test.rs (new) — 14 tests covering successful registration, duplicate rejection, validation guards (empty content, name too long), owner-only update enforcement, missing-ID handling, existence checks, and event emission with correct topic/data assertions
Testing:
All new files pass static diagnostics (no syntax/type errors). I wasn't able to run cargo test locally in this environment (Rust/Cargo wasn't installed on this machine at the time), so I'm relying on CI to confirm the test suite passes — will address any failures CI surfaces.
Notes for reviewers:
errors.rs had pre-existing duplicate discriminants (28, 29, 30) unrelated to this change — I left those as-is and started new variants at 31 to avoid touching unrelated code, but flagging it here in case it should be cleaned up separately.