Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Privilege levels #255

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

feat: Add Privilege levels #255

wants to merge 3 commits into from

Conversation

pscott
Copy link
Collaborator

@pscott pscott commented Jan 16, 2025

Functionality

This PR adds privilege levels (similar to the existing ones on Snapshot).
The different levels are:

  • None -> Default for every address. No privilege.
  • Author -> Can propose even if he doesn't pass the proposal validation strategy
  • Moderator -> Author + Can edit the space's metadata_uri
  • Admin -> Moderator + can edit other settings, cancel a proposal, grant author / moderator privilege
  • Controller -> Admin + can call renounceOwnership, transferOwnership, and grant admin privilege.

--
Adds a new function : function grantPrivilege(address user, PrivilegeLevel level). Can be used to revoke a role by calling grantPrivilege(user, PrivilegeLevel.None)
Adds an event PrivilegeChanged(address user, PrivilegeLevel level)

--
Renames ISpaceOwnerActions to ISpacePrivilegedActions

--
Implements transferOwnership and renounceOwnership instead of using the default OZ one : this is because the Controller role needs to be updated whenever the owner role needs to be updated. The Controller role is a special role because it kind of overlaps with owner from the OZ Ownable lib. This is done to ensure a space controler doesn't mistakenly delete renounce ownership (he must call renounceOwnership in order to properly renounce).

Costs

This change should not increase the cost of voting.
It should decrease the code of proposing for every role because the call will skip calling the proposal validation strategy

Tests

List of tests added:

  • Granting a role emits event
  • TransferOwnership updates the Controller
  • RenounceOwnership updates the Controller
  • A controller CAN grant admin role
  • An admin CAN grant a moderator role
  • An admin CANNOT grant an admin role
  • A controller CANNOT grant a controle role
  • An admin CANNOT modify another admin's role
  • A controller CANNOT modify his own role
  • A moderator CAN update the metadata_uri
  • A moderator CANNOT update something else than metadata_uri
  • An admin CAN upgrade metadata_uri and something else
  • An author CAN skip propose even if he doesn't pass the proposal validation strategy
  • An admin CAN cancel a proposal
  • A moderator CANNOT cancel a proposal

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