Skip to content

Commit

Permalink
fix tests and contract
Browse files Browse the repository at this point in the history
  • Loading branch information
novaknole committed Oct 10, 2024
1 parent 4e5d291 commit 347e54c
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 86 deletions.
21 changes: 1 addition & 20 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(_metadata));

// Store proposal related information
Proposal storage proposal_ = proposals[proposalId];
Expand Down Expand Up @@ -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
7 changes: 0 additions & 7 deletions packages/contracts/src/mocks/MajorityVotingMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading

0 comments on commit 347e54c

Please sign in to comment.