Skip to content
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

Feature/bytes param add #21

Merged
merged 9 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 35 additions & 8 deletions packages/contracts/src/Multisig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import {PluginUUPSUpgradeable} from "@aragon/osx-commons-contracts/src/plugin/PluginUUPSUpgradeable.sol";
import {IProposal} from "@aragon/osx-commons-contracts/src/plugin/extensions/proposal/IProposal.sol";
import {IDAO} from "@aragon/osx-commons-contracts/src/dao/IDAO.sol";
import {IExecutor, Action} from "@aragon/osx-commons-contracts/src/executors/IExecutor.sol";

Check warning on line 14 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / checks

imported name IExecutor is not used

Check warning on line 14 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

imported name IExecutor is not used

Check warning on line 14 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

imported name IExecutor is not used

import {IMultisig} from "./IMultisig.sol";

Expand All @@ -19,7 +20,7 @@
/// @title Multisig
/// @author Aragon X - 2022-2023
/// @notice The on-chain multisig governance plugin in which a proposal passes if X out of Y approvals are met.
/// @dev v1.3 (Release 1, Build 3). For each upgrade, if the reinitialization step is required, increment the version numbers in the modifier for both the initialize and initializeFrom functions.

Check failure on line 23 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / checks

Line length must be no more than 120 but current length is 195

Check failure on line 23 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

Line length must be no more than 120 but current length is 195

Check failure on line 23 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

Line length must be no more than 120 but current length is 195
/// @custom:security-contact sirt@aragon.org
contract Multisig is
IMultisig,
Expand All @@ -44,7 +45,7 @@
uint16 approvals;
ProposalParameters parameters;
mapping(address => bool) approvers;
IDAO.Action[] actions;
Action[] actions;
uint256 allowFailureMap;
TargetConfig targetConfig; // added in build 3.
}
Expand Down Expand Up @@ -181,10 +182,10 @@
_setTargetConfig(_targetConfig);
}

/// @notice Reinitializes the TokenVoting after an upgrade from a previous protocol version. For each reinitialization step, use the `_fromBuild` version to decide which internal functions to call for reinitialization.

Check failure on line 185 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / checks

Line length must be no more than 120 but current length is 222

Check failure on line 185 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

Line length must be no more than 120 but current length is 222

Check failure on line 185 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

Line length must be no more than 120 but current length is 222
/// @dev WARNING: The contract should only be upgradeable through PSP to ensure that _fromBuild is not incorrectly passed, and that the appropriate permissions for the upgrade are properly configured.

Check failure on line 186 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / checks

Line length must be no more than 120 but current length is 204

Check failure on line 186 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

Line length must be no more than 120 but current length is 204

Check failure on line 186 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

Line length must be no more than 120 but current length is 204
/// @param _fromBuild The build version number of the previous implementation contract this upgrade is transitioning from.

Check failure on line 187 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / checks

Line length must be no more than 120 but current length is 126

Check failure on line 187 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

Line length must be no more than 120 but current length is 126

Check failure on line 187 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

Line length must be no more than 120 but current length is 126
/// @param _initData The initialization data to be passed to via `upgradeToAndCall` (see [ERC-1967](https://docs.openzeppelin.com/contracts/4.x/api/proxy#ERC1967Upgrade)).

Check failure on line 188 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / checks

Line length must be no more than 120 but current length is 175

Check failure on line 188 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

Line length must be no more than 120 but current length is 175

Check failure on line 188 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

