// SPDX-License-Identifier: Apache-2.0 pragma solidity >=0.8.0; import {TokenRouter} from "./libs/TokenRouter.sol"; import {IERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; import {ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import {ERC721EnumerableUpgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; /** * @title Hyperlane ERC721 Token Router that extends ERC721 with remote transfer functionality. * @author Abacus Works */ contract HypERC721 is ERC721EnumerableUpgradeable, TokenRouter { constructor(address _mailbox) TokenRouter(_mailbox) {} /** * @notice Initializes the Hyperlane router, ERC721 metadata, and mints initial supply to deployer. * @param _mintAmount The amount of NFTs to mint to `msg.sender`. * @param _name The name of the token. * @param _symbol The symbol of the token. */ function initialize( uint256 _mintAmount, string memory _name, string memory _symbol ) external initializer { address owner = msg.sender; _transferOwnership(owner); __ERC721_init(_name, _symbol); for (uint256 i = 0; i < _mintAmount; i++) { _safeMint(owner, i); } } function balanceOf( address _account ) public view virtual override(TokenRouter, ERC721Upgradeable, IERC721Upgradeable) returns (uint256) { return ERC721Upgradeable.balanceOf(_account); } /** * @dev Asserts `msg.sender` is owner and burns `_tokenId`. * @inheritdoc TokenRouter */ function _transferFromSender( uint256 _tokenId ) internal virtual override returns (bytes memory) { require(ownerOf(_tokenId) == msg.sender, "!owner"); _burn(_tokenId); return bytes(""); // no metadata } /** * @dev Mints `_tokenId` to `_recipient`. * @inheritdoc TokenRouter */ function _transferTo( address _recipient, uint256 _tokenId, bytes calldata // no metadata ) internal virtual override { _safeMint(_recipient, _tokenId); } }