mirror of https://github.com/vacp2p/minime.git
Some changes
This commit is contained in:
parent
e435143aa7
commit
101353f514
|
@ -20,12 +20,11 @@ pragma solidity ^0.4.4;
|
|||
|
||||
contract Owned {
|
||||
/// @notice The address of the owner is the only address that can call a
|
||||
/// function with this modifier
|
||||
/// function with this modifier
|
||||
modifier onlyOwner { if (msg.sender != owner) throw; _; }
|
||||
|
||||
address public owner;
|
||||
|
||||
/// @return Returns the owner of this token
|
||||
function Owned() { owner = msg.sender;}
|
||||
|
||||
/// @notice Changes the owner of the contract
|
||||
|
@ -73,9 +72,14 @@ contract MiniMeToken is Owned {
|
|||
|
||||
// `allowed` tracks any extra transfer rights as in all ERC20 tokens
|
||||
mapping (address => mapping (address => uint256)) allowed;
|
||||
|
||||
// Tracks the history of the `totalSupply` of the token
|
||||
Checkpoint[] totalSupplyHistory;
|
||||
|
||||
// Flag that determines if the token is transferable or not.
|
||||
bool public isConstant;
|
||||
|
||||
// The factory used to create new cloned tokens
|
||||
MiniMeTokenFactory public tokenFactory;
|
||||
|
||||
////////////////
|
||||
|
@ -88,7 +92,8 @@ contract MiniMeToken is Owned {
|
|||
/// @param _parentToken Address of the parent token, set to 0x0 if it is a
|
||||
/// new token
|
||||
/// @param _parentSnapShotBlock Block of the parent token that will
|
||||
/// determine the initial distribution of the cloned token
|
||||
/// determine the initial distribution of the cloned token, set to 0 if it
|
||||
/// is a new token
|
||||
/// @param _tokenName Name of the new token
|
||||
/// @param _decimalUnits Number of decimals of the new token
|
||||
/// @param _tokenSymbol Token Symbol for the new token
|
||||
|
@ -114,7 +119,7 @@ contract MiniMeToken is Owned {
|
|||
|
||||
|
||||
///////////////////
|
||||
// ERC20 Functions
|
||||
// ERC20 Methods
|
||||
///////////////////
|
||||
|
||||
/// @notice Send `_amount` tokens to `_to` from `msg.sender`
|
||||
|
@ -206,7 +211,7 @@ contract MiniMeToken is Owned {
|
|||
return allowed[_owner][_spender];
|
||||
}
|
||||
|
||||
/* Approves and then calls the receiving contract (Copied from the Consensis Standard contract) */
|
||||
/* Approves and then calls the receiving contract (Copied from the Consensys Standard contract) */
|
||||
function approveAndCall(address _spender, uint256 _amount, bytes _extraData) returns (bool success) {
|
||||
if (isConstant) throw;
|
||||
allowed[msg.sender][_spender] = _amount;
|
||||
|
@ -237,7 +242,7 @@ contract MiniMeToken is Owned {
|
|||
returns (uint) {
|
||||
|
||||
// If the _blockNumber requested is before the genesis block for the
|
||||
// `parentToken` the value returned is 0
|
||||
// token the value returned is 0
|
||||
if (_blockNumber < creationBlock) {
|
||||
return 0;
|
||||
|
||||
|
@ -250,6 +255,7 @@ contract MiniMeToken is Owned {
|
|||
if (address(parentToken) != 0) {
|
||||
return parentToken.balanceOfAt(_owner, parentSnapShotBlock);
|
||||
} else {
|
||||
// Has no parent
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -278,19 +284,19 @@ contract MiniMeToken is Owned {
|
|||
}
|
||||
|
||||
////////////////
|
||||
// Create a child token from an snapshot of this token at a given block
|
||||
// Clone Token Method
|
||||
////////////////
|
||||
|
||||
/// @notice creates a new child token with the initial distribution the same
|
||||
/// that this token at `_snapshotBlock`
|
||||
/// that this token at `_snapshotBlock`
|
||||
/// @param _childTokenName Name of the child token
|
||||
/// @param _childDecimalUnits Units of the child token
|
||||
/// @param _childTokenSymbol Symbol of the child token
|
||||
/// @param _snapshotBlock Block at when the the distribution of the parent
|
||||
/// token is taken as the initial thistribution of the new generated token.
|
||||
/// If the block is higher that the actual block, the actual block is token
|
||||
/// token is taken as the initial thistribution of the new generated token.
|
||||
/// If the block is higher that the actual block, the actual block is token
|
||||
/// @param _isConstant Sets if the new child contract will allow transfers
|
||||
/// or not.
|
||||
/// or not.
|
||||
/// @return The address of the new MiniMeToken Contract
|
||||
function createChildToken(string _childTokenName, uint8 _childDecimalUnits, string _childTokenSymbol, uint _snapshotBlock, bool _isConstant) returns(address) {
|
||||
if (_snapshotBlock > block.number) _snapshotBlock = block.number;
|
||||
|
@ -352,6 +358,8 @@ contract MiniMeToken is Owned {
|
|||
// Shorcut for the actual value
|
||||
if (_block >= checkpoints[checkpoints.length-1].fromBlock) return checkpoints[checkpoints.length-1].value;
|
||||
if (_block < checkpoints[0].fromBlock) return 0;
|
||||
|
||||
// Binary search of the value in the array.
|
||||
uint min = 0;
|
||||
uint max = checkpoints.length-1;
|
||||
while (max > min) {
|
||||
|
@ -396,6 +404,14 @@ contract MiniMeToken is Owned {
|
|||
|
||||
}
|
||||
|
||||
|
||||
////////////////
|
||||
// MiniMeTokenFactory
|
||||
////////////////
|
||||
|
||||
// This contract is used to generate child contracts from a contract.
|
||||
// In solidity this is the way to create a contract from a contract of the same
|
||||
// class
|
||||
contract MiniMeTokenFactory {
|
||||
function createChildToken(
|
||||
address _parentToken,
|
||||
|
|
Loading…
Reference in New Issue