Line length must be no more than 120 but current length is 175
function initializeFrom(uint16 _fromBuild, bytes calldata _initData) external reinitializer(2) {
if (_fromBuild < 3) {
TargetConfig memory targetConfig = abi.decode(_initData, (TargetConfig));
Expand Down Expand Up @@ -268,7 +269,7 @@
// solhint-disable-next-line code-complexity
function createProposal(
bytes calldata _metadata,
IDAO.Action[] calldata _actions,
Action[] calldata _actions,
uint256 _allowFailureMap,
bool _approveProposal,
bool _tryExecution,
Expand Down Expand Up @@ -343,14 +344,40 @@
);
}

/// @inheritdoc IProposal
function createProposal(
bytes calldata _metadata,
IDAO.Action[] calldata _actions,
Action[] calldata _actions,
uint64 _startDate,
uint64 _endDate
uint64 _endDate,
bytes memory _data
) external override returns (uint256 proposalId) {
// Calls public function for permission check.
proposalId = createProposal(_metadata, _actions, 0, false, false, _startDate, _endDate);
// Note that this calls public function for permission check.
// Custom parameters
uint256 _allowFailureMap;
bool _approveProposal;
bool _tryExecution;

if (_data.length != 0) {
(_allowFailureMap, _approveProposal, _tryExecution) = abi.decode(
_data,
(uint256, bool, bool)
);
}
proposalId = createProposal(
_metadata,
_actions,
_allowFailureMap,
_approveProposal,
_tryExecution,
_startDate,
_endDate
);
}

/// @inheritdoc IProposal
function createProposalParamsABI() external pure override returns (string memory) {
return "(uint256 allowFailureMap, bool approveProposal, bool tryExecution)";
}

/// @inheritdoc IMultisig
Expand Down Expand Up @@ -407,7 +434,7 @@
bool executed,
uint16 approvals,
ProposalParameters memory parameters,
IDAO.Action[] memory actions,
Action[] memory actions,
uint256 allowFailureMap
)
{
Expand Down Expand Up @@ -440,19 +467,19 @@
}

/// @notice Hashing function used to (re)build the proposal id from the proposal details..
/// @dev The proposal id is produced by hashing the ABI encoded `targets` array, the `values` array, the `calldatas` array

Check failure on line 470 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / checks

Line length must be no more than 120 but current length is 126

Check failure on line 470 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

Line length must be no more than 120 but current length is 126

Check failure on line 470 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

Line length must be no more than 120 but current length is 126
/// and the descriptionHash (bytes32 which itself is the keccak256 hash of the description string). This proposal id
/// can be produced from the proposal data which is part of the {ProposalCreated} event. It can even be computed in
/// advance, before the proposal is submitted.
/// The chainId and the governor address are not part of the proposal id computation. Consequently, the
/// same proposal (with same operation and same description) will have the same id if submitted on multiple governors

Check failure on line 475 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / checks

Line length must be no more than 120 but current length is 121

Check failure on line 475 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

Line length must be no more than 120 but current length is 121

Check failure on line 475 in packages/contracts/src/Multisig.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

Line length must be no more than 120 but current length is 121
/// across multiple networks. This also means that in order to execute the same operation twice (on the same
/// governor) the proposer will have to change the description in order to avoid proposal id conflicts.
/// @param _actions The actions that will be executed after the proposal passes.
/// @param _metadata The metadata of the proposal.
/// @return proposalId The ID of the proposal.
function createProposalId(
IDAO.Action[] calldata _actions,
Action[] calldata _actions,
bytes memory _metadata
) public pure override returns (uint256) {
return uint256(keccak256(abi.encode(_actions, _metadata)));
Expand Down
26 changes: 26 additions & 0 deletions packages/contracts/src/mocks/CustomExecutorMock.sol
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 {IExecutor, Action} from "@aragon/osx-commons-contracts/src/executors/IExecutor.sol";

Check warning on line 5 in packages/contracts/src/mocks/CustomExecutorMock.sol

View workflow job for this annotation

GitHub Actions / checks

imported name IExecutor is not used

Check warning on line 5 in packages/contracts/src/mocks/CustomExecutorMock.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

imported name IExecutor is not used

Check warning on line 5 in packages/contracts/src/mocks/CustomExecutorMock.sol

View workflow job for this annotation

GitHub Actions / formatting-linting / checks

imported name IExecutor is not used

/// @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();
}
}
}
Loading
Loading