IERC1820Registry.sol 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts v4.4.1 (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. /**
  20. * @dev Sets `newManager` as the manager for `account`. A manager of an
  21. * account is able to set interface implementers for it.
  22. *
  23. * By default, each account is its own manager. Passing a value of `0x0` in
  24. * `newManager` will reset the manager to this initial state.
  25. *
  26. * Emits a {ManagerChanged} event.
  27. *
  28. * Requirements:
  29. *
  30. * - the caller must be the current manager for `account`.
  31. */
  32. function setManager(address account, address newManager) external;
  33. /**
  34. * @dev Returns the manager for `account`.
  35. *
  36. * See {setManager}.
  37. */
  38. function getManager(address account) external view returns (address);
  39. /**
  40. * @dev Sets the `implementer` contract as ``account``'s implementer for
  41. * `interfaceHash`.
  42. *
  43. * `account` being the zero address is an alias for the caller's address.
  44. * The zero address can also be used in `implementer` to remove an old one.
  45. *
  46. * See {interfaceHash} to learn how these are created.
  47. *
  48. * Emits an {InterfaceImplementerSet} event.
  49. *
  50. * Requirements:
  51. *
  52. * - the caller must be the current manager for `account`.
  53. * - `interfaceHash` must not be an {IERC165} interface id (i.e. it must not
  54. * end in 28 zeroes).
  55. * - `implementer` must implement {IERC1820Implementer} and return true when
  56. * queried for support, unless `implementer` is the caller. See
  57. * {IERC1820Implementer-canImplementInterfaceForAddress}.
  58. */
  59. function setInterfaceImplementer(
  60. address account,
  61. bytes32 _interfaceHash,
  62. address implementer
  63. ) external;
  64. /**
  65. * @dev Returns the implementer of `interfaceHash` for `account`. If no such
  66. * implementer is registered, returns the zero address.
  67. *
  68. * If `interfaceHash` is an {IERC165} interface id (i.e. it ends with 28
  69. * zeroes), `account` will be queried for support of it.
  70. *
  71. * `account` being the zero address is an alias for the caller's address.
  72. */
  73. function getInterfaceImplementer(address account, bytes32 _interfaceHash) external view returns (address);
  74. /**
  75. * @dev Returns the interface hash for an `interfaceName`, as defined in the
  76. * corresponding
  77. * https://eips.ethereum.org/EIPS/eip-1820#interface-name[section of the EIP].
  78. */
  79. function interfaceHash(string calldata interfaceName) external pure returns (bytes32);
  80. /**
  81. * @notice Updates the cache with whether the contract implements an ERC165 interface or not.
  82. * @param account Address of the contract for which to update the cache.
  83. * @param interfaceId ERC165 interface for which to update the cache.
  84. */
  85. function updateERC165Cache(address account, bytes4 interfaceId) external;
  86. /**
  87. * @notice Checks whether a contract implements an ERC165 interface or not.
  88. * If the result is not cached a direct lookup on the contract address is performed.
  89. * If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling
  90. * {updateERC165Cache} with the contract address.
  91. * @param account Address of the contract to check.
  92. * @param interfaceId ERC165 interface to check.
  93. * @return True if `account` implements `interfaceId`, false otherwise.
  94. */
  95. function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool);
  96. /**
  97. * @notice Checks whether a contract implements an ERC165 interface or not without using nor updating the cache.
  98. * @param account Address of the contract to check.
  99. * @param interfaceId ERC165 interface to check.
  100. * @return True if `account` implements `interfaceId`, false otherwise.
  101. */
  102. function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool);
  103. event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer);
  104. event ManagerChanged(address indexed account, address indexed newManager);
  105. }