From 793f0b2e6a2021727e50266d82254c037080b4e2 Mon Sep 17 00:00:00 2001 From: Jerome de Tychey Date: Fri, 2 Jun 2017 22:35:27 +0200 Subject: [PATCH] Update clientreceipt.sol upgrading to new compiler and improve readability --- clientreceipt/clientreceipt.sol | 34 ++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/clientreceipt/clientreceipt.sol b/clientreceipt/clientreceipt.sol index a24f2c2..98889cb 100644 --- a/clientreceipt/clientreceipt.sol +++ b/clientreceipt/clientreceipt.sol @@ -1,48 +1,52 @@ +pragma solidity ^0.4.10; import "owned"; - contract killswitch is owned { + /* State variables */ + bool isOpen; + address keyholder; + address executive; + /* Modifiers */ + modifier restricted { + require(msg.sender == owner || (isOpen && msg.sender == executive)); + _; + } + /* Events */ event NomineesChanged(address keyholder, address executive); event BoxOpened(); event BoxClosed(); + /* Methods */ function nominate(address _keyholder, address _executive) onlyowner { keyholder = _keyholder; executive = _executive; NomineesChanged(keyholder, executive); } - function open() { - if (msg.sender == owner || msg.sender == keyholder) { + require(msg.sender == owner || msg.sender == keyholder) { isOpen = true; BoxOpened(); } } function close() { - if (msg.sender == owner || msg.sender == keyholder) { + require(msg.sender == owner || msg.sender == keyholder) { isOpen = false; BoxClosed(); } } - modifier restricted { - if (msg.sender == owner || (isOpen && msg.sender == executive)) { - _ - } - } - bool isOpen; - address keyholder; - address executive; } contract ClientReceipt is owned, killswitch { + /* Events */ event AnonymousDeposit(address indexed _from, uint _value); event Deposit(address indexed _from, bytes32 _id, uint _value); event Refill(address indexed _from, uint _value); event Withdraw(address indexed _from, address indexed _to, uint _value); event Drain(address indexed _from, address indexed _to, uint _value); - - function() { + /* fallback function */ + function() payable { AnonymousDeposit(msg.sender, msg.value); } + /* Methods */ function deposit(bytes32 _id) { Deposit(msg.sender, _id, msg.value); } @@ -57,4 +61,4 @@ contract ClientReceipt is owned, killswitch { _to.send(_value); Drain(msg.sender, _to, _value); } -} \ No newline at end of file +}