diff --git a/README.md b/README.md index ed9b145..4da2742 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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/) @@ -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: @@ -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 @@ -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. @@ -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. diff --git a/packages/contracts/deploy/02_setup/11_setup_conclude.ts b/packages/contracts/deploy/02_setup/11_setup_conclude.ts index 62dd76f..d53bc62 100644 --- a/packages/contracts/deploy/02_setup/11_setup_conclude.ts +++ b/packages/contracts/deploy/02_setup/11_setup_conclude.ts @@ -6,7 +6,7 @@ import { import { GovernancePluginsSetup__factory, MainVotingPlugin__factory, - MemberAccessPlugin__factory, + MainMemberAddHelper__factory, PersonalSpaceAdminPlugin__factory, PersonalSpaceAdminPluginSetup__factory, SpacePlugin__factory, @@ -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') { @@ -135,7 +136,7 @@ async function concludeGovernanceSetup(hre: HardhatRuntimeEnvironment) { args: [], }); hre.aragonToVerifyContracts.push({ - address: memberAccessPluginImplementation.address, + address: mainMemberAddHelperImplementation.address, args: [], }); } diff --git a/packages/contracts/plugin-setup-params.ts b/packages/contracts/plugin-setup-params.ts index e3ed83c..c3b8d27 100644 --- a/packages/contracts/plugin-setup-params.ts +++ b/packages/contracts/plugin-setup-params.ts @@ -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. diff --git a/packages/contracts/scripts/managing-dao-setup.ts b/packages/contracts/scripts/managing-dao-setup.ts index 3afebaf..97cc6c2 100644 --- a/packages/contracts/scripts/managing-dao-setup.ts +++ b/packages/contracts/scripts/managing-dao-setup.ts @@ -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% @@ -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 ); @@ -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] ); diff --git a/packages/contracts/src/conditions/MemberAccessExecuteCondition.sol b/packages/contracts/src/conditions/MemberAddCondition.sol similarity index 90% rename from packages/contracts/src/conditions/MemberAccessExecuteCondition.sol rename to packages/contracts/src/conditions/MemberAddCondition.sol index 25c8876..db4a146 100644 --- a/packages/contracts/src/conditions/MemberAccessExecuteCondition.sol +++ b/packages/contracts/src/conditions/MemberAddCondition.sol @@ -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; @@ -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; diff --git a/packages/contracts/src/governance/GovernancePluginsSetup.sol b/packages/contracts/src/governance/GovernancePluginsSetup.sol index 09114f0..a7a5a69 100644 --- a/packages/contracts/src/governance/GovernancePluginsSetup.sol +++ b/packages/contracts/src/governance/GovernancePluginsSetup.sol @@ -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"; @@ -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 }) ) ) @@ -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[] @@ -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) @@ -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), @@ -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 @@ -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 @@ -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() @@ -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) @@ -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 ); } @@ -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) ); diff --git a/packages/contracts/src/governance/MainVotingPlugin.sol b/packages/contracts/src/governance/MainVotingPlugin.sol index 0eaee46..c247bff 100644 --- a/packages/contracts/src/governance/MainVotingPlugin.sol +++ b/packages/contracts/src/governance/MainVotingPlugin.sol @@ -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); } diff --git a/packages/contracts/src/test/TestGovernancePluginsSetup.sol b/packages/contracts/src/test/TestGovernancePluginsSetup.sol index 56a2b68..c8cf1c5 100644 --- a/packages/contracts/src/test/TestGovernancePluginsSetup.sol +++ b/packages/contracts/src/test/TestGovernancePluginsSetup.sol @@ -7,7 +7,7 @@ import {DAO} from "@aragon/osx/core/dao/DAO.sol"; 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 {MemberAccessExecuteCondition} from "../conditions/MemberAccessExecuteCondition.sol"; +import {MemberAddCondition} from "../conditions/MemberAddCondition.sol"; import {OnlyPluginUpgraderCondition} from "../conditions/OnlyPluginUpgraderCondition.sol"; import {MainVotingPlugin} from "../governance/MainVotingPlugin.sol"; import {MainMemberAddHelper} from "../governance/MainMemberAddHelper.sol"; @@ -40,13 +40,13 @@ contract TestGovernancePluginsSetup is PluginSetup { ( MajorityVotingBase.VotingSettings memory _votingSettings, address[] memory _initialEditors, - uint64 _memberAccessProposalDuration, + uint64 _memberAddProposalDuration, address _pluginUpgrader ) = decodeInstallationParams(_data); // Deploy the member access plugin MainMemberAddHelper.MultisigSettings memory _multisigSettings; - _multisigSettings.proposalDuration = _memberAccessProposalDuration; + _multisigSettings.proposalDuration = _memberAddProposalDuration; address _mainMemberAddHelper = createERC1967Proxy( mainMemberAddHelperImplementation(), @@ -68,9 +68,7 @@ contract TestGovernancePluginsSetup is PluginSetup { ); // Condition contract (member access plugin execute) - address _memberAccessExecuteCondition = address( - new MemberAccessExecuteCondition(mainVotingPlugin) - ); + address _memberAddCondition = address(new MemberAddCondition(mainVotingPlugin)); // List the requested permissions PermissionLib.MultiTargetPermission[] @@ -119,7 +117,7 @@ contract TestGovernancePluginsSetup is PluginSetup { operation: PermissionLib.Operation.GrantWithCondition, where: _dao, who: _mainMemberAddHelper, - condition: _memberAccessExecuteCondition, + condition: _memberAddCondition, permissionId: DAO(payable(_dao)).EXECUTE_PERMISSION_ID() }); // The DAO needs to be able to update the member access plugin settings @@ -294,14 +292,14 @@ contract TestGovernancePluginsSetup 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 ); } @@ -315,11 +313,11 @@ contract TestGovernancePluginsSetup 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) ); diff --git a/packages/contracts/src/test/TestMemberAccessExecuteCondition.sol b/packages/contracts/src/test/TestMemberAccessExecuteCondition.sol index 5d031fc..6c9483e 100644 --- a/packages/contracts/src/test/TestMemberAccessExecuteCondition.sol +++ b/packages/contracts/src/test/TestMemberAccessExecuteCondition.sol @@ -3,11 +3,11 @@ pragma solidity 0.8.17; import {IDAO} from "@aragon/osx/core/dao/IDAO.sol"; -import {MemberAccessExecuteCondition} from "../conditions/MemberAccessExecuteCondition.sol"; +import {MemberAddCondition} from "../conditions/MemberAddCondition.sol"; /// @notice The condition associated with `TestSharedPlugin` -contract TestMemberAccessExecuteCondition is MemberAccessExecuteCondition { - constructor(address _targetContract) MemberAccessExecuteCondition(_targetContract) {} +contract TestMemberAddCondition is MemberAddCondition { + constructor(address _targetContract) MemberAddCondition(_targetContract) {} function getSelector(bytes memory _data) public pure returns (bytes4 selector) { return super._getSelector(_data); diff --git a/packages/contracts/test/integration-testing/governance-plugins-setup.ts b/packages/contracts/test/integration-testing/governance-plugins-setup.ts index ed7d68f..31a233c 100644 --- a/packages/contracts/test/integration-testing/governance-plugins-setup.ts +++ b/packages/contracts/test/integration-testing/governance-plugins-setup.ts @@ -5,8 +5,8 @@ import { MainVotingPlugin, MainVotingPlugin__factory, MajorityVotingBase, - MemberAccessPlugin, - MemberAccessPlugin__factory, + MainMemberAddHelper, + MainMemberAddHelper__factory, PluginRepo, } from '../../typechain'; import {PluginSetupRefStruct} from '../../typechain/@aragon/osx/framework/dao/DAOFactory'; @@ -32,7 +32,7 @@ const pluginSettings: MajorityVotingBase.VotingSettingsStruct = { supportThreshold: 1, votingMode: 0, }; -const minMemberAccessProposalDuration = 60 * 60 * 24; +const minMemberAddProposalDuration = 60 * 60 * 24; describe('GovernancePluginsSetup processing', function () { let deployer: SignerWithAddress; @@ -89,7 +89,7 @@ describe('GovernancePluginsSetup processing', function () { let setup: GovernancePluginsSetup; let pluginSetupRef: PluginSetupRefStruct; let mainVotingPlugin: MainVotingPlugin; - let memberAccessPlugin: MemberAccessPlugin; + let mainMemberAddHelper: MainMemberAddHelper; const pluginUpgrader = ADDRESS_ZERO; before(async () => { @@ -113,7 +113,7 @@ describe('GovernancePluginsSetup processing', function () { const data = await setup.encodeInstallationParams( pluginSettings, [deployer.address], - minMemberAccessProposalDuration, + minMemberAddProposalDuration, pluginUpgrader ); const installation = await installPlugin(psp, dao, pluginSetupRef, data); @@ -122,7 +122,7 @@ describe('GovernancePluginsSetup processing', function () { installation.preparedEvent.args.plugin, deployer ); - memberAccessPlugin = MemberAccessPlugin__factory.connect( + mainMemberAddHelper = MainMemberAddHelper__factory.connect( installation.preparedEvent.args.preparedSetupData.helpers[0], deployer ); @@ -132,16 +132,16 @@ describe('GovernancePluginsSetup processing', function () { expect(await mainVotingPlugin.implementation()).to.be.eq( await setup.implementation() ); - expect(await memberAccessPlugin.implementation()).to.be.eq( - await setup.memberAccessPluginImplementation() + expect(await mainMemberAddHelper.implementation()).to.be.eq( + await setup.helperImplementation() ); expect(await mainVotingPlugin.dao()).to.be.eq(dao.address); - expect(await memberAccessPlugin.dao()).to.be.eq(dao.address); + expect(await mainMemberAddHelper.dao()).to.be.eq(dao.address); // Uninstall build 1. const data = await setup.encodeUninstallationParams(pluginUpgrader); await uninstallPlugin(psp, dao, mainVotingPlugin, pluginSetupRef, data, [ - memberAccessPlugin.address, + mainMemberAddHelper.address, ]); }); }); diff --git a/packages/contracts/test/integration-testing/member-access-condition.ts b/packages/contracts/test/integration-testing/member-add-condition.ts similarity index 95% rename from packages/contracts/test/integration-testing/member-access-condition.ts rename to packages/contracts/test/integration-testing/member-add-condition.ts index 3a3e390..3148c0e 100644 --- a/packages/contracts/test/integration-testing/member-access-condition.ts +++ b/packages/contracts/test/integration-testing/member-add-condition.ts @@ -33,7 +33,7 @@ const pluginSettings: MajorityVotingBase.VotingSettingsStruct = { supportThreshold: 1, votingMode: 0, }; -const memberAccessProposalDuration = 60 * 60 * 24; +const memberAddProposalDuration = 60 * 60 * 24; describe('Member Access Condition E2E', () => { let deployer: SignerWithAddress; @@ -48,7 +48,7 @@ describe('Member Access Condition E2E', () => { let pluginSetup: TestGovernancePluginsSetup; let gpsFactory: TestGovernancePluginsSetup__factory; let mainVotingPlugin: MainVotingPlugin; - // let memberAccessPlugin: MemberAccessPlugin; + // let mainMemberAddHelper: MainMemberAddHelper; before(async () => { [deployer, pluginUpgrader, alice] = await ethers.getSigners(); @@ -129,7 +129,7 @@ describe('Member Access Condition E2E', () => { const data = await pluginSetup.encodeInstallationParams( pluginSettings, [deployer.address], - memberAccessProposalDuration, + memberAddProposalDuration, pluginUpgrader.address ); // Internally call prepareInstallation, which deploys the condition @@ -139,7 +139,7 @@ describe('Member Access Condition E2E', () => { installation.preparedEvent.args.plugin, deployer ); - // memberAccessPlugin = MemberAccessPlugin__factory.connect( + // mainMemberAddHelper = MainMemberAddHelper__factory.connect( // installation.preparedEvent.args.preparedSetupData.helpers[0], // deployer // ); diff --git a/packages/contracts/test/integration-testing/plugin-upgrader.ts b/packages/contracts/test/integration-testing/plugin-upgrader.ts index 4f3e175..516c93f 100644 --- a/packages/contracts/test/integration-testing/plugin-upgrader.ts +++ b/packages/contracts/test/integration-testing/plugin-upgrader.ts @@ -3,7 +3,7 @@ import { GovernancePluginsSetup__factory, MainVotingPlugin__factory, MajorityVotingBase, - MemberAccessPlugin__factory, + MainMemberAddHelper__factory, PluginRepo, SpacePluginSetup, SpacePluginSetup__factory, @@ -52,7 +52,7 @@ const pluginSettings: MajorityVotingBase.VotingSettingsStruct = { supportThreshold: 1, votingMode: 0, }; -const minMemberAccessProposalDuration = 60 * 60 * 24; +const minMemberAddProposalDuration = 60 * 60 * 24; const daoInterface = DAO__factory.createInterface(); const pspInterface = PluginSetupProcessor__factory.createInterface(); @@ -169,7 +169,7 @@ describe('Plugin upgrader', () => { const data1 = await pSetupBuild1.encodeInstallationParams( pluginSettings, [deployer.address], - minMemberAccessProposalDuration, + minMemberAddProposalDuration, pluginUpgrader.address ); installation1 = await installPlugin(psp, dao, pluginSetupRef1, data1); @@ -193,7 +193,7 @@ describe('Plugin upgrader', () => { installation1.preparedEvent.args.plugin, deployer ); - const memberAccessPlugin = MemberAccessPlugin__factory.connect( + const mainMemberAddHelper = MainMemberAddHelper__factory.connect( installation1.preparedEvent.args.preparedSetupData.helpers[0], deployer ); @@ -202,8 +202,8 @@ describe('Plugin upgrader', () => { expect(await mainVotingPlugin.implementation()).to.be.eq( await pSetupBuild1.implementation() ); - expect(await memberAccessPlugin.implementation()).to.be.eq( - await pSetupBuild1.memberAccessPluginImplementation() + expect(await mainMemberAddHelper.implementation()).to.be.eq( + await pSetupBuild1.helperImplementation() ); // Check @@ -225,7 +225,7 @@ describe('Plugin upgrader', () => { }, pluginSetupRepo: pluginRepo.address, setupPayload: { - currentHelpers: [memberAccessPlugin.address], + currentHelpers: [mainMemberAddHelper.address], data: dat, plugin: mainVotingPlugin.address, }, @@ -359,8 +359,8 @@ describe('Plugin upgrader', () => { 'Implementation should be build 2' ); - expect(await memberAccessPlugin.implementation()).to.be.eq( - await pSetupBuild1.memberAccessPluginImplementation(), + expect(await mainMemberAddHelper.implementation()).to.be.eq( + await pSetupBuild1.helperImplementation(), 'Implementation should remain as build 1' ); }); @@ -371,7 +371,7 @@ describe('Plugin upgrader', () => { installation1.preparedEvent.args.plugin, deployer ); - const memberAccessPlugin = MemberAccessPlugin__factory.connect( + const mainMemberAddHelper = MainMemberAddHelper__factory.connect( installation1.preparedEvent.args.preparedSetupData.helpers[0], deployer ); @@ -389,7 +389,7 @@ describe('Plugin upgrader', () => { }, pluginSetupRepo: pluginRepo.address, setupPayload: { - currentHelpers: [memberAccessPlugin.address], + currentHelpers: [mainMemberAddHelper.address], data: dat, plugin: mainVotingPlugin.address, }, @@ -463,8 +463,8 @@ describe('Plugin upgrader', () => { 'Implementation should be build 1' ); - expect(await memberAccessPlugin.implementation()).to.be.eq( - await pSetupBuild1.memberAccessPluginImplementation(), + expect(await mainMemberAddHelper.implementation()).to.be.eq( + await pSetupBuild1.helperImplementation(), 'Implementation should remain as build 1' ); }); diff --git a/packages/contracts/test/unit-testing/governance-plugins-setup.ts b/packages/contracts/test/unit-testing/governance-plugins-setup.ts index d838216..328cec5 100644 --- a/packages/contracts/test/unit-testing/governance-plugins-setup.ts +++ b/packages/contracts/test/unit-testing/governance-plugins-setup.ts @@ -59,7 +59,7 @@ describe('Governance Plugins Setup', function () { const nonce = await ethers.provider.getTransactionCount( governancePluginsSetup.address ); - const anticipatedMemberAccessPluginAddress = + const anticipatedMainMemberAddHelperAddress = ethers.utils.getContractAddress({ from: governancePluginsSetup.address, nonce, @@ -69,7 +69,7 @@ describe('Governance Plugins Setup', function () { from: governancePluginsSetup.address, nonce: nonce + 1, }); - const anticipatedMemberAccessConditionAddress = + const anticipatedMemberAddConditionAddress = ethers.utils.getContractAddress({ from: governancePluginsSetup.address, nonce: nonce + 2, @@ -84,8 +84,8 @@ describe('Governance Plugins Setup', function () { ); expect(mainVotingPlugin).to.be.equal(anticipatedMainVotingPluginAddress); expect(helpers.length).to.be.equal(1); - const [memberAccessPlugin] = helpers; - expect(memberAccessPlugin).to.eq(anticipatedMemberAccessPluginAddress); + const [mainMemberAddHelper] = helpers; + expect(mainMemberAddHelper).to.eq(anticipatedMainMemberAddHelperAddress); expect(permissions.length).to.be.equal(6); expect(permissions).to.deep.equal([ @@ -112,7 +112,7 @@ describe('Governance Plugins Setup', function () { ], [ Operation.Grant, - memberAccessPlugin, + mainMemberAddHelper, mainVotingPlugin, NO_CONDITION, PROPOSER_PERMISSION_ID, @@ -120,13 +120,13 @@ describe('Governance Plugins Setup', function () { [ Operation.GrantWithCondition, dao.address, - memberAccessPlugin, - anticipatedMemberAccessConditionAddress, + mainMemberAddHelper, + anticipatedMemberAddConditionAddress, EXECUTE_PERMISSION_ID, ], [ Operation.Grant, - memberAccessPlugin, + mainMemberAddHelper, dao.address, NO_CONDITION, UPDATE_MULTISIG_SETTINGS_PERMISSION_ID, @@ -160,7 +160,7 @@ describe('Governance Plugins Setup', function () { const nonce = await ethers.provider.getTransactionCount( governancePluginsSetup.address ); - const anticipatedMemberAccessPluginAddress = + const anticipatedMainMemberAddHelperAddress = ethers.utils.getContractAddress({ from: governancePluginsSetup.address, nonce, @@ -170,7 +170,7 @@ describe('Governance Plugins Setup', function () { from: governancePluginsSetup.address, nonce: nonce + 1, }); - const anticipatedMemberAccessConditionAddress = + const anticipatedMemberAddConditionAddress = ethers.utils.getContractAddress({ from: governancePluginsSetup.address, nonce: nonce + 2, @@ -190,8 +190,8 @@ describe('Governance Plugins Setup', function () { ); expect(mainVotingPlugin).to.be.equal(anticipatedMainVotingPluginAddress); expect(helpers.length).to.be.equal(1); - const [memberAccessPlugin] = helpers; - expect(memberAccessPlugin).to.eq(anticipatedMemberAccessPluginAddress); + const [mainMemberAddHelper] = helpers; + expect(mainMemberAddHelper).to.eq(anticipatedMainMemberAddHelperAddress); expect(permissions.length).to.be.equal(7); expect(permissions).to.deep.equal([ @@ -218,7 +218,7 @@ describe('Governance Plugins Setup', function () { ], [ Operation.Grant, - memberAccessPlugin, + mainMemberAddHelper, mainVotingPlugin, NO_CONDITION, PROPOSER_PERMISSION_ID, @@ -226,13 +226,13 @@ describe('Governance Plugins Setup', function () { [ Operation.GrantWithCondition, dao.address, - memberAccessPlugin, - anticipatedMemberAccessConditionAddress, + mainMemberAddHelper, + anticipatedMemberAddConditionAddress, EXECUTE_PERMISSION_ID, ], [ Operation.Grant, - memberAccessPlugin, + mainMemberAddHelper, dao.address, NO_CONDITION, UPDATE_MULTISIG_SETTINGS_PERMISSION_ID, @@ -262,7 +262,7 @@ describe('Governance Plugins Setup', function () { const mainVotingPlugin = await new MainVotingPlugin__factory( alice ).deploy(); - const memberAccessPlugin = await new MainVotingPlugin__factory( + const mainMemberAddHelper = await new MainVotingPlugin__factory( alice ).deploy(); @@ -274,7 +274,7 @@ describe('Governance Plugins Setup', function () { dao.address, { plugin: mainVotingPlugin.address, - currentHelpers: [memberAccessPlugin.address], + currentHelpers: [mainMemberAddHelper.address], data: uninstallData, } ); @@ -304,7 +304,7 @@ describe('Governance Plugins Setup', function () { ], [ Operation.Revoke, - memberAccessPlugin.address, + mainMemberAddHelper.address, mainVotingPlugin.address, NO_CONDITION, PROPOSER_PERMISSION_ID, @@ -312,13 +312,13 @@ describe('Governance Plugins Setup', function () { [ Operation.Revoke, dao.address, - memberAccessPlugin.address, + mainMemberAddHelper.address, NO_CONDITION, EXECUTE_PERMISSION_ID, ], [ Operation.Revoke, - memberAccessPlugin.address, + mainMemberAddHelper.address, dao.address, NO_CONDITION, UPDATE_MULTISIG_SETTINGS_PERMISSION_ID, @@ -330,7 +330,7 @@ describe('Governance Plugins Setup', function () { const mainVotingPlugin = await new MainVotingPlugin__factory( alice ).deploy(); - const memberAccessPlugin = await new MainVotingPlugin__factory( + const mainMemberAddHelper = await new MainVotingPlugin__factory( alice ).deploy(); @@ -342,7 +342,7 @@ describe('Governance Plugins Setup', function () { dao.address, { plugin: mainVotingPlugin.address, - currentHelpers: [memberAccessPlugin.address], + currentHelpers: [mainMemberAddHelper.address], data: uninstallData, } ); @@ -372,7 +372,7 @@ describe('Governance Plugins Setup', function () { ], [ Operation.Revoke, - memberAccessPlugin.address, + mainMemberAddHelper.address, mainVotingPlugin.address, NO_CONDITION, PROPOSER_PERMISSION_ID, @@ -380,13 +380,13 @@ describe('Governance Plugins Setup', function () { [ Operation.Revoke, dao.address, - memberAccessPlugin.address, + mainMemberAddHelper.address, NO_CONDITION, EXECUTE_PERMISSION_ID, ], [ Operation.Revoke, - memberAccessPlugin.address, + mainMemberAddHelper.address, dao.address, NO_CONDITION, UPDATE_MULTISIG_SETTINGS_PERMISSION_ID, diff --git a/packages/contracts/test/unit-testing/member-access-plugin.ts b/packages/contracts/test/unit-testing/main-member-add-helper.ts similarity index 74% rename from packages/contracts/test/unit-testing/member-access-plugin.ts rename to packages/contracts/test/unit-testing/main-member-add-helper.ts index 4d7af09..bd2321a 100644 --- a/packages/contracts/test/unit-testing/member-access-plugin.ts +++ b/packages/contracts/test/unit-testing/main-member-add-helper.ts @@ -7,17 +7,17 @@ import { IProposal__factory, MainVotingPlugin, MainVotingPlugin__factory, - MemberAccessPlugin, - MemberAccessPlugin__factory, - MemberAccessExecuteCondition, - MemberAccessExecuteCondition__factory, + MainMemberAddHelper, + MainMemberAddHelper__factory, + MemberAddCondition, + MemberAddCondition__factory, SpacePlugin, SpacePlugin__factory, } from '../../typechain'; import { ApprovedEvent, ProposalCreatedEvent, -} from '../../typechain/src/governance/MemberAccessPlugin'; +} from '../../typechain/src/governance/MainMemberAddHelper'; import {deployWithProxy, findEvent} from '../../utils/helpers'; import {getInterfaceID} from '../../utils/interfaces'; import {deployTestDao} from '../helpers/test-dao'; @@ -63,8 +63,8 @@ describe('Member Access Plugin', function () { let carol: SignerWithAddress; let dave: SignerWithAddress; let dao: DAO; - let memberAccessPlugin: MemberAccessPlugin; - let memberAccessExecuteCondition: MemberAccessExecuteCondition; + let mainMemberAddHelper: MainMemberAddHelper; + let memberAddCondition: MemberAddCondition; let mainVotingPlugin: MainVotingPlugin; let spacePlugin: SpacePlugin; let defaultInput: InitData; @@ -79,8 +79,8 @@ describe('Member Access Plugin', function () { }); beforeEach(async () => { - memberAccessPlugin = await deployWithProxy( - new MemberAccessPlugin__factory(alice) + mainMemberAddHelper = await deployWithProxy( + new MainMemberAddHelper__factory(alice) ); mainVotingPlugin = await deployWithProxy( new MainVotingPlugin__factory(alice) @@ -89,20 +89,19 @@ describe('Member Access Plugin', function () { new SpacePlugin__factory(alice) ); - memberAccessExecuteCondition = - await new MemberAccessExecuteCondition__factory(alice).deploy( - mainVotingPlugin.address - ); + memberAddCondition = await new MemberAddCondition__factory(alice).deploy( + mainVotingPlugin.address + ); // inits - await memberAccessPlugin.initialize(dao.address, { + await mainMemberAddHelper.initialize(dao.address, { proposalDuration: 60 * 60 * 24 * 5, }); await mainVotingPlugin.initialize( dao.address, defaultMainVotingSettings, [alice.address], - memberAccessPlugin.address + mainMemberAddHelper.address ); await spacePlugin.initialize( dao.address, @@ -113,9 +112,9 @@ describe('Member Access Plugin', function () { // The plugin can execute on the DAO await dao.grantWithCondition( dao.address, - memberAccessPlugin.address, + mainMemberAddHelper.address, EXECUTE_PERMISSION_ID, - memberAccessExecuteCondition.address + memberAddCondition.address ); // The main voting plugin can also execute on the DAO await dao.grant( @@ -131,13 +130,13 @@ describe('Member Access Plugin', function () { ); // The DAO can update the plugin settings await dao.grant( - memberAccessPlugin.address, + mainMemberAddHelper.address, dao.address, UPDATE_MULTISIG_SETTINGS_PERMISSION_ID ); // The DAO can upgrade the plugin await dao.grant( - memberAccessPlugin.address, + mainMemberAddHelper.address, dao.address, UPGRADE_PLUGIN_PERMISSION_ID ); @@ -145,7 +144,7 @@ describe('Member Access Plugin', function () { await dao.grant(dao.address, dao.address, ROOT_PERMISSION_ID); // The plugin can propose members on the member access helper await dao.grant( - memberAccessPlugin.address, + mainMemberAddHelper.address, mainVotingPlugin.address, PROPOSER_PERMISSION_ID ); @@ -162,7 +161,7 @@ describe('Member Access Plugin', function () { describe('initialize', () => { it('reverts if trying to re-initialize', async () => { await expect( - memberAccessPlugin.initialize(dao.address, { + mainMemberAddHelper.initialize(dao.address, { proposalDuration: 60 * 60 * 24 * 5, }) ).to.be.revertedWith('Initializable: contract is already initialized'); @@ -177,7 +176,7 @@ describe('Member Access Plugin', function () { ).to.not.be.reverted; await dao.revoke( - memberAccessPlugin.address, + mainMemberAddHelper.address, mainVotingPlugin.address, PROPOSER_PERMISSION_ID ); @@ -195,14 +194,14 @@ describe('Member Access Plugin', function () { ).to.not.be.reverted; await dao.grant( - memberAccessPlugin.address, + mainMemberAddHelper.address, alice.address, PROPOSER_PERMISSION_ID ); // Fail despite the permission await expect( - memberAccessPlugin.proposeAddMember( + mainMemberAddHelper.proposeAddMember( toUtf8Bytes('ipfs://'), dave.address, alice.address @@ -213,14 +212,14 @@ describe('Member Access Plugin', function () { it('Allows any address to request membership via the MainVoting plugin', async () => { // Random expect(await mainVotingPlugin.isMember(carol.address)).to.be.false; - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(carol) .proposeAddMember(toUtf8Bytes('ipfs://1234'), carol.address) ).to.not.be.reverted; - let proposal = await memberAccessPlugin.getProposal(pid); + let proposal = await mainMemberAddHelper.getProposal(pid); expect(proposal.executed).to.eq(false); expect(proposal.approvals).to.eq(0); expect(proposal.parameters.minApprovals).to.eq(1); @@ -230,14 +229,14 @@ describe('Member Access Plugin', function () { expect(await mainVotingPlugin.isMember(carol.address)).to.eq(false); // Member - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(bob) .proposeAddMember(toUtf8Bytes('ipfs://1234'), ADDRESS_ONE) ).to.not.be.reverted; - proposal = await memberAccessPlugin.getProposal(pid); + proposal = await mainMemberAddHelper.getProposal(pid); expect(proposal.executed).to.eq(false); expect(proposal.approvals).to.eq(0); expect(proposal.parameters.minApprovals).to.eq(1); @@ -253,7 +252,7 @@ describe('Member Access Plugin', function () { .proposeAddMember(toUtf8Bytes('ipfs://1234'), ADDRESS_TWO) ).to.not.be.reverted; - proposal = await memberAccessPlugin.getProposal(1); + proposal = await mainMemberAddHelper.getProposal(1); expect(proposal.executed).to.eq(false); expect(proposal.approvals).to.eq(0); expect(proposal.parameters.minApprovals).to.eq(1); @@ -270,13 +269,13 @@ describe('Member Access Plugin', function () { }); it('Emits an event when membership is requested', async () => { - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); const tx = await mainVotingPlugin .connect(carol) .proposeAddMember(toUtf8Bytes('ipfs://2345'), carol.address); - await expect(tx).to.emit(memberAccessPlugin, 'ProposalCreated'); + await expect(tx).to.emit(mainMemberAddHelper, 'ProposalCreated'); const event = await findEvent( tx, @@ -343,7 +342,7 @@ describe('Member Access Plugin', function () { it('Only the editor can approve memberships', async () => { expect(await mainVotingPlugin.addresslistLength()).to.eq(1); - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(carol) @@ -353,13 +352,14 @@ describe('Member Access Plugin', function () { expect(await mainVotingPlugin.isMember(carol.address)).to.eq(false); // Approve it (Bob) => fail - await expect(memberAccessPlugin.connect(bob).approve(pid)).to.be.reverted; + await expect(mainMemberAddHelper.connect(bob).approve(pid)).to.be + .reverted; // Still not a member expect(await mainVotingPlugin.isMember(carol.address)).to.eq(false); // Approve it (Alice) => success - await expect(memberAccessPlugin.connect(alice).approve(pid)).to.not.be + await expect(mainMemberAddHelper.connect(alice).approve(pid)).to.not.be .reverted; // Now Carol is a member @@ -371,7 +371,7 @@ describe('Member Access Plugin', function () { expect(await mainVotingPlugin.isMember(carol.address)).to.eq(false); - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(carol) @@ -381,27 +381,27 @@ describe('Member Access Plugin', function () { expect(await mainVotingPlugin.isMember(carol.address)).to.eq(false); // Reject it (Bob) => fail - await expect(memberAccessPlugin.connect(bob).reject(pid)).to.be.reverted; + await expect(mainMemberAddHelper.connect(bob).reject(pid)).to.be.reverted; // Still not a member expect(await mainVotingPlugin.isMember(carol.address)).to.eq(false); // Reject it (Alice) => success - await expect(memberAccessPlugin.connect(alice).reject(pid)).to.not.be + await expect(mainMemberAddHelper.connect(alice).reject(pid)).to.not.be .reverted; // Carol is not a member expect(await mainVotingPlugin.isMember(carol.address)).to.eq(false); // Try to approve it (Alice) => fail - await expect(memberAccessPlugin.connect(alice).approve(pid)).to.be + await expect(mainMemberAddHelper.connect(alice).approve(pid)).to.be .reverted; }); it('Membership approvals are immediate', async () => { expect(await mainVotingPlugin.addresslistLength()).to.eq(1); - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(carol) @@ -409,21 +409,21 @@ describe('Member Access Plugin', function () { ).to.not.be.reverted; // Approve it (Alice) => success - await expect(memberAccessPlugin.connect(alice).approve(pid)).to.not.be + await expect(mainMemberAddHelper.connect(alice).approve(pid)).to.not.be .reverted; - const proposal = await memberAccessPlugin.getProposal(pid); + const proposal = await mainMemberAddHelper.getProposal(pid); expect(proposal.executed).to.eq(true); // Approve it (Alice) => fail - await expect(memberAccessPlugin.connect(alice).approve(pid)).to.be + await expect(mainMemberAddHelper.connect(alice).approve(pid)).to.be .reverted; }); it('Membership rejections are immediate', async () => { expect(await mainVotingPlugin.addresslistLength()).to.eq(1); - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(carol) @@ -431,14 +431,14 @@ describe('Member Access Plugin', function () { ).to.not.be.reverted; // Reject it (Alice) => success - await expect(memberAccessPlugin.connect(alice).reject(pid)).to.not.be + await expect(mainMemberAddHelper.connect(alice).reject(pid)).to.not.be .reverted; - const proposal = await memberAccessPlugin.getProposal(pid); + const proposal = await mainMemberAddHelper.getProposal(pid); expect(proposal.executed).to.eq(false); // Try to approve it (Alice) => fail - await expect(memberAccessPlugin.connect(bob).reject(pid)).to.be.reverted; + await expect(mainMemberAddHelper.connect(bob).reject(pid)).to.be.reverted; }); it('Proposal execution is immediate when created by the only editor', async () => { @@ -462,28 +462,28 @@ describe('Member Access Plugin', function () { expect(await mainVotingPlugin.addresslistLength()).to.eq(1); expect(await mainVotingPlugin.isMember(dave.address)).to.eq(false); - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(dave) .proposeAddMember(toUtf8Bytes('ipfs://1234'), dave.address) ).to.not.be.reverted; - const proposal = await memberAccessPlugin.getProposal(pid); + const proposal = await mainMemberAddHelper.getProposal(pid); expect(proposal.executed).to.eq(false); expect(proposal.parameters.minApprovals).to.eq(1); - expect(await memberAccessPlugin.canExecute(pid)).to.eq(false); + expect(await mainMemberAddHelper.canExecute(pid)).to.eq(false); expect(await mainVotingPlugin.isMember(dave.address)).to.eq(false); // Dave cannot - await expect(memberAccessPlugin.connect(dave).approve(pid)).to.be + await expect(mainMemberAddHelper.connect(dave).approve(pid)).to.be .reverted; - await expect(memberAccessPlugin.connect(dave).execute(pid)).to.be + await expect(mainMemberAddHelper.connect(dave).execute(pid)).to.be .reverted; expect(await mainVotingPlugin.isMember(dave.address)).to.eq(false); // Alice can - await expect(memberAccessPlugin.connect(alice).approve(pid)).to.not.be + await expect(mainMemberAddHelper.connect(alice).approve(pid)).to.not.be .reverted; expect(await mainVotingPlugin.isMember(dave.address)).to.eq(true); }); @@ -509,7 +509,7 @@ describe('Member Access Plugin', function () { // Requesting membership for Dave expect(await mainVotingPlugin.isMember(dave.address)).to.eq(false); - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(dave) @@ -518,14 +518,14 @@ describe('Member Access Plugin', function () { expect(await mainVotingPlugin.isMember(dave.address)).to.eq(false); // Dave cannot approve (fail) - await expect(memberAccessPlugin.connect(dave).approve(pid)).to.be + await expect(mainMemberAddHelper.connect(dave).approve(pid)).to.be .reverted; // Dave is still not a member expect(await mainVotingPlugin.isMember(dave.address)).to.eq(false); // Approve it (Alice) - await expect(memberAccessPlugin.connect(alice).approve(pid)).to.not.be + await expect(mainMemberAddHelper.connect(alice).approve(pid)).to.not.be .reverted; // Dave is now a member @@ -533,7 +533,7 @@ describe('Member Access Plugin', function () { // Now requesting for 0x1 expect(await mainVotingPlugin.isMember(ADDRESS_ONE)).to.eq(false); - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(dave) @@ -542,14 +542,14 @@ describe('Member Access Plugin', function () { expect(await mainVotingPlugin.isMember(ADDRESS_ONE)).to.eq(false); // Dave cannot approve (fail) - await expect(memberAccessPlugin.connect(dave).approve(pid)).to.be + await expect(mainMemberAddHelper.connect(dave).approve(pid)).to.be .reverted; // ADDRESS_ONE is still not a member expect(await mainVotingPlugin.isMember(ADDRESS_ONE)).to.eq(false); // Approve it (Bob) - await expect(memberAccessPlugin.connect(bob).approve(pid)).to.not.be + await expect(mainMemberAddHelper.connect(bob).approve(pid)).to.not.be .reverted; // ADDRESS_ONE is now a member @@ -557,7 +557,7 @@ describe('Member Access Plugin', function () { // Now requesting for 0x2 expect(await mainVotingPlugin.isMember(ADDRESS_TWO)).to.eq(false); - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(dave) @@ -566,14 +566,14 @@ describe('Member Access Plugin', function () { expect(await mainVotingPlugin.isMember(ADDRESS_TWO)).to.eq(false); // Dave cannot approve (fail) - await expect(memberAccessPlugin.connect(dave).approve(pid)).to.be + await expect(mainMemberAddHelper.connect(dave).approve(pid)).to.be .reverted; // ADDRESS_TWO is still not a member expect(await mainVotingPlugin.isMember(ADDRESS_TWO)).to.eq(false); // Approve it (Carol) - await expect(memberAccessPlugin.connect(carol).approve(pid)).to.not.be + await expect(mainMemberAddHelper.connect(carol).approve(pid)).to.not.be .reverted; // ADDRESS_TWO is now a member @@ -584,46 +584,48 @@ describe('Member Access Plugin', function () { expect(await mainVotingPlugin.addresslistLength()).to.eq(3); // Proposed by a random wallet - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(dave) .proposeAddMember(toUtf8Bytes('ipfs://1234'), dave.address) ).to.not.be.reverted; - let proposal = await memberAccessPlugin.getProposal(pid); + let proposal = await mainMemberAddHelper.getProposal(pid); expect(proposal.executed).to.eq(false); expect(proposal.parameters.minApprovals).to.eq(1); - expect(await memberAccessPlugin.canExecute(pid)).to.eq(false); + expect(await mainMemberAddHelper.canExecute(pid)).to.eq(false); expect(await mainVotingPlugin.isMember(dave.address)).to.eq(false); await mainVotingPlugin.proposeAddMember('0x', dave.address); // Proposed by a (now) member - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(dave) .proposeAddMember(toUtf8Bytes('ipfs://1234'), ADDRESS_ONE) ).to.not.be.reverted; - expect((await memberAccessPlugin.getProposal(pid)).executed).to.eq(false); + expect((await mainMemberAddHelper.getProposal(pid)).executed).to.eq( + false + ); expect(proposal.parameters.minApprovals).to.eq(1); - expect(await memberAccessPlugin.canExecute(pid)).to.eq(false); + expect(await mainMemberAddHelper.canExecute(pid)).to.eq(false); expect(await mainVotingPlugin.isMember(ADDRESS_ONE)).to.eq(false); // Proposed by an editor - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(alice) .proposeAddMember(toUtf8Bytes('ipfs://1234'), ADDRESS_TWO) ).to.not.be.reverted; - proposal = await memberAccessPlugin.getProposal(pid); + proposal = await mainMemberAddHelper.getProposal(pid); expect(proposal.executed).to.eq(false); expect(proposal.parameters.minApprovals).to.eq(2); - expect(await memberAccessPlugin.canExecute(pid)).to.eq(false); + expect(await mainMemberAddHelper.canExecute(pid)).to.eq(false); expect(await mainVotingPlugin.isMember(ADDRESS_TWO)).to.eq(false); }); @@ -632,7 +634,7 @@ describe('Member Access Plugin', function () { expect(await mainVotingPlugin.isMember(dave.address)).to.eq(false); - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(dave) @@ -642,50 +644,54 @@ describe('Member Access Plugin', function () { expect(await mainVotingPlugin.isMember(dave.address)).to.eq(false); // Reject it (Dave) => fail - await expect(memberAccessPlugin.connect(dave).reject(pid)).to.be.reverted; + await expect(mainMemberAddHelper.connect(dave).reject(pid)).to.be + .reverted; // Still not a member expect(await mainVotingPlugin.isMember(dave.address)).to.eq(false); // Reject it (Bob) => success - await expect(memberAccessPlugin.connect(bob).reject(pid)).to.not.be + await expect(mainMemberAddHelper.connect(bob).reject(pid)).to.not.be .reverted; // Still not a member expect(await mainVotingPlugin.isMember(dave.address)).to.eq(false); // Try to approve it (bob) => fail - await expect(memberAccessPlugin.connect(bob).approve(pid)).to.be.reverted; + await expect(mainMemberAddHelper.connect(bob).approve(pid)).to.be + .reverted; - expect((await memberAccessPlugin.getProposal(pid)).executed).to.eq(false); + expect((await mainMemberAddHelper.getProposal(pid)).executed).to.eq( + false + ); }); it("Proposals created by a non-editor need an editor's approval", async () => { expect(await mainVotingPlugin.addresslistLength()).to.eq(3); expect(await mainVotingPlugin.isMember(dave.address)).to.eq(false); - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(dave) .proposeAddMember(toUtf8Bytes('ipfs://1234'), dave.address) ).to.not.be.reverted; - const proposal = await memberAccessPlugin.getProposal(pid); + const proposal = await mainMemberAddHelper.getProposal(pid); expect(proposal.executed).to.eq(false); expect(proposal.parameters.minApprovals).to.eq(1); - expect(await memberAccessPlugin.canExecute(pid)).to.eq(false); + expect(await mainMemberAddHelper.canExecute(pid)).to.eq(false); expect(await mainVotingPlugin.isMember(dave.address)).to.eq(false); // Dave cannot - await expect(memberAccessPlugin.connect(dave).approve(pid)).to.be + await expect(mainMemberAddHelper.connect(dave).approve(pid)).to.be .reverted; - await expect(memberAccessPlugin.connect(dave).execute(pid)).to.be + await expect(mainMemberAddHelper.connect(dave).execute(pid)).to.be .reverted; expect(await mainVotingPlugin.isMember(dave.address)).to.eq(false); // Alice can - await expect(memberAccessPlugin.connect(alice).approve(pid)).to.not.be + await expect(mainMemberAddHelper.connect(alice).approve(pid)).to.not.be .reverted; expect(await mainVotingPlugin.isMember(dave.address)).to.eq(true); }); @@ -693,46 +699,46 @@ describe('Member Access Plugin', function () { it("Proposals created by an editor need another editor's approval", async () => { expect(await mainVotingPlugin.addresslistLength()).to.eq(3); - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(alice) .proposeAddMember(toUtf8Bytes('ipfs://1234'), dave.address) ).to.not.be.reverted; - const proposal = await memberAccessPlugin.getProposal(pid); + const proposal = await mainMemberAddHelper.getProposal(pid); expect(proposal.executed).to.eq(false); expect(proposal.parameters.minApprovals).to.eq(2); - expect(await memberAccessPlugin.canExecute(pid)).to.eq(false); + expect(await mainMemberAddHelper.canExecute(pid)).to.eq(false); }); it('Memberships are approved when the first non-proposer editor approves', async () => { expect(await mainVotingPlugin.addresslistLength()).to.eq(3); // Alice proposes a mew member - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(alice) .proposeAddMember(toUtf8Bytes('ipfs://1234'), dave.address) ).to.not.be.reverted; - let proposal = await memberAccessPlugin.getProposal(pid); + let proposal = await mainMemberAddHelper.getProposal(pid); expect(proposal.executed).to.eq(false); // Approve it (Alice) => fail - await expect(memberAccessPlugin.connect(alice).approve(pid)).to.be + await expect(mainMemberAddHelper.connect(alice).approve(pid)).to.be .reverted; // Approve it (Dave) => fail - await expect(memberAccessPlugin.connect(dave).approve(pid)).to.be + await expect(mainMemberAddHelper.connect(dave).approve(pid)).to.be .reverted; // Approve it (Bob) => succeed - await expect(memberAccessPlugin.connect(bob).approve(pid)).to.not.be + await expect(mainMemberAddHelper.connect(bob).approve(pid)).to.not.be .reverted; - proposal = await memberAccessPlugin.getProposal(pid); + proposal = await mainMemberAddHelper.getProposal(pid); expect(proposal.executed).to.eq(true); // Now Dave is a member @@ -743,31 +749,36 @@ describe('Member Access Plugin', function () { expect(await mainVotingPlugin.addresslistLength()).to.eq(3); // Alice proposes a mew member - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(alice) .proposeAddMember(toUtf8Bytes('ipfs://1234'), dave.address) ).to.not.be.reverted; - expect((await memberAccessPlugin.getProposal(pid)).executed).to.eq(false); + expect((await mainMemberAddHelper.getProposal(pid)).executed).to.eq( + false + ); // Reject it (Alice) => can't change - await expect(memberAccessPlugin.connect(alice).reject(pid)).to.be + await expect(mainMemberAddHelper.connect(alice).reject(pid)).to.be .reverted; // Reject it (Dave) => fail - await expect(memberAccessPlugin.connect(dave).reject(pid)).to.be.reverted; + await expect(mainMemberAddHelper.connect(dave).reject(pid)).to.be + .reverted; // Reject it (Bob) => succeed - await expect(memberAccessPlugin.connect(bob).reject(pid)).to.not.be + await expect(mainMemberAddHelper.connect(bob).reject(pid)).to.not.be .reverted; // Reject it (Carol) => can't anymore - await expect(memberAccessPlugin.connect(carol).reject(pid)).to.be + await expect(mainMemberAddHelper.connect(carol).reject(pid)).to.be .reverted; - expect((await memberAccessPlugin.getProposal(pid)).executed).to.eq(false); + expect((await mainMemberAddHelper.getProposal(pid)).executed).to.eq( + false + ); // Dave is still not a member expect(await mainVotingPlugin.isMember(dave.address)).to.eq(false); @@ -779,14 +790,14 @@ describe('Member Access Plugin', function () { // Bob: member it('proposeNewMember should generate the right action list', async () => { - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(carol) .proposeAddMember(toUtf8Bytes('ipfs://1234'), carol.address) ).to.not.be.reverted; - const proposal = await memberAccessPlugin.getProposal(pid); + const proposal = await mainMemberAddHelper.getProposal(pid); expect(proposal.actions.length).to.eq(1); expect(proposal.actions[0].to).to.eq(mainVotingPlugin.address); expect(proposal.actions[0].value).to.eq(0); @@ -816,27 +827,27 @@ describe('Member Access Plugin', function () { }); it('Attempting to approve twice fails', async () => { - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(dave) .proposeAddMember(toUtf8Bytes('ipfs://1234'), carol.address) ).to.not.be.reverted; - await expect(memberAccessPlugin.approve(pid)).to.not.be.reverted; - await expect(memberAccessPlugin.approve(pid)).to.be.reverted; + await expect(mainMemberAddHelper.approve(pid)).to.not.be.reverted; + await expect(mainMemberAddHelper.approve(pid)).to.be.reverted; }); it('Attempting to reject twice fails', async () => { - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(dave) .proposeAddMember(toUtf8Bytes('ipfs://1234'), carol.address) ).to.not.be.reverted; - await expect(memberAccessPlugin.reject(pid)).to.not.be.reverted; - await expect(memberAccessPlugin.reject(pid)).to.be.reverted; + await expect(mainMemberAddHelper.reject(pid)).to.not.be.reverted; + await expect(mainMemberAddHelper.reject(pid)).to.be.reverted; }); it('Attempting to propose adding an existing member fails', async () => { @@ -860,48 +871,48 @@ describe('Member Access Plugin', function () { }); it('Rejected proposals cannot be approved', async () => { - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(dave) .proposeAddMember(toUtf8Bytes('ipfs://1234'), carol.address) ).to.not.be.reverted; - await expect(memberAccessPlugin.reject(pid)).to.not.be.reverted; - await expect(memberAccessPlugin.approve(pid)).to.be.reverted; + await expect(mainMemberAddHelper.reject(pid)).to.not.be.reverted; + await expect(mainMemberAddHelper.approve(pid)).to.be.reverted; }); it('Rejected proposals cannot be executed', async () => { - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin .connect(dave) .proposeAddMember(toUtf8Bytes('ipfs://1234'), carol.address) ).to.not.be.reverted; - await expect(memberAccessPlugin.reject(pid)).to.not.be.reverted; - await expect(memberAccessPlugin.execute(pid)).to.be.reverted; + await expect(mainMemberAddHelper.reject(pid)).to.not.be.reverted; + await expect(mainMemberAddHelper.execute(pid)).to.be.reverted; }); it('Only the DAO can call the plugin to update the settings', async () => { // Nobody else can await expect( - memberAccessPlugin.connect(alice).updateMultisigSettings({ + mainMemberAddHelper.connect(alice).updateMultisigSettings({ proposalDuration: 60 * 60 * 24 * 5, }) ).to.be.reverted; await expect( - memberAccessPlugin.connect(bob).updateMultisigSettings({ + mainMemberAddHelper.connect(bob).updateMultisigSettings({ proposalDuration: 60 * 60 * 24 * 5, }) ).to.be.reverted; await expect( - memberAccessPlugin.connect(carol).updateMultisigSettings({ + mainMemberAddHelper.connect(carol).updateMultisigSettings({ proposalDuration: 60 * 60 * 24 * 5, }) ).to.be.reverted; await expect( - memberAccessPlugin.connect(dave).updateMultisigSettings({ + mainMemberAddHelper.connect(dave).updateMultisigSettings({ proposalDuration: 60 * 60 * 24 * 5, }) ).to.be.reverted; @@ -909,9 +920,9 @@ describe('Member Access Plugin', function () { // The DAO can const actions: IDAO.ActionStruct[] = [ { - to: memberAccessPlugin.address, + to: mainMemberAddHelper.address, value: 0, - data: MemberAccessPlugin__factory.createInterface().encodeFunctionData( + data: MainMemberAddHelper__factory.createInterface().encodeFunctionData( 'updateMultisigSettings', [ { @@ -927,19 +938,19 @@ describe('Member Access Plugin', function () { it('The DAO can upgrade the plugin', async () => { // Nobody else can - await expect(memberAccessPlugin.connect(alice).upgradeTo(ADDRESS_ONE)).to + await expect(mainMemberAddHelper.connect(alice).upgradeTo(ADDRESS_ONE)).to + .be.reverted; + await expect(mainMemberAddHelper.connect(bob).upgradeTo(ADDRESS_ONE)).to .be.reverted; - await expect(memberAccessPlugin.connect(bob).upgradeTo(ADDRESS_ONE)).to.be - .reverted; await expect( - memberAccessPlugin.connect(carol).upgradeToAndCall( - memberAccessPlugin.implementation(), // upgrade to itself + mainMemberAddHelper.connect(carol).upgradeToAndCall( + mainMemberAddHelper.implementation(), // upgrade to itself EMPTY_DATA ) ).to.be.reverted; await expect( - memberAccessPlugin.connect(dave).upgradeToAndCall( - memberAccessPlugin.implementation(), // upgrade to itself + mainMemberAddHelper.connect(dave).upgradeToAndCall( + mainMemberAddHelper.implementation(), // upgrade to itself EMPTY_DATA ) ).to.be.reverted; @@ -947,11 +958,11 @@ describe('Member Access Plugin', function () { // The DAO can const actions: IDAO.ActionStruct[] = [ { - to: memberAccessPlugin.address, + to: mainMemberAddHelper.address, value: 0, - data: MemberAccessPlugin__factory.createInterface().encodeFunctionData( + data: MainMemberAddHelper__factory.createInterface().encodeFunctionData( 'upgradeTo', - [await memberAccessPlugin.implementation()] + [await mainMemberAddHelper.implementation()] ), }, ]; @@ -964,7 +975,7 @@ describe('Member Access Plugin', function () { describe('initialize', () => { it('reverts if trying to re-initialize', async () => { await expect( - memberAccessPlugin.initialize(dao.address, { + mainMemberAddHelper.initialize(dao.address, { proposalDuration: 60 * 60 * 24 * 5, }) ).to.be.revertedWith('Initializable: contract is already initialized'); @@ -973,7 +984,7 @@ describe('Member Access Plugin', function () { dao.address, defaultMainVotingSettings, [alice.address], - memberAccessPlugin.address + mainMemberAddHelper.address ) ).to.be.revertedWith('Initializable: contract is already initialized'); await expect( @@ -986,58 +997,58 @@ describe('Member Access Plugin', function () { }); it('should emit `MultisigSettingsUpdated` during initialization', async () => { - memberAccessPlugin = await deployWithProxy( - new MemberAccessPlugin__factory(alice) + mainMemberAddHelper = await deployWithProxy( + new MainMemberAddHelper__factory(alice) ); - const multisigSettings: MemberAccessPlugin.MultisigSettingsStruct = { + const multisigSettings: MainMemberAddHelper.MultisigSettingsStruct = { proposalDuration: 60 * 60 * 24 * 5, }; await expect( - memberAccessPlugin.initialize(dao.address, multisigSettings) + mainMemberAddHelper.initialize(dao.address, multisigSettings) ) - .to.emit(memberAccessPlugin, 'MultisigSettingsUpdated') + .to.emit(mainMemberAddHelper, 'MultisigSettingsUpdated') .withArgs(60 * 60 * 24 * 5); }); }); describe('plugin interface: ', () => { it('does not support the empty interface', async () => { - expect(await memberAccessPlugin.supportsInterface('0xffffffff')).to.be + expect(await mainMemberAddHelper.supportsInterface('0xffffffff')).to.be .false; }); it('supports the `IERC165Upgradeable` interface', async () => { const iface = IERC165Upgradeable__factory.createInterface(); expect( - await memberAccessPlugin.supportsInterface(getInterfaceID(iface)) + await mainMemberAddHelper.supportsInterface(getInterfaceID(iface)) ).to.be.true; }); it('supports the `IPlugin` interface', async () => { const iface = IPlugin__factory.createInterface(); expect( - await memberAccessPlugin.supportsInterface(getInterfaceID(iface)) + await mainMemberAddHelper.supportsInterface(getInterfaceID(iface)) ).to.be.true; }); it('supports the `IProposal` interface', async () => { const iface = IProposal__factory.createInterface(); expect( - await memberAccessPlugin.supportsInterface(getInterfaceID(iface)) + await mainMemberAddHelper.supportsInterface(getInterfaceID(iface)) ).to.be.true; }); it('supports the `IMultisig` interface', async () => { const iface = IMultisig__factory.createInterface(); expect( - await memberAccessPlugin.supportsInterface(getInterfaceID(iface)) + await mainMemberAddHelper.supportsInterface(getInterfaceID(iface)) ).to.be.true; }); it('supports the `Multisig` interface', async () => { expect( - await memberAccessPlugin.supportsInterface( + await mainMemberAddHelper.supportsInterface( getInterfaceID(multisigInterface) ) ).to.be.true; @@ -1047,31 +1058,31 @@ describe('Member Access Plugin', function () { describe('updateMultisigSettings:', () => { it('should emit `MultisigSettingsUpdated` when `updateMutlsigSettings` gets called', async () => { await dao.grant( - memberAccessPlugin.address, + mainMemberAddHelper.address, alice.address, - await memberAccessPlugin.UPDATE_MULTISIG_SETTINGS_PERMISSION_ID() + await mainMemberAddHelper.UPDATE_MULTISIG_SETTINGS_PERMISSION_ID() ); const multisigSettings = { proposalDuration: 60 * 60 * 24 * 5, }; await expect( - memberAccessPlugin.updateMultisigSettings(multisigSettings) + mainMemberAddHelper.updateMultisigSettings(multisigSettings) ) - .to.emit(memberAccessPlugin, 'MultisigSettingsUpdated') + .to.emit(mainMemberAddHelper, 'MultisigSettingsUpdated') .withArgs(60 * 60 * 24 * 5); }); }); describe('createProposal:', () => { it('increments the proposal counter', async () => { - const pc = await memberAccessPlugin.proposalCount(); + const pc = await mainMemberAddHelper.proposalCount(); await expect( mainVotingPlugin.proposeAddMember(EMPTY_DATA, carol.address) ).not.to.be.reverted; - expect(await memberAccessPlugin.proposalCount()).to.equal(pc.add(1)); + expect(await mainMemberAddHelper.proposalCount()).to.equal(pc.add(1)); }); it('creates unique proposal IDs for each proposal', async () => { @@ -1098,14 +1109,14 @@ describe('Member Access Plugin', function () { it('emits the `ProposalCreated` event', async () => { await expect( mainVotingPlugin.proposeAddMember(EMPTY_DATA, carol.address) - ).to.emit(memberAccessPlugin, 'ProposalCreated'); + ).to.emit(mainMemberAddHelper, 'ProposalCreated'); }); it('reverts if the multisig settings have been changed in the same block', async () => { await dao.grant( - memberAccessPlugin.address, + mainMemberAddHelper.address, dao.address, - await memberAccessPlugin.UPDATE_MULTISIG_SETTINGS_PERMISSION_ID() + await mainMemberAddHelper.UPDATE_MULTISIG_SETTINGS_PERMISSION_ID() ); await ethers.provider.send('evm_setAutomine', [false]); @@ -1114,9 +1125,9 @@ describe('Member Access Plugin', function () { ZERO_BYTES32, [ { - to: memberAccessPlugin.address, + to: mainMemberAddHelper.address, value: 0, - data: memberAccessPlugin.interface.encodeFunctionData( + data: mainMemberAddHelper.interface.encodeFunctionData( 'updateMultisigSettings', [ { @@ -1131,7 +1142,7 @@ describe('Member Access Plugin', function () { await expect( mainVotingPlugin.proposeAddMember(EMPTY_DATA, carol.address) ).to.revertedWithCustomError( - memberAccessPlugin, + mainMemberAddHelper, 'ProposalCreationForbiddenOnSameBlock' ); @@ -1149,50 +1160,51 @@ describe('Member Access Plugin', function () { expect(await mainVotingPlugin.isEditor(carol.address)).to.be.false; // Alice approves - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await mainVotingPlugin.proposeAddMember(EMPTY_DATA, carol.address); }); it('returns `false` if the proposal is already executed', async () => { - expect((await memberAccessPlugin.getProposal(pid)).executed).to.be + expect((await mainMemberAddHelper.getProposal(pid)).executed).to.be .false; - await memberAccessPlugin.connect(bob).approve(pid); + await mainMemberAddHelper.connect(bob).approve(pid); - expect((await memberAccessPlugin.getProposal(pid)).executed).to.be.true; - expect(await memberAccessPlugin.canApprove(pid, signers[3].address)).to + expect((await mainMemberAddHelper.getProposal(pid)).executed).to.be + .true; + expect(await mainMemberAddHelper.canApprove(pid, signers[3].address)).to .be.false; }); it('returns `false` if the approver is not an editor', async () => { expect(await mainVotingPlugin.isEditor(signers[9].address)).to.be.false; - expect(await memberAccessPlugin.canApprove(pid, signers[9].address)).to + expect(await mainMemberAddHelper.canApprove(pid, signers[9].address)).to .be.false; }); it('returns `false` if the approver has already approved', async () => { - expect(await memberAccessPlugin.canApprove(pid, bob.address)).to.be + expect(await mainMemberAddHelper.canApprove(pid, bob.address)).to.be .true; - await memberAccessPlugin.connect(bob).approve(pid); - expect(await memberAccessPlugin.canApprove(pid, bob.address)).to.be + await mainMemberAddHelper.connect(bob).approve(pid); + expect(await mainMemberAddHelper.canApprove(pid, bob.address)).to.be .false; }); it('returns `true` if the approver is listed', async () => { - expect(await memberAccessPlugin.canApprove(pid, bob.address)).to.be + expect(await mainMemberAddHelper.canApprove(pid, bob.address)).to.be .true; }); it('returns `false` if the proposal is settled', async () => { - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await mainVotingPlugin.proposeAddMember(EMPTY_DATA, carol.address); - expect(await memberAccessPlugin.canApprove(pid, bob.address)).to.be + expect(await mainMemberAddHelper.canApprove(pid, bob.address)).to.be .true; - await memberAccessPlugin.connect(bob).approve(pid); + await mainMemberAddHelper.connect(bob).approve(pid); - expect(await memberAccessPlugin.canApprove(pid, bob.address)).to.be + expect(await mainMemberAddHelper.canApprove(pid, bob.address)).to.be .false; }); }); @@ -1203,18 +1215,18 @@ describe('Member Access Plugin', function () { await mineBlock(); // Carol is a member - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await mainVotingPlugin.proposeAddMember(EMPTY_DATA, carol.address); }); it("returns `false` if user hasn't approved yet", async () => { - expect(await memberAccessPlugin.hasApproved(pid, bob.address)).to.be + expect(await mainMemberAddHelper.hasApproved(pid, bob.address)).to.be .false; }); it('returns `true` if user has approved', async () => { - await memberAccessPlugin.connect(bob).approve(pid); - expect(await memberAccessPlugin.hasApproved(pid, bob.address)).to.be + await mainMemberAddHelper.connect(bob).approve(pid); + expect(await mainMemberAddHelper.hasApproved(pid, bob.address)).to.be .true; }); }); @@ -1225,45 +1237,45 @@ describe('Member Access Plugin', function () { await mineBlock(); // Alice approves - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await mainVotingPlugin.proposeAddMember(EMPTY_DATA, carol.address); }); it('reverts when approving multiple times', async () => { - await memberAccessPlugin.connect(bob).approve(pid); + await mainMemberAddHelper.connect(bob).approve(pid); // Try to vote again - await expect(memberAccessPlugin.connect(bob).approve(pid)) + await expect(mainMemberAddHelper.connect(bob).approve(pid)) .to.be.revertedWithCustomError( - memberAccessPlugin, + mainMemberAddHelper, 'ApprovalCastForbidden' ) .withArgs(pid, bob.address); }); it('reverts if minimal approval is not met yet', async () => { - const proposal = await memberAccessPlugin.getProposal(pid); + const proposal = await mainMemberAddHelper.getProposal(pid); expect(proposal.approvals).to.eq(1); - await expect(memberAccessPlugin.execute(pid)) + await expect(mainMemberAddHelper.execute(pid)) .to.be.revertedWithCustomError( - memberAccessPlugin, + mainMemberAddHelper, 'ProposalExecutionForbidden' ) .withArgs(pid); }); it('approves with the msg.sender address', async () => { - expect((await memberAccessPlugin.getProposal(pid)).approvals).to.equal( + expect((await mainMemberAddHelper.getProposal(pid)).approvals).to.equal( 1 ); - const tx = await memberAccessPlugin.connect(bob).approve(pid); + const tx = await mainMemberAddHelper.connect(bob).approve(pid); const event = await findEvent(tx, 'Approved'); expect(event!.args.proposalId).to.eq(pid); expect(event!.args.editor).to.eq(bob.address); - expect((await memberAccessPlugin.getProposal(pid)).approvals).to.equal( + expect((await mainMemberAddHelper.getProposal(pid)).approvals).to.equal( 2 ); }); @@ -1279,30 +1291,31 @@ describe('Member Access Plugin', function () { expect(await mainVotingPlugin.isEditor(carol.address)).to.be.false; // Alice approves - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await mainVotingPlugin.proposeAddMember(EMPTY_DATA, carol.address); }); it('returns `false` if the proposal has not reached the minimum approval yet', async () => { - const proposal = await memberAccessPlugin.getProposal(pid); + const proposal = await mainMemberAddHelper.getProposal(pid); expect(proposal.approvals).to.be.lt(proposal.parameters.minApprovals); - expect(await memberAccessPlugin.canExecute(pid)).to.be.false; + expect(await mainMemberAddHelper.canExecute(pid)).to.be.false; }); it('returns `false` if the proposal is already executed', async () => { - expect((await memberAccessPlugin.getProposal(pid)).executed).to.be + expect((await mainMemberAddHelper.getProposal(pid)).executed).to.be .false; expect( - (await memberAccessPlugin.getProposal(pid)).actions.length + (await mainMemberAddHelper.getProposal(pid)).actions.length ).to.eq(1); // Approve and execute - await memberAccessPlugin.connect(bob).approve(pid); + await mainMemberAddHelper.connect(bob).approve(pid); - expect((await memberAccessPlugin.getProposal(pid)).executed).to.be.true; + expect((await mainMemberAddHelper.getProposal(pid)).executed).to.be + .true; - expect(await memberAccessPlugin.canExecute(pid)).to.be.false; + expect(await mainMemberAddHelper.canExecute(pid)).to.be.false; }); }); @@ -1312,24 +1325,24 @@ describe('Member Access Plugin', function () { await mineBlock(); // Alice approves - pid = await memberAccessPlugin.proposalCount(); + pid = await mainMemberAddHelper.proposalCount(); await mainVotingPlugin.proposeAddMember(EMPTY_DATA, carol.address); }); it('reverts if the minimum approval is not met', async () => { - await expect(memberAccessPlugin.execute(pid)) + await expect(mainMemberAddHelper.execute(pid)) .to.be.revertedWithCustomError( - memberAccessPlugin, + mainMemberAddHelper, 'ProposalExecutionForbidden' ) .withArgs(pid); }); it('emits the `Approved`, `ProposalExecuted`, and `Executed` events if execute is called inside the `approve` method', async () => { - await expect(memberAccessPlugin.connect(bob).approve(pid)) + await expect(mainMemberAddHelper.connect(bob).approve(pid)) .to.emit(dao, 'Executed') - .to.emit(memberAccessPlugin, 'ProposalExecuted') - .to.emit(memberAccessPlugin, 'Approved'); + .to.emit(mainMemberAddHelper, 'ProposalExecuted') + .to.emit(mainMemberAddHelper, 'Approved'); }); }); }); diff --git a/packages/contracts/test/unit-testing/main-voting-plugin.ts b/packages/contracts/test/unit-testing/main-voting-plugin.ts index 6629f0c..bb1f963 100644 --- a/packages/contracts/test/unit-testing/main-voting-plugin.ts +++ b/packages/contracts/test/unit-testing/main-voting-plugin.ts @@ -4,8 +4,8 @@ import { IDAO, MainVotingPlugin, MainVotingPlugin__factory, - MemberAccessPlugin, - MemberAccessPlugin__factory, + MainMemberAddHelper, + MainMemberAddHelper__factory, SpacePlugin, SpacePlugin__factory, } from '../../typechain'; @@ -63,7 +63,7 @@ describe('Main Voting Plugin', function () { let carol: SignerWithAddress; let dave: SignerWithAddress; let dao: DAO; - let memberAccessPlugin: MemberAccessPlugin; + let mainMemberAddHelper: MainMemberAddHelper; let mainVotingPlugin: MainVotingPlugin; let spacePlugin: SpacePlugin; let defaultInput: InitData; @@ -77,8 +77,8 @@ describe('Main Voting Plugin', function () { }); beforeEach(async () => { - memberAccessPlugin = await deployWithProxy( - new MemberAccessPlugin__factory(alice) + mainMemberAddHelper = await deployWithProxy( + new MainMemberAddHelper__factory(alice) ); mainVotingPlugin = await deployWithProxy( new MainVotingPlugin__factory(alice) @@ -88,14 +88,14 @@ describe('Main Voting Plugin', function () { ); // inits - await memberAccessPlugin.initialize(dao.address, { + await mainMemberAddHelper.initialize(dao.address, { proposalDuration: 60 * 60 * 24 * 5, }); await mainVotingPlugin.initialize( dao.address, defaultMainVotingSettings, [alice.address], - memberAccessPlugin.address + mainMemberAddHelper.address ); await spacePlugin.initialize( dao.address, @@ -109,10 +109,10 @@ describe('Main Voting Plugin', function () { mainVotingPlugin.address, EXECUTE_PERMISSION_ID ); - // MemberAccessPlugin can execute on the DAO + // MainMemberAddHelper can execute on the DAO await dao.grant( dao.address, - memberAccessPlugin.address, + mainMemberAddHelper.address, EXECUTE_PERMISSION_ID ); // The DAO can add/remove editors @@ -141,7 +141,7 @@ describe('Main Voting Plugin', function () { await dao.grant(dao.address, dao.address, ROOT_PERMISSION_ID); // The plugin can propose members on the member access helper await dao.grant( - memberAccessPlugin.address, + mainMemberAddHelper.address, mainVotingPlugin.address, PROPOSER_PERMISSION_ID ); @@ -161,7 +161,7 @@ describe('Main Voting Plugin', function () { dao.address, defaultMainVotingSettings, [alice.address], - memberAccessPlugin.address + mainMemberAddHelper.address ) ).to.be.revertedWith('Initializable: contract is already initialized'); }); @@ -176,7 +176,7 @@ describe('Main Voting Plugin', function () { dao.address, defaultMainVotingSettings, [alice.address], - memberAccessPlugin.address + mainMemberAddHelper.address ) ).to.not.be.reverted; @@ -216,7 +216,7 @@ describe('Main Voting Plugin', function () { dao.address, defaultMainVotingSettings, [alice.address], - memberAccessPlugin.address + mainMemberAddHelper.address ); await mineBlock(); @@ -239,7 +239,7 @@ describe('Main Voting Plugin', function () { dao.address, defaultMainVotingSettings, [bob.address], - memberAccessPlugin.address + mainMemberAddHelper.address ); await mineBlock(); @@ -835,10 +835,10 @@ describe('Main Voting Plugin', function () { ); }); - it('proposeAddMember creates a proposal on the MemberAccessPlugin', async () => { + it('proposeAddMember creates a proposal on the MainMemberAddHelper', async () => { let msPid = 1; expect((await mainVotingPlugin.proposalCount()).toNumber()).to.eq(0); - expect((await memberAccessPlugin.proposalCount()).toNumber()).to.eq(1); + expect((await mainMemberAddHelper.proposalCount()).toNumber()).to.eq(1); await expect( mainVotingPlugin.proposeAddMember( toUtf8Bytes('ipfs://meta'), @@ -847,9 +847,9 @@ describe('Main Voting Plugin', function () { ).to.not.be.reverted; expect((await mainVotingPlugin.proposalCount()).toNumber()).to.eq(0); - expect((await memberAccessPlugin.proposalCount()).toNumber()).to.eq(2); + expect((await mainMemberAddHelper.proposalCount()).toNumber()).to.eq(2); - let proposal = await memberAccessPlugin.getProposal(msPid); + let proposal = await mainMemberAddHelper.getProposal(msPid); expect(proposal.actions.length).to.eq(1); expect(proposal.actions[0].to).to.eq(mainVotingPlugin.address); expect(proposal.actions[0].value.toNumber()).to.eq(0); @@ -869,9 +869,9 @@ describe('Main Voting Plugin', function () { ).to.not.be.reverted; expect((await mainVotingPlugin.proposalCount()).toNumber()).to.eq(0); - expect((await memberAccessPlugin.proposalCount()).toNumber()).to.eq(3); + expect((await mainMemberAddHelper.proposalCount()).toNumber()).to.eq(3); - proposal = await memberAccessPlugin.getProposal(msPid); + proposal = await mainMemberAddHelper.getProposal(msPid); expect(proposal.actions.length).to.eq(1); expect(proposal.actions[0].to).to.eq(mainVotingPlugin.address); expect(proposal.actions[0].value.toNumber()).to.eq(0); @@ -1663,8 +1663,8 @@ describe('Main Voting Plugin', function () { }); }); - context('Joining a space via MemberAccessPlugin', () => { - it('Proposing new members via MemberAccess plugin grants membership', async () => { + context('Joining a space via MainMemberAddHelper', () => { + it('Proposing new members via MainMemberAdd plugin grants membership', async () => { expect(await mainVotingPlugin.isMember(carol.address)).to.be.false; await mainVotingPlugin.proposeAddMember( toUtf8Bytes('ipfs://'), @@ -1854,7 +1854,7 @@ describe('Tests replicated from the original AddressList plugin', async () => { let signers: SignerWithAddress[]; let dao: DAO; let mainVotingPlugin: MainVotingPlugin; - let memberAccessPlugin: MemberAccessPlugin; + let mainMemberAddHelper: MainMemberAddHelper; let votingSettings: VotingSettings; let id = 0; @@ -1873,8 +1873,8 @@ describe('Tests replicated from the original AddressList plugin', async () => { mainVotingPlugin = await deployWithProxy( new MainVotingPlugin__factory(signers[0]) ); - memberAccessPlugin = await deployWithProxy( - new MemberAccessPlugin__factory(signers[0]) + mainMemberAddHelper = await deployWithProxy( + new MainMemberAddHelper__factory(signers[0]) ); // The plugin can execute on the DAO @@ -1883,10 +1883,10 @@ describe('Tests replicated from the original AddressList plugin', async () => { mainVotingPlugin.address, EXECUTE_PERMISSION_ID ); - // MemberAccessPlugin can execute on the DAO + // MainMemberAddHelper can execute on the DAO await dao.grant( dao.address, - memberAccessPlugin.address, + mainMemberAddHelper.address, EXECUTE_PERMISSION_ID ); // The DAO can update the plugin addresses @@ -1934,9 +1934,9 @@ describe('Tests replicated from the original AddressList plugin', async () => { dao.address, votingSettings, [signers[0].address], - memberAccessPlugin.address + mainMemberAddHelper.address ); - await memberAccessPlugin.initialize(dao.address, { + await mainMemberAddHelper.initialize(dao.address, { proposalDuration: 60 * 60 * 24 * 5, }); await makeMembers(signers); @@ -2094,9 +2094,9 @@ describe('Tests replicated from the original AddressList plugin', async () => { dao.address, votingSettings, [signers[0].address], - memberAccessPlugin.address + mainMemberAddHelper.address ); - await memberAccessPlugin.initialize(dao.address, { + await mainMemberAddHelper.initialize(dao.address, { proposalDuration: 60 * 60 * 24 * 5, }); await makeMembers(signers); @@ -2320,9 +2320,9 @@ describe('Tests replicated from the original AddressList plugin', async () => { dao.address, votingSettings, [signers[0].address], - memberAccessPlugin.address + mainMemberAddHelper.address ); - await memberAccessPlugin.initialize(dao.address, { + await mainMemberAddHelper.initialize(dao.address, { proposalDuration: 60 * 60 * 24 * 5, }); await makeMembers(signers); @@ -2488,9 +2488,9 @@ describe('Tests replicated from the original AddressList plugin', async () => { dao.address, votingSettings, [signers[0].address], - memberAccessPlugin.address + mainMemberAddHelper.address ); - await memberAccessPlugin.initialize(dao.address, { + await mainMemberAddHelper.initialize(dao.address, { proposalDuration: 60 * 60 * 24 * 5, }); await makeMembers(signers); @@ -2616,9 +2616,9 @@ describe('Tests replicated from the original AddressList plugin', async () => { dao.address, votingSettings, [signers[0].address], - memberAccessPlugin.address + mainMemberAddHelper.address ); - await memberAccessPlugin.initialize(dao.address, { + await mainMemberAddHelper.initialize(dao.address, { proposalDuration: 60 * 60 * 24 * 5, }); await makeMembers(signers); @@ -2686,9 +2686,9 @@ describe('Tests replicated from the original AddressList plugin', async () => { dao.address, votingSettings, [signers[0].address], - memberAccessPlugin.address + mainMemberAddHelper.address ); - await memberAccessPlugin.initialize(dao.address, { + await mainMemberAddHelper.initialize(dao.address, { proposalDuration: 60 * 60 * 24 * 5, }); await makeMembers(signers); @@ -2761,9 +2761,9 @@ describe('Tests replicated from the original AddressList plugin', async () => { dao.address, votingSettings, [signers[0].address], - memberAccessPlugin.address + mainMemberAddHelper.address ); - await memberAccessPlugin.initialize(dao.address, { + await mainMemberAddHelper.initialize(dao.address, { proposalDuration: 60 * 60 * 24 * 5, }); await makeMembers(signers); // 10 members @@ -2965,3 +2965,7 @@ describe('Tests replicated from the original AddressList plugin', async () => { ); } }); + +// Test that an addresslist of just 1 member works with nonCreatorsVoted +// Test nonCreatorsVoted +// Test that you cannot vote on an uncreated proposal diff --git a/packages/contracts/test/unit-testing/member-access-execute-condition.ts b/packages/contracts/test/unit-testing/member-access-execute-condition.ts index 2225df7..e13fd4c 100644 --- a/packages/contracts/test/unit-testing/member-access-execute-condition.ts +++ b/packages/contracts/test/unit-testing/member-access-execute-condition.ts @@ -3,10 +3,10 @@ import { DAO__factory, IDAO, MainVotingPlugin__factory, - MemberAccessExecuteCondition, - MemberAccessExecuteCondition__factory, - TestMemberAccessExecuteCondition__factory, - TestMemberAccessExecuteCondition, + MemberAddCondition, + MemberAddCondition__factory, + TestMemberAddCondition__factory, + TestMemberAddCondition, } from '../../typechain'; import {getPluginSetupProcessorAddress} from '../../utils/helpers'; import {deployTestDao} from '../helpers/test-dao'; @@ -32,7 +32,7 @@ describe('Member Access Condition', function () { let bob: SignerWithAddress; let carol: SignerWithAddress; let dao: DAO; - let memberAccessExecuteCondition: MemberAccessExecuteCondition; + let memberAddCondition: MemberAddCondition; before(async () => { [alice, bob, carol] = await ethers.getSigners(); @@ -40,8 +40,8 @@ describe('Member Access Condition', function () { }); beforeEach(async () => { - const factory = new MemberAccessExecuteCondition__factory(alice); - memberAccessExecuteCondition = await factory.deploy(SOME_CONTRACT_ADDRESS); + const factory = new MemberAddCondition__factory(alice); + memberAddCondition = await factory.deploy(SOME_CONTRACT_ADDRESS); }); describe('Executing addMember on a certain contract', () => { @@ -56,7 +56,7 @@ describe('Member Access Condition', function () { [carol.address] ); expect( - await memberAccessExecuteCondition.isGranted( + await memberAddCondition.isGranted( ADDRESS_ONE, // where (used) ADDRESS_TWO, // who (used) EXECUTE_PERMISSION_ID, // permission (used) @@ -70,7 +70,7 @@ describe('Member Access Condition', function () { [carol.address] ); expect( - await memberAccessExecuteCondition.isGranted( + await memberAddCondition.isGranted( ADDRESS_ONE, // where (used) ADDRESS_TWO, // who (used) EXECUTE_PERMISSION_ID, // permission (used) @@ -83,7 +83,7 @@ describe('Member Access Condition', function () { hexlify(toUtf8Bytes('ipfs://')), ]); expect( - await memberAccessExecuteCondition.isGranted( + await memberAddCondition.isGranted( ADDRESS_ONE, // where (used) ADDRESS_TWO, // who (used) EXECUTE_PERMISSION_ID, // permission (used) @@ -96,7 +96,7 @@ describe('Member Access Condition', function () { hexlify(toUtf8Bytes('ipfs://')), ]); expect( - await memberAccessExecuteCondition.isGranted( + await memberAddCondition.isGranted( ADDRESS_ONE, // where (used) ADDRESS_TWO, // who (used) EXECUTE_PERMISSION_ID, // permission (used) @@ -110,7 +110,7 @@ describe('Member Access Condition', function () { [ADDRESS_ONE] ); expect( - await memberAccessExecuteCondition.isGranted( + await memberAddCondition.isGranted( ADDRESS_ONE, // where (used) ADDRESS_TWO, // who (used) EXECUTE_PERMISSION_ID, // permission (used) @@ -130,7 +130,7 @@ describe('Member Access Condition', function () { [carol.address] ); expect( - await memberAccessExecuteCondition.isGranted( + await memberAddCondition.isGranted( ADDRESS_ONE, // where (used) ADDRESS_TWO, // who (used) EXECUTE_PERMISSION_ID, // permission (used) @@ -144,7 +144,7 @@ describe('Member Access Condition', function () { [carol.address] ); expect( - await memberAccessExecuteCondition.isGranted( + await memberAddCondition.isGranted( ADDRESS_ONE, // where (used) ADDRESS_TWO, // who (used) EXECUTE_PERMISSION_ID, // permission (used) @@ -158,7 +158,7 @@ describe('Member Access Condition', function () { [carol.address] ); expect( - await memberAccessExecuteCondition.isGranted( + await memberAddCondition.isGranted( ADDRESS_ONE, // where (used) ADDRESS_TWO, // who (used) EXECUTE_PERMISSION_ID, // permission (used) @@ -172,7 +172,7 @@ describe('Member Access Condition', function () { [carol.address] ); expect( - await memberAccessExecuteCondition.isGranted( + await memberAddCondition.isGranted( ADDRESS_ONE, // where (used) ADDRESS_TWO, // who (used) EXECUTE_PERMISSION_ID, // permission (used) @@ -187,7 +187,7 @@ describe('Member Access Condition', function () { ONE_BYTES32, ]); expect( - await memberAccessExecuteCondition.isGranted( + await memberAddCondition.isGranted( ADDRESS_ONE, // where (used) ADDRESS_TWO, // who (used) EXECUTE_PERMISSION_ID, // permission (used) @@ -201,7 +201,7 @@ describe('Member Access Condition', function () { ONE_BYTES32, ]); expect( - await memberAccessExecuteCondition.isGranted( + await memberAddCondition.isGranted( ADDRESS_ONE, // where (used) ADDRESS_TWO, // who (used) EXECUTE_PERMISSION_ID, // permission (used) @@ -216,7 +216,7 @@ describe('Member Access Condition', function () { ONE_BYTES32, ]); expect( - await memberAccessExecuteCondition.isGranted( + await memberAddCondition.isGranted( ADDRESS_ONE, // where (used) ADDRESS_TWO, // who (used) EXECUTE_PERMISSION_ID, // permission (used) @@ -230,7 +230,7 @@ describe('Member Access Condition', function () { ONE_BYTES32, ]); expect( - await memberAccessExecuteCondition.isGranted( + await memberAddCondition.isGranted( ADDRESS_ONE, // where (used) ADDRESS_TWO, // who (used) EXECUTE_PERMISSION_ID, // permission (used) @@ -255,7 +255,7 @@ describe('Member Access Condition', function () { [grantedToAddress] ); expect( - await memberAccessExecuteCondition.isGranted( + await memberAddCondition.isGranted( ADDRESS_ONE, // where (used) ADDRESS_TWO, // who (used) EXECUTE_PERMISSION_ID, // permission (used) @@ -274,7 +274,7 @@ describe('Member Access Condition', function () { it('Should reject adding and removing directly, rather than executing', async () => { // Valid expect( - await memberAccessExecuteCondition.isGranted( + await memberAddCondition.isGranted( ADDRESS_ONE, // where (used) ADDRESS_TWO, // who (used) EXECUTE_PERMISSION_ID, // permission (used) @@ -287,13 +287,11 @@ describe('Member Access Condition', function () { }); describe('Decoders (internal)', () => { - let testMemberAccessExecuteCondition: TestMemberAccessExecuteCondition; + let testMemberAddCondition: TestMemberAddCondition; beforeEach(async () => { - const factory = new TestMemberAccessExecuteCondition__factory(alice); - testMemberAccessExecuteCondition = await factory.deploy( - SOME_CONTRACT_ADDRESS - ); + const factory = new TestMemberAddCondition__factory(alice); + testMemberAddCondition = await factory.deploy(SOME_CONTRACT_ADDRESS); }); it('Should decode getSelector properly', async () => { @@ -314,18 +312,18 @@ describe('Member Access Condition', function () { }, ]; - expect( - await testMemberAccessExecuteCondition.getSelector(actions[0].data) - ).to.eq((actions[0].data as string).slice(0, 10)); + expect(await testMemberAddCondition.getSelector(actions[0].data)).to.eq( + (actions[0].data as string).slice(0, 10) + ); - expect( - await testMemberAccessExecuteCondition.getSelector(actions[1].data) - ).to.eq((actions[1].data as string).slice(0, 10)); + expect(await testMemberAddCondition.getSelector(actions[1].data)).to.eq( + (actions[1].data as string).slice(0, 10) + ); }); it('Should decode decodeGrantRevokeCalldata properly', async () => { - const factory = new TestMemberAccessExecuteCondition__factory(alice); - const testMemberAccessExecuteCondition = await factory.deploy( + const factory = new TestMemberAddCondition__factory(alice); + const testMemberAddCondition = await factory.deploy( SOME_CONTRACT_ADDRESS ); @@ -336,9 +334,7 @@ describe('Member Access Condition', function () { // 1 const [selector, who] = - await testMemberAccessExecuteCondition.decodeAddMemberCalldata( - calldata - ); + await testMemberAddCondition.decodeAddMemberCalldata(calldata); expect(selector).to.eq(calldata.slice(0, 10)); expect(who).to.eq(pspAddress); }); diff --git a/packages/contracts/test/unit-testing/only-plugin-upgrader-condition.ts b/packages/contracts/test/unit-testing/only-plugin-upgrader-condition.ts index 5359cb3..49b097f 100644 --- a/packages/contracts/test/unit-testing/only-plugin-upgrader-condition.ts +++ b/packages/contracts/test/unit-testing/only-plugin-upgrader-condition.ts @@ -1195,15 +1195,14 @@ describe('Only Plugin Upgrader Condition', function () { }); describe('Decoders (internal)', () => { - let testMemberAccessExecuteCondition: TestOnlyPluginUpgraderCondition; + let testMemberAddCondition: TestOnlyPluginUpgraderCondition; beforeEach(async () => { const factory = new TestOnlyPluginUpgraderCondition__factory(alice); - testMemberAccessExecuteCondition = await factory.deploy( - dao.address, - pspAddress, - [ALLOWED_PLUGIN_ADDRESS_1, ALLOWED_PLUGIN_ADDRESS_2] - ); + testMemberAddCondition = await factory.deploy(dao.address, pspAddress, [ + ALLOWED_PLUGIN_ADDRESS_1, + ALLOWED_PLUGIN_ADDRESS_2, + ]); }); it('Should decode getSelector properly', async () => { @@ -1236,17 +1235,17 @@ describe('Only Plugin Upgrader Condition', function () { }, ]; - expect( - await testMemberAccessExecuteCondition.getSelector(actions[0].data) - ).to.eq((actions[0].data as string).slice(0, 10)); + expect(await testMemberAddCondition.getSelector(actions[0].data)).to.eq( + (actions[0].data as string).slice(0, 10) + ); - expect( - await testMemberAccessExecuteCondition.getSelector(actions[1].data) - ).to.eq((actions[1].data as string).slice(0, 10)); + expect(await testMemberAddCondition.getSelector(actions[1].data)).to.eq( + (actions[1].data as string).slice(0, 10) + ); - expect( - await testMemberAccessExecuteCondition.getSelector(actions[2].data) - ).to.eq((actions[2].data as string).slice(0, 10)); + expect(await testMemberAddCondition.getSelector(actions[2].data)).to.eq( + (actions[2].data as string).slice(0, 10) + ); }); it('Should decode decodeGrantRevokeCalldata properly', async () => { @@ -1265,9 +1264,7 @@ describe('Only Plugin Upgrader Condition', function () { // 1 let [selector, where, who, permissionId] = - await testMemberAccessExecuteCondition.decodeGrantRevokeCalldata( - calldataList[0] - ); + await testMemberAddCondition.decodeGrantRevokeCalldata(calldataList[0]); expect(selector).to.eq(calldataList[0].slice(0, 10)); expect(where).to.eq(ALLOWED_PLUGIN_ADDRESS_1); expect(who).to.eq(pspAddress); @@ -1275,9 +1272,7 @@ describe('Only Plugin Upgrader Condition', function () { // 2 [selector, where, who, permissionId] = - await testMemberAccessExecuteCondition.decodeGrantRevokeCalldata( - calldataList[1] - ); + await testMemberAddCondition.decodeGrantRevokeCalldata(calldataList[1]); expect(selector).to.eq(calldataList[1].slice(0, 10)); expect(where).to.eq(ALLOWED_PLUGIN_ADDRESS_2); expect(who).to.eq(ADDRESS_THREE); @@ -1302,18 +1297,14 @@ describe('Only Plugin Upgrader Condition', function () { // 1 let [selector, decodedDaoAddress, pluginAddress] = - await testMemberAccessExecuteCondition.decodeApplyUpdateCalldata( - calldataList[0] - ); + await testMemberAddCondition.decodeApplyUpdateCalldata(calldataList[0]); expect(selector).to.eq(calldataList[0].slice(0, 10)); expect(decodedDaoAddress).to.eq(dao.address); expect(pluginAddress).to.eq(bob.address); // 2 [selector, decodedDaoAddress, pluginAddress] = - await testMemberAccessExecuteCondition.decodeApplyUpdateCalldata( - calldataList[1] - ); + await testMemberAddCondition.decodeApplyUpdateCalldata(calldataList[1]); expect(selector).to.eq(calldataList[1].slice(0, 10)); expect(decodedDaoAddress).to.eq(ADDRESS_THREE); expect(pluginAddress).to.eq(alice.address);