diff --git a/contracts/CurioERC1155Wrapper.sol b/contracts/CurioERC1155Wrapper.sol index 16965fa..dc6c283 100644 --- a/contracts/CurioERC1155Wrapper.sol +++ b/contracts/CurioERC1155Wrapper.sol @@ -5,11 +5,12 @@ import "./ERC1155.sol"; import "./IMastersFedi.sol"; import "./Address.sol"; import "./IERC1155Metadata.sol"; +import "./ERC1155Metadata.sol"; import "@openzeppelin/contracts/utils/Strings.sol"; import "@openzeppelin/contracts/utils/Base64.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; -contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, Ownable { +contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, ERC1155Metadata, Ownable { using Address for address; mapping (uint256 => address) public contracts; @@ -73,6 +74,16 @@ contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, Ownable { urls[_id] = _url; } + /** + @notice Query if a contract implements an interface + @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) { + return ERC1155.supportsInterface(_interfaceId) + || ERC1155Metadata.supportsInterface(_interfaceId); + } + /** @notice If NFT ID exists @dev Makes OpenSea happy @@ -161,7 +172,7 @@ contract CurioERC1155Wrapper is ERC1155, ERC1155Metadata_URI, Ownable { IMastersFedi curio = IMastersFedi(tokenContract); require(balances[_id][msg.sender] >= _quantity, "insufficient balance"); - balances[_id][msg.sender] -= _quantity; + balances[_id][msg.sender] -= _quantity; curio.transfer(msg.sender, _quantity); diff --git a/contracts/ERC1155.sol b/contracts/ERC1155.sol index 86bb542..d413fed 100644 --- a/contracts/ERC1155.sol +++ b/contracts/ERC1155.sol @@ -36,6 +36,7 @@ contract ERC1155 is IERC1155, ERC165, CommonConstants function supportsInterface(bytes4 _interfaceId) public pure + virtual returns (bool) { if (_interfaceId == INTERFACE_SIGNATURE_ERC165 || _interfaceId == INTERFACE_SIGNATURE_ERC1155) { diff --git a/contracts/ERC1155Metadata.sol b/contracts/ERC1155Metadata.sol new file mode 100644 index 0000000..9d1018f --- /dev/null +++ b/contracts/ERC1155Metadata.sol @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later +pragma solidity ^0.8.17; + +import "./IERC1155Metadata.sol"; + +contract ERC1155Metadata { + + /** + @notice Query if a contract implements an interface + @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) { + if (_interfaceId == type(ERC1155Metadata_URI).interfaceId) { + return true; + } + else return false; + } +}