Skip to content

feat: add notification template registry (#352)#419

Open
MAN7A-afk wants to merge 1 commit into
Core-Foundry:mainfrom
MAN7A-afk:contracts/template-registry
Open

feat: add notification template registry (#352)#419
MAN7A-afk wants to merge 1 commit into
Core-Foundry:mainfrom
MAN7A-afk:contracts/template-registry

Conversation

@MAN7A-afk

Copy link
Copy Markdown
Contributor

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.

@drips-wave

drips-wave Bot commented Jul 23, 2026

Copy link
Copy Markdown

@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! 🚀

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.

[Contracts] Add Notification Template Registry

1 participant