mirror of
https://github.com/status-im/contracts.git
synced 2025-02-23 03:58:42 +00:00
separate files
This commit is contained in:
parent
2a06243124
commit
268babcfbf
@ -29,6 +29,7 @@ pragma solidity >=0.5.0 <0.6.0;
|
||||
import "../common/Controlled.sol";
|
||||
import "./TokenController.sol";
|
||||
import "./ApproveAndCallFallBack.sol";
|
||||
import "./MiniMeTokenFactory.sol";
|
||||
|
||||
/**
|
||||
* @dev The actual token contract, the default controller is the msg.sender
|
||||
@ -88,7 +89,7 @@ contract MiniMeToken is Controlled {
|
||||
// Constructor
|
||||
////////////////
|
||||
|
||||
/**
|
||||
/**
|
||||
* @notice Constructor to create a MiniMeToken
|
||||
* @param _tokenFactory The address of the MiniMeTokenFactory contract that
|
||||
* will create the Clone token contracts, the token factory needs to be
|
||||
@ -111,7 +112,7 @@ contract MiniMeToken is Controlled {
|
||||
uint8 _decimalUnits,
|
||||
string memory _tokenSymbol,
|
||||
bool _transfersEnabled
|
||||
)
|
||||
)
|
||||
public
|
||||
{
|
||||
tokenFactory = MiniMeTokenFactory(_tokenFactory);
|
||||
@ -152,8 +153,8 @@ contract MiniMeToken is Controlled {
|
||||
address _from,
|
||||
address _to,
|
||||
uint256 _amount
|
||||
)
|
||||
public
|
||||
)
|
||||
public
|
||||
returns (bool success)
|
||||
{
|
||||
|
||||
@ -165,7 +166,7 @@ contract MiniMeToken is Controlled {
|
||||
require(transfersEnabled, "Transfers disabled");
|
||||
|
||||
// The standard ERC 20 transferFrom functionality
|
||||
if (allowed[_from][msg.sender] < _amount) {
|
||||
if (allowed[_from][msg.sender] < _amount) {
|
||||
return false;
|
||||
}
|
||||
allowed[_from][msg.sender] -= _amount;
|
||||
@ -185,7 +186,7 @@ contract MiniMeToken is Controlled {
|
||||
address _from,
|
||||
address _to,
|
||||
uint _amount
|
||||
)
|
||||
)
|
||||
internal
|
||||
returns(bool)
|
||||
{
|
||||
@ -232,7 +233,7 @@ contract MiniMeToken is Controlled {
|
||||
address _spender,
|
||||
uint256 _amount
|
||||
)
|
||||
internal
|
||||
internal
|
||||
returns (bool)
|
||||
{
|
||||
require(transfersEnabled, "Transfers disabled");
|
||||
@ -283,7 +284,7 @@ contract MiniMeToken is Controlled {
|
||||
function allowance(
|
||||
address _owner,
|
||||
address _spender
|
||||
)
|
||||
)
|
||||
external
|
||||
view
|
||||
returns (uint256 remaining)
|
||||
@ -303,7 +304,7 @@ contract MiniMeToken is Controlled {
|
||||
address _spender,
|
||||
uint256 _amount,
|
||||
bytes memory _extraData
|
||||
)
|
||||
)
|
||||
public
|
||||
returns (bool success)
|
||||
{
|
||||
@ -341,10 +342,10 @@ contract MiniMeToken is Controlled {
|
||||
function balanceOfAt(
|
||||
address _owner,
|
||||
uint _blockNumber
|
||||
)
|
||||
)
|
||||
public
|
||||
view
|
||||
returns (uint)
|
||||
returns (uint)
|
||||
{
|
||||
|
||||
// These next few lines are used when the balance of the token is
|
||||
@ -413,7 +414,7 @@ contract MiniMeToken is Controlled {
|
||||
string memory _cloneTokenSymbol,
|
||||
uint _snapshotBlock,
|
||||
bool _transfersEnabled
|
||||
)
|
||||
)
|
||||
public
|
||||
returns(address)
|
||||
{
|
||||
@ -440,7 +441,7 @@ contract MiniMeToken is Controlled {
|
||||
////////////////
|
||||
// Generate and destroy tokens
|
||||
////////////////
|
||||
|
||||
|
||||
/**
|
||||
* @notice Generates `_amount` tokens that are assigned to `_owner`
|
||||
* @param _owner The address that will be assigned the new tokens
|
||||
@ -474,7 +475,7 @@ contract MiniMeToken is Controlled {
|
||||
function destroyTokens(
|
||||
address _owner,
|
||||
uint _amount
|
||||
)
|
||||
)
|
||||
public
|
||||
onlyController
|
||||
returns (bool)
|
||||
@ -514,7 +515,7 @@ contract MiniMeToken is Controlled {
|
||||
function getValueAt(
|
||||
Checkpoint[] storage checkpoints,
|
||||
uint _block
|
||||
)
|
||||
)
|
||||
internal
|
||||
view
|
||||
returns (uint)
|
||||
@ -571,7 +572,7 @@ contract MiniMeToken is Controlled {
|
||||
uint size;
|
||||
if (_addr == address(0)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
assembly {
|
||||
size := extcodesize(_addr)
|
||||
}
|
||||
@ -630,49 +631,3 @@ contract MiniMeToken is Controlled {
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
////////////////
|
||||
// MiniMeTokenFactory
|
||||
////////////////
|
||||
|
||||
/**
|
||||
* @dev 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 class
|
||||
*/
|
||||
contract MiniMeTokenFactory {
|
||||
|
||||
/**
|
||||
* @notice Update the DApp by creating a new token with new functionalities
|
||||
* the msg.sender becomes the controller of this clone token
|
||||
* @param _parentToken Address of the token being cloned
|
||||
* @param _snapshotBlock Block of the parent token that will
|
||||
* determine the initial distribution of the clone 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
|
||||
* @param _transfersEnabled If true, tokens will be able to be transferred
|
||||
* @return The address of the new token contract
|
||||
*/
|
||||
function createCloneToken(
|
||||
address _parentToken,
|
||||
uint _snapshotBlock,
|
||||
string memory _tokenName,
|
||||
uint8 _decimalUnits,
|
||||
string memory _tokenSymbol,
|
||||
bool _transfersEnabled
|
||||
) public returns (MiniMeToken) {
|
||||
MiniMeToken newToken = new MiniMeToken(
|
||||
address(this),
|
||||
_parentToken,
|
||||
_snapshotBlock,
|
||||
_tokenName,
|
||||
_decimalUnits,
|
||||
_tokenSymbol,
|
||||
_transfersEnabled
|
||||
);
|
||||
|
||||
newToken.changeController(msg.sender);
|
||||
return newToken;
|
||||
}
|
||||
}
|
49
contracts/token/MiniMeTokenFactory.sol
Normal file
49
contracts/token/MiniMeTokenFactory.sol
Normal file
@ -0,0 +1,49 @@
|
||||
pragma solidity >=0.5.0 <0.6.0;
|
||||
|
||||
import "./MiniMeToken.sol";
|
||||
|
||||
////////////////
|
||||
// MiniMeTokenFactory
|
||||
////////////////
|
||||
|
||||
/**
|
||||
* @dev 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 class
|
||||
*/
|
||||
contract MiniMeTokenFactory {
|
||||
|
||||
/**
|
||||
* @notice Update the DApp by creating a new token with new functionalities
|
||||
* the msg.sender becomes the controller of this clone token
|
||||
* @param _parentToken Address of the token being cloned
|
||||
* @param _snapshotBlock Block of the parent token that will
|
||||
* determine the initial distribution of the clone 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
|
||||
* @param _transfersEnabled If true, tokens will be able to be transferred
|
||||
* @return The address of the new token contract
|
||||
*/
|
||||
function createCloneToken(
|
||||
address _parentToken,
|
||||
uint _snapshotBlock,
|
||||
string memory _tokenName,
|
||||
uint8 _decimalUnits,
|
||||
string memory _tokenSymbol,
|
||||
bool _transfersEnabled
|
||||
) public returns (MiniMeToken) {
|
||||
MiniMeToken newToken = new MiniMeToken(
|
||||
address(this),
|
||||
_parentToken,
|
||||
_snapshotBlock,
|
||||
_tokenName,
|
||||
_decimalUnits,
|
||||
_tokenSymbol,
|
||||
_transfersEnabled
|
||||
);
|
||||
|
||||
newToken.changeController(msg.sender);
|
||||
return newToken;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user