feat: Add direct metadata editing for org admins#82
Open
Conversation
- Add updateOrgMetaAsAdmin function for admin hat wearers to edit metadata directly - Add setOrgAdminHat/getOrgAdminHat to configure per-org admin hats - Add setHatsProtocol/getHatsProtocol for Hats Protocol integration - Falls back to topHat if no admin hat is configured - Add IHats interface for checking hat wearers - Add NotOrgAdmin custom error - Add OrgAdminHatSet and HatsProtocolSet events This enables org admins (topHat or configured admin hat wearers) to update organization metadata (name, description, logo, links) without going through the governance proposal flow. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The hats-protocol library already defines an IHats interface in lib/hats-protocol/src/Interfaces/IHats.sol. When OrgRegistry.sol is imported alongside files that import the full IHats, the compiler throws an "Identifier already declared" error. Renamed our minimal interface to IHatsMinimal to avoid the collision. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… interface Removes the custom IHatsMinimal interface and imports the actual IHats interface from the hats-protocol library. This is the proper approach: - Reuses the existing, well-tested interface - Follows the pattern used elsewhere in the codebase - Avoids interface duplication and potential inconsistencies Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove setHatsProtocol/getHatsProtocol - hats address passed as param instead - Rename to OrgMetadataAdmin to clarify scope (metadata editing only, not full admin) - metadataAdminHatOf is optional - if 0, falls back to topHat - Cleaner interface: no global state, explicit hats address per call Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ameter Security fix: Previously updateOrgMetaAsAdmin took hats address as a parameter which could allow malicious callers to pass a fake contract. Now the hats address is stored in contract storage and set via initialize. Changes: - Add IHats hats to Layout storage struct - Add hats parameter to initialize() function - Add getHats() view function - Remove hats parameter from updateOrgMetaAsAdmin (now uses stored address) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1da9f3f to
48e54ff
Compare
Tests cover: - updateOrgMetaAsAdmin with topHat (fallback) - updateOrgMetaAsAdmin with custom admin hat - updateOrgMetaAsAdmin reverts for non-hat wearers - updateOrgMetaAsAdmin reverts when no hats configured - updateOrgMetaAsAdmin reverts for unknown org - setOrgMetadataAdminHat by executor - setOrgMetadataAdminHat reverts for non-executor - setOrgMetadataAdminHat can reset to zero - getOrgMetadataAdminHat returns zero by default - Custom admin hat takes precedence over topHat - getHats returns correct address Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…dress Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.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.
Summary
updateOrgMetaAsAdminfunction for admin hat wearers to edit metadata directly (bypassing governance)setOrgAdminHat/getOrgAdminHatto configure per-org admin hatssetHatsProtocol/getHatsProtocolfor Hats Protocol integrationIHatsinterface for checking hat wearersNotOrgAdmincustom errorOrgAdminHatSetandHatsProtocolSeteventsThis enables org admins (topHat or configured admin hat wearers) to update organization metadata (name, description, logo, links) without going through the governance proposal flow.
How it works
Admin check logic (mirrors frontend implementation):
adminHatOf[orgId] != 0, check if caller wears that hatSetup required:
setHatsProtocol(hatsAddress)once after deploymentsetOrgAdminHat(orgId, hatId)to configure a custom admin hat per orgTest plan
setHatsProtocolwith Hats Protocol addressupdateOrgMetaAsAdminas topHat wearer (should succeed)updateOrgMetaAsAdminas non-admin (should revert withNotOrgAdmin)setOrgAdminHatto configure custom adminupdateOrgMetaAsAdminas custom admin hat wearer (should succeed)🤖 Generated with Claude Code