Skip to content

Commit a8a429e

Browse files
author
valentinpollart
committed
chore: run linters
1 parent 3033d69 commit a8a429e

File tree

8 files changed

+19
-70
lines changed

8 files changed

+19
-70
lines changed

contracts/Ballot.sol

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,6 @@ import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
77
import "@openzeppelin/contracts/proxy/utils/Initializable.sol";
88
import "./VotingProxy.sol";
99

10-
// Can a voter change his/her vote ? --> Yes
11-
// Can a voter who grant proxy to somebody can still vote ? --> No
12-
// Can s.he change proxy voter vote ? -->
13-
// Can a proxy voter change original voter vote ?
14-
// Is there a limit of delegate votes per proxy voters ?
15-
// Can a voter grant proxy to more than one person on a given tag ?
16-
// Do we need to have a started flag so admins can create a vote and start it afterwards ? --> No
17-
18-
// Can a voter delegate to a voter that has less than 25k DPS ? --> No
19-
// Is the 25k DPS limit for delegating balance DPS or undelegated DPS ? --> DPS balance
20-
21-
// If A grant proxy to B, and if A and B call vote and reach the vote verification simultaneously, both A and B might register a vote for A
22-
// ==> Could be solved by registering voters address instead of incrementing a count, but scales badly.
23-
24-
// Currently, order is not kept for tags, causing index issues, 2 solutions :
25-
// - remove reference to tag index and use value => forces to check each time there's a reference to a tag to verify it is a member of tag list.
26-
// - do not change indexes at tag removal => residual value (such as empty string) will be left in the tag list.
27-
// ==> Should owner even be able to remove a tag ?
28-
29-
// Is granting recursive (if A grants proxy to B and B to C, does C has voting power of B+C or A+B+C ?)
30-
31-
// Add/remove choices ?
32-
33-
// A a voté 1
34-
// B a voté 2
35-
36-
// voters = address[]
37-
// mapping(address => uint32) results
38-
// results[C] == 0
39-
4010
contract Ballot is Ownable, Initializable {
4111
IERC20Metadata public immutable DPS;
4212
VotingProxy public proxy;
@@ -81,12 +51,12 @@ contract Ballot is Ownable, Initializable {
8151
}
8252

8353
function vote(uint32 choiceIndex) external {
84-
require(!closed, 'Voting: Ballot is closed.');
85-
require(choices.length > choiceIndex, 'Voting: Choice index is too high.');
54+
require(!closed, "Voting: Ballot is closed.");
55+
require(choices.length > choiceIndex, "Voting: Choice index is too high.");
8656

87-
require(!proxy.hasDelegated(msg.sender,tagIndex), 'Voting: Vote is delegated.'); // Verify that voter has not granted proxy to somebody.
57+
require(!proxy.hasDelegated(msg.sender,tagIndex), "Voting: Vote is delegated."); // Verify that voter has not granted proxy to somebody.
8858

89-
require(DPS.balanceOf(msg.sender) >= 25e3 * 1e18, 'Voting: Not enough DPS to vote.'); // 25k DPS limit
59+
require(DPS.balanceOf(msg.sender) >= 25e3 * 1e18, "Voting: Not enough DPS to vote."); // 25k DPS limit
9060

9161
if(!votes[msg.sender].hasVoted) {
9262
votes[msg.sender].hasVoted = true;
@@ -97,7 +67,7 @@ contract Ballot is Ownable, Initializable {
9767
}
9868

9969
function closeBallot() external onlyOwner {
100-
require(!closed, 'Voting: Ballot already closed.');
70+
require(!closed, "Voting: Ballot already closed.");
10171

10272
closed = true;
10373

contracts/VotingProxy.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ contract VotingProxy is Ownable {
2222

2323
constructor(IERC20Metadata _DPS, BallotTagManager _ballotTagManager) {
2424
require(address(_DPS) != address(0), "VotingProxy: DPS address is zero.");
25-
require(address(_ballotTagManager) != address(0), 'VotingProxy: Ballot tag manager address is zero.');
25+
require(address(_ballotTagManager) != address(0), "VotingProxy: Ballot tag manager address is zero.");
2626

2727
DPS = _DPS;
2828
ballotTagManager = _ballotTagManager;
2929
}
3030

3131
function grantProxy(address to, uint32 tagIndex) external {
32-
require(ballotTagManager.getTags().length > tagIndex, 'VotingProxy: Tag index is too high');
33-
require(DPS.balanceOf(to) >= 25e3 * 1e18 || to == address(0), 'VotingProxy: Proxy has not enough DPS.');
32+
require(ballotTagManager.getTags().length > tagIndex, "VotingProxy: Tag index is too high");
33+
require(DPS.balanceOf(to) >= 25e3 * 1e18 || to == address(0), "VotingProxy: Proxy has not enough DPS.");
3434

3535
if(proxyVoters[msg.sender][tagIndex] != address(0)) {
3636
Grants storage formerDelegateGrants = delegates[proxyVoters[msg.sender][tagIndex]][tagIndex];
@@ -52,7 +52,7 @@ contract VotingProxy is Ownable {
5252
}
5353

5454
function proxyAmount(address voter, uint32 tagIndex) public view returns (uint256) {
55-
require(ballotTagManager.getTags().length > tagIndex, 'VotingProxy: Tag index is too high');
55+
require(ballotTagManager.getTags().length > tagIndex, "VotingProxy: Tag index is too high");
5656
uint256 total;
5757
for(uint32 i = 0; i < delegates[voter][tagIndex].grantCount; i++) {
5858
total += DPS.balanceOf(delegates[voter][tagIndex].indexVoter[i]);

contracts/factories/BallotFactory.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ contract BallotFactory is Ownable {
1616
event BallotCreated(address ballotAddress);
1717

1818
constructor(address _implementationAddress, BallotTagManager _ballotTagManager){
19-
require(_implementationAddress != address(0), 'BallotFactory: Implementation address should not be zero address');
20-
require(address(_ballotTagManager) != address(0), 'BallotFactory: Ballot tag manager address should not be zero address');
19+
require(_implementationAddress != address(0), "BallotFactory: Implementation address should not be zero address");
20+
require(address(_ballotTagManager) != address(0), "BallotFactory: Ballot tag manager address should not be zero address");
2121
implementationAddress = _implementationAddress;
2222
ballotTagManager = _ballotTagManager;
2323
}
2424

2525
function createBallot(string memory subject, uint32 tagIndex, string[] memory _choices) external onlyOwner {
26-
require(ballotTagManager.getTags().length > tagIndex, 'BallotFactory: Tag index is too high.');
26+
require(ballotTagManager.getTags().length > tagIndex, "BallotFactory: Tag index is too high.");
2727

2828
address cloneAddress = Clones.clone(implementationAddress);
2929
Ballot(cloneAddress).init(subject, tagIndex, _choices);
@@ -33,7 +33,7 @@ contract BallotFactory is Ownable {
3333
}
3434

3535
function setImplementationAddress(address newAddress) external onlyOwner {
36-
require(newAddress != address(0), 'BallotFactory: Implementation address should not be zero address');
36+
require(newAddress != address(0), "BallotFactory: Implementation address should not be zero address");
3737
implementationAddress = newAddress;
3838
}
3939

test/Ballot.spec.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ import { BigNumber } from '@ethersproject/bignumber';
33
import { parseUnits } from '@ethersproject/units';
44
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
55
import { ZERO_ADDRESS } from '../lib/constants';
6-
import {
7-
BallotTagManager,
8-
DeepSquare,
9-
ExposedBallot,
10-
ExposedBallot__factory,
11-
ExposedVotingProxy,
12-
} from '../typings';
6+
import { BallotTagManager, DeepSquare, ExposedBallot, ExposedBallot__factory, ExposedVotingProxy } from '../typings';
137
import { ERC20Agent } from './testing/ERC20Agent';
148
import setup from './testing/setup';
159
import setupVoting from './testing/setupVoting';

test/BallotFactory.spec.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
import { expect } from 'chai';
22
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
33
import { ZERO_ADDRESS } from '../lib/constants';
4-
import {
5-
Ballot,
6-
BallotFactory,
7-
BallotFactory__factory,
8-
BallotTagManager,
9-
DeepSquare,
10-
VotingProxy,
11-
} from '../typings';
4+
import { Ballot, BallotFactory, BallotFactory__factory, BallotTagManager, DeepSquare, VotingProxy } from '../typings';
125
import setup from './testing/setup';
136
import setupVoting from './testing/setupVoting';
147

test/BallotTagManager.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ describe('BallotTagManager', () => {
2020
expect(await ballotTagManager.getTags()).to.deep.equals(['foo', 'bar']);
2121
});
2222
});
23-
});
23+
});

test/DeepSquare.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { expect } from 'chai';
22
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
33
import { DPS_TOTAL_SUPPLY } from '../lib/constants';
4-
import waitTx from '../lib/waitTx';
5-
import { DeepSquare } from '../typings/contracts/DeepSquare';
4+
import { DeepSquare } from '../typings';
65
import { ERC20Agent } from './testing/ERC20Agent';
76
import { randomInt } from './testing/random';
87
import setup from './testing/setup';

test/VotingProxy.spec.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ import { BigNumber } from '@ethersproject/bignumber';
33
import { parseUnits } from '@ethersproject/units';
44
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers';
55
import { ZERO_ADDRESS } from '../lib/constants';
6-
import {
7-
BallotFactory,
8-
BallotTagManager,
9-
DeepSquare,
10-
ExposedVotingProxy,
11-
ExposedVotingProxy__factory,
12-
} from '../typings';
6+
import { BallotTagManager, DeepSquare, ExposedVotingProxy, ExposedVotingProxy__factory } from '../typings';
137
import { ERC20Agent } from './testing/ERC20Agent';
148
import setup from './testing/setup';
159
import setupVoting from './testing/setupVoting';
@@ -21,11 +15,10 @@ describe('Voting proxy', async () => {
2115
let agentDPS: ERC20Agent;
2216
let ballotTagManager: BallotTagManager;
2317
let votingProxy: ExposedVotingProxy;
24-
let ballotFactory: BallotFactory;
2518

2619
beforeEach(async () => {
2720
({ owner, accounts, DPS, agentDPS } = await setup());
28-
({ ballotTagManager, votingProxy, ballotFactory } = await setupVoting(owner, DPS));
21+
({ ballotTagManager, votingProxy } = await setupVoting(owner, DPS));
2922
});
3023

3124
describe('constructor', () => {

0 commit comments

Comments
 (0)