-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgroup.sol
132 lines (115 loc) · 2.54 KB
/
group.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
pragma solidity ^0.4.0;
import "assess/user.sol";
import "assess/userRegistry.sol";
contract Group
{
uint public size;
uint public stake;
bytes32 public goal;
address[] public members;
address[] public requirements;
address concept;
address registry;
address userRegistry;
mapping (address => Member) memberData;
enum State {
Init,
Done
}
State state; //1 = started,
struct Member {
mapping (address => bool) votes;
address finalAssessment;
bool done;
}
modifier onlyRegistry()
{
if (msg.sender != registry)
{
throw;
}
_;
}
modifier onlyThis()
{
if(msg.sender != address(this))
{
throw;
}
_;
}
function Group(address _concept, uint _size, uint _stake, address[] _requirements, address _userRegistry)
{
concept = _concept;
registry = msg.sender;
userRegistry = _userRegistry;
requirements = _requirements;
addMember(msg.sender);
size = _size;
stake = _stake;
state = State.Init;
}
function addMember(address member) returns(bool)
{
if(members.length >= size)
{
return false;
}
for (uint i = 0; i <= requirements.length; i++)
{
if(User(member).conceptPassed(requirements[i]) == false)
{
return false;
}
}
if (getStake(member, stake) != true)
{
return false;
}
members.push(member);
return true;
}
function setDone()
{
memberData[msg.sender].done = true;
for(uint i = 0; i <= members.length; i++)
{
if(memberData[members[i]].done == false)
{
return;
}
}
state = State.Done;
}
//function startFinalAssessment(address member) onlyThis{
//memberData[member].finalAssessment = makeAssessment(member, concept, );
//if(memberData[member].finalAssessment != true){
//return;
//}
//}
function makeAssessment(address _member, address _concept, uint _time, uint _size) onlyThis returns(bool)
{
return User(_member).extMakeAssessment(_concept, _time, _size);
}
function getStake(address user, uint value) onlyThis returns(bool)
{
return User(user).extTransferTokens(address(this), value);
}
function returnStake(address user)
{
if(state == State.Done){
//UserRegistry(us)
}
}
function kick(address member) {
memberData[member].votes[msg.sender] = true;
for(uint i=0; i < members.length; i++)
{
if(!memberData[member].votes[members[i]])
{
return;
}
}
//The process for kicking out a member goes here
}
}