735546619e
Signed-off-by: T-Hax <>
38 lines
1.3 KiB
Solidity
38 lines
1.3 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
|
|
pragma solidity ^0.6.0;
|
|
|
|
import "./IERC1820Implementer.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 ERC1820Implementer is IERC1820Implementer {
|
|
bytes32 constant private _ERC1820_ACCEPT_MAGIC = keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC"));
|
|
|
|
mapping(bytes32 => mapping(address => bool)) private _supportedInterfaces;
|
|
|
|
/**
|
|
* See {IERC1820Implementer-canImplementInterfaceForAddress}.
|
|
*/
|
|
function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) public view 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;
|
|
}
|
|
}
|