contract TokenSaleFactory is Ownable{
    //@logs all depoloyed sales
    address[] public deployedSales;
    TokenSales public newTokenSale;
    //@allows checking of which sales are associated with a specific address
    mapping (address => address) public mySales;


    //@dev fee for generating Sale
    uint public tokenFee = 0.01 ether;
    //@dev set token fee (owner only)
    function setTokenFee(uint _fee) external onlyOwner {
      tokenFee = _fee;
    }

  ERCInterface tokenContract;

    //@function that creates sale
    function createTokenSale(address _tokenAddress) external payable returns (TokenSales) {
      tokenContract = ERCInterface(_tokenAddress);
       require(tokenContract.creator() == msg.sender);
        require(msg.value == tokenFee);
        newTokenSale = new TokenSales(msg.sender, _tokenAddress);
        deployedSales.push(address(newTokenSale));
        mySales[address(newTokenSale)] = msg.sender;
        return(newTokenSale);
    }

    //@retreives all deployed sales
    function getDeployedSales() public view returns (address[] memory) {
        return deployedSales;
    }

    //@allows owner to withdraw fees
    function withdraw() external onlyOwner {
      address _owner = address(uint160(owner()));
      _owner.transfer(address(this).balance);
      }
}
//@dev token sale factory creates sales for ERC-20 tokens
function setTokenFee(uint _fee) external onlyOwner {
      tokenFee = _fee;
    }
//@dev set token fee (owner only)