-
Notifications
You must be signed in to change notification settings - Fork 105
/
ColonyStorage.sol
executable file
·163 lines (132 loc) · 4.8 KB
/
ColonyStorage.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
This file is part of The Colony Network.
The Colony Network is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
The Colony Network is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with The Colony Network. If not, see <http://www.gnu.org/licenses/>.
*/
pragma solidity ^0.4.17;
pragma experimental "v0.5.0";
pragma experimental "ABIEncoderV2";
import "../lib/dappsys/auth.sol";
import "./ERC20Extended.sol";
import "./IColonyNetwork.sol";
contract ColonyStorage is DSAuth {
// When adding variables, do not make them public, otherwise all contracts that inherit from
// this one will have the getters. Make custom getters in the contract that seems most appropriate,
// and add it to IColony.sol
address resolver;
mapping (uint256 => Transaction) transactions;
// Mapping function signature to 2 task roles whose approval is needed to execute
mapping (bytes4 => uint8[2]) reviewers;
// Maps transactions to roles and whether they've confirmed the transaction
mapping (uint256 => mapping (uint256 => bool)) confirmations;
uint256 transactionCount;
struct Transaction {
bytes data;
uint256 value;
bool executed;
}
address colonyNetworkAddress;
ERC20Extended token;
mapping (uint256 => Task) tasks;
// Pots can be tied to tasks or to (in the future) domains, so giving them their own mapping.
// Pot 1 can be thought of as the pot belonging to the colony itself that hasn't been assigned
// to anything yet, but has had some siphoned off in to the reward pot.
// Pot 0 is the pot containing funds that can be paid to holders of colony tokens in the future.
mapping (uint256 => Pot) pots;
// This keeps track of how much of the colony's funds that it owns have been moved into pots other than pot 0,
// which (by definition) have also had the reward amount siphoned off and put in to pot 0.
// TODO: This needs to be decremented whenever a payout occurs and the colony loses control of the funds.
mapping (address => uint256) nonRewardPotsTotal;
mapping (uint256 => RatingSecrets) public taskWorkRatings;
mapping (uint256 => Domain) public domains;
uint256 taskCount;
uint256 potCount;
uint256 domainCount;
struct Task {
bytes32 specificationHash;
bytes32 deliverableHash;
bool finalized;
bool cancelled;
uint256 dueDate;
uint256 payoutsWeCannotMake;
uint256 potId;
uint256 deliverableTimestamp;
uint256[] domains;
uint256[] skills;
// TODO switch this mapping to a uint8 when all role instances are uint8-s specifically ColonyFunding source
mapping (uint256 => Role) roles;
// Maps a token to the sum of all payouts of it for this task
mapping (address => uint256) totalPayouts;
// Maps task role ids (0,1,2..) to a token amount to be paid on task completion
mapping (uint256 => mapping (address => uint256)) payouts;
}
struct Role {
// Address of the user for the given role
address user;
// Has the user work been rated
bool rated;
// Rating the user received
uint8 rating;
}
struct RatingSecrets {
uint256 count;
uint256 timestamp;
mapping (uint8 => bytes32) secret;
}
struct Pot {
mapping (address => uint256) balance;
uint256 taskId;
}
struct Domain {
uint256 skillId;
uint256 potId;
}
modifier isManager(uint256 _id) {
Task storage task = tasks[_id];
require(task.roles[0].user == msg.sender);
_;
}
modifier taskExists(uint256 _id) {
require(_id <= taskCount);
_;
}
modifier taskNotFinalized(uint256 _id) {
require(!tasks[_id].finalized);
_;
}
modifier taskFinalized(uint256 _id) {
require(tasks[_id].finalized);
_;
}
modifier globalSkill(uint256 _skillId) {
IColonyNetwork colonyNetworkContract = IColonyNetwork(colonyNetworkAddress);
require(colonyNetworkContract.isGlobalSkill(_skillId));
_;
}
modifier localSkill(uint256 _skillId) {
IColonyNetwork colonyNetworkContract = IColonyNetwork(colonyNetworkAddress);
require(!colonyNetworkContract.isGlobalSkill(_skillId));
_;
}
modifier skillExists(uint256 _skillId) {
IColonyNetwork colonyNetworkContract = IColonyNetwork(colonyNetworkAddress);
require(_skillId <= colonyNetworkContract.getSkillCount());
_;
}
modifier domainExists(uint256 _domainId) {
require(_domainId <= domainCount);
_;
}
modifier self() {
require(address(this) == msg.sender);
_;
}
}