12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- // SPDX-License-Identifier: MIT
- // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC1820Implementer.sol)
- pragma solidity ^0.8.0;
- import "./IERC1820ImplementerUpgradeable.sol";
- import "../../proxy/utils/Initializable.sol";
- /**
- * @dev Implementation of the {IERC1820Implementer} interface.
- *
- * Contracts may inherit from this and call {_registerInterfaceForAddress} to
- * declare their willingness to be implementers.
- * {IERC1820Registry-setInterfaceImplementer} should then be called for the
- * registration to be complete.
- */
- contract ERC1820ImplementerUpgradeable is Initializable, IERC1820ImplementerUpgradeable {
- function __ERC1820Implementer_init() internal onlyInitializing {
- __ERC1820Implementer_init_unchained();
- }
- function __ERC1820Implementer_init_unchained() internal onlyInitializing {
- }
- bytes32 private constant _ERC1820_ACCEPT_MAGIC = keccak256("ERC1820_ACCEPT_MAGIC");
- mapping(bytes32 => mapping(address => bool)) private _supportedInterfaces;
- /**
- * @dev See {IERC1820Implementer-canImplementInterfaceForAddress}.
- */
- function canImplementInterfaceForAddress(bytes32 interfaceHash, address account)
- public
- view
- virtual
- override
- returns (bytes32)
- {
- return _supportedInterfaces[interfaceHash][account] ? _ERC1820_ACCEPT_MAGIC : bytes32(0x00);
- }
- /**
- * @dev Declares the contract as willing to be an implementer of
- * `interfaceHash` for `account`.
- *
- * See {IERC1820Registry-setInterfaceImplementer} and
- * {IERC1820Registry-interfaceHash}.
- */
- function _registerInterfaceForAddress(bytes32 interfaceHash, address account) internal virtual {
- _supportedInterfaces[interfaceHash][account] = true;
- }
- uint256[49] private __gap;
- }
|