ERC165StorageUpgradeable.sol 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Storage.sol)
  3. pragma solidity ^0.8.0;
  4. import "./ERC165Upgradeable.sol";
  5. import "../../proxy/utils/Initializable.sol";
  6. /**
  7. * @dev Storage based implementation of the {IERC165} interface.
  8. *
  9. * Contracts may inherit from this and call {_registerInterface} to declare
  10. * their support of an interface.
  11. */
  12. abstract contract ERC165StorageUpgradeable is Initializable, ERC165Upgradeable {
  13. function __ERC165Storage_init() internal onlyInitializing {
  14. }
  15. function __ERC165Storage_init_unchained() internal onlyInitializing {
  16. }
  17. /**
  18. * @dev Mapping of interface ids to whether or not it's supported.
  19. */
  20. mapping(bytes4 => bool) private _supportedInterfaces;
  21. /**
  22. * @dev See {IERC165-supportsInterface}.
  23. */
  24. function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
  25. return super.supportsInterface(interfaceId) || _supportedInterfaces[interfaceId];
  26. }
  27. /**
  28. * @dev Registers the contract as an implementer of the interface defined by
  29. * `interfaceId`. Support of the actual ERC165 interface is automatic and
  30. * registering its interface id is not required.
  31. *
  32. * See {IERC165-supportsInterface}.
  33. *
  34. * Requirements:
  35. *
  36. * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
  37. */
  38. function _registerInterface(bytes4 interfaceId) internal virtual {
  39. require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
  40. _supportedInterfaces[interfaceId] = true;
  41. }
  42. /**
  43. * This empty reserved space is put in place to allow future versions to add new
  44. * variables without shifting down storage in the inheritance chain.
  45. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  46. */
  47. uint256[49] private __gap;
  48. }