// SPDX-License-Identifier: MIT pragma solidity ^0.8.16; import "forge-std/Test.sol"; import "forge-std/console2.sol"; import "#/extension/ThirdPartyMint721.sol"; import "#/KanjiThirdParty.sol"; import "@erc721/ERC721A/ERC721A.sol"; contract ExampleContract is ThirdPartyMint721, ERC721A { constructor(IAccessControl _thirdParty) ERC721A("TEST", "TST") ThirdPartyMint721(_thirdParty) {} function _afterMintFromThirdParty(address _receiver, uint256 _quantity) internal override { _mint(_receiver, _quantity); } function _beforeChangeThirdPartySetup(IAccessControl) internal view override { console.log("before change third party"); } } contract ThirdPartyMintTest is Test { ExampleContract c; IAccessControl public thirdParty; address public constant BOB = 0x0000000000000000000000000000000000010002; function setUp() public { thirdParty = new KanjiThirdParty(BOB); c = new ExampleContract(thirdParty); } function testCannotMintFromThirdPartyIfMsgSenderIsNotThirdPartyError() public { vm.expectRevert(abi.encodeWithSignature("CannotMintFromThirdPartyIfMsgSenderIsNotMinterError()")); c.mintFromThirdParty(BOB, 1); } function testThirdPartyMint() public { vm.prank(BOB); // can mint to anyone c.mintFromThirdParty(BOB, 1); } }