contract BitDiskToken is StandardToken {

    // metadata
    string  public constant name = "BitDisk";
    string  public constant symbol = "BTD";
    uint8 public constant decimals = 18;
    string  public version = "1.0";

    // contracts
    address public ethFundDeposit;              // deposit address for ETH for BTD team
    address public newContractAddr;

    uint256 public tokenMigrated = 0;           // total migrated tokens

    // events
    event AllocateToken(address indexed _to, uint256 _value);
    event IssueToken(address indexed _to, uint256 _value);
    event IncreaseSupply(uint256 _value);
    event DecreaseSupply(uint256 _value);
    event Migrate(address indexed _to, uint256 _value);
    event CreateBTD(address indexed _to, uint256 _value);

    function formatDecimals(uint256 _value) internal pure returns (uint256) {
        return _value * (10 ** uint256(decimals));
    }

    // constructor
    constructor() public {
        ethFundDeposit = msg.sender;

        totalSupply = formatDecimals(2800 * (10 ** 6)); // // two billion and one hundred million and never raised
        balances[msg.sender] = totalSupply;
        emit CreateBTD(ethFundDeposit, totalSupply);
    }

    modifier onlyOwner() {
        require(msg.sender == ethFundDeposit, "auth fail"); 
        _;
    }

    /// new owner
    function changeOwner(address _newFundDeposit) external onlyOwner {
        require(_newFundDeposit != address(0x0), "error addr");
        require(_newFundDeposit != ethFundDeposit, "not changed");

        ethFundDeposit = _newFundDeposit;
    }

    /// update token
    function setMigrateContract(address _newContractAddr) external onlyOwner {
        require(_newContractAddr != address(0x0), "error addr");
        require(_newContractAddr != newContractAddr, "not changed");

        newContractAddr = _newContractAddr;
    }

    function migrate() external {
        require(newContractAddr != address(0x0), "no newContractAddr");

        uint256 tokens = balances[msg.sender];
        require(tokens != 0, "no tokens to migrate");

        balances[msg.sender] = 0;
        tokenMigrated = tokenMigrated.add(tokens);

        IMigrationContract newContract = IMigrationContract(newContractAddr);
        require(newContract.migrate(msg.sender, tokens), "migrate fail");

        emit Migrate(msg.sender, tokens);
    }

    function withdrawEther(uint256 amount) external {
        require(msg.sender == ethFundDeposit, "not owner");
        msg.sender.transfer(amount);
    }
	
	// can accept ether
    function() external payable {
    }
}
function() external payable {
}

// can accept ether