MasterRegistry
Inherits: IMasterRegistry, AccessControlEnumerable, Multicall
This contract holds list of other registries or contracts and its historical versions.
State Variables
MANAGER_ROLE
Role responsible for adding registries.
bytes32 private constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
_registryMap
mapping(bytes32 => address[]) private _registryMap;
_reverseRegistry
mapping(address => ReverseRegistryData) private _reverseRegistry;
Functions
constructor
constructor(address admin, address manager) payable;
addRegistry
Add a new registry entry to the master list. Reverts if an entry is already found with the given name.
function addRegistry(bytes32 registryName, address registryAddress) external override onlyRole(MANAGER_ROLE);
Parameters
Name | Type | Description |
---|---|---|
registryName | bytes32 | name for the registry |
registryAddress | address | address of the new registry |
updateRegistry
Update an existing registry entry to the master list. Reverts if no match is found.
function updateRegistry(bytes32 registryName, address registryAddress) external override onlyRole(MANAGER_ROLE);
Parameters
Name | Type | Description |
---|---|---|
registryName | bytes32 | name for the registry |
registryAddress | address | address of the new registry |
resolveNameToLatestAddress
Resolves a name to the latest registry address. Reverts if no match is found.
function resolveNameToLatestAddress(bytes32 registryName) external view override returns (address);
Parameters
Name | Type | Description |
---|---|---|
registryName | bytes32 | name for the registry |
Returns
Name | Type | Description |
---|---|---|
<none> | address | address address of the latest registry with the matching name |
resolveNameAndVersionToAddress
Resolves a name and version to an address. Reverts if there is no registry with given name and version.
function resolveNameAndVersionToAddress(
bytes32 registryName,
uint256 version
)
external
view
override
returns (address);
Parameters
Name | Type | Description |
---|---|---|
registryName | bytes32 | address of the registry you want to resolve to |
version | uint256 | version of the registry you want to resolve to |
resolveNameToAllAddresses
Resolves a name to an array of all addresses. Reverts if no match is found.
function resolveNameToAllAddresses(bytes32 registryName) external view override returns (address[] memory);
Parameters
Name | Type | Description |
---|---|---|
registryName | bytes32 | name for the registry |
Returns
Name | Type | Description |
---|---|---|
<none> | address[] | address address of the latest registry with the matching name |
resolveAddressToRegistryData
Resolves an address to registry entry data.
function resolveAddressToRegistryData(address registryAddress)
external
view
override
returns (bytes32 registryName, uint256 version, bool isLatest);
Parameters
Name | Type | Description |
---|---|---|
registryAddress | address | address of a registry you want to resolve |
Returns
Name | Type | Description |
---|---|---|
registryName | bytes32 | name of the resolved registry |
version | uint256 | version of the resolved registry |
isLatest | bool | boolean flag of whether the given address is the latest version of the given registries with matching name |
Events
AddRegistry
Add a new registry entry to the master list.
event AddRegistry(bytes32 indexed name, address registryAddress, uint256 version);
Parameters
Name | Type | Description |
---|---|---|
name | bytes32 | address of the added pool |
registryAddress | address | address of the registry |
version | uint256 | version of the registry |
UpdateRegistry
Update a current registry entry to the master list.
event UpdateRegistry(bytes32 indexed name, address registryAddress, uint256 version);
Parameters
Name | Type | Description |
---|---|---|
name | bytes32 | address of the added pool |
registryAddress | address | address of the registry |
version | uint256 | version of the registry |