contracts/Entropy.solView |
---|
40 | 40 … | * Any funds associated with Actions :bulb: in the Action Stream :clipboard: |
41 | 41 … | * become available in the Slush Pool :moneybag: for the Guardians :guardsman: |
42 | 42 … | * to use towards making those Actions :bulb: happen. |
43 | 43 … | */ |
| 44 … | + Action[] public actions; |
| 45 … | + uint public actions_count; |
44 | 46 … | struct Action { |
45 | 47 … | uint amount; |
46 | 48 … | string description; |
47 | 49 … | uint votingDeadline; |
48 | 50 … | bool done; |
49 | 51 … | bool actionPassed; |
50 | 52 … | uint numberOfVotes; |
51 | | - bytes32 proposalHash; |
| 53 … | + bytes32 actionHash; |
52 | 54 … | Vote[] votes; |
53 | 55 … | mapping (address => bool) voted; |
54 | 56 … | } |
55 | 57 … | |
65 | 67 … | */ |
66 | 68 … | function Entropy() { |
67 | 69 … | // Setup token attributes |
68 | 70 … | name = "Entropy"; |
69 | | - decimals = 0; |
70 | | - symbol = "ENT"; //identifier |
71 | | - safety_limit = 300 ether; |
| 71 … | + decimals = 0; // 1 token cannot be devided |
| 72 … | + symbol = "ENT"; // identifier |
| 73 … | + safety_limit = 300 ether; // Inital safety cap |
72 | 74 … | |
73 | 75 … | // Set the creator as Trusted, a Citizen and a Guardian |
74 | 76 … | totalSupply = 1; |
75 | 77 … | balances[msg.sender] = 1; |
85 | 87 … | * Fallback function |
86 | 88 … | * This runs whenever ether is sent to Entropy without any other information |
87 | 89 … | */ |
88 | 90 … | function() { |
| 91 … | + // Buy tokens 🍪 |
89 | 92 … | buyTokens(); |
90 | 93 … | } |
91 | 94 … | |
92 | | - // Token Selling related |
93 | 95 … | |
| 96 … | + // Token Selling related 🍪 |
| 97 … | + |
94 | 98 … | /** |
95 | 99 … | * Alters the safety limit for the maximum value of tokens bought |
96 | 100 … | */ |
97 | 101 … | function changeSafeyLimit(uint _new_limit) onlyGuardians returns (bool success) { |
102 | 106 … | safety_limit = _new_limit; |
103 | 107 … | SafetyLimitChange(msg.sender, _new_limit); |
104 | 108 … | } |
105 | 109 … | |
| 110 … | + |
106 | 111 … | /** |
| 112 … | + * Actions |
| 113 … | + * |
| 114 … | + * Trusted citizens can create an action, which then can be voted on for 5 days |
| 115 … | + */ |
| 116 … | + function newAction( |
| 117 … | + uint _etherAmount, // Amount to unlock (optional) |
| 118 … | + string _description // The idea, task or destination |
| 119 … | + ) |
| 120 … | + onlyTrusted // Only trusted Citizens |
| 121 … | + returns (uint actionID) |
| 122 … | + { |
| 123 … | + actionID = actions.length++; |
| 124 … | + Action a = actions[actionID]; |
| 125 … | + a.amount = _etherAmount; |
| 126 … | + a.description = _description; |
| 127 … | + a.actionHash = sha3(_etherAmount, _description); |
| 128 … | + a.votingDeadline = now + 5 days; |
| 129 … | + a.done = false; |
| 130 … | + a.actionPassed = false; |
| 131 … | + a.numberOfVotes = 0; |
| 132 … | + ActionAdded(actionID, _etherAmount, _description); |
| 133 … | + actions_count = actionID + 1; |
| 134 … | + } |
| 135 … | + |
| 136 … | + |
| 137 … | + /** |
107 | 138 … | * Guardians 💂 |
108 | 139 … | */ |
109 | 140 … | |
110 | 141 … | // Set someone as a Guardian |
176 | 207 … | * |
177 | 208 … | * Important changes to the state of Entropy |
178 | 209 … | */ |
179 | 210 … | |
| 211 … | + event ActionAdded(uint actionID, uint amount, string description); |
| 212 … | + |
180 | 213 … | // A new guardian has been elected |
181 | 214 … | event NewGuardian(address indexed _guardian, address indexed _creator); |
182 | 215 … | |
183 | 216 … | // A new person has been trusted |
184 | 217 … | event NewTrust(address indexed _citizen, address indexed _guardian); |
| 218 … | + |
185 | 219 … | // A person is no longer trusted |
186 | 220 … | event TrustLost(address indexed _citizen, address indexed _guardian); |
187 | 221 … | |
188 | 222 … | // Safety Limit has been increased |