IERC1820Registry.sol 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts (last updated v4.8.0-rc.0) (utils/introspection/IERC1820Registry.sol)
  3. pragma solidity ^0.8.0;
  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(
  62. address account,
  63. bytes32 _interfaceHash,
  64. address implementer
  65. ) external;
  66. /**
  67. * @dev Returns the implementer of `interfaceHash` for `account`. If no such
  68. * implementer is registered, returns the zero address.
  69. *
  70. * If `interfaceHash` is an {IERC165} interface id (i.e. it ends with 28
  71. * zeroes), `account` will be queried for support of it.
  72. *
  73. * `account` being the zero address is an alias for the caller's address.
  74. */
  75. function getInterfaceImplementer(address account, bytes32 _interfaceHash) external view returns (address);
  76. /**
  77. * @dev Returns the interface hash for an `interfaceName`, as defined in the
  78. * corresponding
  79. * https://eips.ethereum.org/EIPS/eip-1820#interface-name[section of the EIP].
  80. */
  81. function interfaceHash(string calldata interfaceName) external pure returns (bytes32);
  82. /**
  83. * @notice Updates the cache with whether the contract implements an ERC165 interface or not.
  84. * @param account Address of the contract for which to update the cache.
  85. * @param interfaceId ERC165 interface for which to update the cache.
  86. */
  87. function updateERC165Cache(address account, bytes4 interfaceId) external;
  88. /**
  89. * @notice Checks whether a contract implements an ERC165 interface or not.
  90. * If the result is not cached a direct lookup on the contract address is performed.
  91. * If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling
  92. * {updateERC165Cache} with the contract address.
  93. * @param account Address of the contract to check.
  94. * @param interfaceId ERC165 interface to check.
  95. * @return True if `account` implements `interfaceId`, false otherwise.
  96. */
  97. function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool);
  98. /**
  99. * @notice Checks whether a contract implements an ERC165 interface or not without using or updating the cache.
  100. * @param account Address of the contract to check.
  101. * @param interfaceId ERC165 interface to check.
  102. * @return True if `account` implements `interfaceId`, false otherwise.
  103. */
  104. function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool);
  105. }