// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.4;
import "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol";
import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
/**
* @title NftReceiver
* @author NFTfi
* @dev Base contract with capabilities for receiving ERC1155 and ERC721 tokens
*/
abstract contract NftReceiver is IERC1155Receiver, ERC721Holder {
/**
* @dev Handles the receipt of a single ERC1155 token type. This function is called at the end of a
* `safeTransferFrom` after the balance has been updated.
* @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if allowed
*/
function onERC1155Received(
address,
address,
uint256,
uint256,
bytes calldata
) external virtual override returns (bytes4) {
return this.onERC1155Received.selector;
}
/**
* @dev Handles the receipt of a multiple ERC1155 token types. This function is called at the end of a
* `safeBatchTransferFrom` after the balances have been updated.
* @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if allowed
*/
function onERC1155BatchReceived(
address,
address,
uint256[] calldata,
uint256[] calldata,
bytes calldata
) external virtual override returns (bytes4) {
revert("ERC1155 batch not supported");
}
/**
* @dev Checks whether this contract implements the interface defined by `interfaceId`.
* @param _interfaceId Id of the interface
* @return true if this contract implements the interface
*/
function supportsInterface(bytes4 _interfaceId) public view virtual override returns (bool) {
return
_interfaceId == type(IERC1155Receiver).interfaceId ||
_interfaceId == type(IERC721Receiver).interfaceId ||
_interfaceId == type(IERC165).interfaceId;
}
}