-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
487 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
contracts/src/mocks/plugin/extensions/proposal/ProposalMock.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
pragma solidity ^0.8.8; | ||
|
||
import {Proposal} from "../../../../plugin/extensions/proposal/Proposal.sol"; | ||
import {IDAO} from "../../../../dao/IDAO.sol"; | ||
|
||
/// @notice A mock contract. | ||
/// @dev DO NOT USE IN PRODUCTION! | ||
contract ProposalMock is Proposal { | ||
// We don't need to test these below functions as they will be tested in the actual plugins. | ||
// This mock contract is only used to test `supportsInterface` function. | ||
|
||
function createProposal( | ||
bytes memory data, | ||
IDAO.Action[] memory actions, | ||
uint64 startDate, | ||
uint64 endDate | ||
) external returns (uint256 proposalId) {} | ||
|
||
function canExecute(uint256 proposalId) external returns (bool) {} | ||
} |
22 changes: 22 additions & 0 deletions
22
contracts/src/mocks/plugin/extensions/proposal/ProposalUpgradeableMock.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
pragma solidity ^0.8.8; | ||
|
||
import {ProposalUpgradeable} from "../../../../plugin/extensions/proposal/ProposalUpgradeable.sol"; | ||
import {IDAO} from "../../../../dao/IDAO.sol"; | ||
|
||
/// @notice A mock contract. | ||
/// @dev DO NOT USE IN PRODUCTION! | ||
contract ProposalUpgradeableMock is ProposalUpgradeable { | ||
// We don't need to test these below functions as they will be tested in the actual plugins. | ||
// This mock contract is only used to test `supportsInterface` function. | ||
|
||
function createProposal( | ||
bytes memory data, | ||
IDAO.Action[] memory actions, | ||
uint64 startDate, | ||
uint64 endDate | ||
) external returns (uint256 proposalId) {} | ||
|
||
function canExecute(uint256 proposalId) external returns (bool) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,11 +15,14 @@ import {IPlugin} from "./IPlugin.sol"; | |
/// @notice An abstract, non-upgradeable contract to inherit from when creating a plugin being deployed via the `new` keyword. | ||
/// @custom:security-contact [email protected] | ||
abstract contract Plugin is IPlugin, ERC165, DaoAuthorizable, ProtocolVersion { | ||
address public target; | ||
address private target; | ||
|
||
/// @dev Emitted each time the Target is set. | ||
event TargetSet(address indexed previousTarget, address indexed newTarget); | ||
|
||
/// @notice The ID of the permission required to call the `setTarget` function. | ||
bytes32 public constant SET_TARGET_PERMISSION_ID = keccak256("SET_TARGET_PERMISSION"); | ||
|
||
/// @notice Constructs the plugin by storing the associated DAO. | ||
/// @param _dao The DAO contract. | ||
constructor(IDAO _dao) DaoAuthorizable(_dao) {} | ||
|
@@ -30,11 +33,14 @@ abstract contract Plugin is IPlugin, ERC165, DaoAuthorizable, ProtocolVersion { | |
} | ||
|
||
/// @dev Sets the target to a new target (`newTarget`). | ||
/// @notice Can only be called by the current owner. TODO | ||
function setTarget(address _target) public { | ||
address previousTarget = target; | ||
target = _target; | ||
emit TargetSet(previousTarget, _target); | ||
/// @param _target The target contract. | ||
function setTarget(address _target) public auth(SET_TARGET_PERMISSION_ID) { | ||
_setTarget(_target); | ||
} | ||
|
||
/// @notice Returns the currently set target contract. | ||
function getTarget() public view returns (address) { | ||
return target; | ||
} | ||
|
||
/// @notice Checks if this or the parent contract supports an interface by its ID. | ||
|
@@ -44,9 +50,18 @@ abstract contract Plugin is IPlugin, ERC165, DaoAuthorizable, ProtocolVersion { | |
return | ||
_interfaceId == type(IPlugin).interfaceId || | ||
_interfaceId == type(IProtocolVersion).interfaceId || | ||
_interfaceId == this.setTarget.selector ^ this.getTarget.selector || | ||
super.supportsInterface(_interfaceId); | ||
} | ||
|
||
/// @notice Sets the target to a new target (`newTarget`). | ||
/// @param _target The target contract. | ||
function _setTarget(address _target) internal virtual { | ||
address previousTarget = target; | ||
target = _target; | ||
emit TargetSet(previousTarget, _target); | ||
} | ||
|
||
/// @notice Forwards the actions to the currently set `target` for the execution. | ||
/// @param _callId Identifier for this execution. | ||
/// @param _actions actions that will be eventually called. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,27 +2,18 @@ | |
|
||
pragma solidity ^0.8.8; | ||
|
||
import {Counters} from "@openzeppelin/contracts/utils/Counters.sol"; | ||
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; | ||
|
||
import {IDAO} from "../../../dao/IDAO.sol"; | ||
import {IProposal} from "./IProposal.sol"; | ||
|
||
/// @title Proposal | ||
/// @author Aragon X - 2022-2023 | ||
/// @notice An abstract contract containing the traits and internal functionality to create and execute proposals that can be inherited by non-upgradeable DAO plugins. | ||
/// @custom:security-contact [email protected] | ||
abstract contract Proposal is IProposal, ERC165 { | ||
using Counters for Counters.Counter; | ||
|
||
/// @notice The incremental ID for proposals and executions. | ||
Counters.Counter private proposalCounter; | ||
|
||
/// Shall we remove this ? Does anyone use this ? if we keep having this, | ||
// this will not return the correct value anyways anymore. | ||
/// @inheritdoc IProposal | ||
function proposalCount() public view override returns (uint256) { | ||
return 0; | ||
function proposalCount() public pure override returns (uint256) { | ||
return type(uint256).max; | ||
} | ||
|
||
/// @notice Checks if this or the parent contract supports an interface by its ID. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.