Skip to content

Commit

Permalink
Renaming functions and removing unused parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed May 7, 2024
1 parent 3ce375e commit e828700
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 144 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ There's an optional feature, where a predefined address can execute the actions
### Emitting content and managing subspaces

1. When a proposal regarding the space is passed, the `MainVotingPlugin` will call `execute()` on the DAO
2. The actions from the proposal will target the `processGeoProposal()`, `acceptSubspace()` or `removeSubspace()` functions on the `SpacePlugin`.
2. The actions from the proposal will target the `publishEdits()`, `acceptSubspace()` or `removeSubspace()` functions on the `SpacePlugin`.
3. The `SpacePlugin` will be called by the DAO and emit the corresponding events
4. An external indexer will fetch all these events and update the current state of this specific space

Expand Down Expand Up @@ -256,7 +256,7 @@ This plugin is upgradeable.
```solidity
function initialize(IDAO _dao, string _firstBlockContentUri, address predecessorSpace);
function processGeoProposal(uint32 _blockIndex, uint32 _itemIndex, string _contentUri);
function publishEdits(uint32 _blockIndex, uint32 _itemIndex, string _contentUri);
function acceptSubspace(address _dao);
Expand All @@ -282,15 +282,15 @@ function implementation() returns (address);
#### Events

```solidity
event GeoProposalProcessed(uint32 blockIndex, uint32 itemIndex, string contentUri);
event EditsPublished(uint32 blockIndex, uint32 itemIndex, string contentUri);
event SuccessorSpaceCreated(address predecessorSpace);
event SubspaceAccepted(address dao);
event SubspaceRemoved(address dao);
```

#### Permissions

- The DAO can call `processGeoProposal()` on the plugin
- The DAO can call `publishEdits()` on the plugin
- The DAO can accept/remove a subspace on the plugin
- The DAO can upgrade the plugin
- See [Plugin upgrader](#plugin-upgrader) (optional)
Expand Down
13 changes: 0 additions & 13 deletions packages/contracts/src/common.sol

This file was deleted.

49 changes: 17 additions & 32 deletions packages/contracts/src/governance/MainVotingPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ import {IMembers} from "./base/IMembers.sol";
import {IEditors} from "./base/IEditors.sol";
import {Addresslist} from "./base/Addresslist.sol";
import {SpacePlugin} from "../space/SpacePlugin.sol";
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.proposeData.selector ^
MainVotingPlugin.proposeEdits.selector ^
MainVotingPlugin.proposeAcceptSubspace.selector ^
MainVotingPlugin.proposeRemoveSubspace.selector ^
MainVotingPlugin.addEditor.selector ^
Expand Down Expand Up @@ -64,8 +63,8 @@ contract MainVotingPlugin is Addresslist, MajorityVotingBase, IEditors, IMembers
error EmptyContent();

modifier onlyMembers() {
if (!isMember(_msgSender())) {
revert NotAMember(_msgSender());
if (!isMember(msg.sender)) {
revert NotAMember(msg.sender);
}
_;
}
Expand Down Expand Up @@ -172,7 +171,7 @@ contract MainVotingPlugin is Addresslist, MajorityVotingBase, IEditors, IMembers
uint64 _startDate = block.timestamp.toUint64();

proposalId = _createProposal({
_creator: _msgSender(),
_creator: msg.sender,
_metadata: _metadata,
_startDate: _startDate,
_endDate: _startDate + duration(),
Expand All @@ -192,7 +191,7 @@ contract MainVotingPlugin is Addresslist, MajorityVotingBase, IEditors, IMembers
totalVotingPower(snapshotBlock),
minParticipation()
);
proposalCreators[proposalId] = _msgSender();
proposalCreators[proposalId] = msg.sender;

// Reduce costs
if (_allowFailureMap != 0) {
Expand All @@ -212,13 +211,10 @@ 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 _contentUri The URI of the IPFS content to publish
/// @param _spacePlugin The address of the space plugin where changes will be executed
function proposeData(
ProposalContentItem[] calldata _proposalContentItem,
address _spacePlugin
) public onlyMembers {
if (_proposalContentItem.length == 0 || _spacePlugin == address(0)) {
function proposeEdits(string memory _contentUri, address _spacePlugin) public onlyMembers {
if (_spacePlugin == address(0)) {
revert EmptyContent();
}

Expand All @@ -242,26 +238,15 @@ contract MainVotingPlugin is Addresslist, MajorityVotingBase, IEditors, IMembers
totalVotingPower(snapshotBlock),
minParticipation()
);
for (uint256 i; i < _proposalContentItem.length; ) {
IDAO.Action memory _action = IDAO.Action({
proposal_.actions.push(
IDAO.Action({
to: _spacePlugin,
value: 0,
data: abi.encodeCall(
SpacePlugin.processGeoProposal,
(
_proposalContentItem[i].blockIndex,
_proposalContentItem[i].itemIndex,
_proposalContentItem[i].contentUri
)
)
});
proposal_.actions.push(_action);
unchecked {
++i;
}
}
data: abi.encodeCall(SpacePlugin.publishEdits, (_contentUri))
})
);

proposalCreators[proposalId] = _msgSender();
proposalCreators[proposalId] = msg.sender;

emit ProposalCreated({
proposalId: proposalId,
Expand Down Expand Up @@ -308,7 +293,7 @@ contract MainVotingPlugin is Addresslist, MajorityVotingBase, IEditors, IMembers
});
proposal_.actions.push(_action);

proposalCreators[proposalId] = _msgSender();
proposalCreators[proposalId] = msg.sender;

emit ProposalCreated({
proposalId: proposalId,
Expand Down Expand Up @@ -360,7 +345,7 @@ contract MainVotingPlugin is Addresslist, MajorityVotingBase, IEditors, IMembers
});
proposal_.actions.push(_action);

proposalCreators[proposalId] = _msgSender();
proposalCreators[proposalId] = msg.sender;

emit ProposalCreated({
proposalId: proposalId,
Expand Down Expand Up @@ -418,7 +403,7 @@ contract MainVotingPlugin is Addresslist, MajorityVotingBase, IEditors, IMembers

/// @notice Cancels the given proposal. It can only be called by the creator and the proposal must have not ended.
function cancelProposal(uint256 _proposalId) external {
if (proposalCreators[_proposalId] != _msgSender()) {
if (proposalCreators[_proposalId] != msg.sender) {
revert OnlyCreatorCanCancel();
}
Proposal storage proposal_ = proposals[_proposalId];
Expand Down
22 changes: 10 additions & 12 deletions packages/contracts/src/governance/MemberAccessPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ contract MemberAccessPlugin is IMultisig, PluginUUPSUpgradeable, ProposalUpgrade
// Revert if the settings have been changed in the same block as this proposal should be created in.
// This prevents a malicious party from voting with previous addresses and the new settings.
if (lastMultisigSettingsChange > snapshotBlock) {
revert ProposalCreationForbidden(_msgSender());
revert ProposalCreationForbidden(msg.sender);
}

uint64 _startDate = block.timestamp.toUint64();
Expand All @@ -184,7 +184,7 @@ contract MemberAccessPlugin is IMultisig, PluginUUPSUpgradeable, ProposalUpgrade

emit ProposalCreated({
proposalId: proposalId,
creator: _msgSender(),
creator: msg.sender,
metadata: _metadata,
startDate: _startDate,
endDate: _endDate,
Expand All @@ -206,7 +206,7 @@ contract MemberAccessPlugin is IMultisig, PluginUUPSUpgradeable, ProposalUpgrade
}
}

if (isEditor(_msgSender())) {
if (isEditor(msg.sender)) {
if (multisigSettings.mainVotingPlugin.addresslistLength() < 2) {
proposal_.parameters.minApprovals = MIN_APPROVALS_WHEN_CREATED_BY_SINGLE_EDITOR;
} else {
Expand Down Expand Up @@ -271,9 +271,8 @@ contract MemberAccessPlugin is IMultisig, PluginUUPSUpgradeable, ProposalUpgrade
/// @inheritdoc IMultisig
/// @dev The second parameter is left empty to keep compatibility with the existing multisig interface
function approve(uint256 _proposalId) public {
address sender = _msgSender();
if (!_canApprove(_proposalId, sender)) {
revert ApprovalCastForbidden(_proposalId, sender);
if (!_canApprove(_proposalId, msg.sender)) {
revert ApprovalCastForbidden(_proposalId, msg.sender);
}

Proposal storage proposal_ = proposals[_proposalId];
Expand All @@ -284,9 +283,9 @@ contract MemberAccessPlugin is IMultisig, PluginUUPSUpgradeable, ProposalUpgrade
proposal_.approvals += 1;
}

proposal_.approvers[sender] = true;
proposal_.approvers[msg.sender] = true;

emit Approved({proposalId: _proposalId, editor: sender});
emit Approved({proposalId: _proposalId, editor: msg.sender});

if (_canExecute(_proposalId)) {
_execute(_proposalId);
Expand All @@ -295,17 +294,16 @@ contract MemberAccessPlugin is IMultisig, PluginUUPSUpgradeable, ProposalUpgrade

/// @notice Rejects the given proposal immediately.
function reject(uint256 _proposalId) public {
address sender = _msgSender();
if (!_canApprove(_proposalId, sender)) {
revert ApprovalCastForbidden(_proposalId, sender);
if (!_canApprove(_proposalId, msg.sender)) {
revert ApprovalCastForbidden(_proposalId, msg.sender);
}

Proposal storage proposal_ = proposals[_proposalId];

// Prevent any further approvals, expire it
proposal_.parameters.endDate = block.timestamp.toUint64();

emit Rejected({proposalId: _proposalId, editor: sender});
emit Rejected({proposalId: _proposalId, editor: msg.sender});
}

/// @inheritdoc IMultisig
Expand Down
8 changes: 3 additions & 5 deletions packages/contracts/src/governance/base/MajorityVotingBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -262,16 +262,14 @@ abstract contract MajorityVotingBase is
VoteOption _voteOption,
bool _tryEarlyExecution
) public virtual {
address account = _msgSender();

if (!_canVote(_proposalId, account, _voteOption)) {
if (!_canVote(_proposalId, msg.sender, _voteOption)) {
revert VoteCastForbidden({
proposalId: _proposalId,
account: account,
account: msg.sender,
voteOption: _voteOption
});
}
_vote(_proposalId, _voteOption, account, _tryEarlyExecution);
_vote(_proposalId, _voteOption, msg.sender, _tryEarlyExecution);
}

/// @inheritdoc IMajorityVoting
Expand Down
47 changes: 17 additions & 30 deletions packages/contracts/src/personal/PersonalSpaceAdminPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {IDAO} from "@aragon/osx/core/dao/IDAO.sol";
import {PermissionManager} from "@aragon/osx/core/permission/PermissionManager.sol";
import {SpacePlugin} from "../space/SpacePlugin.sol";
import {EDITOR_PERMISSION_ID, MEMBER_PERMISSION_ID} from "../constants.sol";
import {ProposalContentItem} from "../common.sol";

/// @title PersonalSpaceAdminPlugin
/// @author Aragon - 2023
Expand All @@ -22,7 +21,7 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
this.isMember.selector ^
this.isEditor.selector ^
this.executeProposal.selector ^
this.submitData.selector ^
this.submitEdits.selector ^
this.submitAcceptSubspace.selector ^
this.submitRemoveSubspace.selector ^
this.submitNewMember.selector ^
Expand Down Expand Up @@ -71,7 +70,7 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
uint64 _currentTimestamp64 = block.timestamp.toUint64();

uint256 _proposalId = _createProposal({
_creator: _msgSender(),
_creator: msg.sender,
_metadata: _metadata,
_startDate: _currentTimestamp64,
_endDate: _currentTimestamp64,
Expand All @@ -82,30 +81,18 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
}

/// @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 _contentUri The URI of the IPFS content to publish
/// @param _spacePlugin The address of the space plugin where changes will be executed
function submitData(
ProposalContentItem[] calldata _proposalContentItems,
function submitEdits(
string memory _contentUri,
address _spacePlugin
) public auth(MEMBER_PERMISSION_ID) {
IDAO.Action[] memory _actions = new IDAO.Action[](_proposalContentItems.length);

for (uint i = 0; i < _proposalContentItems.length; ) {
_actions[i].to = _spacePlugin;
_actions[i].data = abi.encodeCall(
SpacePlugin.processGeoProposal,
(
_proposalContentItems[i].blockIndex,
_proposalContentItems[i].itemIndex,
_proposalContentItems[i].contentUri
)
);
unchecked {
i++;
}
}

uint256 _proposalId = _createProposal(_msgSender(), _actions);
IDAO.Action[] memory _actions = new IDAO.Action[](1);

_actions[0].to = _spacePlugin;
_actions[0].data = abi.encodeCall(SpacePlugin.publishEdits, (_contentUri));

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

dao().execute(bytes32(_proposalId), _actions, 0);
}
Expand All @@ -121,7 +108,7 @@ 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(msg.sender, _actions);

dao().execute(bytes32(_proposalId), _actions, 0);
}
Expand All @@ -137,7 +124,7 @@ 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(msg.sender, _actions);

dao().execute(bytes32(_proposalId), _actions, 0);
}
Expand All @@ -152,7 +139,7 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
(address(this), _newMember, MEMBER_PERMISSION_ID)
);

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

dao().execute(bytes32(_proposalId), _actions, 0);
}
Expand All @@ -167,7 +154,7 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
(address(this), _member, MEMBER_PERMISSION_ID)
);

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

dao().execute(bytes32(_proposalId), _actions, 0);
}
Expand All @@ -182,7 +169,7 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
(address(this), _newEditor, EDITOR_PERMISSION_ID)
);

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

dao().execute(bytes32(_proposalId), _actions, 0);
}
Expand All @@ -197,7 +184,7 @@ contract PersonalSpaceAdminPlugin is PluginCloneable, ProposalUpgradeable {
(address(this), _editor, EDITOR_PERMISSION_ID)
);

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

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

0 comments on commit e828700

Please sign in to comment.