Add natspec to all remaing contracts, except for vestedToken.sol
This commit is contained in:
committed by
maurelian
parent
1547922b61
commit
f6f91298f0
@ -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,12 +24,22 @@ 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];
|
||||
}
|
||||
|
||||
@ -5,11 +5,11 @@ 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 {
|
||||
|
||||
@ -23,10 +23,18 @@ contract CrowdsaleToken is StandardToken {
|
||||
// 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;
|
||||
@ -42,7 +50,10 @@ contract CrowdsaleToken is StandardToken {
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -2,20 +2,16 @@ pragma solidity ^0.4.8;
|
||||
|
||||
import "./ERC20.sol";
|
||||
|
||||
/*
|
||||
/**
|
||||
|
||||
LimitedTransferToken defines the generic interface and the implementation
|
||||
* @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);
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -18,6 +18,9 @@ contract SimpleToken is StandardToken {
|
||||
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;
|
||||
|
||||
@ -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];
|
||||
}
|
||||
|
||||
@ -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];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user