update to new solc + lint
This commit is contained in:
parent
f51ae08fa9
commit
8bae559ec9
|
@ -1,6 +1,7 @@
|
||||||
pragma solidity ^0.4.11;
|
pragma solidity ^0.4.17;
|
||||||
|
|
||||||
import "../common/Controlled.sol";
|
import "../common/Controlled.sol";
|
||||||
|
import "./MiniMeTokenFactory.sol";
|
||||||
import "./TokenController.sol";
|
import "./TokenController.sol";
|
||||||
import "./ApproveAndCallFallBack.sol";
|
import "./ApproveAndCallFallBack.sol";
|
||||||
|
|
||||||
|
@ -36,7 +37,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 a
|
/// @dev `Checkpoint` is the structure that attaches a block number to a
|
||||||
|
@ -104,7 +105,9 @@ contract MiniMeToken is Controlled {
|
||||||
uint8 _decimalUnits,
|
uint8 _decimalUnits,
|
||||||
string _tokenSymbol,
|
string _tokenSymbol,
|
||||||
bool _transfersEnabled
|
bool _transfersEnabled
|
||||||
) {
|
)
|
||||||
|
public
|
||||||
|
{
|
||||||
tokenFactory = MiniMeTokenFactory(_tokenFactory);
|
tokenFactory = MiniMeTokenFactory(_tokenFactory);
|
||||||
name = _tokenName; // Set the name
|
name = _tokenName; // Set the name
|
||||||
decimals = _decimalUnits; // Set the decimals
|
decimals = _decimalUnits; // Set the decimals
|
||||||
|
@ -112,7 +115,7 @@ contract MiniMeToken is Controlled {
|
||||||
parentToken = MiniMeToken(_parentToken);
|
parentToken = MiniMeToken(_parentToken);
|
||||||
parentSnapShotBlock = _parentSnapShotBlock;
|
parentSnapShotBlock = _parentSnapShotBlock;
|
||||||
transfersEnabled = _transfersEnabled;
|
transfersEnabled = _transfersEnabled;
|
||||||
creationBlock = getBlockNumber();
|
creationBlock = block.number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,8 +127,8 @@ contract MiniMeToken is Controlled {
|
||||||
/// @param _to The address of the recipient
|
/// @param _to The address of the recipient
|
||||||
/// @param _amount The amount of tokens to be transferred
|
/// @param _amount The amount of tokens to be transferred
|
||||||
/// @return Whether the transfer was successful or not
|
/// @return Whether the transfer was successful or not
|
||||||
function transfer(address _to, uint256 _amount) returns (bool success) {
|
function transfer(address _to, uint256 _amount) public returns (bool success) {
|
||||||
if (!transfersEnabled) throw;
|
require(transfersEnabled);
|
||||||
return doTransfer(msg.sender, _to, _amount);
|
return doTransfer(msg.sender, _to, _amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,18 +138,26 @@ contract MiniMeToken is Controlled {
|
||||||
/// @param _to The address of the recipient
|
/// @param _to The address of the recipient
|
||||||
/// @param _amount The amount of tokens to be transferred
|
/// @param _amount The amount of tokens to be transferred
|
||||||
/// @return True if the transfer was successful
|
/// @return True if the transfer was successful
|
||||||
function transferFrom(address _from, address _to, uint256 _amount
|
function transferFrom(
|
||||||
) returns (bool success) {
|
address _from,
|
||||||
|
address _to,
|
||||||
|
uint256 _amount
|
||||||
|
)
|
||||||
|
public
|
||||||
|
returns (bool success)
|
||||||
|
{
|
||||||
|
|
||||||
// The controller of this contract can move tokens around at will,
|
// The controller of this contract can move tokens around at will,
|
||||||
// this is important to recognize! Confirm that you trust the
|
// this is important to recognize! Confirm that you trust the
|
||||||
// controller of this contract, which in most situations should be
|
// controller of this contract, which in most situations should be
|
||||||
// another open source smart contract or 0x0
|
// another open source smart contract or 0x0
|
||||||
if (msg.sender != controller) {
|
if (msg.sender != controller) {
|
||||||
if (!transfersEnabled) throw;
|
require(transfersEnabled);
|
||||||
|
|
||||||
// The standard ERC 20 transferFrom functionality
|
// The standard ERC 20 transferFrom functionality
|
||||||
if (allowed[_from][msg.sender] < _amount) return false;
|
if (allowed[_from][msg.sender] < _amount) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
allowed[_from][msg.sender] -= _amount;
|
allowed[_from][msg.sender] -= _amount;
|
||||||
}
|
}
|
||||||
return doTransfer(_from, _to, _amount);
|
return doTransfer(_from, _to, _amount);
|
||||||
|
@ -158,29 +169,34 @@ contract MiniMeToken is Controlled {
|
||||||
/// @param _to The address of the recipient
|
/// @param _to The address of the recipient
|
||||||
/// @param _amount The amount of tokens to be transferred
|
/// @param _amount The amount of tokens to be transferred
|
||||||
/// @return True if the transfer was successful
|
/// @return True if the transfer was successful
|
||||||
function doTransfer(address _from, address _to, uint _amount
|
function doTransfer(
|
||||||
) internal returns(bool) {
|
address _from,
|
||||||
|
address _to,
|
||||||
|
uint _amount
|
||||||
|
)
|
||||||
|
internal
|
||||||
|
returns(bool)
|
||||||
|
{
|
||||||
|
|
||||||
if (_amount == 0) {
|
if (_amount == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentSnapShotBlock >= getBlockNumber()) throw;
|
require(parentSnapShotBlock < block.number);
|
||||||
|
|
||||||
// Do not allow transfer to 0x0 or the token contract itself
|
// Do not allow transfer to 0x0 or the token contract itself
|
||||||
if ((_to == 0) || (_to == address(this))) throw;
|
require((_to != 0) && (_to != address(this)));
|
||||||
|
|
||||||
// If the amount being transfered is more than the balance of the
|
// If the amount being transfered is more than the balance of the
|
||||||
// account the transfer returns false
|
// account the transfer returns false
|
||||||
var previousBalanceFrom = balanceOfAt(_from, getBlockNumber());
|
var previousBalanceFrom = balanceOfAt(_from, block.number);
|
||||||
if (previousBalanceFrom < _amount) {
|
if (previousBalanceFrom < _amount) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alerts the token controller of the transfer
|
// Alerts the token controller of the transfer
|
||||||
if (isContract(controller)) {
|
if (isContract(controller)) {
|
||||||
if (!TokenController(controller).onTransfer(_from, _to, _amount))
|
require(TokenController(controller).onTransfer(_from, _to, _amount));
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// First update the balance array with the new value for the address
|
// First update the balance array with the new value for the address
|
||||||
|
@ -189,8 +205,8 @@ contract MiniMeToken is Controlled {
|
||||||
|
|
||||||
// Then update the balance array with the new value for the address
|
// Then update the balance array with the new value for the address
|
||||||
// receiving the tokens
|
// receiving the tokens
|
||||||
var previousBalanceTo = balanceOfAt(_to, getBlockNumber());
|
var previousBalanceTo = balanceOfAt(_to, block.number);
|
||||||
if (previousBalanceTo + _amount < previousBalanceTo) throw; // Check for overflow
|
require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
|
||||||
updateValueAtNow(balances[_to], previousBalanceTo + _amount);
|
updateValueAtNow(balances[_to], previousBalanceTo + _amount);
|
||||||
|
|
||||||
// An event to make the transfer easy to find on the blockchain
|
// An event to make the transfer easy to find on the blockchain
|
||||||
|
@ -201,8 +217,8 @@ contract MiniMeToken is Controlled {
|
||||||
|
|
||||||
/// @param _owner The address that's balance is being requested
|
/// @param _owner The address that's balance is being requested
|
||||||
/// @return The balance of `_owner` at the current block
|
/// @return The balance of `_owner` at the current block
|
||||||
function balanceOf(address _owner) constant returns (uint256 balance) {
|
function balanceOf(address _owner) public constant returns (uint256 balance) {
|
||||||
return balanceOfAt(_owner, getBlockNumber());
|
return balanceOfAt(_owner, block.number);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
|
/// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on
|
||||||
|
@ -211,19 +227,18 @@ contract MiniMeToken is Controlled {
|
||||||
/// @param _spender The address of the account able to transfer the tokens
|
/// @param _spender The address of the account able to transfer the tokens
|
||||||
/// @param _amount The amount of tokens to be approved for transfer
|
/// @param _amount The amount of tokens to be approved for transfer
|
||||||
/// @return True if the approval was successful
|
/// @return True if the approval was successful
|
||||||
function approve(address _spender, uint256 _amount) returns (bool success) {
|
function approve(address _spender, uint256 _amount) public returns (bool success) {
|
||||||
if (!transfersEnabled) throw;
|
require(transfersEnabled);
|
||||||
|
|
||||||
// To change the approve amount you first have to reduce the addresses`
|
// To change the approve amount you first have to reduce the addresses`
|
||||||
// allowance to zero by calling `approve(_spender,0)` if it is not
|
// allowance to zero by calling `approve(_spender,0)` if it is not
|
||||||
// already 0 to mitigate the race condition described here:
|
// already 0 to mitigate the race condition described here:
|
||||||
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
|
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
|
||||||
if ((_amount!=0) && (allowed[msg.sender][_spender] !=0)) throw;
|
require((_amount == 0) || (allowed[msg.sender][_spender] == 0));
|
||||||
|
|
||||||
// Alerts the token controller of the approve function call
|
// Alerts the token controller of the approve function call
|
||||||
if (isContract(controller)) {
|
if (isContract(controller)) {
|
||||||
if (!TokenController(controller).onApprove(msg.sender, _spender, _amount))
|
require(TokenController(controller).onApprove(msg.sender, _spender, _amount));
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
allowed[msg.sender][_spender] = _amount;
|
allowed[msg.sender][_spender] = _amount;
|
||||||
|
@ -236,8 +251,14 @@ contract MiniMeToken is Controlled {
|
||||||
/// @param _spender The address of the account able to transfer the tokens
|
/// @param _spender The address of the account able to transfer the tokens
|
||||||
/// @return Amount of remaining tokens of _owner that _spender is allowed
|
/// @return Amount of remaining tokens of _owner that _spender is allowed
|
||||||
/// to spend
|
/// to spend
|
||||||
function allowance(address _owner, address _spender
|
function allowance(
|
||||||
) constant returns (uint256 remaining) {
|
address _owner,
|
||||||
|
address _spender
|
||||||
|
)
|
||||||
|
public
|
||||||
|
constant
|
||||||
|
returns (uint256 remaining)
|
||||||
|
{
|
||||||
return allowed[_owner][_spender];
|
return allowed[_owner][_spender];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,9 +269,15 @@ contract MiniMeToken is Controlled {
|
||||||
/// @param _spender The address of the contract able to transfer the tokens
|
/// @param _spender The address of the contract able to transfer the tokens
|
||||||
/// @param _amount The amount of tokens to be approved for transfer
|
/// @param _amount The amount of tokens to be approved for transfer
|
||||||
/// @return True if the function call was successful
|
/// @return True if the function call was successful
|
||||||
function approveAndCall(address _spender, uint256 _amount, bytes _extraData
|
function approveAndCall(
|
||||||
) returns (bool success) {
|
address _spender,
|
||||||
if (!approve(_spender, _amount)) throw;
|
uint256 _amount,
|
||||||
|
bytes _extraData
|
||||||
|
)
|
||||||
|
public
|
||||||
|
returns (bool success)
|
||||||
|
{
|
||||||
|
require(approve(_spender, _amount));
|
||||||
|
|
||||||
ApproveAndCallFallBack(_spender).receiveApproval(
|
ApproveAndCallFallBack(_spender).receiveApproval(
|
||||||
msg.sender,
|
msg.sender,
|
||||||
|
@ -264,8 +291,8 @@ contract MiniMeToken is Controlled {
|
||||||
|
|
||||||
/// @dev This function makes it easy to get the total number of tokens
|
/// @dev This function makes it easy to get the total number of tokens
|
||||||
/// @return The total number of tokens
|
/// @return The total number of tokens
|
||||||
function totalSupply() constant returns (uint) {
|
function totalSupply() public constant returns (uint) {
|
||||||
return totalSupplyAt(getBlockNumber());
|
return totalSupplyAt(block.number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -277,8 +304,14 @@ contract MiniMeToken is Controlled {
|
||||||
/// @param _owner The address from which the balance will be retrieved
|
/// @param _owner The address from which the balance will be retrieved
|
||||||
/// @param _blockNumber The block number when the balance is queried
|
/// @param _blockNumber The block number when the balance is queried
|
||||||
/// @return The balance at `_blockNumber`
|
/// @return The balance at `_blockNumber`
|
||||||
function balanceOfAt(address _owner, uint _blockNumber) constant
|
function balanceOfAt(
|
||||||
returns (uint) {
|
address _owner,
|
||||||
|
uint _blockNumber
|
||||||
|
)
|
||||||
|
public
|
||||||
|
constant
|
||||||
|
returns (uint)
|
||||||
|
{
|
||||||
|
|
||||||
// These next few lines are used when the balance of the token is
|
// These next few lines are used when the balance of the token is
|
||||||
// requested before a check point was ever created for this token, it
|
// requested before a check point was ever created for this token, it
|
||||||
|
@ -303,7 +336,7 @@ contract MiniMeToken is Controlled {
|
||||||
/// @notice Total amount of tokens at a specific `_blockNumber`.
|
/// @notice Total amount of tokens at a specific `_blockNumber`.
|
||||||
/// @param _blockNumber The block number when the totalSupply is queried
|
/// @param _blockNumber The block number when the totalSupply is queried
|
||||||
/// @return The total amount of tokens at `_blockNumber`
|
/// @return The total amount of tokens at `_blockNumber`
|
||||||
function totalSupplyAt(uint _blockNumber) constant returns(uint) {
|
function totalSupplyAt(uint _blockNumber) public constant returns(uint) {
|
||||||
|
|
||||||
// These next few lines are used when the totalSupply of the token is
|
// These next few lines are used when the totalSupply of the token is
|
||||||
// requested before a check point was ever created for this token, it
|
// requested before a check point was ever created for this token, it
|
||||||
|
@ -344,8 +377,13 @@ contract MiniMeToken is Controlled {
|
||||||
string _cloneTokenSymbol,
|
string _cloneTokenSymbol,
|
||||||
uint _snapshotBlock,
|
uint _snapshotBlock,
|
||||||
bool _transfersEnabled
|
bool _transfersEnabled
|
||||||
) returns(address) {
|
)
|
||||||
if (_snapshotBlock == 0) _snapshotBlock = getBlockNumber();
|
public
|
||||||
|
returns(address)
|
||||||
|
{
|
||||||
|
if (_snapshotBlock == 0) {
|
||||||
|
_snapshotBlock = block.number;
|
||||||
|
}
|
||||||
MiniMeToken cloneToken = tokenFactory.createCloneToken(
|
MiniMeToken cloneToken = tokenFactory.createCloneToken(
|
||||||
this,
|
this,
|
||||||
_snapshotBlock,
|
_snapshotBlock,
|
||||||
|
@ -370,13 +408,19 @@ contract MiniMeToken is Controlled {
|
||||||
/// @param _owner The address that will be assigned the new tokens
|
/// @param _owner The address that will be assigned the new tokens
|
||||||
/// @param _amount The quantity of tokens generated
|
/// @param _amount The quantity of tokens generated
|
||||||
/// @return True if the tokens are generated correctly
|
/// @return True if the tokens are generated correctly
|
||||||
function generateTokens(address _owner, uint _amount
|
function generateTokens(
|
||||||
) onlyController returns (bool) {
|
address _owner,
|
||||||
uint curTotalSupply = getValueAt(totalSupplyHistory, getBlockNumber());
|
uint _amount
|
||||||
if (curTotalSupply + _amount < curTotalSupply) throw; // Check for overflow
|
)
|
||||||
|
public
|
||||||
|
onlyController
|
||||||
|
returns (bool)
|
||||||
|
{
|
||||||
|
uint curTotalSupply = totalSupply();
|
||||||
|
require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow
|
||||||
|
uint previousBalanceTo = balanceOf(_owner);
|
||||||
|
require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow
|
||||||
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
|
updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount);
|
||||||
var previousBalanceTo = balanceOf(_owner);
|
|
||||||
if (previousBalanceTo + _amount < previousBalanceTo) throw; // Check for overflow
|
|
||||||
updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
|
updateValueAtNow(balances[_owner], previousBalanceTo + _amount);
|
||||||
Transfer(0, _owner, _amount);
|
Transfer(0, _owner, _amount);
|
||||||
return true;
|
return true;
|
||||||
|
@ -387,13 +431,19 @@ contract MiniMeToken is Controlled {
|
||||||
/// @param _owner The address that will lose the tokens
|
/// @param _owner The address that will lose the tokens
|
||||||
/// @param _amount The quantity of tokens to burn
|
/// @param _amount The quantity of tokens to burn
|
||||||
/// @return True if the tokens are burned correctly
|
/// @return True if the tokens are burned correctly
|
||||||
function destroyTokens(address _owner, uint _amount
|
function destroyTokens(
|
||||||
) onlyController returns (bool) {
|
address _owner,
|
||||||
uint curTotalSupply = getValueAt(totalSupplyHistory, getBlockNumber());
|
uint _amount
|
||||||
if (curTotalSupply < _amount) throw;
|
)
|
||||||
|
public
|
||||||
|
onlyController
|
||||||
|
returns (bool)
|
||||||
|
{
|
||||||
|
uint curTotalSupply = totalSupply();
|
||||||
|
require(curTotalSupply >= _amount);
|
||||||
|
uint previousBalanceFrom = balanceOf(_owner);
|
||||||
|
require(previousBalanceFrom >= _amount);
|
||||||
updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
|
updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount);
|
||||||
var previousBalanceFrom = balanceOf(_owner);
|
|
||||||
if (previousBalanceFrom < _amount) throw;
|
|
||||||
updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
|
updateValueAtNow(balances[_owner], previousBalanceFrom - _amount);
|
||||||
Transfer(_owner, 0, _amount);
|
Transfer(_owner, 0, _amount);
|
||||||
return true;
|
return true;
|
||||||
|
@ -406,7 +456,7 @@ contract MiniMeToken is Controlled {
|
||||||
|
|
||||||
/// @notice Enables token holders to transfer their tokens freely if true
|
/// @notice Enables token holders to transfer their tokens freely if true
|
||||||
/// @param _transfersEnabled True if transfers are allowed in the clone
|
/// @param _transfersEnabled True if transfers are allowed in the clone
|
||||||
function enableTransfers(bool _transfersEnabled) onlyController {
|
function enableTransfers(bool _transfersEnabled) public onlyController {
|
||||||
transfersEnabled = _transfersEnabled;
|
transfersEnabled = _transfersEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,14 +468,25 @@ contract MiniMeToken is Controlled {
|
||||||
/// @param checkpoints The history of values being queried
|
/// @param checkpoints The history of values being queried
|
||||||
/// @param _block The block number to retrieve the value at
|
/// @param _block The block number to retrieve the value at
|
||||||
/// @return The number of tokens being queried
|
/// @return The number of tokens being queried
|
||||||
function getValueAt(Checkpoint[] storage checkpoints, uint _block
|
function getValueAt(
|
||||||
) constant internal returns (uint) {
|
Checkpoint[] storage checkpoints,
|
||||||
if (checkpoints.length == 0) return 0;
|
uint _block
|
||||||
|
)
|
||||||
|
constant
|
||||||
|
internal
|
||||||
|
returns (uint)
|
||||||
|
{
|
||||||
|
if (checkpoints.length == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Shortcut for the actual value
|
// Shortcut for the actual value
|
||||||
if (_block >= checkpoints[checkpoints.length-1].fromBlock)
|
if (_block >= checkpoints[checkpoints.length-1].fromBlock) {
|
||||||
return checkpoints[checkpoints.length-1].value;
|
return checkpoints[checkpoints.length-1].value;
|
||||||
if (_block < checkpoints[0].fromBlock) return 0;
|
}
|
||||||
|
if (_block < checkpoints[0].fromBlock) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Binary search of the value in the array
|
// Binary search of the value in the array
|
||||||
uint min = 0;
|
uint min = 0;
|
||||||
|
@ -445,15 +506,14 @@ contract MiniMeToken is Controlled {
|
||||||
/// `totalSupplyHistory`
|
/// `totalSupplyHistory`
|
||||||
/// @param checkpoints The history of data being updated
|
/// @param checkpoints The history of data being updated
|
||||||
/// @param _value The new number of tokens
|
/// @param _value The new number of tokens
|
||||||
function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value
|
function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value) internal {
|
||||||
) internal {
|
|
||||||
if ((checkpoints.length == 0)
|
if ((checkpoints.length == 0)
|
||||||
|| (checkpoints[checkpoints.length -1].fromBlock < getBlockNumber())) {
|
|| (checkpoints[checkpoints.length -1].fromBlock < block.number)) {
|
||||||
Checkpoint newCheckPoint = checkpoints[ checkpoints.length++ ];
|
Checkpoint storage newCheckPoint = checkpoints[ checkpoints.length++ ];
|
||||||
newCheckPoint.fromBlock = uint128(getBlockNumber());
|
newCheckPoint.fromBlock = uint128(block.number);
|
||||||
newCheckPoint.value = uint128(_value);
|
newCheckPoint.value = uint128(_value);
|
||||||
} else {
|
} else {
|
||||||
Checkpoint oldCheckPoint = checkpoints[checkpoints.length-1];
|
Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length-1];
|
||||||
oldCheckPoint.value = uint128(_value);
|
oldCheckPoint.value = uint128(_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,7 +523,9 @@ contract MiniMeToken is Controlled {
|
||||||
/// @return True if `_addr` is a contract
|
/// @return True if `_addr` is a contract
|
||||||
function isContract(address _addr) constant internal returns(bool) {
|
function isContract(address _addr) constant internal returns(bool) {
|
||||||
uint size;
|
uint size;
|
||||||
if (_addr == 0) return false;
|
if (_addr == 0){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
assembly {
|
assembly {
|
||||||
size := extcodesize(_addr)
|
size := extcodesize(_addr)
|
||||||
}
|
}
|
||||||
|
@ -478,23 +540,9 @@ contract MiniMeToken is Controlled {
|
||||||
/// @notice The fallback function: If the contract's controller has not been
|
/// @notice The fallback function: If the contract's controller has not been
|
||||||
/// set to 0, then the `proxyPayment` method is called which relays the
|
/// set to 0, then the `proxyPayment` method is called which relays the
|
||||||
/// ether and creates tokens as described in the token controller contract
|
/// ether and creates tokens as described in the token controller contract
|
||||||
function () payable {
|
function () public payable {
|
||||||
if (isContract(controller)) {
|
require(isContract(controller));
|
||||||
if (! TokenController(controller).proxyPayment.value(msg.value)(msg.sender))
|
require(TokenController(controller).proxyPayment.value(msg.value)(msg.sender));
|
||||||
throw;
|
|
||||||
} else {
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////
|
|
||||||
// Testing specific methods
|
|
||||||
//////////
|
|
||||||
|
|
||||||
/// @notice This function is overridden by the test Mocks.
|
|
||||||
function getBlockNumber() internal constant returns (uint256) {
|
|
||||||
return block.number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
|
@ -505,13 +553,13 @@ contract MiniMeToken is Controlled {
|
||||||
/// sent tokens to this contract.
|
/// sent tokens to this contract.
|
||||||
/// @param _token The address of the token contract that you want to recover
|
/// @param _token The address of the token contract that you want to recover
|
||||||
/// set to 0 in case you want to extract ether.
|
/// set to 0 in case you want to extract ether.
|
||||||
function claimTokens(address _token) onlyController {
|
function claimTokens(address _token) public onlyController {
|
||||||
if (_token == 0x0) {
|
if (_token == 0x0) {
|
||||||
controller.transfer(this.balance);
|
controller.transfer(this.balance);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ERC20Token token = ERC20Token(_token);
|
MiniMeToken token = MiniMeToken(_token);
|
||||||
uint balance = token.balanceOf(this);
|
uint balance = token.balanceOf(this);
|
||||||
token.transfer(controller, balance);
|
token.transfer(controller, balance);
|
||||||
ClaimedTokens(_token, controller, balance);
|
ClaimedTokens(_token, controller, balance);
|
||||||
|
@ -520,7 +568,6 @@ contract MiniMeToken is Controlled {
|
||||||
////////////////
|
////////////////
|
||||||
// Events
|
// Events
|
||||||
////////////////
|
////////////////
|
||||||
|
|
||||||
event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount);
|
event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount);
|
||||||
event Transfer(address indexed _from, address indexed _to, uint256 _amount);
|
event Transfer(address indexed _from, address indexed _to, uint256 _amount);
|
||||||
event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock);
|
event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock);
|
||||||
|
|
Loading…
Reference in New Issue