diff --git a/contracts/CurioERC1155Wrapper.sol b/contracts/CurioERC1155Wrapper.sol index deab02f..09baedc 100644 --- a/contracts/CurioERC1155Wrapper.sol +++ b/contracts/CurioERC1155Wrapper.sol @@ -10,13 +10,16 @@ import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/Base64.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; +import "@openzeppelin/contracts/token/common/ERC2981.sol"; -contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, ERC1155Metadata, Ownable, Pausable { +contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, ERC1155Metadata, ERC2981, Ownable, Pausable { using Address for address; mapping (uint256 => address) public contracts; mapping (uint256 => string) public urls; + uint96 internal defaultRoyalty = 100; + /** @notice Initialize an nft id's data */ @@ -41,6 +44,13 @@ contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, ERC1155Metadata, O create(7, 0x5e7318f75b177a0F27A31CB20bB26bd0C049620c, "https://twitter.com/sonyasupposedly"); create(8, 0x5539907D45a608828756765429f2B4e6311c295c, "https://shpposter.club/users/shpuld"); create(9, 0x0a0e64067B1F7aDfbF876Dde4322633Ff7Df9702, "https://bbs.kawa-kun.com/users/tk"); + + _setDefaultRoyalty(msg.sender, defaultRoyalty); + } + + function transferOwnership(address newOwner) public override onlyOwner { + _setDefaultRoyalty(newOwner, defaultRoyalty); + super.transferOwnership(newOwner); } /** @@ -81,9 +91,11 @@ contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, ERC1155Metadata, O @param _interfaceId The interface identifier, as specified in ERC-165 @return `true` if the contract implements `_interfaceId` */ - function supportsInterface(bytes4 _interfaceId) public pure override(ERC1155, ERC1155Metadata) returns (bool) { + function supportsInterface(bytes4 _interfaceId) public view override(ERC1155, ERC1155Metadata, ERC2981) returns (bool) { return ERC1155.supportsInterface(_interfaceId) - || ERC1155Metadata.supportsInterface(_interfaceId); + || ERC1155Metadata.supportsInterface(_interfaceId) + || ERC2981.supportsInterface(_interfaceId) + ; } /** diff --git a/contracts/ERC1155.sol b/contracts/ERC1155.sol index ec641af..e84546b 100644 --- a/contracts/ERC1155.sol +++ b/contracts/ERC1155.sol @@ -36,7 +36,7 @@ contract ERC1155 is IERC1155, IERC165, CommonConstants function supportsInterface(bytes4 _interfaceId) public - pure + view virtual returns (bool) { if (_interfaceId == INTERFACE_SIGNATURE_ERC165 || diff --git a/contracts/ERC1155Metadata.sol b/contracts/ERC1155Metadata.sol index 9d1018f..48b7e87 100644 --- a/contracts/ERC1155Metadata.sol +++ b/contracts/ERC1155Metadata.sol @@ -10,7 +10,7 @@ contract ERC1155Metadata { @param _interfaceId The interface identifier, as specified in ERC-165 @return `true` if the contract implements `_interfaceID` */ - function supportsInterface(bytes4 _interfaceId) public virtual pure returns (bool) { + function supportsInterface(bytes4 _interfaceId) public virtual view returns (bool) { if (_interfaceId == type(ERC1155Metadata_URI).interfaceId) { return true; } diff --git a/contracts/IERC2981.sol b/contracts/IERC2981.sol new file mode 100644 index 0000000..d1e1ef8 --- /dev/null +++ b/contracts/IERC2981.sol @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later +pragma solidity ^0.8.17; + +import "@openzeppelin/contracts/interfaces/IERC165.sol"; + +interface IERC2981 is IERC165 { + /// ERC165 bytes to add to interface array - set in parent contract + /// implementing this standard + /// + /// bytes4(keccak256("royaltyInfo(uint256,uint256)")) == 0x2a55205a + /// bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a; + /// _registerInterface(_INTERFACE_ID_ERC2981); + + /// @notice Called with the sale price to determine how much royalty + // is owed and to whom. + /// @param _tokenId - the NFT asset queried for royalty information + /// @param _salePrice - the sale price of the NFT asset specified by _tokenId + /// @return receiver - address of who should be sent the royalty payment + /// @return royaltyAmount - the royalty payment amount for _salePrice + function royaltyInfo( + uint256 _tokenId, + uint256 _salePrice + ) external view returns ( + address receiver, + uint256 royaltyAmount + ); +}