3
3
FILE INFORMATION
4
4
-----------------------------------------------------------------
5
5
file: Court.sol
6
- version: 1.0
6
+ version: 1.1
7
7
author: Anton Jurisevic
8
8
Mike Spain
9
+ Dominic Romanowski
9
10
10
- date: 2018-2-6
11
+ date: 2018-05-02
11
12
12
13
checked: Mike Spain
13
14
approved: Samuel Brooks
@@ -96,13 +97,13 @@ Confirmation:
96
97
97
98
98
99
User votes are not automatically cancelled upon the conclusion of a motion.
99
- Therefore, after a motion comes to a conclusion, if a user wishes to vote
100
+ Therefore, after a motion comes to a conclusion, if a user wishes to vote
100
101
in another motion, they must manually cancel their vote in order to do so.
101
102
102
103
This procedure is designed to be relatively simple.
103
104
There are some things that can be added to enhance the functionality
104
105
at the expense of simplicity and efficiency:
105
-
106
+
106
107
- Democratic unfreezing of nomin accounts (induces multiple categories of vote)
107
108
- Configurable per-vote durations;
108
109
- Vote standing denominated in a fiat quantity rather than a quantity of havvens;
@@ -208,7 +209,7 @@ contract Court is SafeDecimalMath, Owned {
208
209
/* ========== CONSTRUCTOR ========== */
209
210
210
211
/**
211
- * @dev Constructor.
212
+ * @dev Court Constructor.
212
213
*/
213
214
constructor (Havven _havven , Nomin _nomin , address _owner )
214
215
Owned (_owner)
@@ -238,7 +239,7 @@ contract Court is SafeDecimalMath, Owned {
238
239
/**
239
240
* @notice Set the length of time a vote runs for.
240
241
* @dev Only the contract owner may call this. The proposed duration must fall
241
- * within sensible bounds (1 to 4 weeks), and must be no longer than a single fee period.
242
+ * within sensible bounds (3 days to 4 weeks), and must be no longer than a single fee period.
242
243
*/
243
244
function setVotingPeriod (uint duration )
244
245
external
@@ -252,6 +253,11 @@ contract Court is SafeDecimalMath, Owned {
252
253
votingPeriod = duration;
253
254
}
254
255
256
+ /**
257
+ * @notice Set the confirmation period after a vote has concluded.
258
+ * @dev Only the contract owner may call this. The proposed duration must fall
259
+ * within sensible bounds (1 day to 2 weeks).
260
+ */
255
261
function setConfirmationPeriod (uint duration )
256
262
external
257
263
onlyOwner
@@ -261,6 +267,10 @@ contract Court is SafeDecimalMath, Owned {
261
267
confirmationPeriod = duration;
262
268
}
263
269
270
+ /**
271
+ * @notice Set the required fraction of all Havvens that need to be part of
272
+ * a vote for it to pass.
273
+ */
264
274
function setRequiredParticipation (uint fraction )
265
275
external
266
276
onlyOwner
@@ -269,6 +279,10 @@ contract Court is SafeDecimalMath, Owned {
269
279
requiredParticipation = fraction;
270
280
}
271
281
282
+ /**
283
+ * @notice Set what portion of voting havvens need to be in the affirmative
284
+ * to allow it to pass.
285
+ */
272
286
function setRequiredMajority (uint fraction )
273
287
external
274
288
onlyOwner
@@ -280,35 +294,37 @@ contract Court is SafeDecimalMath, Owned {
280
294
281
295
/* ========== VIEW FUNCTIONS ========== */
282
296
283
- /* There is a motion in progress on the specified
284
- * account, and votes are being accepted in that motion. */
297
+ /**
298
+ * @notice There is a motion in progress on the specified
299
+ * account, and votes are being accepted in that motion.
300
+ */
285
301
function motionVoting (uint motionID )
286
302
public
287
303
view
288
304
returns (bool )
289
305
{
290
- /* No need to check (startTime < now) as there is no way
291
- * to set future start times for votes.
292
- * These values are timestamps, they will not overflow
293
- * as they can only ever be initialised to relatively small values. */
294
306
return motionStartTime[motionID] < now && now < motionStartTime[motionID] + votingPeriod;
295
307
}
296
308
297
- /* A vote on the target account has concluded, but the motion
309
+ /**
310
+ * @notice A vote on the target account has concluded, but the motion
298
311
* has not yet been approved, vetoed, or closed. */
299
312
function motionConfirming (uint motionID )
300
313
public
301
314
view
302
315
returns (bool )
303
316
{
304
317
/* These values are timestamps, they will not overflow
305
- * as they can only ever be initialised to relatively small values. */
318
+ * as they can only ever be initialised to relatively small values.
319
+ */
306
320
uint startTime = motionStartTime[motionID];
307
321
return startTime + votingPeriod <= now &&
308
322
now < startTime + votingPeriod + confirmationPeriod;
309
323
}
310
324
311
- /* A vote motion either not begun, or it has completely terminated. */
325
+ /**
326
+ * @notice A vote motion either not begun, or it has completely terminated.
327
+ */
312
328
function motionWaiting (uint motionID )
313
329
public
314
330
view
@@ -319,8 +335,10 @@ contract Court is SafeDecimalMath, Owned {
319
335
return motionStartTime[motionID] + votingPeriod + confirmationPeriod <= now ;
320
336
}
321
337
322
- /* If the motion was to terminate at this instant, it would pass.
323
- * That is: there was sufficient participation and a sizeable enough majority. */
338
+ /**
339
+ * @notice If the motion was to terminate at this instant, it would pass.
340
+ * That is: there was sufficient participation and a sizeable enough majority.
341
+ */
324
342
function motionPasses (uint motionID )
325
343
public
326
344
view
@@ -343,6 +361,9 @@ contract Court is SafeDecimalMath, Owned {
343
361
fractionInFavour > requiredMajority;
344
362
}
345
363
364
+ /**
365
+ * @notice Return if the specified account has voted on the specified motion
366
+ */
346
367
function hasVoted (address account , uint motionID )
347
368
public
348
369
view
@@ -354,10 +375,12 @@ contract Court is SafeDecimalMath, Owned {
354
375
355
376
/* ========== MUTATIVE FUNCTIONS ========== */
356
377
357
- /* Begin a motion to confiscate the funds in a given nomin account.
358
- * Only the foundation, or accounts with sufficient havven balances
378
+ /**
379
+ * @notice Begin a motion to confiscate the funds in a given nomin account.
380
+ * @dev Only the foundation, or accounts with sufficient havven balances
359
381
* may elect to start such a motion.
360
- * Returns the ID of the motion that was begun. */
382
+ * @return Returns the ID of the motion that was begun.
383
+ */
361
384
function beginMotion (address target )
362
385
external
363
386
returns (uint )
@@ -376,22 +399,21 @@ contract Court is SafeDecimalMath, Owned {
376
399
/* Disallow votes on accounts that have previously been frozen. */
377
400
require (! nomin.frozen (target));
378
401
379
- /* Rollover the fee period in case it hasn't happened yet */
380
- havven.rolloverFeePeriod ();
381
-
382
402
uint motionID = nextMotionID++ ;
383
403
motionTarget[motionID] = target;
384
404
targetMotionID[target] = motionID;
385
405
386
406
/* Start the vote at the start of the next fee period */
387
- motionStartTime[motionID] = havven.feePeriodStartTime () + havven.targetFeePeriodDurationSeconds ();
388
- emit MotionBegun (msg .sender , msg .sender , target, target, motionID, motionID, motionStartTime[motionID]);
407
+ uint startTime = havven.feePeriodStartTime () + havven.targetFeePeriodDurationSeconds ();
408
+ motionStartTime[motionID] = startTime;
409
+ emit MotionBegun (msg .sender , msg .sender , target, target, motionID, motionID, startTime);
389
410
390
411
return motionID;
391
412
}
392
413
393
- /* Shared vote setup function between voteFor and voteAgainst.
394
- * Returns the voter's vote weight. */
414
+ /**
415
+ * @notice Shared vote setup function between voteFor and voteAgainst.
416
+ * @return Returns the voter's vote weight. */
395
417
function setupVote (uint motionID )
396
418
internal
397
419
returns (uint )
@@ -406,11 +428,6 @@ contract Court is SafeDecimalMath, Owned {
406
428
/* The voter may not cast votes on themselves. */
407
429
require (msg .sender != motionTarget[motionID]);
408
430
409
- /* Ensure the voter's vote weight is current. */
410
- /* We use a fee period guaranteed to have terminated before
411
- * the start of the vote. Select the right period if
412
- * a fee period rolls over in the middle of the vote. */
413
-
414
431
uint weight = havven.recomputeAccountLastHavvenAverageBalance (msg .sender );
415
432
416
433
/* Users must have a nonzero voting weight to vote. */
@@ -421,8 +438,10 @@ contract Court is SafeDecimalMath, Owned {
421
438
return weight;
422
439
}
423
440
424
- /* The sender casts a vote in favour of confiscation of the
425
- * target account's nomin balance. */
441
+ /**
442
+ * @notice The sender casts a vote in favour of confiscation of the
443
+ * target account's nomin balance.
444
+ */
426
445
function voteFor (uint motionID )
427
446
external
428
447
{
@@ -432,8 +451,10 @@ contract Court is SafeDecimalMath, Owned {
432
451
emit VotedFor (msg .sender , msg .sender , motionID, motionID, weight);
433
452
}
434
453
435
- /* The sender casts a vote against confiscation of the
436
- * target account's nomin balance. */
454
+ /**
455
+ * @notice The sender casts a vote against confiscation of the
456
+ * target account's nomin balance.
457
+ */
437
458
function voteAgainst (uint motionID )
438
459
external
439
460
{
@@ -443,8 +464,10 @@ contract Court is SafeDecimalMath, Owned {
443
464
emit VotedAgainst (msg .sender , msg .sender , motionID, motionID, weight);
444
465
}
445
466
446
- /* Cancel an existing vote by the sender on a motion
447
- * to confiscate the target balance. */
467
+ /**
468
+ * @notice Cancel an existing vote by the sender on a motion
469
+ * to confiscate the target balance.
470
+ */
448
471
function cancelVote (uint motionID )
449
472
external
450
473
{
@@ -476,6 +499,9 @@ contract Court is SafeDecimalMath, Owned {
476
499
delete vote[msg .sender ][motionID];
477
500
}
478
501
502
+ /**
503
+ * @notice clear all data associated with a motionID for hygiene purposes.
504
+ */
479
505
function _closeMotion (uint motionID )
480
506
internal
481
507
{
@@ -487,17 +513,21 @@ contract Court is SafeDecimalMath, Owned {
487
513
emit MotionClosed (motionID, motionID);
488
514
}
489
515
490
- /* If a motion has concluded, or if it lasted its full duration but not passed,
491
- * then anyone may close it. */
516
+ /**
517
+ * @notice If a motion has concluded, or if it lasted its full duration but not passed,
518
+ * then anyone may close it.
519
+ */
492
520
function closeMotion (uint motionID )
493
521
external
494
522
{
495
523
require ((motionConfirming (motionID) && ! motionPasses (motionID)) || motionWaiting (motionID));
496
524
_closeMotion (motionID);
497
525
}
498
526
499
- /* The foundation may only confiscate a balance during the confirmation
500
- * period after a motion has passed. */
527
+ /**
528
+ * @notice The foundation may only confiscate a balance during the confirmation
529
+ * period after a motion has passed.
530
+ */
501
531
function approveMotion (uint motionID )
502
532
external
503
533
onlyOwner
@@ -509,7 +539,7 @@ contract Court is SafeDecimalMath, Owned {
509
539
emit MotionApproved (motionID, motionID);
510
540
}
511
541
512
- /* The foundation may veto a motion at any time. */
542
+ /* @notice The foundation may veto a motion at any time. */
513
543
function vetoMotion (uint motionID )
514
544
external
515
545
onlyOwner
0 commit comments