Skip to main content

InterfaceBasedRegistry

Description

An ERC-165-based registry for contracts.

Implementation

public variable UPGRADE_REGISTRY_PERMISSION_ID

The ID of the permission required to call the _authorizeUpgrade function.

bytes32 UPGRADE_REGISTRY_PERMISSION_ID

public variable targetInterfaceId

The ERC-165 interface ID that the target contracts being registered must support.

bytes4 targetInterfaceId

public variable entries

The mapping containing the registry entries returning true for registered contract addresses.

mapping(address => bool) entries

error ContractAlreadyRegistered

Thrown if the contract is already registered.

error ContractAlreadyRegistered(address registrant)
InputTypeDescription
registrantaddressThe address of the contract to be registered.

error ContractInterfaceInvalid

Thrown if the contract does not support the required interface.

error ContractInterfaceInvalid(address registrant)
InputTypeDescription
registrantaddressThe address of the contract to be registered.

error ContractERC165SupportInvalid

Thrown if the contract does not support ERC165.

error ContractERC165SupportInvalid(address registrant)
InputTypeDescription
registrantaddressThe address of the contract.

internal function __InterfaceBasedRegistry_init

Initializes the component.

function __InterfaceBasedRegistry_init(contract IDAO _managingDao, bytes4 _targetInterfaceId) internal virtual
InputTypeDescription
_managingDaocontract IDAOThe interface of the DAO managing the components permissions.
_targetInterfaceIdbytes4The ERC-165 interface id of the contracts to be registered.

This is required for the UUPS upgradability pattern.

internal function _authorizeUpgrade

Internal method authorizing the upgrade of the contract via the upgradeability mechanism for UUPS proxies (see ERC-1822).

function _authorizeUpgrade(address) internal virtual

The caller must have the UPGRADE_REGISTRY_PERMISSION_ID permission.

internal function _register

Register an ERC-165 contract address.

function _register(address _registrant) internal
InputTypeDescription
_registrantaddressThe address of an ERC-165 contract.

The managing DAO needs to grant REGISTER_PERMISSION_ID to registrar.

© 2024