Skip to content

Commit

Permalink
Applying review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed May 31, 2024
1 parent a25346d commit e0e5022
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions packages/contracts/src/governance/MainVotingPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ contract MainVotingPlugin is Addresslist, MajorityVotingBase, IEditors, IMembers
/// @notice Raised when a content proposal is called with empty data
error EmptyContent();

/// @notice Raised when a non-editor attempts to call a restricted function.
error Unauthorized();

/// @notice Thrown when attempting propose removing membership for a non-member.
error AlreadyNotAMember(address _member);

Expand Down Expand Up @@ -176,6 +179,22 @@ contract MainVotingPlugin is Addresslist, MajorityVotingBase, IEditors, IMembers
}
}

/// @notice Removes msg.sender from the list of editors. If the last editor leaves the space, the space will become read-only.
function leaveSpaceAsEditor() external {
if (!isEditor(msg.sender)) {
revert NotAnEditor();
}

// Not checking whether msg.sender is the last editor. It is acceptable
// that a DAO/Space remains in read-only mode, as it can always be forked.

address[] memory _editors = new address[](1);
_editors[0] = msg.sender;

_removeAddresses(_editors);
emit EditorLeft(address(dao()), msg.sender);
}

/// @notice Returns whether the given address is currently listed as an editor
function isEditor(address _account) public view returns (bool) {
return isListed(_account);
Expand Down Expand Up @@ -380,8 +399,10 @@ contract MainVotingPlugin is Addresslist, MajorityVotingBase, IEditors, IMembers
/// @notice Creates a proposal to remove an existing member.
/// @param _metadata The metadata of the proposal.
/// @param _member The address of the member who may eveutnally be removed.
function proposeRemoveMember(bytes calldata _metadata, address _member) public onlyMembers {
if (!isMember(_member)) {
function proposeRemoveMember(bytes calldata _metadata, address _member) public {
if (!isEditor(msg.sender)) {
revert Unauthorized();
} else if (!isMember(_member)) {
revert AlreadyNotAMember(_member);
}
uint64 snapshotBlock;
Expand Down

0 comments on commit e0e5022

Please sign in to comment.