Skip to content

Commit

Permalink
Allowing to leave spaces and making proposeRemoveMember editor-only
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed May 10, 2024
1 parent 96b0132 commit 1ba15c4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
41 changes: 40 additions & 1 deletion packages/contracts/src/governance/MemberAccessPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,43 @@ contract MemberAccessPlugin is IMultisig, PluginUUPSUpgradeable, ProposalUpgrade
return createProposal(_metadata, _actions);
}

/// @notice Creates and executes a proposal that makes the DAO revoke membership permission from the sender address.
/// @param _metadata The metadata of the proposal.
function leaveSpace(bytes calldata _metadata) external {
if (!isMember(msg.sender)) {
revert AlreadyNotMember(msg.sender);
}

// Build the list of actions
IDAO.Action[] memory _actions = new IDAO.Action[](1);
_actions[0] = IDAO.Action({
to: address(multisigSettings.mainVotingPlugin),
value: 0,
data: abi.encodeCall(MainVotingPlugin.removeMember, (msg.sender))
});

uint _proposalId = _createProposalId();
emit ProposalCreated({
proposalId: _proposalId,
creator: msg.sender,
metadata: _metadata,
startDate: block.timestamp.toUint64(),
endDate: block.timestamp.toUint64(),
actions: _actions,
allowFailureMap: uint8(0)
});

// Register as a proposal
Proposal storage proposal_ = proposals[_proposalId];

proposal_.parameters.snapshotBlock = uint64(block.number) - 1;
proposal_.parameters.startDate = block.timestamp.toUint64();
proposal_.parameters.endDate = block.timestamp.toUint64();
proposal_.actions.push(_actions[0]);

_executeProposal(dao(), _createProposalId(), proposals[_proposalId].actions, 0);
}

/// @notice Creates a proposal to remove an existing member.
/// @param _metadata The metadata of the proposal.
/// @param _proposedMember The address of the member who may eveutnally be removed.
Expand All @@ -252,7 +289,9 @@ contract MemberAccessPlugin is IMultisig, PluginUUPSUpgradeable, ProposalUpgrade
bytes calldata _metadata,
address _proposedMember
) external returns (uint256 proposalId) {
if (!isMember(_proposedMember)) {
if (!isEditor(msg.sender)) {
revert ProposalCreationForbidden(msg.sender);
} else if (!isMember(_proposedMember)) {
revert AlreadyNotMember(_proposedMember);
}

Expand Down
14 changes: 14 additions & 0 deletions packages/contracts/src/personal/PersonalSpaceAdminPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,20 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
dao().execute(bytes32(_proposalId), _actions, 0);
}

/// @notice Creates and executes a proposal that makes the DAO revoke membership permission from the sender address
function leaveSpace() public auth(MEMBER_PERMISSION_ID) {
IDAO.Action[] memory _actions = new IDAO.Action[](1);
_actions[0].to = address(dao());
_actions[0].data = abi.encodeCall(
PermissionManager.revoke,
(address(this), msg.sender, MEMBER_PERMISSION_ID)
);

uint256 _proposalId = _createProposal(msg.sender, _actions);

dao().execute(bytes32(_proposalId), _actions, 0);
}

/// @notice Creates and executes a proposal that makes the DAO grant editor permission to the given address
/// @param _newEditor The address to grant editor permission to
function submitNewEditor(address _newEditor) public auth(EDITOR_PERMISSION_ID) {
Expand Down

0 comments on commit 1ba15c4

Please sign in to comment.