This commit is contained in:
Griff Green 2016-11-12 21:27:38 +01:00 committed by GitHub
parent 9b1bd455a1
commit 8c93008e4a
1 changed files with 29 additions and 28 deletions

View File

@ -19,8 +19,8 @@ pragma solidity ^0.4.4;
/// @title MiniMeToken Contract /// @title MiniMeToken Contract
/// @author Jordi Baylina /// @author Jordi Baylina
/// @dev This token contract's goal is to make it easy to clone this token to /// @dev This token contract's goal is to make it easy to clone this token and
/// spawn cloned tokens using the token distribution at a given block. /// spawn new tokens using the token distribution at a given block.
/// @dev It is ERC20 compliant, but still needs to under go further testing. /// @dev It is ERC20 compliant, but still needs to under go further testing.
@ -51,7 +51,7 @@ contract MiniMeToken is Controlled {
string public name; //The Token's name: e.g. DigixDAO Tokens string public name; //The Token's name: e.g. DigixDAO Tokens
uint8 public decimals; //Number of decimals of the smallest unit uint8 public decimals; //Number of decimals of the smallest unit
string public symbol; //An identifier: e.g. REP string public symbol; //An identifier: e.g. REP
string public version = 'MMT_0.1'; //An arbitrary versioning scheme. string public version = 'MMT_0.1'; //An arbitrary versioning scheme
/// @dev `Checkpoint` is the structure that attaches a block number to the a /// @dev `Checkpoint` is the structure that attaches a block number to the a
@ -65,14 +65,15 @@ contract MiniMeToken is Controlled {
uint value; uint value;
} }
// `parentToken` is the Token address that was cloned. 0x0 for a root token // `parentToken` is the Token address that was cloned to produce this token;
// it will be 0x0 for a token that was not cloned
MiniMeToken public parentToken; MiniMeToken public parentToken;
// `parentSnapShotBlock` is the Block number from the Parent Token that was // `parentSnapShotBlock` is the Block number from the Parent Token that was
// used to determine the initial distribution of the Cloned Token. // used to determine the initial distribution of the Clone Token
uint public parentSnapShotBlock; uint public parentSnapShotBlock;
// `creationBlock` is the block number that the Cloned Token was created // `creationBlock` is the block number that the Clone Token was created
uint public creationBlock; uint public creationBlock;
// `balances` is the map that tracks the balance of each address // `balances` is the map that tracks the balance of each address
@ -87,7 +88,7 @@ contract MiniMeToken is Controlled {
// Flag that determines if the token is transferable or not. // Flag that determines if the token is transferable or not.
bool public isConstant; bool public isConstant;
// The factory used to create new cloned tokens // The factory used to create new clone tokens
MiniMeTokenFactory public tokenFactory; MiniMeTokenFactory public tokenFactory;
//////////////// ////////////////
@ -96,11 +97,11 @@ contract MiniMeToken is Controlled {
/// @notice Constructor to create a MiniMeToken /// @notice Constructor to create a MiniMeToken
/// @param _tokenFactory The address of the MiniMeTokenFactory contract that /// @param _tokenFactory The address of the MiniMeTokenFactory contract that
/// will create the Cloned token contracts /// will create the Clone token contracts
/// @param _parentToken Address of the parent token, set to 0x0 if it is a /// @param _parentToken Address of the parent token, set to 0x0 if it is a
/// new token /// new token
/// @param _parentSnapShotBlock Block of the parent token that will /// @param _parentSnapShotBlock Block of the parent token that will
/// determine the initial distribution of the cloned token, set to 0 if it /// determine the initial distribution of the clone token, set to 0 if it
/// is a new token /// is a new token
/// @param _tokenName Name of the new token /// @param _tokenName Name of the new token
/// @param _decimalUnits Number of decimals of the new token /// @param _decimalUnits Number of decimals of the new token
@ -326,37 +327,37 @@ contract MiniMeToken is Controlled {
// Clone Token Method // Clone Token Method
//////////////// ////////////////
/// @notice Creates a new cloned token with the initial distribution being /// @notice Creates a new clone token with the initial distribution being
/// this token at `_snapshotBlock` /// this token at `_snapshotBlock`
/// @param _clonedTokenName Name of the cloned token /// @param _cloneTokenName Name of the clone token
/// @param _clonedDecimalUnits Units of the cloned token /// @param _cloneDecimalUnits Units of the clone token
/// @param _clonedTokenSymbol Symbol of the cloned token /// @param _cloneTokenSymbol Symbol of the clone token
/// @param _snapshotBlock Block when the distribution of the parent token is /// @param _snapshotBlock Block when the distribution of the parent token is
/// copied to set the initial distribution of the new cloned token; /// copied to set the initial distribution of the new clone token;
/// if the block is higher than the actual block, the current block is used /// if the block is higher than the actual block, the current block is used
/// @param _isConstant True if transfers are not allowed in the cloned token /// @param _isConstant True if transfers are not allowed in the clone token
/// if the block is higher than the actual block, the current block is used /// if the block is higher than the actual block, the current block is used
/// @return The address of the new MiniMeToken Contract /// @return The address of the new MiniMeToken Contract
function createClonedToken( function createCloneToken(
string _clonedTokenName, string _cloneTokenName,
uint8 _clonedDecimalUnits, uint8 _cloneDecimalUnits,
string _clonedTokenSymbol, string _cloneTokenSymbol,
uint _snapshotBlock, uint _snapshotBlock,
bool _isConstant bool _isConstant
) returns(address) { ) returns(address) {
if (_snapshotBlock > block.number) _snapshotBlock = block.number; if (_snapshotBlock > block.number) _snapshotBlock = block.number;
MiniMeToken clonedToken = tokenFactory.createClonedToken( MiniMeToken cloneToken = tokenFactory.createCloneToken(
this, this,
_snapshotBlock, _snapshotBlock,
_clonedTokenName, _cloneTokenName,
_clonedDecimalUnits, _cloneDecimalUnits,
_clonedTokenSymbol, _cloneTokenSymbol,
_isConstant _isConstant
); );
// An event to make the token easy to find on the blockchain // An event to make the token easy to find on the blockchain
NewClonedToken(address(clonedToken), _snapshotBlock); NewCloneToken(address(cloneToken), _snapshotBlock);
return address(clonedToken); return address(cloneToken);
} }
//////////////// ////////////////
@ -459,7 +460,7 @@ contract MiniMeToken is Controlled {
// Events // Events
//////////////// ////////////////
event Transfer(address indexed _from, address indexed _to, uint256 _amount); event Transfer(address indexed _from, address indexed _to, uint256 _amount);
event NewClonedToken(address indexed _clonedToken, uint _snapshotBlock); event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock);
event Approval( event Approval(
address indexed _owner, address indexed _owner,
address indexed _spender, address indexed _spender,
@ -473,11 +474,11 @@ contract MiniMeToken is Controlled {
// MiniMeTokenFactory // MiniMeTokenFactory
//////////////// ////////////////
// This contract is used to generate cloned contracts from a contract. // This contract is used to generate clone contracts from a contract.
// In solidity this is the way to create a contract from a contract of the same // In solidity this is the way to create a contract from a contract of the same
// class // class
contract MiniMeTokenFactory { contract MiniMeTokenFactory {
function createClonedToken( function createCloneToken(
address _parentToken, address _parentToken,
uint _snapshotBlock, uint _snapshotBlock,
string _tokenName, string _tokenName,