contract DegenPass is ERC1155, Ownable, ReentrancyGuard {
    
  string public constant name = "Degen Pass";
  string public constant symbol = "DEP";

  uint private constant maxPasses = 222;
  uint public passCount = 0;
  uint private constant passID = 1;

  bool public isSecondPass = false;
  bool public isMintOpen = false;

  bytes32 public merkleRoot = 0xb273f668854fc22a03370abfa36c32b2db9837d8364b79c3b773328809e4bbfa;

  mapping(address => uint) public whiteListMints;

  constructor() ERC1155("ipfs://QmdMn3YvP3vGSSKBy5AqCJoEGxY51MC1D388QJ9Ea7p2Gw/metadata.json") {}

  /**
   Allows mintlisted members to mint 1 pass during the first pass and allows 
   them to mint 1 more during the second pass.
   */
  function mintListMint(bytes32[] calldata _merkleProof) external nonReentrant{
    require(passCount < maxPasses, "Sold out.");
    require((whiteListMints[msg.sender] < 1) || (isSecondPass && (whiteListMints[msg.sender] < 2)), "Reached mint limit.");
    require(MerkleProof.verify(_merkleProof, merkleRoot,keccak256(abi.encodePacked(msg.sender))), "Proof invalid.");
    require(isMintOpen, "Mint not open.");

    whiteListMints[msg.sender]++;
    passCount++;
    _mint(msg.sender, passID, 1, "");
  }

  function setSecondPass() external onlyOwner{
    isSecondPass = !isSecondPass;
  }
  
  function setMintOpen() external onlyOwner{
    isMintOpen = !isMintOpen;
  }

  function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner{
    merkleRoot = _merkleRoot;
  }

  /**
  Allows contract owner to mint while still under mint limit.
   */
  function ownerMint(address _to, uint _amount) external onlyOwner {
    require(passCount + _amount <= maxPasses, "Sold out.");
    passCount += _amount;
    _mint(_to, passID, _amount, "");
  }

  function setURI(string memory _uri) external onlyOwner {
    _setURI(_uri);
  }

  function totalSupply() external view returns (uint256) {
    return passCount;
  }
}
function ownerMint(address _to, uint _amount) external onlyOwner {
    require(passCount + _amount <= maxPasses, "Sold out.");
    passCount += _amount;
    _mint(_to, passID, _amount, "");
  }
/**
 Allows contract owner to mint while still under mint limit.
 */