// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface ICapitalistPigs {
    enum MintStatus { Closed, Presale, Public }

    struct TierInfo {
        uint price;
        MintStatus mintStatus;
        uint minId;
        uint nextId;
        uint maxId;
    }

    function getTierInfo(uint _edition) external view returns (TierInfo memory);
    function mintPublic(uint _edition, uint _quantity) external payable;
    function safeTransferFrom(address from, address to, uint256 tokenId) external;
    function balanceOf(address) external returns(uint256);
    function ownerOf(uint256) external returns(address);
}

contract PigWrapper {
    ICapitalistPigs PIGS;

    constructor(address _pigs) {
        PIGS = ICapitalistPigs(_pigs);
    }

    function mintPigTo(uint edition, address to, uint quantity) public payable {
        uint nextTokenId = PIGS.getTierInfo(edition).nextId;
        PIGS.mintPublic{value: msg.value}(edition, quantity);

        for (uint i = nextTokenId; i < nextTokenId + quantity; i++) {
            PIGS.safeTransferFrom(address(this), to, i);
        }
    }

    function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4) {
        return bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"));
    }
}