Skip to content

Commit

Permalink
First round of global renames
Browse files Browse the repository at this point in the history
  • Loading branch information
brickpop committed Aug 9, 2024
1 parent da5d8e8 commit e361300
Show file tree
Hide file tree
Showing 17 changed files with 411 additions and 413 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ There's an optional feature, where a predefined address can execute the actions

1. Someone calls `proposeAddMember()` on the `MainVotingPlugin`
- If the caller is the only editor, the proposal succeeds immediately
- The proposal is created on the `MemberAccessPlugin` because the governance rules differ from the rest of proposals
- The proposal is created on the `MainMemberAddHelper` because the governance rules differ from the rest of proposals
2. One of the editors calls `approve()` or `reject()`
- Calling `approve()` makes the proposal succeed
- Calling `reject()` cancels the proposal
Expand Down Expand Up @@ -143,7 +143,7 @@ function grantWithCondition(
);
```

See the `MemberAccessExecuteCondition` contract. It restricts what the [MemberAccessPlugin](#member-access-plugin) can execute on the DAO.
See the `MemberAddCondition` contract. It restricts what the [MainMemberAddHelper](#main-member-add-helper) can execute on the DAO.

[Learn more about OSx permissions](https://devs.aragon.org/docs/osx/how-it-works/core/permissions/)

Expand Down Expand Up @@ -176,7 +176,7 @@ Governance settings:
- `UPDATE_VOTING_SETTINGS_PERMISSION_ID` is required to change the settings of the [MainVotingPlugin](#main-voting-plugin)
- `UPDATE_ADDRESSES_PERMISSION_ID` is required to add or remove members or editors on the [MainVotingPlugin](#main-voting-plugin)
- Typically called by the DAO via proposal
- `UPDATE_MULTISIG_SETTINGS_PERMISSION_ID` is required to change the settings of the [MemberAccessPlugin](#member-access-plugin)
- `UPDATE_MULTISIG_SETTINGS_PERMISSION_ID` is required to change the settings of the [MainMemberAddHelper](#main-member-add-helper)
- Typically called by the DAO via proposal

Permission management:
Expand Down Expand Up @@ -221,7 +221,7 @@ It uses the generated typechain artifacts, which contain the interfaces for the

## Adding members and editors

On Spaces with the standard governance, a [MemberAccessPlugin](#member-access-plugin) and a [MainVotingPlugin](#main-voting-plugin) will be installed.
On Spaces with the standard governance, a [MainMemberAddHelper](#main-member-add-helper) and a [MainVotingPlugin](#main-voting-plugin) will be installed.

### Members

Expand Down Expand Up @@ -302,7 +302,7 @@ event SubspaceRemoved(address dao, address subspaceDao);
- The DAO can upgrade the plugin
- See [Plugin upgrader](#plugin-upgrader) (optional)

### Member Access plugin
### Main Member Add Helper

Provides a simple way for any address to request membership on a space. It is a adapted version of Aragon's [Multisig plugin](https://github.com/aragon/osx/blob/develop/packages/contracts/src/plugins/governance/multisig/Multisig.sol). It creates a proposal to `addMember()` on the main voting plugin and Editors can approve or reject it. Once approved, the member create proposals on the main voting plugin.

Expand Down Expand Up @@ -645,7 +645,7 @@ The same also applies to `prepareUpdate` (if present) and to `prepareUninstallat

#### GovernancePluginsSetup

[This contract](./packages/contracts/src/governance/GovernancePluginsSetup.sol) handles the install/update/uninstall scripts for `MainVotingPlugin` and `MemberAccessPlugin`
[This contract](./packages/contracts/src/governance/GovernancePluginsSetup.sol) handles the install/update/uninstall scripts for `MainVotingPlugin` and `MainMemberAddHelper`

The second plugin needs to know the address of the first one, therefore the setup deploys them together.

