contract Crowdsale is Context, ReentrancyGuard  {
    using SafeMath for uint256;

    // The token being sold
    IWoofpackNFTToken private _token;

    // Amount of wei raised
    uint256 private _weiRaised;

    // Address where funds are collected
    address payable private _wallet;

    // Private Sale price is 0.06 ETH
    uint256 internal _rate = 60000000000000000;

    /**
     * Event for token purchase logging
     * @param purchaser who paid for the tokens
     * @param beneficiary who got the tokens
     */
    event TokensPurchased(address indexed purchaser, address indexed beneficiary, uint256 mintAmount);

    /**
     * @param __wallet Address where collected funds will be forwarded to
     * @param __token Address of the token being sold
     */
    constructor (address payable __wallet, IWoofpackNFTToken __token) public {
        require(__wallet != address(0), "Crowdsale: wallet is the zero address");
        require(address(__token) != address(0), "Crowdsale: token is the zero address");

        _wallet = __wallet;
        _token = __token;
    }

    /**
     * @return the token being sold.
     */
    function token() public view virtual returns (IWoofpackNFTToken) {
        return _token;
    }

    /**
     * @return the address where funds are collected.
     */
    function wallet() public view virtual returns (address payable) {
        return _wallet;
    }

    /**
     * @return the number of token units a buyer gets per wei.
     */
    function rate() public view virtual returns (uint256) {
        return _rate;
    }

    /**
     * @return the amount of wei raised.
     */
    function weiRaised() public view virtual returns (uint256) {
        return _weiRaised;
    }

    /**
     * @dev low level token purchase ***DO NOT OVERRIDE***
     * This function has a non-reentrancy guard, so it shouldn't be called by
     * another `nonReentrant` function.
     * @param beneficiary Recipient of the token purchase
    **/
    function buyNFT(address beneficiary, uint256 mintAmount) public nonReentrant payable {
        uint256 weiAmount = msg.value;
        _preValidatePurchase(beneficiary, mintAmount, weiAmount);

        // update state ETH Amount
        _weiRaised = _weiRaised.add(weiAmount);

        _processPurchase(beneficiary, mintAmount);
        emit TokensPurchased(_msgSender(), beneficiary, mintAmount);

        _updatePurchasingState(beneficiary, weiAmount);

        _forwardFunds(beneficiary, weiAmount);
        _postValidatePurchase(beneficiary, weiAmount);
    }

    /**
     * @dev Override for extensions that require an internal state to check for validity (current user contributions,
     * etc.)
     * @param beneficiary Address receiving the tokens
     * @param mintAmount total no of tokens to be minted
     * @param weiAmount no of ETH sent
     */
    function _preValidatePurchase(address beneficiary, uint256 mintAmount, uint256 weiAmount) internal virtual {
        // solhint-disable-previous-line no-empty-blocks
    }

    /**
     * @dev Executed when a purchase has been validated and is ready to be executed. Doesn't necessarily emit/send
     * tokens.
     * @param beneficiary Address receiving the tokens
     * @param mintAmount Total mint tokens
     */
    function _processPurchase(address beneficiary, uint256 mintAmount) internal virtual {
        _deliverTokens(beneficiary, mintAmount);
    }

    /**
     * @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends
     * its tokens.
     * @param beneficiary Address performing the token purchase
     * @param mintAmount Total mint tokens
     */
    function _deliverTokens(address beneficiary, uint256 mintAmount) internal {
         
         /*********** COMMENTED REQUIRE BECAUSE IT WAS RETURNING BOOLEAN AND WE WERE LISTENING FROM THE INTERFACE THAT IT WILL RETURN BOOLEAN BUT IT REVERTS OUR TRANSACTION**************** */
         // Potentially dangerous assumption about the type of the token.
        require(
            token().mint(beneficiary, mintAmount)
            , "Crowdsale: transfer failed"
        );
    }

    /**
     * @dev Override for extensions that require an internal state to check for validity (current user contributions,
     * etc.)
     * @param beneficiary Address receiving the tokens
     * @param weiAmount Value in wei involved in the purchase
     */
    function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal virtual {
        // solhint-disable-previous-line no-empty-blocks
    }

    /**
     * @dev Determines how ETH is stored/forwarded on purchases.
     */
    function _forwardFunds(address /*beneficiary*/, uint256 /*weiAmount*/) internal virtual {
        _wallet.transfer(msg.value);
    }

    /**
     * @dev Validation of an executed purchase. Observe state and use revert statements to undo rollback when valid
     * conditions are not met.
     * @param beneficiary Address performing the token purchase
     * @param weiAmount Value in wei involved in the purchase
     */
    function _postValidatePurchase(address beneficiary, uint256 weiAmount) internal view virtual {
        // solhint-disable-previous-line no-empty-blocks
    }
}
/**
 * @title Crowdsale
 * @dev Crowdsale is a base contract for managing a token crowdsale,
 * allowing investors to purchase tokens with ether. This contract implements
 * such functionality in its most fundamental form and can be extended to provide additional
 * functionality and/or custom behavior.
 * The external interface represents the basic interface for purchasing tokens, and conforms
 * the base architecture for crowdsales. It is *not* intended to be modified / overridden.
 * The internal interface conforms the extensible and modifiable surface of crowdsales. Override
 * the methods to add functionality. Consider using 'super' where appropriate to concatenate
 * behavior.
 */
function weiRaised() public view virtual returns (uint256) {
        return _weiRaised;
    }
/**
 * @return the amount of wei raised.
 */