From e8519381991466f2eba6cfb1a61fddc742aaf2c9 Mon Sep 17 00:00:00 2001 From: maurelian Date: Tue, 25 Apr 2017 08:51:05 -0400 Subject: [PATCH 01/10] Add natspec comments to four ownership contracts --- contracts/ownership/Claimable.sol | 20 ++++++++++++++++---- contracts/ownership/Contactable.sol | 17 ++++++++++++----- contracts/ownership/DelayedClaimable.sol | 17 ++++++++++++++--- contracts/ownership/Ownable.sol | 23 +++++++++++++++++++---- 4 files changed, 61 insertions(+), 16 deletions(-) diff --git a/contracts/ownership/Claimable.sol b/contracts/ownership/Claimable.sol index e825f28bf..899606d67 100644 --- a/contracts/ownership/Claimable.sol +++ b/contracts/ownership/Claimable.sol @@ -4,14 +4,18 @@ pragma solidity ^0.4.8; import './Ownable.sol'; -/* - * Claimable - * - * Extension for the Ownable contract, where the ownership needs to be claimed. This allows the new owner to accept the transfer. +/** + * @title Claimable + * @dev Extension for the Ownable contract, where the ownership needs to be claimed. + * This allows the new owner to accept the transfer. */ contract Claimable is Ownable { address public pendingOwner; + /** + * @dev The onlyPendingOwner modifier throws if called by any account other than the + * pendingOwner. + */ modifier onlyPendingOwner() { if (msg.sender != pendingOwner) { throw; @@ -19,10 +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. + */ function transferOwnership(address newOwner) onlyOwner { pendingOwner = newOwner; } + /** + * @dev The claimOwnership function allows the pendingOwner address to finalize the transfer. + */ function claimOwnership() onlyPendingOwner { owner = pendingOwner; pendingOwner = 0x0; diff --git a/contracts/ownership/Contactable.sol b/contracts/ownership/Contactable.sol index f9d5800a1..824bc7498 100644 --- a/contracts/ownership/Contactable.sol +++ b/contracts/ownership/Contactable.sol @@ -1,15 +1,22 @@ pragma solidity ^0.4.8; import './Ownable.sol'; -/* - * Contactable token - * Basic version of a contactable contract + +/** + * @title Contactable token + * @dev Basic version of a contactable contract, allowing the owner to provide a string with their + * contact information. */ contract Contactable is Ownable{ - string public contactInformation; + string public contactInformation; - function setContactInformation(string info) onlyOwner{ + /** + * @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. + */ + function setContactInformation(string info) onlyOwner{ contactInformation = info; } diff --git a/contracts/ownership/DelayedClaimable.sol b/contracts/ownership/DelayedClaimable.sol index 77425d805..5af3828d8 100644 --- a/contracts/ownership/DelayedClaimable.sol +++ b/contracts/ownership/DelayedClaimable.sol @@ -4,15 +4,22 @@ pragma solidity ^0.4.8; import './Claimable.sol'; -/* - * DelayedClaimable - * Extension for the Claimable contract, where the ownership needs to be claimed before/after certain block number +/** + * @title DelayedClaimable + * @dev Extension for the Claimable contract, where the ownership needs to be claimed before/after + * a certain block number. */ contract DelayedClaimable is Claimable { uint public end; uint public start; + /** + * @dev the setLimits function can be used to specify the time period during which a pending + * owner can claim ownership. + * @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 { if (_start > _end) throw; @@ -20,6 +27,10 @@ contract DelayedClaimable is Claimable { start = _start; } + + /** + * @dev setLimit() modifier throws if called by any account other than the owner. + */ function claimOwnership() onlyPendingOwner { if ((block.number > end) || (block.number < start)) throw; diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index 53c56a789..23f7efbd2 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -1,19 +1,28 @@ pragma solidity ^0.4.8; -/* - * Ownable +/** + * @title Ownable * - * Base contract with an owner. - * Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner. + * @dev The Ownable contract has an owner address, and provides basic authorization control + * functions, this simplifies the implementation of "user permissions". */ contract Ownable { address public owner; + + /** + * @dev The Ownable constructor sets the original `owner` of the contract to the sender + * account. + */ function Ownable() { owner = msg.sender; } + + /** + * @dev The onlyOwner modifier throws if called by any account other than the owner. + */ modifier onlyOwner() { if (msg.sender != owner) { throw; @@ -21,6 +30,12 @@ contract Ownable { _; } + + /** + * @dev The transferOwnership function 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 { if (newOwner != address(0)) { owner = newOwner; From b5d4120adbd43cd5d251a454cf56a13bd003e9cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gabriel=20Carvalho?= Date: Tue, 25 Apr 2017 19:16:02 -0300 Subject: [PATCH 02/10] Added natsec for all lifecycle contracts + bounty.sol, DayLimit.sol and LimitBalance.sol --- contracts/Bounty.sol | 32 ++++++++++++++----- contracts/DayLimit.sol | 38 +++++++++++++++-------- contracts/LimitBalance.sol | 20 +++++++----- contracts/lifecycle/Destructible.sol | 8 +++-- contracts/lifecycle/Migrations.sol | 6 ++-- contracts/lifecycle/Pausable.sol | 22 +++++++++---- contracts/lifecycle/TokenDestructible.sol | 2 +- 7 files changed, 90 insertions(+), 38 deletions(-) diff --git a/contracts/Bounty.sol b/contracts/Bounty.sol index 621d33c11..d24edeb8b 100644 --- a/contracts/Bounty.sol +++ b/contracts/Bounty.sol @@ -6,9 +6,8 @@ import './lifecycle/Destructible.sol'; /* - * Bounty - * - * This bounty will pay out to a researcher if they break invariant logic of the contract. + * @title Bounty + * @dev This bounty will pay out to a researcher if they break invariant logic of the contract. */ contract Bounty is PullPayment, Destructible { bool public claimed; @@ -16,12 +15,19 @@ contract Bounty is PullPayment, Destructible { event TargetCreated(address createdAddress); + /* + * @dev Function that allows the contract to recieve funds, if it hasn't been claimed. + */ function() payable { if (claimed) { throw; } } + /* + * @dev Create and deploy the target contract(extension of Target contract), and sets the msg.sender as a researcher + * @return A target contract + */ function createTarget() returns(Target) { Target target = Target(deployContract()); researchers[target] = msg.sender; @@ -29,8 +35,16 @@ contract Bounty is PullPayment, Destructible { return target; } + /* + * @dev Internal function to deploy the target contract. + * @return A target contract address + */ function deployContract() internal returns(address); + /* + * @dev Sends the contract funds to the researcher that proved the contract is broken. + * @param Target contract + */ function claim(Target target) { address researcher = researchers[target]; if (researcher == 0) { @@ -48,11 +62,15 @@ contract Bounty is PullPayment, Destructible { /* - * Target - * - * Your main contract should inherit from this class and implement the checkInvariant method. This is a function that should check everything your contract assumes to be true all the time. If this function returns false, it means your contract was broken in some way and is in an inconsistent state. This is what security researchers will try to acomplish when trying to get the bounty. + * @title Target + * + * @dev Your main contract should inherit from this class and implement the checkInvariant method. */ contract Target { + + /* + * @dev Funtion tha should check everything your contract assumes to be true all the time. If this function returns false, it means your contract was broken in some way and is in an inconsistent state. This is what security researchers will try to acomplish when trying to get the bounty. + * @return A boolean that indicates if the contract is broken or not. + */ function checkInvariant() returns(bool); } - diff --git a/contracts/DayLimit.sol b/contracts/DayLimit.sol index 2e22fbcb0..960e5d33d 100644 --- a/contracts/DayLimit.sol +++ b/contracts/DayLimit.sol @@ -1,11 +1,8 @@ pragma solidity ^0.4.8; /* - * DayLimit - * - * inheritable "property" contract that enables methods to be protected by placing a linear limit (specifiable) - * on a particular resource per calendar day. is multiowned to allow the limit to be altered. resource that method - * uses is specified in the modifier. + * @title DayLimit + * @dev Base contract that enables methods to be protected by placing a linear limit (specifiable) on a particular resource per calendar day. Is multiowned to allow the limit to be altered */ contract DayLimit { @@ -13,24 +10,35 @@ contract DayLimit { uint public spentToday; uint public lastDay; - + /* + * @dev Constructor that sets the passed value as a dailyLimit + * @param _limit Uint to represent the daily limit. + */ function DayLimit(uint _limit) { dailyLimit = _limit; lastDay = today(); } - // sets the daily limit. doesn't alter the amount already spent today + /* + * @dev sets the daily limit. doesn't alter the amount already spent today + * @param _newLimit Uint to represent the new limit. + */ function _setDailyLimit(uint _newLimit) internal { dailyLimit = _newLimit; } - // resets the amount already spent today. + /* + * @dev Resets the amount already spent today. + */ function _resetSpentToday() internal { spentToday = 0; } - // 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. + /* + * @dev Checks to see if there is enough resource to spend today. If true, the resource is expended. + * @param _value Uint representing the amout of resurce to spend. + * @return Boolean. True if the resource was spended and false otherwise. + */ function underLimit(uint _value) internal returns (bool) { // reset the spend limit if we're on a different day to last time. if (today() > lastDay) { @@ -46,13 +54,17 @@ contract DayLimit { return false; } - // determines today's index. + /* + * @dev Private function to determine today index + * @return Uint of todays index. + */ function today() private constant returns (uint) { return now / 1 days; } - - // simple modifier for daily limit. + /* + * @dev Simple modifier for daily limit. + */ modifier limitedDaily(uint _value) { if (!underLimit(_value)) { throw; diff --git a/contracts/LimitBalance.sol b/contracts/LimitBalance.sol index 8d73eb9e9..62a5b5c5b 100644 --- a/contracts/LimitBalance.sol +++ b/contracts/LimitBalance.sol @@ -2,26 +2,32 @@ pragma solidity ^0.4.8; /** - * LimitBalance - * Simple contract to limit the balance of child contract. - * Note this doesn't prevent other contracts to send funds - * by using selfdestruct(address); - * See: https://github.com/ConsenSys/smart-contract-best-practices#remember-that-ether-can-be-forcibly-sent-to-an-account + * @title LimitBalance + * @dev Simple contract to limit the balance of child contract. + * @dev Note this doesn't prevent other contracts to send funds by using selfdestruct(address); + * @dev See: https://github.com/ConsenSys/smart-contract-best-practices#remember-that-ether-can-be-forcibly-sent-to-an-account */ contract LimitBalance { uint public limit; + /* + * @dev Constructor that sets the passed value as a limit + * @param _limit Uint to represent the limit. + */ function LimitBalance(uint _limit) { limit = _limit; } - modifier limitedPayable() { + /* + * @dev Checks if limit was reached. Case true, it throws. + */ + modifier limitedPayable() { if (this.balance > limit) { throw; } _; - + } } diff --git a/contracts/lifecycle/Destructible.sol b/contracts/lifecycle/Destructible.sol index 05d4966f0..a4a5728d9 100644 --- a/contracts/lifecycle/Destructible.sol +++ b/contracts/lifecycle/Destructible.sol @@ -5,10 +5,14 @@ import "../ownership/Ownable.sol"; /* - * Destructible - * Base contract that can be destroyed by owner. All funds in contract will be sent to the owner. + * @title Destructible + * @dev Base contract that can be destroyed by owner. All funds in contract will be sent to the owner. */ contract Destructible is Ownable { + + /* + *@dev The destroy function transfer the current balance to the owner and terminate de lifecycle + */ function destroy() onlyOwner { selfdestruct(owner); } diff --git a/contracts/lifecycle/Migrations.sol b/contracts/lifecycle/Migrations.sol index b503c6d7b..1ad337183 100644 --- a/contracts/lifecycle/Migrations.sol +++ b/contracts/lifecycle/Migrations.sol @@ -3,8 +3,10 @@ pragma solidity ^0.4.8; import '../ownership/Ownable.sol'; - -// This is a truffle contract, needed for truffle integration, not meant for use by Zeppelin users. +/* + * @title Migrations + * @dev This is a truffle contract, needed for truffle integration, not meant for use by Zeppelin users. + */ contract Migrations is Ownable { uint public lastCompletedMigration; diff --git a/contracts/lifecycle/Pausable.sol b/contracts/lifecycle/Pausable.sol index 9ebefad15..419159086 100644 --- a/contracts/lifecycle/Pausable.sol +++ b/contracts/lifecycle/Pausable.sol @@ -4,10 +4,9 @@ pragma solidity ^0.4.8; import "../ownership/Ownable.sol"; -/* - * Pausable - * Abstract contract that allows children to implement a - * pause mechanism. +/** + * @title Pausable + * @dev Abstract contract that allows children to implement an emergency stop mechanism. */ contract Pausable is Ownable { event Pause(); @@ -15,24 +14,35 @@ contract Pausable is Ownable { bool public paused = false; + + /** + * @dev modifier to allow actions only when the contract IS paused + */ modifier whenNotPaused() { if (paused) throw; _; } + /** + * @dev modifier to allow actions only when the contract IS NOT paused + */ modifier whenPaused { if (!paused) throw; _; } - // called by the owner to pause, triggers stopped state + /** + * @dev called by the owner to pause, triggers stopped state + */ function pause() onlyOwner whenNotPaused returns (bool) { paused = true; Pause(); return true; } - // called by the owner to unpause, returns to normal state + /** + * @dev called by the owner to unpause, returns to normal state + */ function unpause() onlyOwner whenPaused returns (bool) { paused = false; Unpause(); diff --git a/contracts/lifecycle/TokenDestructible.sol b/contracts/lifecycle/TokenDestructible.sol index 69c686ff8..dab03c52a 100644 --- a/contracts/lifecycle/TokenDestructible.sol +++ b/contracts/lifecycle/TokenDestructible.sol @@ -6,7 +6,7 @@ import "../token/ERC20Basic.sol"; /// @title TokenDestructible: /// @author Remco Bloemen -///.Base contract that can be destroyed by owner. All funds in contract including +/// @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 { From 602c18b394dc5b424549bf283575c0698c009aa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gabriel=20Carvalho?= Date: Sat, 29 Apr 2017 12:56:46 -0300 Subject: [PATCH 03/10] Applied change regarding the styling --- contracts/Bounty.sol | 15 +++++++-------- contracts/DayLimit.sol | 16 ++++++++-------- contracts/LimitBalance.sol | 4 ++-- contracts/lifecycle/Destructible.sol | 4 ++-- contracts/lifecycle/Migrations.sol | 2 +- contracts/lifecycle/TokenDestructible.sol | 20 +++++++++++--------- 6 files changed, 31 insertions(+), 30 deletions(-) diff --git a/contracts/Bounty.sol b/contracts/Bounty.sol index d24edeb8b..0d2871cd8 100644 --- a/contracts/Bounty.sol +++ b/contracts/Bounty.sol @@ -5,7 +5,7 @@ import './payment/PullPayment.sol'; import './lifecycle/Destructible.sol'; -/* +/** * @title Bounty * @dev This bounty will pay out to a researcher if they break invariant logic of the contract. */ @@ -15,7 +15,7 @@ contract Bounty is PullPayment, Destructible { event TargetCreated(address createdAddress); - /* + /** * @dev Function that allows the contract to recieve funds, if it hasn't been claimed. */ function() payable { @@ -24,7 +24,7 @@ contract Bounty is PullPayment, Destructible { } } - /* + /** * @dev Create and deploy the target contract(extension of Target contract), and sets the msg.sender as a researcher * @return A target contract */ @@ -35,13 +35,13 @@ contract Bounty is PullPayment, Destructible { return target; } - /* + /** * @dev Internal function to deploy the target contract. * @return A target contract address */ function deployContract() internal returns(address); - /* + /** * @dev Sends the contract funds to the researcher that proved the contract is broken. * @param Target contract */ @@ -61,14 +61,13 @@ contract Bounty is PullPayment, Destructible { } -/* +/** * @title Target - * * @dev Your main contract should inherit from this class and implement the checkInvariant method. */ contract Target { - /* + /** * @dev Funtion tha should check everything your contract assumes to be true all the time. If this function returns false, it means your contract was broken in some way and is in an inconsistent state. This is what security researchers will try to acomplish when trying to get the bounty. * @return A boolean that indicates if the contract is broken or not. */ diff --git a/contracts/DayLimit.sol b/contracts/DayLimit.sol index 960e5d33d..aba01d07f 100644 --- a/contracts/DayLimit.sol +++ b/contracts/DayLimit.sol @@ -1,6 +1,6 @@ pragma solidity ^0.4.8; -/* +/** * @title DayLimit * @dev Base contract that enables methods to be protected by placing a linear limit (specifiable) on a particular resource per calendar day. Is multiowned to allow the limit to be altered */ @@ -10,7 +10,7 @@ contract DayLimit { uint public spentToday; uint public lastDay; - /* + /** * @dev Constructor that sets the passed value as a dailyLimit * @param _limit Uint to represent the daily limit. */ @@ -19,7 +19,7 @@ contract DayLimit { lastDay = today(); } - /* + /** * @dev sets the daily limit. doesn't alter the amount already spent today * @param _newLimit Uint to represent the new limit. */ @@ -27,17 +27,17 @@ contract DayLimit { dailyLimit = _newLimit; } - /* + /** * @dev Resets the amount already spent today. */ function _resetSpentToday() internal { spentToday = 0; } - /* + /** * @dev Checks to see if there is enough resource to spend today. If true, the resource is expended. * @param _value Uint representing the amout of resurce to spend. - * @return Boolean. True if the resource was spended and false otherwise. + * @return A boolean that is True if the resource was spended and false otherwise. */ function underLimit(uint _value) internal returns (bool) { // reset the spend limit if we're on a different day to last time. @@ -54,7 +54,7 @@ contract DayLimit { return false; } - /* + /** * @dev Private function to determine today index * @return Uint of todays index. */ @@ -62,7 +62,7 @@ contract DayLimit { return now / 1 days; } - /* + /** * @dev Simple modifier for daily limit. */ modifier limitedDaily(uint _value) { diff --git a/contracts/LimitBalance.sol b/contracts/LimitBalance.sol index 62a5b5c5b..eb3edc394 100644 --- a/contracts/LimitBalance.sol +++ b/contracts/LimitBalance.sol @@ -11,7 +11,7 @@ contract LimitBalance { uint public limit; - /* + /** * @dev Constructor that sets the passed value as a limit * @param _limit Uint to represent the limit. */ @@ -19,7 +19,7 @@ contract LimitBalance { limit = _limit; } - /* + /** * @dev Checks if limit was reached. Case true, it throws. */ modifier limitedPayable() { diff --git a/contracts/lifecycle/Destructible.sol b/contracts/lifecycle/Destructible.sol index a4a5728d9..ad6afe682 100644 --- a/contracts/lifecycle/Destructible.sol +++ b/contracts/lifecycle/Destructible.sol @@ -4,13 +4,13 @@ pragma solidity ^0.4.8; import "../ownership/Ownable.sol"; -/* +/** * @title Destructible * @dev Base contract that can be destroyed by owner. All funds in contract will be sent to the owner. */ contract Destructible is Ownable { - /* + /** *@dev The destroy function transfer the current balance to the owner and terminate de lifecycle */ function destroy() onlyOwner { diff --git a/contracts/lifecycle/Migrations.sol b/contracts/lifecycle/Migrations.sol index 1ad337183..8cc949ae0 100644 --- a/contracts/lifecycle/Migrations.sol +++ b/contracts/lifecycle/Migrations.sol @@ -3,7 +3,7 @@ pragma solidity ^0.4.8; import '../ownership/Ownable.sol'; -/* +/** * @title Migrations * @dev This is a truffle contract, needed for truffle integration, not meant for use by Zeppelin users. */ diff --git a/contracts/lifecycle/TokenDestructible.sol b/contracts/lifecycle/TokenDestructible.sol index dab03c52a..ab473fb73 100644 --- a/contracts/lifecycle/TokenDestructible.sol +++ b/contracts/lifecycle/TokenDestructible.sol @@ -4,17 +4,19 @@ pragma solidity ^0.4.8; import "../ownership/Ownable.sol"; import "../token/ERC20Basic.sol"; -/// @title TokenDestructible: -/// @author Remco Bloemen -/// @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 +* @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 + */ function destroy(address[] tokens) onlyOwner { // Transfer tokens to owner From 1547922b6115d185d680a84afc5022675d97384a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gabriel=20Carvalho?= Date: Mon, 1 May 2017 13:48:20 -0300 Subject: [PATCH 04/10] Added natspec to the remaining ownership contracts and payment contracts --- contracts/ownership/HasNoContracts.sol | 16 ++++---- contracts/ownership/HasNoEther.sol | 48 +++++++++++++----------- contracts/ownership/HasNoTokens.sol | 24 +++++++----- contracts/ownership/NoOwner.sol | 10 ++--- contracts/ownership/Shareable.sol | 52 +++++++++++++++++++------- contracts/payment/PullPayment.sol | 18 ++++++--- 6 files changed, 106 insertions(+), 62 deletions(-) diff --git a/contracts/ownership/HasNoContracts.sol b/contracts/ownership/HasNoContracts.sol index 842638dc2..3d3dee2bb 100644 --- a/contracts/ownership/HasNoContracts.sol +++ b/contracts/ownership/HasNoContracts.sol @@ -2,15 +2,17 @@ pragma solidity ^0.4.8; import "./Ownable.sol"; -/// @title Contracts that should not own Contracts -/// @author Remco Bloemen -/// -/// 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 +* @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 { - /// Reclaim ownership of Ownable contracts + /** + * @dev Reclaim ownership of Ownable contracts + * @param contractAddr address The Ownable contract address wished to + be reclaimed + */ function reclaimContract(address contractAddr) external onlyOwner { Ownable contractInst = Ownable(contractAddr); contractInst.transferOwnership(owner); diff --git a/contracts/ownership/HasNoEther.sol b/contracts/ownership/HasNoEther.sol index 765983791..d18745d0d 100644 --- a/contracts/ownership/HasNoEther.sol +++ b/contracts/ownership/HasNoEther.sol @@ -2,38 +2,44 @@ pragma solidity ^0.4.8; import "./Ownable.sol"; -/// @title Contracts that should not own Ether -/// @author Remco Bloemen -/// -/// 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 + +* @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 +*/ contract HasNoEther is Ownable { - /// 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 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. + */ function HasNoEther() payable { if(msg.value > 0) { throw; } } - /// Disallow direct send by settings a default function without `payable` + /** + * @dev Disallow direct send by settings a default function without `payable` + */ function() external { } - /// Transfer all Ether owned by the contract to the owner - /// @dev What if owner is itself a contract marked HasNoEther? + /** + * @dev Transfer all Ether owned by the contract to the owner + * @dev What if owner is itself a contract marked HasNoEther? + */ function reclaimEther() external onlyOwner { if(!owner.send(this.balance)) { throw; diff --git a/contracts/ownership/HasNoTokens.sol b/contracts/ownership/HasNoTokens.sol index 9b376930b..533d57db8 100644 --- a/contracts/ownership/HasNoTokens.sol +++ b/contracts/ownership/HasNoTokens.sol @@ -3,21 +3,27 @@ pragma solidity ^0.4.8; import "./Ownable.sol"; import "../token/ERC20Basic.sol"; -/// @title Contracts that should not own Tokens -/// @author Remco Bloemen -/// -/// 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 +* @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 { - /// Reject all ERC23 compatible tokens + /** @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. + */ function tokenFallback(address from_, uint value_, bytes data_) external { throw; } - /// Reclaim all ERC20Basic compatible tokens + /** + * @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); diff --git a/contracts/ownership/NoOwner.sol b/contracts/ownership/NoOwner.sol index f7a567e56..ff06b7ae1 100644 --- a/contracts/ownership/NoOwner.sol +++ b/contracts/ownership/NoOwner.sol @@ -4,11 +4,9 @@ import "./HasNoEther.sol"; import "./HasNoTokens.sol"; import "./HasNoContracts.sol"; -/// @title Base contract for contracts that should not own things. -/// @author Remco Bloemen -/// -/// Solves 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 +* @devSolves 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 { } diff --git a/contracts/ownership/Shareable.sol b/contracts/ownership/Shareable.sol index 8b8477d41..e9d7f4671 100644 --- a/contracts/ownership/Shareable.sol +++ b/contracts/ownership/Shareable.sol @@ -1,17 +1,14 @@ pragma solidity ^0.4.8; -/* - * Shareable +/** + * @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. * - * Based on https://github.com/ethereum/dapp-bin/blob/master/wallet/wallet.sol - * - * 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. - * - * 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. + * @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 { + // struct for the status of a pending operation. struct PendingState { uint yetNeeded; @@ -54,8 +51,11 @@ contract Shareable { } } - // constructor is given number of sigs required to do protected "onlymanyowners" transactions - // as well as the selection of addresses capable of confirming them. + /** @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. + */ function Shareable(address[] _owners, uint _required) { owners[1] = msg.sender; ownerIndex[msg.sender] = 1; @@ -69,7 +69,10 @@ contract Shareable { } } - // Revokes a prior confirmation of the given 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 @@ -85,15 +88,30 @@ contract Shareable { } } - // Gets an owner by 0-indexed position (using numOwners as the count) + /** + * @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. + */ 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 + */ function hasConfirmed(bytes32 _operation, address _owner) constant returns (bool) { var pending = pendings[_operation]; uint index = ownerIndex[_owner]; @@ -108,7 +126,11 @@ contract Shareable { return !(pending.ownersDone & ownerIndexBit == 0); } - // returns true when operation can be executed + /** + * @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 + */ function confirmAndCheck(bytes32 _operation) internal returns (bool) { // determine what index the present sender is: uint index = ownerIndex[msg.sender]; @@ -147,6 +169,10 @@ contract Shareable { return false; } + + /** + * @dev Clear the pedings list. + */ function clearPending() internal { uint length = pendingsIndex.length; for (uint i = 0; i < length; ++i) { diff --git a/contracts/payment/PullPayment.sol b/contracts/payment/PullPayment.sol index 69e30c1d8..9efc8da96 100644 --- a/contracts/payment/PullPayment.sol +++ b/contracts/payment/PullPayment.sol @@ -4,10 +4,10 @@ pragma solidity ^0.4.8; import '../SafeMath.sol'; -/* - * PullPayment - * Base contract supporting async send for pull payments. - * Inherit from this contract and use asyncSend instead of send. +/** + * @title PullPayment + * @dev Base contract supporting async send for pull payments. Inherit from this + contract and use asyncSend instead of send. */ contract PullPayment { using SafeMath for uint; @@ -15,13 +15,19 @@ contract PullPayment { mapping(address => uint) public payments; uint public totalPayments; - // store sent amount as credit to be pulled, called by payer + /** + * @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 + */ function asyncSend(address dest, uint amount) internal { payments[dest] = payments[dest].add(amount); totalPayments = totalPayments.add(amount); } - // withdraw accumulated balance, called by payee + /** + @dev withdraw accumulated balance, called by payee. + */ function withdrawPayments() { address payee = msg.sender; uint payment = payments[payee]; From f6f91298f00b69bb58a3a3f52477d9a4b0e83b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gabriel=20Carvalho?= Date: Wed, 3 May 2017 18:16:28 -0300 Subject: [PATCH 05/10] Add natspec to all remaing contracts, except for vestedToken.sol --- contracts/token/BasicToken.sol | 22 +++++++++++---- contracts/token/CrowdsaleToken.sol | 31 +++++++++++++------- contracts/token/ERC20.sol | 6 ++-- contracts/token/ERC20Basic.sol | 8 +++--- contracts/token/LimitedTransferToken.sol | 36 ++++++++++++++++-------- contracts/token/MintableToken.sol | 22 ++++++++++----- contracts/token/SimpleToken.sol | 15 ++++++---- contracts/token/StandardToken.sol | 26 ++++++++++++++--- contracts/token/VestedToken.sol | 30 ++++++++++++++++++++ 9 files changed, 144 insertions(+), 52 deletions(-) diff --git a/contracts/token/BasicToken.sol b/contracts/token/BasicToken.sol index 81192144b..8b0cb3147 100644 --- a/contracts/token/BasicToken.sol +++ b/contracts/token/BasicToken.sol @@ -5,17 +5,17 @@ import './ERC20Basic.sol'; import '../SafeMath.sol'; -/* - * Basic token - * Basic version of StandardToken, with no allowances +/** + * @title Basic token + * @dev Basic version of StandardToken, with no allowances */ contract BasicToken is ERC20Basic { using SafeMath for uint; mapping(address => uint) balances; - /* - * Fix for the ERC20 short address attack + /** + * @dev Fix for the ERC20 short address attack */ modifier onlyPayloadSize(uint size) { if(msg.data.length < size + 4) { @@ -24,14 +24,24 @@ contract BasicToken is ERC20Basic { _; } + /** + * @dev transfer token for a specified address + * @param _to address The address which you want to transfer to + * @param _value uint the amout to be transfered + */ function transfer(address _to, uint _value) onlyPayloadSize(2 * 32) { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); } + /** + * @dev Function to get the balance of the specified address + * @param _owner address The address you wish to get the balance from + * @return An uint representing the amout owned by the passed address + */ function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; } - + } diff --git a/contracts/token/CrowdsaleToken.sol b/contracts/token/CrowdsaleToken.sol index fad970c1e..df63e6bab 100644 --- a/contracts/token/CrowdsaleToken.sol +++ b/contracts/token/CrowdsaleToken.sol @@ -5,28 +5,36 @@ import "./StandardToken.sol"; /* - * CrowdsaleToken + * @title CrowdsaleToken * - * Simple ERC20 Token example, with crowdsale token creation - * IMPORTANT NOTE: do not use or deploy this contract as-is. - * It needs some changes to be production ready. + * @dev Simple ERC20 Token example, with crowdsale token creation + * @dev IMPORTANT NOTE: do not use or deploy this contract as-is. It + needs some changes to be production ready. */ contract CrowdsaleToken is StandardToken { string public constant name = "CrowdsaleToken"; string public constant symbol = "CRW"; uint public constant decimals = 18; - // replace with your fund collection multisig address - address public constant multisig = 0x0; + // replace with your fund collection multisig address + address public constant multisig = 0x0; - // 1 ether = 500 example tokens + // 1 ether = 500 example tokens uint public constant PRICE = 500; + /** + * @dev A function that recieves ether and send the equivalent amount of + the token to the msg.sender + */ function () payable { createTokens(msg.sender); } - + + /** + * @dev Function to create tokens and send to the specified address + * @param recipient address The address which will recieve the new tokens. + */ function createTokens(address recipient) payable { if (msg.value == 0) { throw; @@ -41,8 +49,11 @@ contract CrowdsaleToken is StandardToken { throw; } } - - // replace this with any other price function + + /** + * @dev replace this with any other price function + * @return The price per unit of token. + */ function getPrice() constant returns (uint result) { return PRICE; } diff --git a/contracts/token/ERC20.sol b/contracts/token/ERC20.sol index 2116ab95b..57b213edf 100644 --- a/contracts/token/ERC20.sol +++ b/contracts/token/ERC20.sol @@ -4,9 +4,9 @@ pragma solidity ^0.4.8; import './ERC20Basic.sol'; -/* - * ERC20 interface - * see https://github.com/ethereum/EIPs/issues/20 +/** + * @title ERC20 interface + * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20 is ERC20Basic { function allowance(address owner, address spender) constant returns (uint); diff --git a/contracts/token/ERC20Basic.sol b/contracts/token/ERC20Basic.sol index 809addebf..11185765b 100644 --- a/contracts/token/ERC20Basic.sol +++ b/contracts/token/ERC20Basic.sol @@ -1,10 +1,10 @@ pragma solidity ^0.4.8; -/* - * ERC20Basic - * Simpler version of ERC20 interface - * see https://github.com/ethereum/EIPs/issues/20 +/** + * @title ERC20Basic + * @dev Simpler version of ERC20 interface + * @dev see https://github.com/ethereum/EIPs/issues/20 */ contract ERC20Basic { uint public totalSupply; diff --git a/contracts/token/LimitedTransferToken.sol b/contracts/token/LimitedTransferToken.sol index 91d5309e0..6dcd0df4b 100644 --- a/contracts/token/LimitedTransferToken.sol +++ b/contracts/token/LimitedTransferToken.sol @@ -2,20 +2,16 @@ pragma solidity ^0.4.8; import "./ERC20.sol"; -/* +/** -LimitedTransferToken defines the generic interface and the implementation -to limit token transferability for different events. +* @title LimitedTransferToken +* @dev LimitedTransferToken defines the generic interface and the implementation +to limit token transferability for different events. It is intended to be used as a base class for other token contracts. - -Overwriting transferableTokens(address holder, uint64 time) is the way to provide -the specific logic for limiting token transferability for a holder over time. - LimitedTransferToken has been designed to allow for different limiting factors, this can be achieved by recursively calling super.transferableTokens() until the base class is hit. For example: - function transferableTokens(address holder, uint64 time) constant public returns (uint256) { return min256(unlockedTokens, super.transferableTokens(holder, time)); } @@ -26,23 +22,39 @@ https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/Ve */ contract LimitedTransferToken is ERC20 { - // Checks whether it can transfer or otherwise throws. + + /** + * @dev Checks whether it can transfer or otherwise throws. + */ modifier canTransfer(address _sender, uint _value) { if (_value > transferableTokens(_sender, uint64(now))) throw; _; } - // Checks modifier and allows transfer if tokens are not locked. + /** + * @dev Checks modifier and allows transfer if tokens are not locked. + * @param _to address The address that will recieve the tokens + * @param _value uint The amount of tokens to be transfered + */ function transfer(address _to, uint _value) canTransfer(msg.sender, _value) { return super.transfer(_to, _value); } - // Checks modifier and allows transfer if tokens are not locked. + /** + * @dev Checks modifier and allows transfer if tokens are not locked. + * @param _from address The address that will send the tokens. + * @param _to address The address that will recieve the tokens. + * @param _value uint The amount of tokens to be transfered. + */ function transferFrom(address _from, address _to, uint _value) canTransfer(_from, _value) { return super.transferFrom(_from, _to, _value); } - // Default transferable tokens function returns all tokens for a holder (no limit). + /** + * @dev Default transferable tokens function returns all tokens for a holder (no limit). + * @dev Overwriting transferableTokens(address holder, uint64 time) is the way to provide + the specific logic for limiting token transferability for a holder over time. + */ function transferableTokens(address holder, uint64 time) constant public returns (uint256) { return balanceOf(holder); } diff --git a/contracts/token/MintableToken.sol b/contracts/token/MintableToken.sol index cef7ff8d4..62c568a3c 100644 --- a/contracts/token/MintableToken.sol +++ b/contracts/token/MintableToken.sol @@ -7,13 +7,10 @@ import '../ownership/Ownable.sol'; /** - * Mintable token - * - * Simple ERC20 Token example, with mintable token creation - * Issue: - * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120 - * Based on code by TokenMarketNet: - * https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol + * @tit;e Mintable token + * @dev: Simple ERC20 Token example, with mintable token creation + @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120 + * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ contract MintableToken is StandardToken, Ownable { @@ -23,11 +20,18 @@ contract MintableToken is StandardToken, Ownable { bool public mintingFinished = false; uint public totalSupply = 0; + modifier canMint() { if(mintingFinished) throw; _; } + /** + * @dev Function to mint tokens + * @param _to address The address that will recieve the minted tokens + * @param _amout uint The amount of tokens to mint + * @return A boolean that indicates if the operation was successful + */ function mint(address _to, uint _amount) onlyOwner canMint returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); @@ -35,6 +39,10 @@ contract MintableToken is StandardToken, Ownable { return true; } + /** + * @dev Function to spot minting new tokens + * @return True if the operation was successful + */ function finishMinting() onlyOwner returns (bool) { mintingFinished = true; MintFinished(); diff --git a/contracts/token/SimpleToken.sol b/contracts/token/SimpleToken.sol index db9137ff3..9a3fee650 100644 --- a/contracts/token/SimpleToken.sol +++ b/contracts/token/SimpleToken.sol @@ -4,12 +4,12 @@ pragma solidity ^0.4.8; import "./StandardToken.sol"; -/* - * SimpleToken +/** + * @title SimpleToken * - * Very simple ERC20 Token example, where all tokens are pre-assigned - * to the creator. Note they can later distribute these tokens - * as they wish using `transfer` and other `StandardToken` functions. + * @dev Very simple ERC20 Token example, where all tokens are pre-assigned + to the creator. Note they can later distribute these tokens + as they wish using `transfer` and other `StandardToken` functions. */ contract SimpleToken is StandardToken { @@ -17,7 +17,10 @@ contract SimpleToken is StandardToken { string public symbol = "SIM"; uint public decimals = 18; uint public INITIAL_SUPPLY = 10000; - + + /** + * @dev Contructor that gives the msg.sender all of existing tokens. + */ function SimpleToken() { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; diff --git a/contracts/token/StandardToken.sol b/contracts/token/StandardToken.sol index 865fe1b3c..ec067e6f5 100644 --- a/contracts/token/StandardToken.sol +++ b/contracts/token/StandardToken.sol @@ -6,16 +6,23 @@ import './ERC20.sol'; /** - * Standard ERC20 token + * @title Standard ERC20 token * - * https://github.com/ethereum/EIPs/issues/20 - * Based on code by FirstBlood: - * https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol + * @dev Implemantation of the basic standart token. + * @dev https://github.com/ethereum/EIPs/issues/20 + * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol */ contract StandardToken is BasicToken, ERC20 { mapping (address => mapping (address => uint)) allowed; + + /** + * @dev Transfer tokens from one address to another + * @param _from address The address which you want to send tokens from + * @param _to address The address which you want to transfer to + * @param _value uint the amout of tokens to be transfered + */ function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3 * 32) { var _allowance = allowed[_from][msg.sender]; @@ -28,6 +35,11 @@ contract StandardToken is BasicToken, ERC20 { Transfer(_from, _to, _value); } + /** + * @dev Aprove the passed address to spend the specified amout tokens on the msg.sender behalf. + * @param _spender address The address which will spend the funds. + * @param _value uint the amout of tokens to be spended. + */ function approve(address _spender, uint _value) { // To change the approve amount you first have to reduce the addresses` @@ -40,6 +52,12 @@ contract StandardToken is BasicToken, ERC20 { Approval(msg.sender, _spender, _value); } + /** + * @dev Function to check the amount of tokens than an owner allowed to a spender. + * @param _owner address The address which owns the funds. + * @param _spender address The address which will spend the funds. + * @return A uint specifing the amount of tokens still avaible for the spender. + */ function allowance(address _owner, address _spender) constant returns (uint remaining) { return allowed[_owner][_spender]; } diff --git a/contracts/token/VestedToken.sol b/contracts/token/VestedToken.sol index ded654ebe..e563ba680 100644 --- a/contracts/token/VestedToken.sol +++ b/contracts/token/VestedToken.sol @@ -4,7 +4,13 @@ pragma solidity ^0.4.8; import "./StandardToken.sol"; import "./LimitedTransferToken.sol"; +/** +* @title Vested token +* @dev This tokens can be granted to a specific address after a determined +amount of time. +*/ contract VestedToken is StandardToken, LimitedTransferToken { + struct TokenGrant { address granter; uint256 value; @@ -15,6 +21,14 @@ contract VestedToken is StandardToken, LimitedTransferToken { mapping (address => TokenGrant[]) public grants; + /** + * @dev Grant tokens to a specified address + * @param _to address The address which the tokens will be granted to. + * @param _value uint256 The amount of tokens to be granted. + * @param _start uint 64 The time of the begining of the grant. + * @param _cliff uint64 The time before the grant is enforceble. + * @param _vesting uint64 The time in which the tokens will be vested. + */ function grantVestedTokens( address _to, uint256 _value, @@ -39,6 +53,12 @@ contract VestedToken is StandardToken, LimitedTransferToken { transfer(_to, _value); } + + /** + * @dev Revoke the grant of tokens of a specifed address. + * @param _holder address The address which will have its tokens revoked. + * @param _grantId uint The id of the token grant. + */ function revokeTokenGrant(address _holder, uint _grantId) { TokenGrant grant = grants[_holder][_grantId]; @@ -57,10 +77,20 @@ contract VestedToken is StandardToken, LimitedTransferToken { Transfer(_holder, msg.sender, nonVested); } + /** + * @dev Check the amount of grants that an address has. + * @param _holder address The holder of the grants. + * @return A uint representing the index of the grant. + */ function tokenGrantsCount(address _holder) constant returns (uint index) { return grants[_holder].length; } + /** + * @dev + * @param _holder address The address which will have its tokens revoked. + * @param _grantId uint The id of the token grant. + */ function tokenGrant(address _holder, uint _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting) { TokenGrant grant = grants[_holder][_grantId]; From d85be4a8664af4740ae581f82457b5ffb9beea66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Gabriel=20Carvalho?= Date: Thu, 4 May 2017 12:41:09 -0300 Subject: [PATCH 06/10] Add natspec to vestedToken.sol --- contracts/token/VestedToken.sol | 49 ++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/contracts/token/VestedToken.sol b/contracts/token/VestedToken.sol index e563ba680..d2b4da196 100644 --- a/contracts/token/VestedToken.sol +++ b/contracts/token/VestedToken.sol @@ -6,8 +6,7 @@ import "./LimitedTransferToken.sol"; /** * @title Vested token -* @dev This tokens can be granted to a specific address after a determined -amount of time. +* @dev Tokens that can be vested for a group of addresses. */ contract VestedToken is StandardToken, LimitedTransferToken { @@ -25,9 +24,9 @@ contract VestedToken is StandardToken, LimitedTransferToken { * @dev Grant tokens to a specified address * @param _to address The address which the tokens will be granted to. * @param _value uint256 The amount of tokens to be granted. - * @param _start uint 64 The time of the begining of the grant. - * @param _cliff uint64 The time before the grant is enforceble. - * @param _vesting uint64 The time in which the tokens will be vested. + * @param _start uint64 Represents time of the begining of the grant. + * @param _cliff uint64 Represents the cliff period. + * @param _vesting uint64 Represents the vesting period. */ function grantVestedTokens( address _to, @@ -80,16 +79,18 @@ contract VestedToken is StandardToken, LimitedTransferToken { /** * @dev Check the amount of grants that an address has. * @param _holder address The holder of the grants. - * @return A uint representing the index of the grant. + * @return A uint representing the total amount of grants. */ function tokenGrantsCount(address _holder) constant returns (uint index) { return grants[_holder].length; } /** - * @dev + * @dev Get all information about a specifc grant. * @param _holder address The address which will have its tokens revoked. * @param _grantId uint The id of the token grant. + * @return Returns all the values that represent a TokenGrant(address, value, + start, cliff and vesting) plus the vested value at the current time. */ function tokenGrant(address _holder, uint _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting) { TokenGrant grant = grants[_holder][_grantId]; @@ -103,6 +104,13 @@ contract VestedToken is StandardToken, LimitedTransferToken { vested = vestedTokens(grant, uint64(now)); } + /** + * @dev Get the amount of vested tokens at a specifc time. + * @param grant TokenGrant The grant to be checked. + * @param time uint64 The time to be checked + * @return An uint representing the amount of vested tokens of a specifc grant + on specifc time. + */ function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) { return calculateVestedTokens( grant.value, @@ -113,6 +121,15 @@ contract VestedToken is StandardToken, LimitedTransferToken { ); } + /** + * @dev Calculate amount of vested tokens at a specifc time. + * @param tokens uint256 The amount of tokens grantted. + * @param time uint64 The time to be checked + * @param start uint64 A time representing the begining of the grant + * @param _cliff uint64 Represents the cliff period. + * @param _vesting uint64 Represents the vesting period. + * @return An uint representing the amount of vested tokensof a specif grant. + */ function calculateVestedTokens( uint256 tokens, uint256 time, @@ -136,10 +153,22 @@ contract VestedToken is StandardToken, LimitedTransferToken { vestedTokens = vestedTokens.add(vestingTokens.mul(time.sub(cliff)).div(vesting.sub(cliff))); } + /** + * @dev Calculate the amount of non vested tokens at a specific time. + * @param grant TokenGrant The grant to be checked. + * @param time uint64 The time to be checked + * @return An uint representing the amount of non vested tokens of a specifc grant + on the passed time frame. + */ function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) { return grant.value.sub(vestedTokens(grant, time)); } + /** + * @dev Calculate the date when the holder can trasfer all its tokens + * @param holder address The address of the holder + * @return An uint representing the date of the last transferable tokens. + */ function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) { date = uint64(now); uint256 grantIndex = grants[holder].length; @@ -148,6 +177,12 @@ contract VestedToken is StandardToken, LimitedTransferToken { } } + /** + * @dev Calculate the total amount of transferable tokens of a holder at a given time + * @param holder address The address of the holder + * @param time uint64 The specific time. + * @return An uint representing a holder's total amount of transferable tokens. + */ function transferableTokens(address holder, uint64 time) constant public returns (uint256 nonVested) { uint256 grantIndex = grants[holder].length; for (uint256 i = 0; i < grantIndex; i++) { From 83f2849446868a1e357b20c00295b0e180b115cf Mon Sep 17 00:00:00 2001 From: maurelian Date: Mon, 8 May 2017 08:08:06 -0400 Subject: [PATCH 07/10] Minor edits to doc commenst in lifecycle, ownership, payment contracts. --- contracts/lifecycle/Destructible.sol | 2 +- contracts/lifecycle/Pausable.sol | 2 +- contracts/lifecycle/TokenDestructible.sol | 24 ++++---- contracts/ownership/Claimable.sol | 11 ++-- contracts/ownership/Contactable.sol | 6 +- contracts/ownership/DelayedClaimable.sol | 7 ++- contracts/ownership/HasNoContracts.sol | 17 +++--- contracts/ownership/HasNoEther.sol | 38 ++++++------ contracts/ownership/HasNoTokens.sol | 30 +++++----- contracts/ownership/Multisig.sol | 7 +-- contracts/ownership/NoOwner.sol | 10 ++-- contracts/ownership/Ownable.sol | 8 +-- contracts/ownership/Shareable.sol | 70 ++++++++++++----------- contracts/payment/PullPayment.sol | 10 ++-- 14 files changed, 121 insertions(+), 121 deletions(-) diff --git a/contracts/lifecycle/Destructible.sol b/contracts/lifecycle/Destructible.sol index ad6afe682..005c6b8c1 100644 --- a/contracts/lifecycle/Destructible.sol +++ b/contracts/lifecycle/Destructible.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); diff --git a/contracts/lifecycle/Pausable.sol b/contracts/lifecycle/Pausable.sol index 419159086..8960ec135 100644 --- a/contracts/lifecycle/Pausable.sol +++ b/contracts/lifecycle/Pausable.sol @@ -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(); diff --git a/contracts/lifecycle/TokenDestructible.sol b/contracts/lifecycle/TokenDestructible.sol index ab473fb73..de9fa50d4 100644 --- a/contracts/lifecycle/TokenDestructible.sol +++ b/contracts/lifecycle/TokenDestructible.sol @@ -4,19 +4,21 @@ pragma solidity ^0.4.8; import "../ownership/Ownable.sol"; import "../token/ERC20Basic.sol"; -/** @title TokenDestructible: -* @author Remco Bloemen -* @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 + * @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 diff --git a/contracts/ownership/Claimable.sol b/contracts/ownership/Claimable.sol index 899606d67..42997cf48 100644 --- a/contracts/ownership/Claimable.sol +++ b/contracts/ownership/Claimable.sol @@ -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; } - } diff --git a/contracts/ownership/Contactable.sol b/contracts/ownership/Contactable.sol index 824bc7498..ca81c76cd 100644 --- a/contracts/ownership/Contactable.sol +++ b/contracts/ownership/Contactable.sol @@ -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; } - } diff --git a/contracts/ownership/DelayedClaimable.sol b/contracts/ownership/DelayedClaimable.sol index 5af3828d8..028405c9d 100644 --- a/contracts/ownership/DelayedClaimable.sol +++ b/contracts/ownership/DelayedClaimable.sol @@ -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)) diff --git a/contracts/ownership/HasNoContracts.sol b/contracts/ownership/HasNoContracts.sol index 3d3dee2bb..cd650499c 100644 --- a/contracts/ownership/HasNoContracts.sol +++ b/contracts/ownership/HasNoContracts.sol @@ -2,17 +2,18 @@ pragma solidity ^0.4.8; import "./Ownable.sol"; -/** @title Contracts that should not own Contracts -* @author Remco Bloemen -* @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 + * @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); diff --git a/contracts/ownership/HasNoEther.sol b/contracts/ownership/HasNoEther.sol index d18745d0d..0fd4305da 100644 --- a/contracts/ownership/HasNoEther.sol +++ b/contracts/ownership/HasNoEther.sol @@ -2,27 +2,24 @@ pragma solidity ^0.4.8; import "./Ownable.sol"; -/** @title Contracts that should not own Ether -* @author Remco Bloemen - -* @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 + * @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; diff --git a/contracts/ownership/HasNoTokens.sol b/contracts/ownership/HasNoTokens.sol index 533d57db8..3a69673f8 100644 --- a/contracts/ownership/HasNoTokens.sol +++ b/contracts/ownership/HasNoTokens.sol @@ -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 -* @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 + * @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); diff --git a/contracts/ownership/Multisig.sol b/contracts/ownership/Multisig.sol index b124b54dd..ffb379ff5 100644 --- a/contracts/ownership/Multisig.sol +++ b/contracts/ownership/Multisig.sol @@ -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); } - diff --git a/contracts/ownership/NoOwner.sol b/contracts/ownership/NoOwner.sol index ff06b7ae1..4979c2b38 100644 --- a/contracts/ownership/NoOwner.sol +++ b/contracts/ownership/NoOwner.sol @@ -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 -* @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 + * @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 { } diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index 23f7efbd2..77496627f 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -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 { diff --git a/contracts/ownership/Shareable.sol b/contracts/ownership/Shareable.sol index e9d7f4671..10bb3bddd 100644 --- a/contracts/ownership/Shareable.sol +++ b/contracts/ownership/Shareable.sol @@ -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) { diff --git a/contracts/payment/PullPayment.sol b/contracts/payment/PullPayment.sol index 9efc8da96..eadc93b40 100644 --- a/contracts/payment/PullPayment.sol +++ b/contracts/payment/PullPayment.sol @@ -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; From d357cf3a2e5e5dadc154a31bc11fd083ee084f4d Mon Sep 17 00:00:00 2001 From: maurelian Date: Mon, 8 May 2017 09:07:03 -0400 Subject: [PATCH 08/10] Minor changes to doc comments for token and other contracts --- contracts/Bounty.sol | 11 ++- contracts/DayLimit.sol | 15 ++-- contracts/LimitBalance.sol | 2 +- contracts/ReentrancyGuard.sol | 28 ++++--- contracts/ownership/Shareable.sol | 10 +-- contracts/token/BasicToken.sol | 14 ++-- contracts/token/CrowdsaleToken.sol | 24 +++--- contracts/token/LimitedTransferToken.sol | 56 +++++++------- contracts/token/MintableToken.sol | 20 ++--- contracts/token/SimpleToken.sol | 11 ++- contracts/token/StandardToken.sol | 6 +- contracts/token/VestedToken.sol | 93 ++++++++++++------------ 12 files changed, 147 insertions(+), 143 deletions(-) diff --git a/contracts/Bounty.sol b/contracts/Bounty.sol index 0d2871cd8..074e63a1c 100644 --- a/contracts/Bounty.sol +++ b/contracts/Bounty.sol @@ -16,7 +16,7 @@ contract Bounty is PullPayment, Destructible { event TargetCreated(address createdAddress); /** - * @dev Function that allows the contract to recieve funds, if it hasn't been claimed. + * @dev Fallback function allowing the contract to recieve funds, if they haven't already been claimed. */ function() payable { if (claimed) { @@ -25,7 +25,8 @@ contract Bounty is PullPayment, Destructible { } /** - * @dev Create and deploy the target contract(extension of Target contract), and sets the msg.sender as a researcher + * @dev Create and deploy the target contract (extension of Target contract), and sets the + * msg.sender as a researcher * @return A target contract */ function createTarget() returns(Target) { @@ -68,8 +69,10 @@ contract Bounty is PullPayment, Destructible { contract Target { /** - * @dev Funtion tha should check everything your contract assumes to be true all the time. If this function returns false, it means your contract was broken in some way and is in an inconsistent state. This is what security researchers will try to acomplish when trying to get the bounty. - * @return A boolean that indicates if the contract is broken or not. + * @dev Checks all values a contract assumes to be true all the time. If this function returns + * false, the contract is broken in some way and is in an inconsistent state. + * In order to win the bounty, security researchers will try to cause this broken state. + * @return True if all invariant values are correct, false otherwise. */ function checkInvariant() returns(bool); } diff --git a/contracts/DayLimit.sol b/contracts/DayLimit.sol index aba01d07f..66fb72782 100644 --- a/contracts/DayLimit.sol +++ b/contracts/DayLimit.sol @@ -2,7 +2,8 @@ pragma solidity ^0.4.8; /** * @title DayLimit - * @dev Base contract that enables methods to be protected by placing a linear limit (specifiable) on a particular resource per calendar day. Is multiowned to allow the limit to be altered + * @dev Base contract that enables methods to be protected by placing a linear limit (specifiable) + * on a particular resource per calendar day. Is multiowned to allow the limit to be altered. */ contract DayLimit { @@ -11,7 +12,7 @@ contract DayLimit { uint public lastDay; /** - * @dev Constructor that sets the passed value as a dailyLimit + * @dev Constructor that sets the passed value as a dailyLimit. * @param _limit Uint to represent the daily limit. */ function DayLimit(uint _limit) { @@ -20,7 +21,7 @@ contract DayLimit { } /** - * @dev sets the daily limit. doesn't alter the amount already spent today + * @dev sets the daily limit. Does not alter the amount already spent today. * @param _newLimit Uint to represent the new limit. */ function _setDailyLimit(uint _newLimit) internal { @@ -35,8 +36,8 @@ contract DayLimit { } /** - * @dev Checks to see if there is enough resource to spend today. If true, the resource is expended. - * @param _value Uint representing the amout of resurce to spend. + * @dev Checks to see if there is enough resource to spend today. If true, the resource may be expended. + * @param _value Uint representing the amount of resource to spend. * @return A boolean that is True if the resource was spended and false otherwise. */ function underLimit(uint _value) internal returns (bool) { @@ -55,8 +56,8 @@ contract DayLimit { } /** - * @dev Private function to determine today index - * @return Uint of todays index. + * @dev Private function to determine today's index + * @return Uint of today's index. */ function today() private constant returns (uint) { return now / 1 days; diff --git a/contracts/LimitBalance.sol b/contracts/LimitBalance.sol index eb3edc394..a5a77ccf3 100644 --- a/contracts/LimitBalance.sol +++ b/contracts/LimitBalance.sol @@ -12,7 +12,7 @@ contract LimitBalance { uint public limit; /** - * @dev Constructor that sets the passed value as a limit + * @dev Constructor that sets the passed value as a limit. * @param _limit Uint to represent the limit. */ function LimitBalance(uint _limit) { diff --git a/contracts/ReentrancyGuard.sol b/contracts/ReentrancyGuard.sol index 02c3c49c8..3492d7bdf 100644 --- a/contracts/ReentrancyGuard.sol +++ b/contracts/ReentrancyGuard.sol @@ -1,20 +1,26 @@ pragma solidity ^0.4.8; -/// @title Helps contracts guard agains rentrancy attacks. -/// @author Remco Bloemen -/// @notice If you mark a function `nonReentrant`, you should also -/// mark it `external`. +/** + * @title Helps contracts guard agains rentrancy attacks. + * @author Remco Bloemen + * @notice If you mark a function `nonReentrant`, you should also + * mark it `external`. + */ contract ReentrancyGuard { - /// @dev We use a single lock for the whole contract. + /** + * @dev We use a single lock for the whole contract. + */ bool private rentrancy_lock = false; - /// Prevent contract from calling itself, directly or indirectly. - /// @notice If you mark a function `nonReentrant`, you should also - /// mark it `external`. Calling one nonReentrant function from - /// another is not supported. Instead, you can implement a - /// `private` function doing the actual work, and a `external` - /// wrapper marked as `nonReentrant`. + /** + * @dev Prevents a contract from calling itself, directly or indirectly. + * @notice If you mark a function `nonReentrant`, you should also + * mark it `external`. Calling one nonReentrant function from + * another is not supported. Instead, you can implement a + * `private` function doing the actual work, and a `external` + * wrapper marked as `nonReentrant`. + */ modifier nonReentrant() { if(rentrancy_lock == false) { rentrancy_lock = true; diff --git a/contracts/ownership/Shareable.sol b/contracts/ownership/Shareable.sol index 10bb3bddd..4f77dc55e 100644 --- a/contracts/ownership/Shareable.sol +++ b/contracts/ownership/Shareable.sol @@ -44,9 +44,8 @@ contract Shareable { /** * @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. + * @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)) { @@ -59,6 +58,7 @@ contract Shareable { * 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. + * @param _limit Uint to represent the daily limit. */ function Shareable(address[] _owners, uint _required) { owners[1] = msg.sender; @@ -74,8 +74,8 @@ 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 A string identifying the operation. */ function revoke(bytes32 _operation) external { uint index = ownerIndex[msg.sender]; diff --git a/contracts/token/BasicToken.sol b/contracts/token/BasicToken.sol index 8b0cb3147..c560d0ab5 100644 --- a/contracts/token/BasicToken.sol +++ b/contracts/token/BasicToken.sol @@ -7,7 +7,7 @@ import '../SafeMath.sol'; /** * @title Basic token - * @dev Basic version of StandardToken, with no allowances + * @dev Basic version of StandardToken, with no allowances. */ contract BasicToken is ERC20Basic { using SafeMath for uint; @@ -15,7 +15,7 @@ contract BasicToken is ERC20Basic { mapping(address => uint) balances; /** - * @dev Fix for the ERC20 short address attack + * @dev Fix for the ERC20 short address attack. */ modifier onlyPayloadSize(uint size) { if(msg.data.length < size + 4) { @@ -26,8 +26,8 @@ contract BasicToken is ERC20Basic { /** * @dev transfer token for a specified address - * @param _to address The address which you want to transfer to - * @param _value uint the amout to be transfered + * @param _to The address to transfer to. + * @param _value The amount to be transferred. */ function transfer(address _to, uint _value) onlyPayloadSize(2 * 32) { balances[msg.sender] = balances[msg.sender].sub(_value); @@ -36,9 +36,9 @@ contract BasicToken is ERC20Basic { } /** - * @dev Function to get the balance of the specified address - * @param _owner address The address you wish to get the balance from - * @return An uint representing the amout owned by the passed address + * @dev Gets the balance of the specified address. + * @param _owner The address to query the the balance of. + * @return An uint representing the amount owned by the passed address. */ function balanceOf(address _owner) constant returns (uint balance) { return balances[_owner]; diff --git a/contracts/token/CrowdsaleToken.sol b/contracts/token/CrowdsaleToken.sol index df63e6bab..1cdbdc1c1 100644 --- a/contracts/token/CrowdsaleToken.sol +++ b/contracts/token/CrowdsaleToken.sol @@ -4,12 +4,12 @@ pragma solidity ^0.4.8; import "./StandardToken.sol"; -/* +/** * @title CrowdsaleToken * * @dev Simple ERC20 Token example, with crowdsale token creation - * @dev IMPORTANT NOTE: do not use or deploy this contract as-is. It - needs some changes to be production ready. + * @dev IMPORTANT NOTE: do not use or deploy this contract as-is. It needs some changes to be + * production ready. */ contract CrowdsaleToken is StandardToken { @@ -24,17 +24,17 @@ contract CrowdsaleToken is StandardToken { uint public constant PRICE = 500; /** - * @dev A function that recieves ether and send the equivalent amount of - the token to the msg.sender - */ + * @dev Fallback function which receives ether and sends the appropriate number of tokens to the + * msg.sender. + */ function () payable { createTokens(msg.sender); } /** - * @dev Function to create tokens and send to the specified address - * @param recipient address The address which will recieve the new tokens. - */ + * @dev Creates tokens and send to the specified address. + * @param recipient The address which will recieve the new tokens. + */ function createTokens(address recipient) payable { if (msg.value == 0) { throw; @@ -51,9 +51,9 @@ contract CrowdsaleToken is StandardToken { } /** - * @dev replace this with any other price function - * @return The price per unit of token. - */ + * @dev replace this with any other price function + * @return The price per unit of token. + */ function getPrice() constant returns (uint result) { return PRICE; } diff --git a/contracts/token/LimitedTransferToken.sol b/contracts/token/LimitedTransferToken.sol index 6dcd0df4b..85c05216d 100644 --- a/contracts/token/LimitedTransferToken.sol +++ b/contracts/token/LimitedTransferToken.sol @@ -3,58 +3,54 @@ pragma solidity ^0.4.8; import "./ERC20.sol"; /** - -* @title LimitedTransferToken - -* @dev LimitedTransferToken defines the generic interface and the implementation -to limit token transferability for different events. -It is intended to be used as a base class for other token contracts. -LimitedTransferToken has been designed to allow for different limiting factors, -this can be achieved by recursively calling super.transferableTokens() until the -base class is hit. For example: -function transferableTokens(address holder, uint64 time) constant public returns (uint256) { - return min256(unlockedTokens, super.transferableTokens(holder, time)); -} - -A working example is VestedToken.sol: -https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/VestedToken.sol - -*/ + * @title LimitedTransferToken + * @dev LimitedTransferToken defines the generic interface and the implementation to limit token + * transferability for different events. It is intended to be used as a base class for other token + * contracts. + * LimitedTransferToken has been designed to allow for different limiting factors, + * this can be achieved by recursively calling super.transferableTokens() until the base class is + * hit. For example: + * function transferableTokens(address holder, uint64 time) constant public returns (uint256) { + * return min256(unlockedTokens, super.transferableTokens(holder, time)); + * } + * A working example is VestedToken.sol: + * https://github.com/OpenZeppelin/zeppelin-solidity/blob/master/contracts/token/VestedToken.sol + */ contract LimitedTransferToken is ERC20 { /** - * @dev Checks whether it can transfer or otherwise throws. - */ + * @dev Checks whether it can transfer or otherwise throws. + */ modifier canTransfer(address _sender, uint _value) { if (_value > transferableTokens(_sender, uint64(now))) throw; _; } /** - * @dev Checks modifier and allows transfer if tokens are not locked. - * @param _to address The address that will recieve the tokens - * @param _value uint The amount of tokens to be transfered - */ + * @dev Checks modifier and allows transfer if tokens are not locked. + * @param _to The address that will recieve the tokens. + * @param _value The amount of tokens to be transferred. + */ function transfer(address _to, uint _value) canTransfer(msg.sender, _value) { return super.transfer(_to, _value); } /** * @dev Checks modifier and allows transfer if tokens are not locked. - * @param _from address The address that will send the tokens. - * @param _to address The address that will recieve the tokens. - * @param _value uint The amount of tokens to be transfered. + * @param _from The address that will send the tokens. + * @param _to The address that will recieve the tokens. + * @param _value The amount of tokens to be transferred. */ function transferFrom(address _from, address _to, uint _value) canTransfer(_from, _value) { return super.transferFrom(_from, _to, _value); } /** - * @dev Default transferable tokens function returns all tokens for a holder (no limit). - * @dev Overwriting transferableTokens(address holder, uint64 time) is the way to provide - the specific logic for limiting token transferability for a holder over time. - */ + * @dev Default transferable tokens function returns all tokens for a holder (no limit). + * @dev Overwriting transferableTokens(address holder, uint64 time) is the way to provide the + * specific logic for limiting token transferability for a holder over time. + */ function transferableTokens(address holder, uint64 time) constant public returns (uint256) { return balanceOf(holder); } diff --git a/contracts/token/MintableToken.sol b/contracts/token/MintableToken.sol index 62c568a3c..fc29748a6 100644 --- a/contracts/token/MintableToken.sol +++ b/contracts/token/MintableToken.sol @@ -7,9 +7,9 @@ import '../ownership/Ownable.sol'; /** - * @tit;e Mintable token + * @title Mintable token * @dev: Simple ERC20 Token example, with mintable token creation - @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120 + * @dev Issue: * https://github.com/OpenZeppelin/zeppelin-solidity/issues/120 * Based on code by TokenMarketNet: https://github.com/TokenMarketNet/ico/blob/master/contracts/MintableToken.sol */ @@ -27,11 +27,11 @@ contract MintableToken is StandardToken, Ownable { } /** - * @dev Function to mint tokens - * @param _to address The address that will recieve the minted tokens - * @param _amout uint The amount of tokens to mint - * @return A boolean that indicates if the operation was successful - */ + * @dev Function to mint tokens + * @param _to The address that will recieve the minted tokens. + * @param _amount The amount of tokens to mint. + * @return A boolean that indicates if the operation was successful. + */ function mint(address _to, uint _amount) onlyOwner canMint returns (bool) { totalSupply = totalSupply.add(_amount); balances[_to] = balances[_to].add(_amount); @@ -40,9 +40,9 @@ contract MintableToken is StandardToken, Ownable { } /** - * @dev Function to spot minting new tokens - * @return True if the operation was successful - */ + * @dev Function to spot minting new tokens. + * @return True if the operation was successful. + */ function finishMinting() onlyOwner returns (bool) { mintingFinished = true; MintFinished(); diff --git a/contracts/token/SimpleToken.sol b/contracts/token/SimpleToken.sol index 9a3fee650..fa2241fcb 100644 --- a/contracts/token/SimpleToken.sol +++ b/contracts/token/SimpleToken.sol @@ -6,10 +6,9 @@ import "./StandardToken.sol"; /** * @title SimpleToken - * - * @dev Very simple ERC20 Token example, where all tokens are pre-assigned - to the creator. Note they can later distribute these tokens - as they wish using `transfer` and other `StandardToken` functions. + * @dev Very simple ERC20 Token example, where all tokens are pre-assigned to the creator. + * Note they can later distribute these tokens as they wish using `transfer` and other + * `StandardToken` functions. */ contract SimpleToken is StandardToken { @@ -19,8 +18,8 @@ contract SimpleToken is StandardToken { uint public INITIAL_SUPPLY = 10000; /** - * @dev Contructor that gives the msg.sender all of existing tokens. - */ + * @dev Contructor that gives msg.sender all of existing tokens. + */ function SimpleToken() { totalSupply = INITIAL_SUPPLY; balances[msg.sender] = INITIAL_SUPPLY; diff --git a/contracts/token/StandardToken.sol b/contracts/token/StandardToken.sol index ec067e6f5..676356d2d 100644 --- a/contracts/token/StandardToken.sol +++ b/contracts/token/StandardToken.sol @@ -36,9 +36,9 @@ contract StandardToken is BasicToken, ERC20 { } /** - * @dev Aprove the passed address to spend the specified amout tokens on the msg.sender behalf. - * @param _spender address The address which will spend the funds. - * @param _value uint the amout of tokens to be spended. + * @dev Aprove the passed address to spend the specified amount of tokens on beahlf of msg.sender. + * @param _spender The address which will spend the funds. + * @param _value The amount of tokens to be spent. */ function approve(address _spender, uint _value) { diff --git a/contracts/token/VestedToken.sol b/contracts/token/VestedToken.sol index d2b4da196..14ff7ed8c 100644 --- a/contracts/token/VestedToken.sol +++ b/contracts/token/VestedToken.sol @@ -5,9 +5,9 @@ import "./StandardToken.sol"; import "./LimitedTransferToken.sol"; /** -* @title Vested token -* @dev Tokens that can be vested for a group of addresses. -*/ + * @title Vested token + * @dev Tokens that can be vested for a group of addresses. + */ contract VestedToken is StandardToken, LimitedTransferToken { struct TokenGrant { @@ -21,13 +21,13 @@ contract VestedToken is StandardToken, LimitedTransferToken { mapping (address => TokenGrant[]) public grants; /** - * @dev Grant tokens to a specified address - * @param _to address The address which the tokens will be granted to. - * @param _value uint256 The amount of tokens to be granted. - * @param _start uint64 Represents time of the begining of the grant. - * @param _cliff uint64 Represents the cliff period. - * @param _vesting uint64 Represents the vesting period. - */ + * @dev Grant tokens to a specified address + * @param _to address The address which the tokens will be granted to. + * @param _value uint256 The amount of tokens to be granted. + * @param _start uint64 Represents time of the begining of the grant. + * @param _cliff uint64 Represents the cliff period. + * @param _vesting uint64 Represents the vesting period. + */ function grantVestedTokens( address _to, uint256 _value, @@ -53,11 +53,11 @@ contract VestedToken is StandardToken, LimitedTransferToken { } - /** - * @dev Revoke the grant of tokens of a specifed address. - * @param _holder address The address which will have its tokens revoked. - * @param _grantId uint The id of the token grant. - */ + /** + * @dev Revoke the grant of tokens of a specifed address. + * @param _holder The address which will have its tokens revoked. + * @param _grantId The id of the token grant. + */ function revokeTokenGrant(address _holder, uint _grantId) { TokenGrant grant = grants[_holder][_grantId]; @@ -76,22 +76,22 @@ contract VestedToken is StandardToken, LimitedTransferToken { Transfer(_holder, msg.sender, nonVested); } - /** - * @dev Check the amount of grants that an address has. - * @param _holder address The holder of the grants. - * @return A uint representing the total amount of grants. - */ + /** + * @dev Check the amount of grants that an address has. + * @param _holder The holder of the grants. + * @return A uint representing the total amount of grants. + */ function tokenGrantsCount(address _holder) constant returns (uint index) { return grants[_holder].length; } /** - * @dev Get all information about a specifc grant. - * @param _holder address The address which will have its tokens revoked. - * @param _grantId uint The id of the token grant. - * @return Returns all the values that represent a TokenGrant(address, value, - start, cliff and vesting) plus the vested value at the current time. - */ + * @dev Get all information about a specifc grant. + * @param _holder The address which will have its tokens revoked. + * @param _grantId The id of the token grant. + * @return Returns all the values that represent a TokenGrant(address, value, start, cliff + * and vesting) plus the vested value at the current time. + */ function tokenGrant(address _holder, uint _grantId) constant returns (address granter, uint256 value, uint256 vested, uint64 start, uint64 cliff, uint64 vesting) { TokenGrant grant = grants[_holder][_grantId]; @@ -105,12 +105,11 @@ contract VestedToken is StandardToken, LimitedTransferToken { } /** - * @dev Get the amount of vested tokens at a specifc time. - * @param grant TokenGrant The grant to be checked. - * @param time uint64 The time to be checked - * @return An uint representing the amount of vested tokens of a specifc grant - on specifc time. - */ + * @dev Get the amount of vested tokens at a specific time. + * @param grant TokenGrant The grant to be checked. + * @param time The time to be checked + * @return An uint representing the amount of vested tokens of a specific grant at a specific time. + */ function vestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) { return calculateVestedTokens( grant.value, @@ -154,21 +153,21 @@ contract VestedToken is StandardToken, LimitedTransferToken { } /** - * @dev Calculate the amount of non vested tokens at a specific time. - * @param grant TokenGrant The grant to be checked. - * @param time uint64 The time to be checked - * @return An uint representing the amount of non vested tokens of a specifc grant - on the passed time frame. - */ + * @dev Calculate the amount of non vested tokens at a specific time. + * @param grant TokenGrant The grant to be checked. + * @param time uint64 The time to be checked + * @return An uint representing the amount of non vested tokens of a specifc grant on the + * passed time frame. + */ function nonVestedTokens(TokenGrant grant, uint64 time) private constant returns (uint256) { return grant.value.sub(vestedTokens(grant, time)); } /** - * @dev Calculate the date when the holder can trasfer all its tokens - * @param holder address The address of the holder - * @return An uint representing the date of the last transferable tokens. - */ + * @dev Calculate the date when the holder can trasfer all its tokens + * @param holder address The address of the holder + * @return An uint representing the date of the last transferable tokens. + */ function lastTokenIsTransferableDate(address holder) constant public returns (uint64 date) { date = uint64(now); uint256 grantIndex = grants[holder].length; @@ -178,11 +177,11 @@ contract VestedToken is StandardToken, LimitedTransferToken { } /** - * @dev Calculate the total amount of transferable tokens of a holder at a given time - * @param holder address The address of the holder - * @param time uint64 The specific time. - * @return An uint representing a holder's total amount of transferable tokens. - */ + * @dev Calculate the total amount of transferable tokens of a holder at a given time + * @param holder address The address of the holder + * @param time uint64 The specific time. + * @return An uint representing a holder's total amount of transferable tokens. + */ function transferableTokens(address holder, uint64 time) constant public returns (uint256 nonVested) { uint256 grantIndex = grants[holder].length; for (uint256 i = 0; i < grantIndex; i++) { From 111f13f0ce061ce170d58d2d4b7b74f8d734f7d5 Mon Sep 17 00:00:00 2001 From: maurelian Date: Mon, 8 May 2017 09:07:33 -0400 Subject: [PATCH 09/10] Add doc comments to multisig wallet --- contracts/MultisigWallet.sol | 54 +++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/contracts/MultisigWallet.sol b/contracts/MultisigWallet.sol index 4c26241c1..69118febd 100644 --- a/contracts/MultisigWallet.sol +++ b/contracts/MultisigWallet.sol @@ -6,11 +6,11 @@ import "./ownership/Shareable.sol"; import "./DayLimit.sol"; -/* +/** * MultisigWallet - * usage: - * bytes32 h = Wallet(w).from(oneOwner).execute(to, value, data); - * Wallet(w).from(anotherOwner).confirm(h); + * Usage: + * bytes32 h = Wallet(w).from(oneOwner).execute(to, value, data); + * Wallet(w).from(anotherOwner).confirm(h); */ contract MultisigWallet is Multisig, Shareable, DayLimit { @@ -20,26 +20,41 @@ contract MultisigWallet is Multisig, Shareable, DayLimit { bytes data; } + /** + * Constructor, sets the owners addresses, number of approvals required, and daily spending limit + * @param _owners A list of owners. + * @param _required The amount required for a transaction to be approved. + */ function MultisigWallet(address[] _owners, uint _required, uint _daylimit) Shareable(_owners, _required) DayLimit(_daylimit) { } - // destroys the contract sending everything to `_to`. + /** + * @dev destroys the contract sending everything to `_to`. + */ function destroy(address _to) onlymanyowners(keccak256(msg.data)) external { selfdestruct(_to); } - // gets called when no other function matches + /** + * @dev Fallback function, receives value and emits a deposit event. + */ function() payable { // just being sent some cash? if (msg.value > 0) Deposit(msg.sender, msg.value); } - // Outside-visible transact entry point. Executes transaction immediately if below daily spend limit. - // If not, goes into multisig process. We provide a hash on return to allow the sender to provide - // shortcuts for the other confirmations (allowing them to avoid replicating the _to, _value - // and _data arguments). They still get the option of using them if they want, anyways. + /** + * @dev Outside-visible transaction entry point. Executes transaction immediately if below daily + * spending limit. If not, goes into multisig process. We provide a hash on return to allow the + * sender to provide shortcuts for the other confirmations (allowing them to avoid replicating + * the _to, _value, and _data arguments). They still get the option of using them if they want, + * anyways. + * @param _to The receiver address + * @param _value The value to send + * @param _data The data part of the transaction + */ function execute(address _to, uint _value, bytes _data) external onlyOwner returns (bytes32 _r) { // first, take the opportunity to check that we're under the daily limit. if (underLimit(_value)) { @@ -60,8 +75,11 @@ contract MultisigWallet is Multisig, Shareable, DayLimit { } } - // confirm a transaction through just the hash. we use the previous transactions map, txs, in order - // to determine the body of the transaction from the hash provided. + /** + * @dev Confirm a transaction by providing just the hash. We use the previous transactions map, + * txs, in order to determine the body of the transaction from the hash provided. + * @param _h The transaction hash to approve. + */ function confirm(bytes32 _h) onlymanyowners(_h) returns (bool) { if (txs[_h].to != 0) { if (!txs[_h].to.call.value(txs[_h].value)(txs[_h].data)) { @@ -73,17 +91,27 @@ contract MultisigWallet is Multisig, Shareable, DayLimit { } } + /** + * @dev Updates the daily limit value. + * @param _newLimit + */ function setDailyLimit(uint _newLimit) onlymanyowners(keccak256(msg.data)) external { _setDailyLimit(_newLimit); } + /** + * @dev Resets the value spent to enable more spending + * @param _newLimit + */ function resetSpentToday() onlymanyowners(keccak256(msg.data)) external { _resetSpentToday(); } // INTERNAL METHODS - + /** + * @dev Clears the list of transactions pending approval. + */ function clearPending() internal { uint length = pendingsIndex.length; for (uint i = 0; i < length; ++i) { From c4796bb918322e32241b2e80fadb6a14c055105c Mon Sep 17 00:00:00 2001 From: maurelian Date: Wed, 24 May 2017 17:27:05 -0400 Subject: [PATCH 10/10] Fix comments again --- contracts/token/MintableToken.sol | 2 +- contracts/token/VestedToken.sol | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/contracts/token/MintableToken.sol b/contracts/token/MintableToken.sol index fc29748a6..2aa70641a 100644 --- a/contracts/token/MintableToken.sol +++ b/contracts/token/MintableToken.sol @@ -40,7 +40,7 @@ contract MintableToken is StandardToken, Ownable { } /** - * @dev Function to spot minting new tokens. + * @dev Function to stop minting new tokens. * @return True if the operation was successful. */ function finishMinting() onlyOwner returns (bool) { diff --git a/contracts/token/VestedToken.sol b/contracts/token/VestedToken.sol index 14ff7ed8c..77a229ac4 100644 --- a/contracts/token/VestedToken.sol +++ b/contracts/token/VestedToken.sol @@ -9,7 +9,6 @@ import "./LimitedTransferToken.sol"; * @dev Tokens that can be vested for a group of addresses. */ contract VestedToken is StandardToken, LimitedTransferToken { - struct TokenGrant { address granter; uint256 value; @@ -24,9 +23,9 @@ contract VestedToken is StandardToken, LimitedTransferToken { * @dev Grant tokens to a specified address * @param _to address The address which the tokens will be granted to. * @param _value uint256 The amount of tokens to be granted. - * @param _start uint64 Represents time of the begining of the grant. - * @param _cliff uint64 Represents the cliff period. - * @param _vesting uint64 Represents the vesting period. + * @param _start uint64 Time of the beginning of the grant. + * @param _cliff uint64 Time of the cliff period. + * @param _vesting uint64 The vesting period. */ function grantVestedTokens( address _to, @@ -121,14 +120,14 @@ contract VestedToken is StandardToken, LimitedTransferToken { } /** - * @dev Calculate amount of vested tokens at a specifc time. - * @param tokens uint256 The amount of tokens grantted. - * @param time uint64 The time to be checked - * @param start uint64 A time representing the begining of the grant - * @param _cliff uint64 Represents the cliff period. - * @param _vesting uint64 Represents the vesting period. - * @return An uint representing the amount of vested tokensof a specif grant. - */ + * @dev Calculate amount of vested tokens at a specifc time. + * @param tokens uint256 The amount of tokens grantted. + * @param time uint64 The time to be checked + * @param start uint64 A time representing the begining of the grant + * @param _cliff uint64 The cliff period. + * @param _vesting uint64 The vesting period. + * @return An uint representing the amount of vested tokensof a specif grant. + */ function calculateVestedTokens( uint256 tokens, uint256 time,