Skip to content

Commit

Permalink
Misc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed May 6, 2024
1 parent 619895c commit be64e7e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 27 deletions.
9 changes: 7 additions & 2 deletions packages/contracts/src/governance/MainVotingPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {ProposalContentItem} from "../common.sol";
// The [ERC-165](https://eips.ethereum.org/EIPS/eip-165) interface ID of the contract.
bytes4 constant MAIN_SPACE_VOTING_INTERFACE_ID = MainVotingPlugin.initialize.selector ^
MainVotingPlugin.createProposal.selector ^
MainVotingPlugin.proposeNewContent.selector ^
MainVotingPlugin.proposeData.selector ^
MainVotingPlugin.proposeAcceptSubspace.selector ^
MainVotingPlugin.proposeRemoveSubspace.selector ^
MainVotingPlugin.addEditor.selector ^
Expand Down Expand Up @@ -214,7 +214,7 @@ contract MainVotingPlugin is Addresslist, MajorityVotingBase, IEditors, IMembers
/// @notice Creates and executes a proposal that makes the DAO emit new content on the given space.
/// @param _proposalContentItem A list with the content changes to emit
/// @param _spacePlugin The address of the space plugin where changes will be executed
function proposeNewContent(
function proposeData(
ProposalContentItem[] calldata _proposalContentItem,
address _spacePlugin
) public onlyMembers {
Expand Down Expand Up @@ -319,6 +319,11 @@ contract MainVotingPlugin is Addresslist, MajorityVotingBase, IEditors, IMembers
actions: proposal_.actions,
allowFailureMap: 0
});

if (isEditor(proposalCreators[proposalId])) {
// Assuming that the proposer approves (if an editor)
vote(proposalId, VoteOption.Yes, false);
}
}

/// @notice Creates a proposal to make the DAO remove the given DAO as a subspace.
Expand Down
39 changes: 20 additions & 19 deletions packages/contracts/src/personal/PersonalSpaceAdminPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
this.isMember.selector ^
this.isEditor.selector ^
this.executeProposal.selector ^
this.submitNewContent.selector ^
this.submitData.selector ^
this.submitAcceptSubspace.selector ^
this.submitRemoveSubspace.selector ^
this.submitNewMember.selector ^
Expand Down Expand Up @@ -70,21 +70,21 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
) external auth(EDITOR_PERMISSION_ID) {
uint64 _currentTimestamp64 = block.timestamp.toUint64();

uint256 proposalId = _createProposal({
uint256 _proposalId = _createProposal({
_creator: _msgSender(),
_metadata: _metadata,
_startDate: _currentTimestamp64,
_endDate: _currentTimestamp64,
_actions: _actions,
_allowFailureMap: _allowFailureMap
});
_executeProposal(dao(), proposalId, _actions, _allowFailureMap);
dao().execute(bytes32(_proposalId), _actions, _allowFailureMap);
}

/// @notice Creates and executes a proposal that makes the DAO emit new content on the given space.
/// @param _proposalContentItems A list with the content changes to emit
/// @param _spacePlugin The address of the space plugin where changes will be executed
function submitNewContent(
function submitData(
ProposalContentItem[] calldata _proposalContentItems,
address _spacePlugin
) public auth(MEMBER_PERMISSION_ID) {
Expand All @@ -105,9 +105,9 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
}
}

uint256 proposalId = _createProposal(_msgSender(), _actions);
uint256 _proposalId = _createProposal(_msgSender(), _actions);

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

/// @notice Creates and executes a proposal that makes the DAO accept the given DAO as a subspace.
Expand All @@ -121,9 +121,9 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
_actions[0].to = _spacePlugin;
_actions[0].data = abi.encodeCall(SpacePlugin.acceptSubspace, (address(_subspaceDao)));

uint256 proposalId = _createProposal(_msgSender(), _actions);
uint256 _proposalId = _createProposal(_msgSender(), _actions);

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

/// @notice Creates and executes a proposal that makes the DAO remove the given DAO as a subspace.
Expand All @@ -137,9 +137,9 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
_actions[0].to = _spacePlugin;
_actions[0].data = abi.encodeCall(SpacePlugin.removeSubspace, (address(_subspaceDao)));

uint256 proposalId = _createProposal(_msgSender(), _actions);
uint256 _proposalId = _createProposal(_msgSender(), _actions);

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

/// @notice Creates and executes a proposal that makes the DAO grant membership permission to the given address
Expand All @@ -152,9 +152,9 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
(address(this), _newMember, MEMBER_PERMISSION_ID)
);

uint256 proposalId = _createProposal(_msgSender(), _actions);
uint256 _proposalId = _createProposal(_msgSender(), _actions);

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

/// @notice Creates and executes a proposal that makes the DAO revoke membership permission from the given address
Expand All @@ -167,9 +167,9 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
(address(this), _member, MEMBER_PERMISSION_ID)
);

