This commit is contained in:
Manuel Araoz
2017-02-13 13:26:50 -03:00
parent f4624837a3
commit 60b48b0235
5 changed files with 40 additions and 48 deletions

1
.soliumignore Normal file
View File

@ -0,0 +1 @@
node_modules

22
.soliumrc.json Normal file
View File

@ -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
}
}

View File

@ -11,18 +11,19 @@ import './lifecycle/Killable.sol';
* This bounty will pay out to a researcher if they break invariant logic of the contract. * This bounty will pay out to a researcher if they break invariant logic of the contract.
*/ */
contract Bounty is PullPayment, Killable { contract Bounty is PullPayment, Killable {
Target target;
bool public claimed; bool public claimed;
mapping(address => address) public researchers; mapping(address => address) public researchers;
event TargetCreated(address createdAddress); event TargetCreated(address createdAddress);
function() payable { function() payable {
if (claimed) throw; if (claimed) {
throw;
}
} }
function createTarget() returns(Target) { function createTarget() returns(Target) {
target = Target(deployContract()); Target target = Target(deployContract());
researchers[target] = msg.sender; researchers[target] = msg.sender;
TargetCreated(target); TargetCreated(target);
return target; return target;
@ -30,13 +31,11 @@ contract Bounty is PullPayment, Killable {
function deployContract() internal returns(address); function deployContract() internal returns(address);
function checkInvariant() returns(bool){
return target.checkInvariant();
}
function claim(Target target) { function claim(Target target) {
address researcher = researchers[target]; address researcher = researchers[target];
if (researcher == 0) throw; if (researcher == 0) {
throw;
}
// Check Target contract invariants // Check Target contract invariants
if (target.checkInvariant()) { if (target.checkInvariant()) {
throw; throw;
@ -47,6 +46,7 @@ contract Bounty is PullPayment, Killable {
} }
/* /*
* Target * Target
* *

View File

@ -12,33 +12,18 @@ import './ownership/Shareable.sol';
* uses is specified in the modifier. * uses is specified in the modifier.
*/ */
contract DayLimit { contract DayLimit {
// FIELDS
uint public dailyLimit; uint public dailyLimit;
uint public spentToday; uint public spentToday;
uint public lastDay; 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) { function DayLimit(uint _limit) {
dailyLimit = _limit; dailyLimit = _limit;
lastDay = today(); lastDay = today();
} }
// sets the daily limit. doesn't alter the amount already spent today
// METHODS
// (re)sets the daily limit. doesn't alter the amount already spent today.
function _setDailyLimit(uint _newLimit) internal { function _setDailyLimit(uint _newLimit) internal {
dailyLimit = _newLimit; dailyLimit = _newLimit;
} }
@ -48,9 +33,6 @@ contract DayLimit {
spentToday = 0; 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 // 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. // returns true. otherwise just returns false.
function underLimit(uint _value) internal returns (bool) { function underLimit(uint _value) internal returns (bool) {
@ -72,4 +54,12 @@ contract DayLimit {
function today() private constant returns (uint) { function today() private constant returns (uint) {
return now / 1 days; return now / 1 days;
} }
// simple modifier for daily limit.
modifier limitedDaily(uint _value) {
if (underLimit(_value)) {
_;
}
}
} }

View File

@ -13,27 +13,6 @@ import "./DayLimit.sol";
* Wallet(w).from(anotherOwner).confirm(h); * Wallet(w).from(anotherOwner).confirm(h);
*/ */
contract MultisigWallet is Multisig, Shareable, DayLimit { 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`. // kills the contract sending everything to `_to`.
function kill(address _to) onlymanyowners(sha3(msg.data)) external { function kill(address _to) onlymanyowners(sha3(msg.data)) external {
suicide(_to); suicide(_to);