Minor edits to doc commenst in lifecycle, ownership, payment contracts.

pull/210/head
maurelian 8 years ago
parent d85be4a866
commit 83f2849446
  1. 2
      contracts/lifecycle/Destructible.sol
  2. 2
      contracts/lifecycle/Pausable.sol
  3. 24
      contracts/lifecycle/TokenDestructible.sol
  4. 11
      contracts/ownership/Claimable.sol
  5. 6
      contracts/ownership/Contactable.sol
  6. 7
      contracts/ownership/DelayedClaimable.sol
  7. 17
      contracts/ownership/HasNoContracts.sol
  8. 38
      contracts/ownership/HasNoEther.sol
  9. 30
      contracts/ownership/HasNoTokens.sol
  10. 7
      contracts/ownership/Multisig.sol
  11. 10
      contracts/ownership/NoOwner.sol
  12. 8
      contracts/ownership/Ownable.sol
  13. 70
      contracts/ownership/Shareable.sol
  14. 10
      contracts/payment/PullPayment.sol

@ -11,7 +11,7 @@ import "../ownership/Ownable.sol";
contract Destructible is Ownable {
/**
*@dev The destroy function transfer the current balance to the owner and terminate de lifecycle
* @dev Transfers the current balance to the owner and terminates the contract.
*/
function destroy() onlyOwner {
selfdestruct(owner);

@ -6,7 +6,7 @@ import "../ownership/Ownable.sol";
/**
* @title Pausable
* @dev Abstract contract that allows children to implement an emergency stop mechanism.
* @dev Base contract which allows children to implement an emergency stop mechanism.
*/
contract Pausable is Ownable {
event Pause();

@ -4,19 +4,21 @@ pragma solidity ^0.4.8;
import "../ownership/Ownable.sol";
import "../token/ERC20Basic.sol";
/** @title TokenDestructible:
* @author Remco Bloemen <remco@2π.com>
* @dev Base contract that can be destroyed by owner. All funds in contract including
* listed tokens will be sent to the owner
*/
/**
* @title TokenDestructible:
* @author Remco Bloemen <remco@2π.com>
* @dev Base contract that can be destroyed by owner. All funds in contract including
* listed tokens will be sent to the owner.
*/
contract TokenDestructible is Ownable {
/** @notice Terminate contract and refund to owner
* @param tokens List of addresses of ERC20 or ERC20Basic token contracts to
refund
* @notice The called token contracts could try to re-enter this contract.Only
supply token contracts you
*/
/**
* @notice Terminate contract and refund to owner
* @param tokens List of addresses of ERC20 or ERC20Basic token contracts to
refund.
* @notice The called token contracts could try to re-enter this contract. Only
supply token contracts you trust.
*/
function destroy(address[] tokens) onlyOwner {
// Transfer tokens to owner

@ -13,8 +13,7 @@ contract Claimable is Ownable {
address public pendingOwner;
/**
* @dev The onlyPendingOwner modifier throws if called by any account other than the
* pendingOwner.
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
if (msg.sender != pendingOwner) {
@ -24,20 +23,18 @@ contract Claimable is Ownable {
}
/**
* @dev The transferOwnership function allows the current owner to set the pendingOwner
* address.
* @param pendingOwner The address to transfer ownership to.
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner {
pendingOwner = newOwner;
}
/**
* @dev The claimOwnership function allows the pendingOwner address to finalize the transfer.
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() onlyPendingOwner {
owner = pendingOwner;
pendingOwner = 0x0;
}
}

@ -12,12 +12,10 @@ contract Contactable is Ownable{
string public contactInformation;
/**
* @dev The setContactInformation() function allows the current owner to transfer control of the
* contract to a newOwner.
* @param newOwner The address to transfer ownership to.
* @dev Allows the owner to set a string with their contact information.
* @param info The contact information to attach to the contract.
*/
function setContactInformation(string info) onlyOwner{
contactInformation = info;
}
}

@ -15,9 +15,9 @@ contract DelayedClaimable is Claimable {
uint public start;
/**
* @dev the setLimits function can be used to specify the time period during which a pending
* @dev Used to specify the time period during which a pending
* owner can claim ownership.
* @params _start The earliest time ownership can be claimed
* @params _start The earliest time ownership can be claimed.
* @params _end The latest time ownership can be claimed.
*/
function setLimits(uint _start, uint _end) onlyOwner {
@ -29,7 +29,8 @@ contract DelayedClaimable is Claimable {
/**
* @dev setLimit() modifier throws if called by any account other than the owner.
* @dev Allows the pendingOwner address to finalize the transfer, as long as it is called within
* the specified start and end time.
*/
function claimOwnership() onlyPendingOwner {
if ((block.number > end) || (block.number < start))

@ -2,17 +2,18 @@ pragma solidity ^0.4.8;
import "./Ownable.sol";
/** @title Contracts that should not own Contracts
* @author Remco Bloemen <remco@2π.com>
* @dev Should contracts (anything Ownable) end up being owned by this contract, it allows the owner of this contract to reclaim ownership of the contracts.
*/
/**
* @title Contracts that should not own Contracts
* @author Remco Bloemen <remco@2π.com>
* @dev Should contracts (anything Ownable) end up being owned by this contract, it allows the owner
* of this contract to reclaim ownership of the contracts.
*/
contract HasNoContracts is Ownable {
/**
* @dev Reclaim ownership of Ownable contracts
* @param contractAddr address The Ownable contract address wished to
be reclaimed
*/
* @dev Reclaim ownership of Ownable contracts
* @param contractAddr The address of the Ownable to be reclaimed.
*/
function reclaimContract(address contractAddr) external onlyOwner {
Ownable contractInst = Ownable(contractAddr);
contractInst.transferOwnership(owner);

@ -2,27 +2,24 @@ pragma solidity ^0.4.8;
import "./Ownable.sol";
/** @title Contracts that should not own Ether
* @author Remco Bloemen <remco@2π.com>
* @dev This tries to block incoming ether to prevent accidental loss of Ether.
Should Ether end up in the contrat, it will allow the owner to reclaim
this ether.
* @notice Ether can still be send to this contract by:
* calling functions labeled `payable`
* `selfdestruct(contract_address)`
* mining directly to the contract address
/**
* @title Contracts that should not own Ether
* @author Remco Bloemen <remco@2π.com>
* @dev This tries to block incoming ether to prevent accidental loss of Ether. Should Ether end up
* in the contract, it will allow the owner to reclaim this ether.
* @notice Ether can still be send to this contract by:
* calling functions labeled `payable`
* `selfdestruct(contract_address)`
* mining directly to the contract address
*/
contract HasNoEther is Ownable {
/**
* @dev Constructor that rejects incoming Ether
* @dev The flag `payable` is added so we can access `msg.value`
without compiler warning. If we leave out payable, then
Solidity will allow inheriting contracts to implement a
payable constructor. By doing it this way we prevent a
payable constructor from working. Alternatively we could
use assembly to access msg.value.
* @dev The `payable` flag is added so we can access `msg.value` without compiler warning. If we
* leave out payable, then Solidity will allow inheriting contracts to implement a payable
* constructor. By doing it this way we prevent a payable constructor from working. Alternatively
* we could use assembly to access msg.value.
*/
function HasNoEther() payable {
if(msg.value > 0) {
@ -31,15 +28,14 @@ contract HasNoEther is Ownable {
}
/**
* @dev Disallow direct send by settings a default function without `payable`
*/
* @dev Disallows direct send by settings a default function without the `payable` flag.
*/
function() external {
}
/**
* @dev Transfer all Ether owned by the contract to the owner
* @dev What if owner is itself a contract marked HasNoEther?
*/
* @dev Transfer all Ether held by the contract to the owner.
*/
function reclaimEther() external onlyOwner {
if(!owner.send(this.balance)) {
throw;

@ -3,27 +3,29 @@ pragma solidity ^0.4.8;
import "./Ownable.sol";
import "../token/ERC20Basic.sol";
/** @title Contracts that should not own Tokens
* @author Remco Bloemen <remco@2π.com>
* @dev This blocks incoming ERC23 tokens to prevent accidental loss of tokens.
Should tokens (any ERC20Basic compatible) end up in the contract, it allows the
owner to reclaim the tokens.
*/
/**
* @title Contracts that should not own Tokens
* @author Remco Bloemen <remco@2π.com>
* @dev This blocks incoming ERC23 tokens to prevent accidental loss of tokens.
* Should tokens (any ERC20Basic compatible) end up in the contract, it allows the
* owner to reclaim the tokens.
*/
contract HasNoTokens is Ownable {
/** @dev Reject all ERC23 compatible tokens
* @param from_ address The address that is transfering the tokens
* @param value_ Uint the amount of the specified token
* @param data_ Bytes The data passed from the caller.
*/
/**
* @dev Reject all ERC23 compatible tokens
* @param from_ address The address that is transferring the tokens
* @param value_ Uint the amount of the specified token
* @param data_ Bytes The data passed from the caller.
*/
function tokenFallback(address from_, uint value_, bytes data_) external {
throw;
}
/**
* @dev Reclaim all ERC20Basic compatible tokens
* @param tokenAddr address The address of the token contract
*/
* @dev Reclaim all ERC20Basic compatible tokens
* @param tokenAddr address The address of the token contract
*/
function reclaimToken(address tokenAddr) external onlyOwner {
ERC20Basic tokenInst = ERC20Basic(tokenAddr);
uint256 balance = tokenInst.balanceOf(this);

@ -1,9 +1,9 @@
pragma solidity ^0.4.8;
/*
* Multisig
* Interface contract for multisig proxy contracts; see below for docs.
/**
* @title Multisig
* @dev Interface contract for multisig proxy contracts; see below for docs.
*/
contract Multisig {
// EVENTS
@ -26,4 +26,3 @@ contract Multisig {
function execute(address _to, uint _value, bytes _data) external returns (bytes32);
function confirm(bytes32 _h) returns (bool);
}

@ -4,9 +4,11 @@ import "./HasNoEther.sol";
import "./HasNoTokens.sol";
import "./HasNoContracts.sol";
/** @title Base contract for contracts that should not own things.
* @author Remco Bloemen <remco@2π.com>
* @devSolves a class of errors where a contract accidentally becomes owner of Ether, Tokens or Owned contracts. See respective base contracts for details.
*/
/**
* @title Base contract for contracts that should not own things.
* @author Remco Bloemen <remco@2π.com>
* @dev Solves a class of errors where a contract accidentally becomes owner of Ether, Tokens or
* Owned contracts. See respective base contracts for details.
*/
contract NoOwner is HasNoEther, HasNoTokens, HasNoContracts {
}

@ -3,9 +3,8 @@ pragma solidity ^0.4.8;
/**
* @title Ownable
*
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
@ -21,7 +20,7 @@ contract Ownable {
/**
* @dev The onlyOwner modifier throws if called by any account other than the owner.
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
if (msg.sender != owner) {
@ -32,8 +31,7 @@ contract Ownable {
/**
* @dev The transferOwnership function allows the current owner to transfer control of the
* contract to a newOwner.
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner {

@ -3,8 +3,8 @@ pragma solidity ^0.4.8;
/**
* @title Shareable
* @dev inheritable "property" contract that enables methods to be protected by requiring the acquiescence of either a single, or, crucially, each of a number of, designated owners.
*
* @dev inheritable "property" contract that enables methods to be protected by requiring the
* acquiescence of either a single, or, crucially, each of a number of, designated owners.
* @dev Usage: use modifiers onlyowner (just own owned) or onlymanyowners(hash), whereby the same hash must be provided by some number (specified in constructor) of the set of owners (specified in the constructor) before the interior is executed.
*/
contract Shareable {
@ -41,21 +41,25 @@ contract Shareable {
}
_;
}
// multi-sig function modifier: the operation must have an intrinsic hash in order
// that later attempts can be realised as the same underlying operation and
// thus count as confirmations.
/**
* @dev Modifier for multisig functions.
* @param _operation The operation must have an intrinsic hash in order
* that later attempts can be realised as the same underlying operation and
* thus count as confirmations.
*/
modifier onlymanyowners(bytes32 _operation) {
if (confirmAndCheck(_operation)) {
_;
}
}
/** @dev Constructor is given number of sigs required to do protected "onlymanyowners" transactions
* as well as the selection of addresses capable of confirming them.
* @param _owners address[] A list of owners
* @param _required Uint The amout required for a transaction to be approved.
*/
/**
* @dev Constructor is given the number of sigs required to do protected "onlymanyowners"
* transactions as well as the selection of addresses capable of confirming them.
* @param _owners A list of owners.
* @param _required The amount required for a transaction to be approved.
*/
function Shareable(address[] _owners, uint _required) {
owners[1] = msg.sender;
ownerIndex[msg.sender] = 1;
@ -70,9 +74,9 @@ contract Shareable {
}
/**
* @dev Revokes a prior confirmation of the given operation
* @param _operation bytes32 A string the identfies the operation.
*/
* @dev Revokes a prior confirmation of the given operation
* @param _operation bytes32 A string the identfies the operation.
*/
function revoke(bytes32 _operation) external {
uint index = ownerIndex[msg.sender];
// make sure they're an owner
@ -89,29 +93,29 @@ contract Shareable {
}
/**
* @dev Gets an owner by 0-indexed position (using numOwners as the count)
* @param ownerIndex Uint The index of the owner
* @return The address of the owner
*/
* @dev Gets an owner by 0-indexed position (using numOwners as the count)
* @param ownerIndex Uint The index of the owner
* @return The address of the owner
*/
function getOwner(uint ownerIndex) external constant returns (address) {
return address(owners[ownerIndex + 1]);
}
/**
* @dev Checks if given address is an owner.
* @param _addr address The address which you want to check.
* @return True if the address is an owner and fase otherwise.
*/
* @dev Checks if given address is an owner.
* @param _addr address The address which you want to check.
* @return True if the address is an owner and fase otherwise.
*/
function isOwner(address _addr) constant returns (bool) {
return ownerIndex[_addr] > 0;
}
/**
* @dev Function to check is specific owner has already confirme the operation
* @param _operation bytes32 The operation identifier
* @param _owner address The owner address
* @return True if the owner has confirmed and flase otherwise
*/
* @dev Function to check is specific owner has already confirme the operation.
* @param _operation The operation identifier.
* @param _owner The owner address.
* @return True if the owner has confirmed and false otherwise.
*/
function hasConfirmed(bytes32 _operation, address _owner) constant returns (bool) {
var pending = pendings[_operation];
uint index = ownerIndex[_owner];
@ -127,10 +131,10 @@ contract Shareable {
}
/**
* @dev Confirm and operation and checks if it's already executable
* @param _operation bytes32 The operation identifier
* @return returns true when operation can be executed
*/
* @dev Confirm and operation and checks if it's already executable.
* @param _operation The operation identifier.
* @return Returns true when operation can be executed.
*/
function confirmAndCheck(bytes32 _operation) internal returns (bool) {
// determine what index the present sender is:
uint index = ownerIndex[msg.sender];
@ -171,8 +175,8 @@ contract Shareable {
/**
* @dev Clear the pedings list.
*/
* @dev Clear the pending list.
*/
function clearPending() internal {
uint length = pendingsIndex.length;
for (uint i = 0; i < length; ++i) {

@ -7,7 +7,7 @@ import '../SafeMath.sol';
/**
* @title PullPayment
* @dev Base contract supporting async send for pull payments. Inherit from this
contract and use asyncSend instead of send.
* contract and use asyncSend instead of send.
*/
contract PullPayment {
using SafeMath for uint;
@ -16,9 +16,9 @@ contract PullPayment {
uint public totalPayments;
/**
* @dev store sent amount as credit to be pulled, called by payer
* @param dest address The destination address of the funds
* @param amount uint The amount to transfer
* @dev Called by the payer to store the sent amount as credit to be pulled.
* @param dest The destination address of the funds.
* @param amount The amount to transfer.
*/
function asyncSend(address dest, uint amount) internal {
payments[dest] = payments[dest].add(amount);
@ -26,7 +26,7 @@ contract PullPayment {
}
/**
@dev withdraw accumulated balance, called by payee.
* @dev withdraw accumulated balance, called by payee.
*/
function withdrawPayments() {
address payee = msg.sender;

Loading…
Cancel
Save