From fa8fd3044b2c8a39ac5307883b57d2ae47662e44 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Fri, 12 Aug 2016 11:30:46 -0300 Subject: [PATCH] limitfunds and fixes --- contracts/Bounty.sol | 8 ++------ contracts/GoodFailEarly.sol | 8 ++------ contracts/LimitFunds.sol | 11 +++++++++++ migrations/2_deploy_contracts.js | 1 + 4 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 contracts/LimitFunds.sol diff --git a/contracts/Bounty.sol b/contracts/Bounty.sol index e86eb0112..fcd17917c 100644 --- a/contracts/Bounty.sol +++ b/contracts/Bounty.sol @@ -13,9 +13,7 @@ contract Bounty is PullPaymentCapable { mapping(address => address) public researchers; function() { - if (claimed) { - throw; - } + if (claimed) throw; } function createTarget() returns(Token) { @@ -26,9 +24,7 @@ contract Bounty is PullPaymentCapable { function claim(Token target) { address researcher = researchers[target]; - if (researcher == 0) { - throw; - } + if (researcher == 0) throw; // check Token contract invariants if (target.totalSupply() == target.balance) { throw; diff --git a/contracts/GoodFailEarly.sol b/contracts/GoodFailEarly.sol index f76cb0b68..2cc3bb711 100644 --- a/contracts/GoodFailEarly.sol +++ b/contracts/GoodFailEarly.sol @@ -4,12 +4,8 @@ contract GoodFailEarly { mapping(string => uint) nameToSalary; function getSalary(string name) constant returns (uint) { - if (bytes(name).length == 0) { - throw; - } - if (nameToSalary[name] == 0) { - throw; - } + if (bytes(name).length == 0) throw; + if (nameToSalary[name] == 0) throw; return nameToSalary[name]; } diff --git a/contracts/LimitFunds.sol b/contracts/LimitFunds.sol new file mode 100644 index 000000000..8c8e1c19a --- /dev/null +++ b/contracts/LimitFunds.sol @@ -0,0 +1,11 @@ +contract LimitFunds { + + uint LIMIT = 5000; + + function() { throw; } + + function deposit() { + if (this.balance > LIMIT) throw; + } + +} diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js index 86e1b0b12..6731fa0ec 100644 --- a/migrations/2_deploy_contracts.js +++ b/migrations/2_deploy_contracts.js @@ -2,4 +2,5 @@ module.exports = function(deployer) { deployer.deploy(PullPaymentBid); deployer.deploy(BadArrayUse); deployer.deploy(Bounty); + deployer.deploy(LimitFunds); };