IERC1820Registry.sol 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. pragma solidity ^0.5.7;
  2. /**
  3. * @title ERC1820 Pseudo-introspection Registry Contract
  4. * @author Jordi Baylina and Jacques Dafflon
  5. * @notice For more details, see https://eips.ethereum.org/EIPS/eip-1820
  6. */
  7. interface IERC1820Registry {
  8. /**
  9. * @notice Sets the contract which implements a specific interface for an address.
  10. * Only the manager defined for that address can set it.
  11. * (Each address is the manager for itself until it sets a new manager.)
  12. * @param account Address for which to set the interface.
  13. * (If 'account' is the zero address then 'msg.sender' is assumed.)
  14. * @param interfaceHash Keccak256 hash of the name of the interface as a string.
  15. * E.g., 'web3.utils.keccak256("ERC777TokensRecipient")' for the 'ERC777TokensRecipient' interface.
  16. * @param implementer Contract address implementing `interfaceHash` for `account.address()`.
  17. */
  18. function setInterfaceImplementer(address account, bytes32 interfaceHash, address implementer) external;
  19. /**
  20. * @notice Sets `newManager.address()` as manager for `account.address()`.
  21. * The new manager will be able to call 'setInterfaceImplementer' for `account.address()`.
  22. * @param account Address for which to set the new manager.
  23. * @param newManager Address of the new manager for `addr.address()`.
  24. * (Pass '0x0' to reset the manager to `account.address()`.)
  25. */
  26. function setManager(address account, address newManager) external;
  27. /**
  28. * @notice Updates the cache with whether the contract implements an ERC165 interface or not.
  29. * @param account Address of the contract for which to update the cache.
  30. * @param interfaceId ERC165 interface for which to update the cache.
  31. */
  32. function updateERC165Cache(address account, bytes4 interfaceId) external;
  33. /**
  34. * @notice Get the manager of an address.
  35. * @param account Address for which to return the manager.
  36. * @return Address of the manager for a given address.
  37. */
  38. function getManager(address account) external view returns (address);
  39. /**
  40. * @notice Query if an address implements an interface and through which contract.
  41. * @param account Address being queried for the implementer of an interface.
  42. * (If 'account' is the zero address then 'msg.sender' is assumed.)
  43. * @param interfaceHash Keccak256 hash of the name of the interface as a string.
  44. * E.g., 'web3.utils.keccak256("ERC777TokensRecipient")' for the 'ERC777TokensRecipient' interface.
  45. * @return The address of the contract which implements the interface `interfaceHash` for `account.address()`
  46. * or '0' if `account.address()` did not register an implementer for this interface.
  47. */
  48. function getInterfaceImplementer(address account, bytes32 interfaceHash) external view returns (address);
  49. /**
  50. * @notice Checks whether a contract implements an ERC165 interface or not.
  51. * If the result is not cached a direct lookup on the contract address is performed.
  52. * If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling
  53. * 'updateERC165Cache' with the contract address.
  54. * @param account Address of the contract to check.
  55. * @param interfaceId ERC165 interface to check.
  56. * @return True if `account.address()` implements `interfaceId`, false otherwise.
  57. */
  58. function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool);
  59. /**
  60. * @notice Checks whether a contract implements an ERC165 interface or not without using nor updating the cache.
  61. * @param account Address of the contract to check.
  62. * @param interfaceId ERC165 interface to check.
  63. * @return True if `account.address()` implements `interfaceId`, false otherwise.
  64. */
  65. function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool);
  66. /**
  67. * @notice Compute the keccak256 hash of an interface given its name.
  68. * @param interfaceName Name of the interface.
  69. * @return The keccak256 hash of an interface name.
  70. */
  71. function interfaceHash(string calldata interfaceName) external pure returns (bytes32);
  72. /**
  73. * @notice Indicates a contract is the `implementer` of `interfaceHash` for `account`.
  74. */
  75. event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer);
  76. /**
  77. * @notice Indicates `newManager` is the address of the new manager for `account`.
  78. */
  79. event ManagerChanged(address indexed account, address indexed newManager);
  80. }