contract GengWhiteListMinter is Ownable {
    using SafeMath for uint256;

    GengNft public gengNft;

    uint256 private mintCount = 0;
    uint256 private maxMint = 1000;

    mapping (address => bool) public whitelist;
    // mapping address to nft count
    mapping (address => uint256) public minters;

    // events
    event NftMint(uint256 id, address owner);

    constructor(GengNft _gengNft) {
        gengNft = _gengNft;
    }

    /**
     * @dev mints GengNft to sender
     */
    function whiteListMax(address[] memory addresses) public onlyOwner {
        for (uint256 index = 0; index < addresses.length; index++) {
            if (!whitelist[addresses[index]]) {
                whitelist[addresses[index]] = true;
            }
        }
    }

    /**
     * @dev mints GengNft to sender
     */
    function whiteList(address _address) public onlyOwner {
        if (!whitelist[_address]) {
            whitelist[_address] = true;
        }
    }

    /**
     * @dev mints GengNfts to sender
     */
    function mint(string[] memory _ipfsHashs) public {
        address receiver = msg.sender;
        uint256 nftCount = minters[receiver];
        uint256 amount = _ipfsHashs.length;

        require(whitelist[receiver], "GengMinter: you are not whitelisted");
        require(mintCount <= maxMint, "GengMinter: nft mint is completed");
        require(nftCount.add(amount) < 10, "GengMinter: you can not mint more than 10 nft");

        for (uint256 index = 0; index < amount; index++) {
            gengNft.mint(receiver, _ipfsHashs[index]);
        }

        mintCount = mintCount.add(amount);
        minters[receiver] = nftCount.add(amount);
    }
}
function mint(string[] memory _ipfsHashs) public {
    address receiver = msg.sender;
    uint256 nftCount = minters[receiver];
    uint256 amount = _ipfsHashs.length;

    require(whitelist[receiver], "GengMinter: you are not whitelisted");
    require(mintCount <= maxMint, "GengMinter: nft mint is completed");
    require(nftCount.add(amount) < 10, "GengMinter: you can not mint more than 10 nft");

    for (uint256 index = 0; index < amount; index++) {
        gengNft.mint(receiver, _ipfsHashs[index]);
    }

    mintCount = mintCount.add(amount);
    minters[receiver] = nftCount.add(amount);
}

/**
 * @dev mints GengNfts to sender
 */