Minor changes to doc comments for token and other contracts
This commit is contained in:
@ -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];
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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) {
|
||||
|
||||
|
||||
@ -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++) {
|
||||
|
||||
Reference in New Issue
Block a user