feat(registry): permission separation and audit trail for restaurant deactivation#295
Merged
Leothosine merged 1 commit intoJun 25, 2026
Conversation
…d operations with audit trail - Add deactivated_by: Option<Address> and deactivated_at: Option<u64> to Restaurant struct for full audit trail - Add owner_close_restaurant(): owner-only permanent closure; panics with 'unauthorized' if called by non-owner (including admin) - Add admin_suspend_restaurant(reason: Symbol): admin-only recoverable suspension; emits (rest, suspend) event with caller, timestamp, and reason - Add admin_unsuspend_restaurant(): admin-only; clears deactivated_by and deactivated_at; emits (rest, unsuspnd) event - Remove set_active() to enforce strict role separation — admins and owners can no longer silently cross permission boundaries - Add Symbol to imports - Add tests: owner closes own restaurant, admin cannot call owner_close, admin suspends and unsuspends, owner cannot call admin_suspend, plus retained legacy tests
Leothosine
approved these changes
Jun 25, 2026
Closed
5 tasks
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.
Summary
Replaces the permissionless set_active() function with three strictly separated operations, adds a full audit trail to the Restaurant struct, and covers all actor/action permutations with unit tests.
Root cause
set_active() allowed either the admin or the restaurant owner to flip is_active on any restaurant with no record of who performed the action. A compromised admin key could silently deactivate every restaurant, and there was no way to distinguish a voluntary owner closure from an admin suspension.
Changes
Restaurant struct
Removed
Added
owner_close_restaurant(env, caller, restaurant_id)
�dmin_suspend_restaurant(env, caller, restaurant_id, reason: Symbol)
�dmin_unsuspend_restaurant(env, caller, restaurant_id)
Tests added / updated
closes #284