IERC1820Registry.sol 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v4.8.0) (utils/introspection/IERC1820Registry.sol)
  3. pragma solidity ^0.8.19;
  4. /**
  5. * @dev Interface of the global ERC1820 Registry, as defined in the
  6. * https://eips.ethereum.org/EIPS/eip-1820[EIP]. Accounts may register
  7. * implementers for interfaces in this registry, as well as query support.
  8. *
  9. * Implementers may be shared by multiple accounts, and can also implement more
  10. * than a single interface for each account. Contracts can implement interfaces
  11. * for themselves, but externally-owned accounts (EOA) must delegate this to a
  12. * contract.
  13. *
  14. * {IERC165} interfaces can also be queried via the registry.
  15. *
  16. * For an in-depth explanation and source code analysis, see the EIP text.
  17. */
  18. interface IERC1820Registry {
  19. event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer);
  20. event ManagerChanged(address indexed account, address indexed newManager);
  21. /**
  22. * @dev Sets `newManager` as the manager for `account`. A manager of an
  23. * account is able to set interface implementers for it.
  24. *
  25. * By default, each account is its own manager. Passing a value of `0x0` in
  26. * `newManager` will reset the manager to this initial state.
  27. *
  28. * Emits a {ManagerChanged} event.
  29. *
  30. * Requirements:
  31. *
  32. * - the caller must be the current manager for `account`.
  33. */
  34. function setManager(address account, address newManager) external;
  35. /**
  36. * @dev Returns the manager for `account`.
  37. *
  38. * See {setManager}.
  39. */
  40. function getManager(address account) external view returns (address);
  41. /**
  42. * @dev Sets the `implementer` contract as ``account``'s implementer for
  43. * `interfaceHash`.
  44. *
  45. * `account` being the zero address is an alias for the caller's address.
  46. * The zero address can also be used in `implementer` to remove an old one.
  47. *
  48. * See {interfaceHash} to learn how these are created.
  49. *
  50. * Emits an {InterfaceImplementerSet} event.
  51. *
  52. * Requirements:
  53. *
  54. * - the caller must be the current manager for `account`.
  55. * - `interfaceHash` must not be an {IERC165} interface id (i.e. it must not
  56. * end in 28 zeroes).
  57. * - `implementer` must implement {IERC1820Implementer} and return true when
  58. * queried for support, unless `implementer` is the caller. See
  59. * {IERC1820Implementer-canImplementInterfaceForAddress}.
  60. */
  61. function setInterfaceImplementer(address account, bytes32 _interfaceHash, address implementer) external;
  62. /**
  63. * @dev Returns the implementer of `interfaceHash` for `account`. If no such
  64. * implementer is registered, returns the zero address.
  65. *
  66. * If `interfaceHash` is an {IERC165} interface id (i.e. it ends with 28
  67. * zeroes), `account` will be queried for support of it.
  68. *
  69. * `account` being the zero address is an alias for the caller's address.
  70. */
  71. function getInterfaceImplementer(address account, bytes32 _interfaceHash) external view returns (address);
  72. /**
  73. * @dev Returns the interface hash for an `interfaceName`, as defined in the
  74. * corresponding
  75. * https://eips.ethereum.org/EIPS/eip-1820#interface-name[section of the EIP].
  76. */
  77. function interfaceHash(string calldata interfaceName) external pure returns (bytes32);
  78. /**
  79. * @notice Updates the cache with whether the contract implements an ERC165 interface or not.
  80. * @param account Address of the contract for which to update the cache.
  81. * @param interfaceId ERC165 interface for which to update the cache.
  82. */
  83. function updateERC165Cache(address account, bytes4 interfaceId) external;
  84. /**
  85. * @notice Checks whether a contract implements an ERC165 interface or not.
  86. * If the result is not cached a direct lookup on the contract address is performed.
  87. * If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling
  88. * {updateERC165Cache} with the contract address.
  89. * @param account Address of the contract to check.
  90. * @param interfaceId ERC165 interface to check.
  91. * @return True if `account` implements `interfaceId`, false otherwise.
  92. */
  93. function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool);
  94. /**
  95. * @notice Checks whether a contract implements an ERC165 interface or not without using or updating the cache.
  96. * @param account Address of the contract to check.
  97. * @param interfaceId ERC165 interface to check.
  98. * @return True if `account` implements `interfaceId`, false otherwise.
  99. */
  100. function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool);
  101. }