Skip to content

Commit

Permalink
updated DPF-01
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbeny committed Jul 26, 2024
1 parent 2418e0a commit 842bd1c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions packages/contracts/src/DaofinPlugin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ contract DaofinPlugin is BaseDaofinPlugin {
uint64 _startDate = electionPeriod_[i];
uint64 _endDate = electionPeriod_[i + 1];

if (_startDate > _endDate) revert InValidDate();
if (_startDate + 1 weeks >= _endDate) revert InValidDate();
_electionPeriods.push(ElectionPeriod(_startDate, _endDate));

emit ElectionPeriodUpdated(_startDate, _endDate);
Expand Down Expand Up @@ -325,7 +325,7 @@ contract DaofinPlugin is BaseDaofinPlugin {

function resignHouse() external {
address _member = _msgSender();
uint64 _now = block.timestamp.toUint64();
uint64 _now = getBlockTimestamp();

// resign request must not be
// in an active election period
Expand All @@ -349,7 +349,7 @@ contract DaofinPlugin is BaseDaofinPlugin {

function executeResignHouse() external {
address _member = _msgSender();
uint64 _now = block.timestamp.toUint64();
uint64 _now = getBlockTimestamp();

HouseDeposit memory _hd = _voterToLockedAmounts[_member];

Expand Down Expand Up @@ -386,7 +386,7 @@ contract DaofinPlugin is BaseDaofinPlugin {
uint64 endDate,
bool executed
) private view returns (bool) {
uint64 currentTime = block.timestamp.toUint64();
uint64 currentTime = getBlockTimestamp();
return startDate <= currentTime && currentTime < endDate && !executed;
}

Expand Down Expand Up @@ -626,7 +626,7 @@ contract DaofinPlugin is BaseDaofinPlugin {
) private view returns (uint64, uint64) {
uint64 _startDate = _electionPeriods[_electionIndex].startDate;
uint64 _endDate = _electionPeriods[_electionIndex].endDate;
uint64 _now = block.timestamp.toUint64();
uint64 _now = getBlockTimestamp();

// fetched dates must not be zero
if (_startDate == 0 || _endDate == 0) revert InValidDate();
Expand Down Expand Up @@ -801,7 +801,7 @@ contract DaofinPlugin is BaseDaofinPlugin {
}

function isWithinElectionPeriod() public view returns (bool) {
uint64 _now = block.timestamp.toUint64();
uint64 _now = getBlockTimestamp();

for (uint i = 0; i < _electionPeriods.length; i++) {
if (_electionPeriods[i].startDate <= _now && _electionPeriods[i].endDate > _now) {
Expand All @@ -815,7 +815,7 @@ contract DaofinPlugin is BaseDaofinPlugin {
return isMasterNodeDelegatee(_voter) || isJudiciaryMember(_voter) || isPeopleHouse(_voter);
}

function getBlockSnapshot() public view returns (uint256 snapshotBlock) {
function getBlockSnapshot() private view returns (uint256 snapshotBlock) {
unchecked {
/*
The snapshot block must be mined
Expand All @@ -827,5 +827,9 @@ contract DaofinPlugin is BaseDaofinPlugin {
}
}

function getBlockTimestamp() private view returns (uint64 timestamp) {
return block.timestamp.toUint64();
}

receive() external payable {}
}

0 comments on commit 842bd1c

Please sign in to comment.