Expand Down
13 changes: 7 additions & 6 deletions packages/contracts/deploy/02_setup/11_setup_conclude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import {
GovernancePluginsSetup__factory,
MainVotingPlugin__factory,
MemberAccessPlugin__factory,
MainMemberAddHelper__factory,
PersonalSpaceAdminPlugin__factory,
PersonalSpaceAdminPluginSetup__factory,
SpacePlugin__factory,
Expand Down Expand Up @@ -115,10 +115,11 @@ async function concludeGovernanceSetup(hre: HardhatRuntimeEnvironment) {
await setup.implementation(),
deployer
);
const memberAccessPluginImplementation = MemberAccessPlugin__factory.connect(
await setup.memberAccessPluginImplementation(),
deployer
);
const mainMemberAddHelperImplementation =
MainMemberAddHelper__factory.connect(
await setup.helperImplementation(),
deployer
);

// Add a timeout for polygon because the call to `implementation()` can fail for newly deployed contracts in the first few seconds
if (network.name === 'polygon') {
Expand All @@ -135,7 +136,7 @@ async function concludeGovernanceSetup(hre: HardhatRuntimeEnvironment) {
args: [],
});
hre.aragonToVerifyContracts.push({
address: memberAccessPluginImplementation.address,
address: mainMemberAddHelperImplementation.address,
args: [],
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/plugin-setup-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const PersonalSpaceAdminPluginSetupParams: PluginSetupParams = {

export const GovernancePluginsSetupParams: PluginSetupParams = {
PLUGIN_REPO_ENS_NAME: 'geo-browser-governance',
PLUGIN_CONTRACT_NAME: 'MainVotingPlugin and MemberAccessPlugin',
PLUGIN_CONTRACT_NAME: 'MainVotingPlugin and MainMemberAddHelper',
PLUGIN_SETUP_CONTRACT_NAME: 'GovernancePluginsSetup',
VERSION: {
release: 1, // Increment this number ONLY if breaking/incompatible changes were made. Updates between releases are NOT possible.
Expand Down
10 changes: 3 additions & 7 deletions packages/contracts/scripts/managing-dao-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ const {
const MGMT_DAO_PROPOSAL_DURATION =
parseInt(process.env.MGMT_DAO_PROPOSAL_DURATION ?? '604800') ||
60 * 60 * 24 * 7;
const MGMT_DAO_MIN_PROPOSAL_PARTICIPATION =
parseInt(process.env.MGMT_DAO_MIN_PROPOSAL_PARTICIPATION ?? '500000') ||
500_000; // 50%
const MGMT_DAO_PROPOSAL_SUPPORT_THRESHOLD =
parseInt(process.env.MGMT_DAO_PROPOSAL_SUPPORT_THRESHOLD ?? '500000') ||
500_000; // 50%
Expand Down Expand Up @@ -147,16 +144,15 @@ async function prepareInstallation() {

const settings: MajorityVotingBase.VotingSettingsStruct = {
duration: MGMT_DAO_PROPOSAL_DURATION,
minParticipation: MGMT_DAO_MIN_PROPOSAL_PARTICIPATION,
supportThreshold: MGMT_DAO_PROPOSAL_SUPPORT_THRESHOLD,
votingMode: 1, // Early execution
};
const memberAccessProposalDuration = MGMT_DAO_PROPOSAL_DURATION * 3; // Time before expired
const memberAddProposalDuration = MGMT_DAO_PROPOSAL_DURATION * 3; // Time before expired
const pluginUpgrader = '0x0000000000000000000000000000000000000000'; // Just the DAO
const installData = await pluginSetup.encodeInstallationParams(
settings,
MGMT_DAO_INITIAL_EDITORS,
memberAccessProposalDuration,
memberAddProposalDuration,
pluginUpgrader
);

Expand Down Expand Up @@ -193,7 +189,7 @@ async function prepareInstallation() {
preparedEvent.args.plugin
);
console.log(
'- Deployed a MemberAccessPlugin plugin at',
'- Deployed a MainMemberAddHelper plugin at',
preparedEvent.args.preparedSetupData.helpers[0]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {PermissionCondition} from "@aragon/osx/core/permission/PermissionConditi
import {PermissionManager} from "@aragon/osx/core/permission/PermissionManager.sol";
import {MainVotingPlugin} from "../governance/MainVotingPlugin.sol";

/// @notice The condition associated with `TestSharedPlugin`
contract MemberAccessExecuteCondition is PermissionCondition {
/// @notice Restricts execution to only calls to `addMember`
contract MemberAddCondition is PermissionCondition {
/// @notice The address of the contract where the permission can be granted
address private targetContract;

Expand Down Expand Up @@ -44,6 +44,7 @@ contract MemberAccessExecuteCondition is PermissionCondition {
// Decode the call being requested (both have the same parameters)
(bytes4 _requestedSelector, ) = _decodeAddMemberCalldata(_actions[0].data);

// Note: The selectors of MainVotingPlugin.addMember and PersonalSpaceAdminPlugin.addMember are the same. Checking only once.
if (_requestedSelector != MainVotingPlugin.addMember.selector) return false;

return true;
Expand Down
44 changes: 21 additions & 23 deletions packages/contracts/src/governance/GovernancePluginsSetup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {IDAO} from "@aragon/osx/core/dao/IDAO.sol";
import {PluginSetup, IPluginSetup} from "@aragon/osx/framework/plugin/setup/PluginSetup.sol";
import {PluginSetupProcessor} from "@aragon/osx/framework/plugin/setup/PluginSetupProcessor.sol";
import {MainMemberAddHelper} from "./MainMemberAddHelper.sol";
import {MemberAccessExecuteCondition} from "../conditions/MemberAccessExecuteCondition.sol";
import {MemberAddCondition} from "../conditions/MemberAddCondition.sol";
import {OnlyPluginUpgraderCondition} from "../conditions/OnlyPluginUpgraderCondition.sol";
import {MainVotingPlugin} from "./MainVotingPlugin.sol";
import {MajorityVotingBase} from "./base/MajorityVotingBase.sol";
Expand Down Expand Up @@ -41,19 +41,19 @@ contract GovernancePluginsSetup is PluginSetup {
(
MajorityVotingBase.VotingSettings memory _votingSettings,
address[] memory _initialEditors,
uint64 _memberAccessProposalDuration,
uint64 _memberAddProposalDuration,
address _pluginUpgrader
) = decodeInstallationParams(_data);

// Deploy the member access plugin
address _ainMemberAccessHelper = createERC1967Proxy(
address _mainMemberAddHelper = createERC1967Proxy(
helperImplementation,
abi.encodeCall(
MainMemberAddHelper.initialize,
(
IDAO(_dao),
MainMemberAddHelper.MultisigSettings({
proposalDuration: _memberAccessProposalDuration
proposalDuration: _memberAddProposalDuration
})
)
)
Expand All @@ -68,15 +68,13 @@ contract GovernancePluginsSetup is PluginSetup {
IDAO(_dao),
_votingSettings,
_initialEditors,
MainMemberAddHelper(_ainMemberAccessHelper)
MainMemberAddHelper(_mainMemberAddHelper)
)
)
);

// Condition contract (member access plugin execute)
address _memberAccessExecuteCondition = address(
new MemberAccessExecuteCondition(mainVotingPlugin)
);
address _memberAddCondition = address(new MemberAddCondition(mainVotingPlugin));

// List the requested permissions
PermissionLib.MultiTargetPermission[]
Expand Down Expand Up @@ -113,25 +111,25 @@ contract GovernancePluginsSetup is PluginSetup {
// The MainVotingPlugin can create membership proposals on the MainMemberAddHelper
permissions[3] = PermissionLib.MultiTargetPermission({
operation: PermissionLib.Operation.Grant,
where: _ainMemberAccessHelper,
where: _mainMemberAddHelper,
who: mainVotingPlugin,
condition: PermissionLib.NO_CONDITION,
permissionId: MainMemberAddHelper(_ainMemberAccessHelper).PROPOSER_PERMISSION_ID()
permissionId: MainMemberAddHelper(_mainMemberAddHelper).PROPOSER_PERMISSION_ID()
});

// The member access plugin needs to execute on the DAO
permissions[4] = PermissionLib.MultiTargetPermission({
operation: PermissionLib.Operation.GrantWithCondition,
where: _dao,
who: _ainMemberAccessHelper,
who: _mainMemberAddHelper,
// Conditional execution
condition: _memberAccessExecuteCondition,
condition: _memberAddCondition,
permissionId: DAO(payable(_dao)).EXECUTE_PERMISSION_ID()
});
// The DAO needs to be able to update the member access plugin settings
permissions[5] = PermissionLib.MultiTargetPermission({
operation: PermissionLib.Operation.Grant,
where: _ainMemberAccessHelper,
where: _mainMemberAddHelper,
who: _dao,
condition: PermissionLib.NO_CONDITION,
permissionId: MainMemberAddHelper(helperImplementation)
Expand All @@ -146,7 +144,7 @@ contract GovernancePluginsSetup is PluginSetup {
// pluginUpgrader can make the DAO execute grant/revoke
address[] memory _targetPluginAddresses = new address[](2);
_targetPluginAddresses[0] = mainVotingPlugin;
_targetPluginAddresses[1] = _ainMemberAccessHelper;
_targetPluginAddresses[1] = _mainMemberAddHelper;
OnlyPluginUpgraderCondition _onlyPluginUpgraderCondition = new OnlyPluginUpgraderCondition(
DAO(payable(_dao)),
PluginSetupProcessor(pluginSetupProcessor),
Expand All @@ -163,7 +161,7 @@ contract GovernancePluginsSetup is PluginSetup {

preparedSetupData.permissions = permissions;
preparedSetupData.helpers = new address[](1);
preparedSetupData.helpers[0] = _ainMemberAccessHelper;
preparedSetupData.helpers[0] = _mainMemberAddHelper;
}

/// @inheritdoc IPluginSetup
Expand All @@ -177,7 +175,7 @@ contract GovernancePluginsSetup is PluginSetup {

// Decode incoming params
address _pluginUpgrader = decodeUninstallationParams(_payload.data);
address _ainMemberAccessHelper = _payload.currentHelpers[0];
address _mainMemberAddHelper = _payload.currentHelpers[0];

permissionChanges = new PermissionLib.MultiTargetPermission[](
_pluginUpgrader == address(0x0) ? 6 : 7
Expand Down Expand Up @@ -216,7 +214,7 @@ contract GovernancePluginsSetup is PluginSetup {
// The MainVotingPlugin can no longer propose on the MainMemberAddHelper
permissionChanges[3] = PermissionLib.MultiTargetPermission({
operation: PermissionLib.Operation.Revoke,
where: _ainMemberAccessHelper,
where: _mainMemberAddHelper,
who: _payload.plugin,
condition: address(0),
permissionId: MainMemberAddHelper(helperImplementation).PROPOSER_PERMISSION_ID()
Expand All @@ -226,14 +224,14 @@ contract GovernancePluginsSetup is PluginSetup {
permissionChanges[4] = PermissionLib.MultiTargetPermission({
operation: PermissionLib.Operation.Revoke,
where: _dao,
who: _ainMemberAccessHelper,
who: _mainMemberAddHelper,
condition: address(0),
permissionId: DAO(payable(_dao)).EXECUTE_PERMISSION_ID()
});
// The DAO can no longer update the plugin settings
permissionChanges[5] = PermissionLib.MultiTargetPermission({
operation: PermissionLib.Operation.Revoke,
where: _ainMemberAccessHelper,
where: _mainMemberAddHelper,
who: _dao,
condition: address(0),
permissionId: MainMemberAddHelper(helperImplementation)
Expand Down Expand Up @@ -262,14 +260,14 @@ contract GovernancePluginsSetup is PluginSetup {
function encodeInstallationParams(
MajorityVotingBase.VotingSettings calldata _votingSettings,
address[] calldata _initialEditors,
uint64 _memberAccessProposalDuration,
uint64 _memberAddProposalDuration,
address _pluginUpgrader
) public pure returns (bytes memory) {
return
abi.encode(
_votingSettings,
_initialEditors,
_memberAccessProposalDuration,
_memberAddProposalDuration,
_pluginUpgrader
);
}
Expand All @@ -283,11 +281,11 @@ contract GovernancePluginsSetup is PluginSetup {
returns (
MajorityVotingBase.VotingSettings memory votingSettings,
address[] memory initialEditors,
uint64 memberAccessProposalDuration,
uint64 memberAddProposalDuration,
address pluginUpgrader
)
{
(votingSettings, initialEditors, memberAccessProposalDuration, pluginUpgrader) = abi.decode(
(votingSettings, initialEditors, memberAddProposalDuration, pluginUpgrader) = abi.decode(
_data,
(MajorityVotingBase.VotingSettings, address[], uint64, address)
);
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/src/governance/MainVotingPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ contract MainVotingPlugin is Addresslist, MajorityVotingBase, IEditors, IMembers
}

/// @dev Creating the actual proposal on a separate plugin because the approval rules differ.
/// @dev Keeping all wrappers on the MainVoting plugin, even if one type of approvals are handled on the MemberAccess plugin.
/// @dev Keeping all wrappers on the MainVoting plugin, even if one type of approvals are handled on the MainMemberAdd plugin.
return
mainMemberAddHelper.proposeAddMember(_metadataContentUri, _proposedMember, msg.sender);
}
Expand Down
Loading

0 comments on commit e361300

Please sign in to comment.