From 60b48b0235d21c0aa6001b1a18083afba89865fb Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Mon, 13 Feb 2017 13:26:50 -0300 Subject: [PATCH] Solium --- .soliumignore | 1 + .soliumrc.json | 22 ++++++++++++++++++++++ contracts/Bounty.sol | 16 ++++++++-------- contracts/DayLimit.sol | 28 +++++++++------------------- contracts/MultisigWallet.sol | 21 --------------------- 5 files changed, 40 insertions(+), 48 deletions(-) create mode 100644 .soliumignore create mode 100644 .soliumrc.json diff --git a/.soliumignore b/.soliumignore new file mode 100644 index 000000000..b512c09d4 --- /dev/null +++ b/.soliumignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/.soliumrc.json b/.soliumrc.json new file mode 100644 index 000000000..81876bcd6 --- /dev/null +++ b/.soliumrc.json @@ -0,0 +1,22 @@ +{ + "custom-rules-filename": null, + "rules": { + "imports-on-top": true, + "variable-declarations": true, + "array-declarations": true, + "operator-whitespace": true, + "lbrace": true, + "mixedcase": false, + "camelcase": true, + "uppercase": true, + "no-with": true, + "no-empty-blocks": true, + "no-unused-vars": true, + "double-quotes": true, + "blank-lines": true, + "indentation": true, + "whitespace": true, + "deprecated-suicide": true, + "pragma-on-top": true + } +} diff --git a/contracts/Bounty.sol b/contracts/Bounty.sol index a90d2e44a..529342e6b 100644 --- a/contracts/Bounty.sol +++ b/contracts/Bounty.sol @@ -11,18 +11,19 @@ import './lifecycle/Killable.sol'; * This bounty will pay out to a researcher if they break invariant logic of the contract. */ contract Bounty is PullPayment, Killable { - Target target; bool public claimed; mapping(address => address) public researchers; event TargetCreated(address createdAddress); function() payable { - if (claimed) throw; + if (claimed) { + throw; + } } function createTarget() returns(Target) { - target = Target(deployContract()); + Target target = Target(deployContract()); researchers[target] = msg.sender; TargetCreated(target); return target; @@ -30,13 +31,11 @@ contract Bounty is PullPayment, Killable { function deployContract() internal returns(address); - function checkInvariant() returns(bool){ - return target.checkInvariant(); - } - function claim(Target target) { address researcher = researchers[target]; - if (researcher == 0) throw; + if (researcher == 0) { + throw; + } // Check Target contract invariants if (target.checkInvariant()) { throw; @@ -47,6 +46,7 @@ contract Bounty is PullPayment, Killable { } + /* * Target * diff --git a/contracts/DayLimit.sol b/contracts/DayLimit.sol index 8fd07255b..49be5f194 100644 --- a/contracts/DayLimit.sol +++ b/contracts/DayLimit.sol @@ -12,33 +12,18 @@ import './ownership/Shareable.sol'; * uses is specified in the modifier. */ contract DayLimit { - // FIELDS uint public dailyLimit; uint public spentToday; uint public lastDay; - // MODIFIERS - - // simple modifier for daily limit. - modifier limitedDaily(uint _value) { - if (underLimit(_value)) - _; - } - - - // CONSTRUCTOR - // stores initial daily limit and records the present day's index. function DayLimit(uint _limit) { dailyLimit = _limit; lastDay = today(); } - - // METHODS - - // (re)sets the daily limit. doesn't alter the amount already spent today. + // sets the daily limit. doesn't alter the amount already spent today function _setDailyLimit(uint _newLimit) internal { dailyLimit = _newLimit; } @@ -48,9 +33,6 @@ contract DayLimit { spentToday = 0; } - - // INTERNAL METHODS - // checks to see if there is at least `_value` left from the daily limit today. if there is, subtracts it and // returns true. otherwise just returns false. function underLimit(uint _value) internal returns (bool) { @@ -72,4 +54,12 @@ contract DayLimit { function today() private constant returns (uint) { return now / 1 days; } + + + // simple modifier for daily limit. + modifier limitedDaily(uint _value) { + if (underLimit(_value)) { + _; + } + } } diff --git a/contracts/MultisigWallet.sol b/contracts/MultisigWallet.sol index 245ae3e1a..5aac8303c 100644 --- a/contracts/MultisigWallet.sol +++ b/contracts/MultisigWallet.sol @@ -13,27 +13,6 @@ import "./DayLimit.sol"; * Wallet(w).from(anotherOwner).confirm(h); */ contract MultisigWallet is Multisig, Shareable, DayLimit { - // TYPES - - // Transaction structure to remember details of transaction lest it need be saved for a later call. - struct Transaction { - address to; - uint value; - bytes data; - } - - - // CONSTRUCTOR - - // just pass on the owner array to the multiowned and - // the limit to daylimit - function MultisigWallet(address[] _owners, uint _required, uint _daylimit) - Shareable(_owners, _required) - DayLimit(_daylimit) { } - - - // METHODS - // kills the contract sending everything to `_to`. function kill(address _to) onlymanyowners(sha3(msg.data)) external { suicide(_to);