contract KOPrintRegistryMinter  {
    using SafeMath for uint256;

    ///////////////
    // Variables //
    ///////////////


    KOPrintRegistryInterface public koprContract;
    KOv1Interface public kov1Contract;
    KOv2Interface public kov2Contract;

    address public owner1;
    address public owner2;

    mapping(address => uint256) public addressToCreditsToSpend;

    mapping(address => uint256) public managerAddressToCreditsToGive;





    /////////////////
    // Constructor //
    /////////////////

    constructor(address _owner2, address _registryContract) public {

        koprContract = KOPrintRegistryInterface(_registryContract);
        kov1Contract = KOv1Interface(0xDdE2D979e8d39BB8416eAfcFC1758f3CaB2C9C72);
        kov2Contract = KOv2Interface(0xFBeef911Dc5821886e1dda71586d90eD28174B7d);
        
        owner1 = msg.sender;
        owner2 = _owner2;

    }



    //////////////////////////////
    // Minting Function         //
    //////////////////////////////

    function mint(uint256 _artId, string memory _contactMethodAndType) public returns (uint256 _tokenId) {
        uint256 balance = addressToCreditsToSpend[msg.sender];
        if (_artId<304){
        require(msg.sender == kov1Contract.ownerOf(_artId), "You must own artwork.");
        } else {
        require(msg.sender == kov2Contract.ownerOf(_artId), "You must own artwork.");
        }
        require(balance>0, "You must have credits!");
        uint256 mintedToken = koprContract.mint(_artId, _contactMethodAndType); 
        addressToCreditsToSpend[msg.sender] --;
        return mintedToken;
    }

    //////////////////////////////
    // Manager Function         //
    //////////////////////////////

    function giveCredit(address _recipient) public {
        uint creditsToGive = managerAddressToCreditsToGive[msg.sender];
        require(creditsToGive>0 || msg.sender==owner1 || msg.sender==owner2 , "You must have permission!");
        addressToCreditsToSpend[_recipient] ++;
        managerAddressToCreditsToGive[msg.sender] --;
    }

    //////////////////////////////
    // Owner Functions          //
    //////////////////////////////

    function setManagerCredits(address _manager, uint _credits) public returns (bool) {
        require(msg.sender == owner1 || msg.sender == owner2);
        managerAddressToCreditsToGive[_manager]=_credits;
        return true;
    }

    function removeManager(address _manager) public returns (bool) {
        require(msg.sender == owner1 || msg.sender == owner2);
        managerAddressToCreditsToGive[_manager]=0;
        return true;
    }

}
function mint(uint256 _artId, string memory _contactMethodAndType) public returns (uint256 _tokenId) {
    uint256 balance = addressToCreditsToSpend[msg.sender];
    if (_artId<304){
    require(msg.sender == kov1Contract.ownerOf(_artId), "You must own artwork.");
    } else {
    require(msg.sender == kov2Contract.ownerOf(_artId), "You must own artwork.");
    }
    require(balance>0, "You must have credits!");
    uint256 mintedToken = koprContract.mint(_artId, _contactMethodAndType); 
    addressToCreditsToSpend[msg.sender] --;
    return mintedToken;
}

//////////////////////////////