contract FootPunks is ERC721Enumerable, ERC2981, Ownable {
    IToeken public Toeken;

    string internal _baseTokenURI;

    uint256 public constant MAX_SUPPLY = 2_000;
    uint96 public constant ROYALTY_BPS = 1_000; // 10%

    constructor(string memory baseTokenURI) ERC721("FootPunks", "FOOT") {
        _baseTokenURI = baseTokenURI;
        _setDefaultRoyalty(msg.sender, ROYALTY_BPS);
    }

    function supportsInterface(bytes4 interfaceId) public view override(ERC721Enumerable, ERC2981) returns (bool) {
        return super.supportsInterface(interfaceId);
    }

    function setToekenAddress(address toeken) public onlyOwner {
        Toeken = IToeken(toeken);
    }

    function setBaseURI(string calldata baseURI) external onlyOwner {
        _baseTokenURI = baseURI;
    }

    function _baseURI() internal view virtual override returns (string memory) {
        return _baseTokenURI;
    }

    function mint(address to, uint256 tokenId) external payable onlyOwner {
        require(totalSupply() < MAX_SUPPLY, "Would exceed max supply");
        require(tokenId < MAX_SUPPLY, "Invalid tokenId");
        _mint(to, tokenId);
    }

    // OVERRIDES

    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public override(ERC721, IERC721) {
        if (address(Toeken) != address(0)) {
            Toeken.update(from, to);
        }

        super.transferFrom(from, to, tokenId);
    }

    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public override(ERC721, IERC721) {
        if (address(Toeken) != address(0)) {
            Toeken.update(from, to);
        }

        super.safeTransferFrom(from, to, tokenId, "");
    }

    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes memory data
    ) public override(ERC721, IERC721) {
        if (address(Toeken) != address(0)) {
            Toeken.update(from, to);
        }

        super.safeTransferFrom(from, to, tokenId, data);
    }
}
function transferFrom(
    address from,
    address to,
    uint256 tokenId
) public override(ERC721, IERC721) {
    if (address(Toeken) != address(0)) {
        Toeken.update(from, to);
    }

    super.transferFrom(from, to, tokenId);
}

// OVERRIDES