-
Notifications
You must be signed in to change notification settings - Fork 19
/
OpenRegistryRules.sol
48 lines (37 loc) · 1.24 KB
/
OpenRegistryRules.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
pragma solidity ^0.4.3;
import "examples/OpenRegistry.sol";
import "Rules.sol";
import "BoardRoom.sol";
contract OpenRegistryRules is Rules {
function OpenRegistryRules(address _registry) public {
registry = OpenRegistry(_registry);
}
function hasWon(uint _proposalID) public constant returns (bool) {
BoardRoom board = BoardRoom(msg.sender);
uint nay = board.positionWeightOf(_proposalID, 0);
uint yea = board.positionWeightOf(_proposalID, 1);
uint totalVoters = board.numVoters(_proposalID);
if(totalVoters > 0 && yea > nay) {
return true;
}
}
function canVote(address _sender, uint _proposalID) public constant returns (bool) {
BoardRoom board = BoardRoom(msg.sender);
uint created = board.createdOn(_proposalID);
uint debatePeriod = board.debatePeriodOf(_proposalID);
if(registry.isMember(_sender)
&& now < created + debatePeriod
&& !board.hasVoted(_proposalID, _sender)) {
return true;
}
}
function canPropose(address _sender) public constant returns (bool) {
if(registry.isMember(_sender)) {
return true;
}
}
function votingWeightOf(address _sender, uint _proposalID) public constant returns (uint) {
return 1;
}
OpenRegistry public registry;
}