-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build 1.2 new changes #18
base: develop
Are you sure you want to change the base?
Changes from all commits
80b1458
676ee89
e800751
8659fac
17169ba
4211987
f4944e3
d86d779
23998dc
c193c5b
9896454
c0e69f2
59ea727
50411cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -10,6 +10,8 @@ import {IMembership} from "@aragon/osx-commons-contracts/src/plugin/extensions/m | |||||||
import {ProposalUpgradeable} from "@aragon/osx-commons-contracts/src/plugin/extensions/proposal/ProposalUpgradeable.sol"; | ||||||||
import {PluginCloneable} from "@aragon/osx-commons-contracts/src/plugin/PluginCloneable.sol"; | ||||||||
import {IDAO} from "@aragon/osx-commons-contracts/src/dao/IDAO.sol"; | ||||||||
import {IProposal} from "@aragon/osx-commons-contracts/src/plugin/extensions/proposal/IProposal.sol"; | ||||||||
import {Action} from "@aragon/osx-commons-contracts/src/executors/IExecutor.sol"; | ||||||||
|
||||||||
/// @title Admin | ||||||||
/// @author Aragon X - 2022-2023 | ||||||||
|
@@ -20,8 +22,7 @@ contract Admin is IMembership, PluginCloneable, ProposalUpgradeable { | |||||||
using SafeCastUpgradeable for uint256; | ||||||||
|
||||||||
/// @notice The [ERC-165](https://eips.ethereum.org/EIPS/eip-165) interface ID of the contract. | ||||||||
bytes4 internal constant ADMIN_INTERFACE_ID = | ||||||||
this.initialize.selector ^ this.executeProposal.selector; | ||||||||
bytes4 internal constant ADMIN_INTERFACE_ID = this.executeProposal.selector; | ||||||||
|
||||||||
/// @notice The ID of the permission required to call the `executeProposal` function. | ||||||||
bytes32 public constant EXECUTE_PROPOSAL_PERMISSION_ID = | ||||||||
|
@@ -30,9 +31,11 @@ contract Admin is IMembership, PluginCloneable, ProposalUpgradeable { | |||||||
/// @notice Initializes the contract. | ||||||||
/// @param _dao The associated DAO. | ||||||||
/// @dev This method is required to support [ERC-1167](https://eips.ethereum.org/EIPS/eip-1167). | ||||||||
function initialize(IDAO _dao) external initializer { | ||||||||
function initialize(IDAO _dao, TargetConfig calldata _targetConfig) external initializer { | ||||||||
__PluginCloneable_init(_dao); | ||||||||
|
||||||||
_setTargetConfig(_targetConfig); | ||||||||
|
||||||||
Comment on lines
33
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Admin is non-upgradeable but cloneable, so no.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. true |
||||||||
emit MembershipContractAnnounced({definingContract: address(_dao)}); | ||||||||
} | ||||||||
|
||||||||
|
@@ -59,6 +62,34 @@ contract Admin is IMembership, PluginCloneable, ProposalUpgradeable { | |||||||
}); | ||||||||
} | ||||||||
|
||||||||
/// @inheritdoc IProposal | ||||||||
function customProposalParamsABI() external pure override returns (string memory) { | ||||||||
return "(uint256 allowFailureMap)"; | ||||||||
} | ||||||||
|
||||||||
/// @inheritdoc IProposal | ||||||||
function createProposal( | ||||||||
bytes calldata _metadata, | ||||||||
Action[] calldata _actions, | ||||||||
uint64, | ||||||||
uint64, | ||||||||
bytes memory _data | ||||||||
) public override returns (uint256 proposalId) { | ||||||||
uint256 allowFailureMap; | ||||||||
|
||||||||
if (_data.length > 0) { | ||||||||
allowFailureMap = abi.decode(_data, (uint256)); | ||||||||
} | ||||||||
|
||||||||
// Uses public function for permission check. | ||||||||
proposalId = executeProposal(_metadata, _actions, allowFailureMap); | ||||||||
} | ||||||||
|
||||||||
/// @inheritdoc IProposal | ||||||||
function canExecute(uint256) public view virtual override returns (bool) { | ||||||||
return true; | ||||||||
} | ||||||||
|
||||||||
/// @notice Creates and executes a new proposal. | ||||||||
/// @param _metadata The metadata of the proposal. | ||||||||
/// @param _actions The actions to be executed. | ||||||||
|
@@ -67,19 +98,33 @@ contract Admin is IMembership, PluginCloneable, ProposalUpgradeable { | |||||||
// of 0 requires every action to not revert. | ||||||||
function executeProposal( | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
bytes calldata _metadata, | ||||||||
IDAO.Action[] calldata _actions, | ||||||||
Action[] calldata _actions, | ||||||||
uint256 _allowFailureMap | ||||||||
) external auth(EXECUTE_PROPOSAL_PERMISSION_ID) { | ||||||||
uint64 currentTimestamp64 = block.timestamp.toUint64(); | ||||||||
|
||||||||
uint256 proposalId = _createProposal({ | ||||||||
_creator: _msgSender(), | ||||||||
_metadata: _metadata, | ||||||||
_startDate: currentTimestamp64, | ||||||||
_endDate: currentTimestamp64, | ||||||||
_actions: _actions, | ||||||||
_allowFailureMap: _allowFailureMap | ||||||||
}); | ||||||||
_executeProposal(dao(), proposalId, _actions, _allowFailureMap); | ||||||||
) public auth(EXECUTE_PROPOSAL_PERMISSION_ID) returns (uint256 proposalId) { | ||||||||
uint64 currentTimestamp = block.timestamp.toUint64(); | ||||||||
|
||||||||
proposalId = _createProposalId(keccak256(abi.encode(_actions, _metadata))); | ||||||||
|
||||||||
TargetConfig memory targetConfig = getTargetConfig(); | ||||||||
|
||||||||
_execute( | ||||||||
targetConfig.target, | ||||||||
bytes32(proposalId), | ||||||||
_actions, | ||||||||
_allowFailureMap, | ||||||||
targetConfig.operation | ||||||||
); | ||||||||
|
||||||||
emit ProposalCreated( | ||||||||
proposalId, | ||||||||
_msgSender(), | ||||||||
currentTimestamp, | ||||||||
currentTimestamp, | ||||||||
_metadata, | ||||||||
_actions, | ||||||||
_allowFailureMap | ||||||||
); | ||||||||
|
||||||||
emit ProposalExecuted(proposalId); | ||||||||
} | ||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
pragma solidity ^0.8.8; | ||
|
||
import {Action} from "@aragon/osx-commons-contracts/src/executors/IExecutor.sol"; | ||
|
||
/// @dev DO NOT USE IN PRODUCTION! | ||
contract CustomExecutorMock { | ||
error FailedCustom(); | ||
|
||
event ExecutedCustom(); | ||
|
||
function execute( | ||
bytes32 callId, | ||
Action[] memory, | ||
uint256 | ||
) external returns (bytes[] memory execResults, uint256 failureMap) { | ||
(execResults, failureMap); | ||
|
||
if (callId == bytes32(0)) { | ||
revert FailedCustom(); | ||
} else { | ||
emit ExecutedCustom(); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as for multisig
aragon#19 (review)
This interface is now deprecated