Skip to content

Commit

Permalink
fix tests and contract (#37)
Browse files Browse the repository at this point in the history
* fix tests and contract

* change

* add actions in proposal id generation

* rename'
  • Loading branch information
novaknole authored Oct 14, 2024
1 parent 4e5d291 commit a857d9e
Show file tree
Hide file tree
Showing 4 changed files with 274 additions and 90 deletions.
23 changes: 2 additions & 21 deletions packages/contracts/src/TokenVoting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ contract TokenVoting is IMembership, MajorityVotingBase {

(_startDate, _endDate) = _validateProposalDates(_startDate, _endDate);

proposalId = createProposalId(_actions, _metadata);
proposalId = _createProposalId(keccak256(abi.encode(_actions, _metadata)));

// Store proposal related information
Proposal storage proposal_ = proposals[proposalId];
Expand Down Expand Up @@ -211,7 +211,7 @@ contract TokenVoting is IMembership, MajorityVotingBase {
}

/// @inheritdoc IProposal
function createProposalParamsABI() external pure override returns (string memory) {
function customProposalParamsABI() external pure override returns (string memory) {
return "(uint256 allowFailureMap, uint8 voteOption, bool tryEarlyExecution)";
}

Expand All @@ -223,25 +223,6 @@ contract TokenVoting is IMembership, MajorityVotingBase {
IERC20Upgradeable(address(votingToken)).balanceOf(_account) > 0;
}

/// @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
/// 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
/// 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(
Action[] calldata _actions,
bytes memory _metadata
) public pure override returns (uint256) {
return uint256(keccak256(abi.encode(_actions, _metadata)));
}

/// @inheritdoc MajorityVotingBase
function _vote(
uint256 _proposalId,
Expand Down
1 change: 0 additions & 1 deletion packages/contracts/src/TokenVotingSetup.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {IERC20Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC20
import {IVotesUpgradeable} from "@openzeppelin/contracts-upgradeable/governance/utils/IVotesUpgradeable.sol";

import {GovernanceERC20} from "./ERC20/governance/GovernanceERC20.sol";
import {IGovernanceWrappedERC20} from "./ERC20/governance/IGovernanceWrappedERC20.sol";
import {GovernanceWrappedERC20} from "./ERC20/governance/GovernanceWrappedERC20.sol";

import {IDAO} from "@aragon/osx-commons-contracts/src/dao/IDAO.sol";
Expand Down
11 changes: 2 additions & 9 deletions packages/contracts/src/mocks/MajorityVotingMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity ^0.8.8;

import {IExecutor, Action} from "@aragon/osx-commons-contracts/src/executors/IExecutor.sol";
import {Action} from "@aragon/osx-commons-contracts/src/executors/IExecutor.sol";

import {MajorityVotingBase, IDAO} from "../MajorityVotingBase.sol";

Expand All @@ -17,13 +17,6 @@ contract MajorityVotingMock is MajorityVotingBase {
__MajorityVotingBase_init(_dao, _votingSettings, _targetConfig, _minApprovals, _metadata);
}

function createProposalId(
Action[] calldata _actions,
bytes memory _metadata
) public pure override returns (uint256) {
return uint256(keccak256(abi.encode(_actions, _metadata)));
}

function createProposal(
bytes calldata /* _metadata */,
Action[] calldata /* _actions */,
Expand Down Expand Up @@ -55,7 +48,7 @@ contract MajorityVotingMock is MajorityVotingBase {
);
}

function createProposalParamsABI() external pure override returns (string memory) {
function customProposalParamsABI() external pure override returns (string memory) {
return "[uint256 allowFailureMap, uint8 voteOption, bool tryEarlyExecution]";
}

Expand Down
Loading

0 comments on commit a857d9e

Please sign in to comment.