Skip to content

Commit

Permalink
✨ lint
Browse files Browse the repository at this point in the history
  • Loading branch information
cmontecoding committed Aug 10, 2023
1 parent 4097bb8 commit 9ae08c9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 35 deletions.
69 changes: 38 additions & 31 deletions src/AutomatedVoting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity 0.8.19;
import "./interfaces/IAutomatedVoting.sol";

contract AutomatedVoting is IAutomatedVoting {

address[] public council;
mapping(uint256 => election) elections;
uint256[] public electionNumbers;
Expand Down Expand Up @@ -35,22 +34,26 @@ contract AutomatedVoting is IAutomatedVoting {
constructor(address[] memory _council) {
council = _council;
}


function timeUntilNextScheduledElection() public view override returns (uint256) {
if (block.timestamp > lastScheduledElection + 24 weeks ) {
function timeUntilNextScheduledElection()
public
view
override
returns (uint256)
{
if (block.timestamp > lastScheduledElection + 24 weeks) {
return 0;
}
else {
} else {
return block.timestamp + 24 weeks - lastScheduledElection;
}
}

function timeUntilElectionStateEnd(uint256 _election) public view override returns (uint256) {
function timeUntilElectionStateEnd(
uint256 _election
) public view override returns (uint256) {
if (elections[_election].isFinalized) {
return 0;
}
else {
} else {
return elections[_election].endTime - block.timestamp;
}
}
Expand All @@ -59,7 +62,9 @@ contract AutomatedVoting is IAutomatedVoting {
return council;
}

function isElectionFinalized(uint256 _election) public view override returns (bool) {
function isElectionFinalized(
uint256 _election
) public view override returns (bool) {
return elections[_election].isFinalized;
}

Expand All @@ -71,38 +76,39 @@ contract AutomatedVoting is IAutomatedVoting {
}
}

function startCouncilElection(address _council) public override onlyCouncil() {
function startCouncilElection(
address _council
) public override onlyCouncil {}

}

function startCKIPElection(address _council) public override onlyStaker() {

}
function startCKIPElection(address _council) public override onlyStaker {}

function stepDown() public override {
//todo: burn msg.sender rights
_recordElectionState();
}

function finalizeElection(uint256 _election) public override {
if(block.timestamp > elections[_election].endTime) {
elections[_election].isFinalized = true;
if (block.timestamp > elections[_election].endTime) {
elections[_election].isFinalized = true;
} else {
revert ElectionNotReadyToBeFinalized();
}
}

function voteInScheduledElection(uint256 _election, address[] calldata candidates) public override onlyStaker() {
function voteInScheduledElection(
uint256 _election,
address[] calldata candidates
) public override onlyStaker {}

}

function voteInCouncilElection(uint256 _election, address candidate) public override onlyCouncil() {

}
function voteInCouncilElection(
uint256 _election,
address candidate
) public override onlyCouncil {}

function voteInCKIPElection(uint256 _election, address[] calldata candidates) public override onlyStaker() {

}
function voteInCKIPElection(
uint256 _election,
address[] calldata candidates
) public override onlyStaker {}

function _recordElectionState() internal {
lastScheduledElection = block.timestamp;
Expand All @@ -113,7 +119,9 @@ contract AutomatedVoting is IAutomatedVoting {
elections[electionNumber].isFinalized = false;
}

function _isCouncilMember(address voter) internal view returns(bool isCouncilMember) {
function _isCouncilMember(
address voter
) internal view returns (bool isCouncilMember) {
for (uint i = 0; i < council.length; i++) {
if (council[i] == voter) {
return true;
Expand All @@ -124,8 +132,7 @@ contract AutomatedVoting is IAutomatedVoting {
}
}

function _isStaker(address voter) internal view returns(bool isStaker) {
function _isStaker(address voter) internal view returns (bool isStaker) {
//todo: check if voter is staker
}

}
}
7 changes: 4 additions & 3 deletions src/interfaces/IAutomatedVoting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ interface IAutomatedVoting {

/// @notice returns the time until the election state ends
/// @param election the election to check
function timeUntilElectionStateEnd(uint256 election) external view returns (uint256);
function timeUntilElectionStateEnd(
uint256 election
) external view returns (uint256);

/// @notice returns the current council
function getCouncil() external view returns (address[] memory);
Expand Down Expand Up @@ -84,5 +86,4 @@ interface IAutomatedVoting {
/// @param election the election to vote in
/// @param nominee the nominee to vote for
function vote(uint256 election, address nominee) external;

}
}
2 changes: 1 addition & 1 deletion test/AutomatedVoting.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ contract CounterTest is Test {
assertEq(result.length, 1, "Council should have 1 member");
assertEq(result[0], address(0x1), "Council member should be 0x1");
}
}
}

0 comments on commit 9ae08c9

Please sign in to comment.