Skip to content

Commit

Permalink
fixed DPX-16
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbeny committed May 6, 2024
1 parent 1f71497 commit 4107caa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/contracts/src/Base/BaseDaofinPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ error NotReadyToExecute();
error UnexpectedFailure();
error InValidTime();
error CannotCreateProposalWithinElectionPeriod();
error WrongOperation();

abstract contract BaseDaofinPlugin is
Initializable,
Expand Down
20 changes: 16 additions & 4 deletions packages/contracts/src/DaofinPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ contract DaofinPlugin is BaseDaofinPlugin {
address voter = _msgSender();

// retrieve proposal Object
(bool open, , , uint256 proposalTypeId) = getProposal(_proposalId);
(bool open, , , uint256 proposalTypeId, ) = getProposal(_proposalId);

// check if is not open, revert()
if (!open) revert InValidDate();
Expand Down Expand Up @@ -407,7 +407,17 @@ contract DaofinPlugin is BaseDaofinPlugin {

function getProposal(
uint256 _proposalId
) public view returns (bool open, bool executed, address proposer, uint256 proposalTypeId) {
)
public
view
returns (
bool open,
bool executed,
address proposer,
uint256 proposalTypeId,
uint64 snapshotBlock
)
{
open = _isProposalOpen(
_proposals[_proposalId].startDate,
_proposals[_proposalId].endDate,
Expand All @@ -417,17 +427,19 @@ contract DaofinPlugin is BaseDaofinPlugin {
open,
_proposals[_proposalId].executed,
_proposals[_proposalId].proposer,
_proposals[_proposalId].proposalTypeId
_proposals[_proposalId].proposalTypeId,
_proposals[_proposalId].snapshotBlock
);
}

function _canExecute(uint256 _proposalId) private view returns (bool isValid) {
(bool open, bool executed, , ) = getProposal(_proposalId);
(bool open, bool executed, , , uint64 snapshotBlock) = getProposal(_proposalId);

// Verify that the proposal has not been executed or expired.
if (!open && executed) {
return false;
}
if (getBlockSnapshot() > snapshotBlock) revert WrongOperation();
if (!isMinParticipationReached(_proposalId)) return false;
if (!isThresholdReached(_proposalId)) return false;

Expand Down

0 comments on commit 4107caa

Please sign in to comment.