Skip to content

Comments

feat: Add direct metadata editing for org admins#82

Open
hudsonhrh wants to merge 8 commits intomainfrom
hudsonhrh/louisville
Open

feat: Add direct metadata editing for org admins#82
hudsonhrh wants to merge 8 commits intomainfrom
hudsonhrh/louisville

Conversation

@hudsonhrh
Copy link
Member

Summary

  • Add updateOrgMetaAsAdmin function for admin hat wearers to edit metadata directly (bypassing governance)
  • 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.

How it works

  1. Admin check logic (mirrors frontend implementation):

    • If adminHatOf[orgId] != 0, check if caller wears that hat
    • Otherwise, fall back to checking if caller wears the topHat
  2. Setup required:

    • Call setHatsProtocol(hatsAddress) once after deployment
    • Optionally call setOrgAdminHat(orgId, hatId) to configure a custom admin hat per org

Test plan

  • Deploy updated contract to testnet
  • Call setHatsProtocol with Hats Protocol address
  • Test updateOrgMetaAsAdmin as topHat wearer (should succeed)
  • Test updateOrgMetaAsAdmin as non-admin (should revert with NotOrgAdmin)
  • Test setOrgAdminHat to configure custom admin
  • Test updateOrgMetaAsAdmin as custom admin hat wearer (should succeed)

🤖 Generated with Claude Code

hudsonhrh and others added 5 commits February 1, 2026 15:02
- 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>
@hudsonhrh hudsonhrh force-pushed the hudsonhrh/louisville branch from 1da9f3f to 48e54ff Compare February 2, 2026 03:01
hudsonhrh and others added 3 commits February 1, 2026 22:02
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>
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.

1 participant