uint256 proposalId = _createProposal(_msgSender(), _actions);
uint256 _proposalId = _createProposal(_msgSender(), _actions);

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

/// @notice Creates and executes a proposal that makes the DAO grant editor permission to the given address
Expand All @@ -182,9 +182,9 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
(address(this), _newEditor, EDITOR_PERMISSION_ID)
);

uint256 proposalId = _createProposal(_msgSender(), _actions);
uint256 _proposalId = _createProposal(_msgSender(), _actions);

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

/// @notice Creates and executes a proposal that makes the DAO revoke editor permission from the given address
Expand All @@ -197,14 +197,15 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
(address(this), _editor, EDITOR_PERMISSION_ID)
);

uint256 proposalId = _createProposal(_msgSender(), _actions);
uint256 _proposalId = _createProposal(_msgSender(), _actions);

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

// Internal helpers

/// @notice Internal function to create a proposal.
/// @notice Internal, simplified function to create a proposal.
/// @param _creator The address who created the proposal.
/// @param _actions The actions that will be executed after the proposal passes.
/// @return proposalId The ID of the proposal.
function _createProposal(
Expand Down
21 changes: 15 additions & 6 deletions packages/contracts/src/space/SpacePlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,25 @@ bytes4 constant SPACE_INTERFACE_ID = SpacePlugin.initialize.selector ^
/// @dev Release 1, Build 1
contract SpacePlugin is PluginUUPSUpgradeable {
/// @notice Emitted when the contents of a space change.
/// @param dao The address of the DAO where this proposal was executed.
/// @param blockIndex The index of the block whose items have new contents.
/// @param itemIndex The index of the item that has new contents.
/// @param contentUri An IPFS URI pointing to the new contents behind the block's item.
event GeoProposalProcessed(uint32 blockIndex, uint32 itemIndex, string contentUri);
event GeoProposalProcessed(address dao, uint32 blockIndex, uint32 itemIndex, string contentUri);

/// @notice Announces that the current space plugin is the successor of an already existing Space
/// @param predecessorSpace The address of the space contract that the plugin will replace
event SuccessorSpaceCreated(address predecessorSpace);

/// @notice Emitted when the DAO accepts another DAO as a subspace.
/// @param dao The address of the DAO where this proposal was executed.
/// @param subspaceDao The address of the DAO to be accepted as a subspace.
event SubspaceAccepted(address subspaceDao);
event SubspaceAccepted(address dao, address subspaceDao);

/// @notice Emitted when the DAO stops recognizing another DAO as a subspace.
/// @param dao The address of the DAO where this proposal was executed.
/// @param subspaceDao The address of the DAO to be removed as a subspace.
event SubspaceRemoved(address subspaceDao);
event SubspaceRemoved(address dao, address subspaceDao);

/// @notice Initializes the plugin when build 1 is installed.
/// @param _dao The address of the DAO to read the permissions from.
Expand All @@ -44,7 +47,12 @@ contract SpacePlugin is PluginUUPSUpgradeable {
if (_predecessorSpace != address(0)) {
emit SuccessorSpaceCreated(_predecessorSpace);
}
emit GeoProposalProcessed({blockIndex: 0, itemIndex: 0, contentUri: _firstBlockContentUri});
emit GeoProposalProcessed({
dao: address(dao()),
blockIndex: 0,
itemIndex: 0,
contentUri: _firstBlockContentUri
});
}

/// @notice Checks if this or the parent contract supports an interface by its ID.
Expand All @@ -66,6 +74,7 @@ contract SpacePlugin is PluginUUPSUpgradeable {
string memory _contentUri
) external auth(CONTENT_PERMISSION_ID) {
emit GeoProposalProcessed({
dao: address(dao()),
blockIndex: _blockIndex,
itemIndex: _itemIndex,
contentUri: _contentUri
Expand All @@ -75,13 +84,13 @@ contract SpacePlugin is PluginUUPSUpgradeable {
/// @notice Emits an event accepting another DAO as a subspace. Caller needs CONTENT_PERMISSION.
/// @param _subspaceDao The address of the DAO to accept as a subspace.
function acceptSubspace(address _subspaceDao) external auth(SUBSPACE_PERMISSION_ID) {
emit SubspaceAccepted(_subspaceDao);
emit SubspaceAccepted(address(dao()), _subspaceDao);
}

/// @notice Emits an event removing another DAO as a subspace. Caller needs CONTENT_PERMISSION.
/// @param _subspaceDao The address of the DAO to remove as a subspace.
function removeSubspace(address _subspaceDao) external auth(SUBSPACE_PERMISSION_ID) {
emit SubspaceRemoved(_subspaceDao);
emit SubspaceRemoved(address(dao()), _subspaceDao);
}

/// @notice This empty reserved space is put in place to allow future versions to add new variables without shifting down storage in the inheritance chain (see [OpenZeppelin's guide about storage gaps](https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps)).
Expand Down

0 comments on commit be64e7e

Please sign in to comment.