contract MintGenerator is Ownable {
    
    IMintFactory public MINT_FACTORY;
    ITokenFees public TOKEN_FEES;
    
    constructor(address _mintFactory, address _tokenFees) {
        MINT_FACTORY = IMintFactory(_mintFactory);
        TOKEN_FEES = ITokenFees(_tokenFees);
    }
    
    /**
     * @notice Creates a new Token contract and registers it in the TokenFactory.sol.
     */
    
    function createToken (
      string memory name, 
      string memory symbol, 
      uint8 decimals, 
      uint256 totalSupply
      ) public payable {
          // Charge ETH fee for contract creation
        require(msg.value == TOKEN_FEES.getFlatFee(), 'FEE NOT MET');
        payable(TOKEN_FEES.getTokenFeeAddress()).transfer(TOKEN_FEES.getFlatFee());

        IERC20 newToken = new ENMT(name, symbol, decimals, payable(msg.sender), totalSupply);
        uint256 bal = newToken.balanceOf(address(this));
        uint256 tsFee = bal * TOKEN_FEES.getTotalSupplyFee() / 1000;
        newToken.transfer(TOKEN_FEES.getTokenFeeAddress(), tsFee);
        newToken.transfer(msg.sender, bal - tsFee);
        MINT_FACTORY.registerToken(msg.sender, address(newToken));
    }
}
function createToken (
  string memory name, 
  string memory symbol, 
  uint8 decimals, 
  uint256 totalSupply
  ) public payable {
      // Charge ETH fee for contract creation
    require(msg.value == TOKEN_FEES.getFlatFee(), 'FEE NOT MET');
    payable(TOKEN_FEES.getTokenFeeAddress()).transfer(TOKEN_FEES.getFlatFee());

    IERC20 newToken = new ENMT(name, symbol, decimals, payable(msg.sender), totalSupply);
    uint256 bal = newToken.balanceOf(address(this));
    uint256 tsFee = bal * TOKEN_FEES.getTotalSupplyFee() / 1000;
    newToken.transfer(TOKEN_FEES.getTokenFeeAddress(), tsFee);
    newToken.transfer(msg.sender, bal - tsFee);
    MINT_FACTORY.registerToken(msg.sender, address(newToken));
}

/**
 * @notice Creates a new Token contract and registers it in the TokenFactory.sol.
 */