MasterRegistry

Git Source

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

NameTypeDescription
registryNamebytes32name for the registry
registryAddressaddressaddress 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

NameTypeDescription
registryNamebytes32name for the registry
registryAddressaddressaddress 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

NameTypeDescription
registryNamebytes32name for the registry

Returns

NameTypeDescription
<none>addressaddress 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

NameTypeDescription
registryNamebytes32address of the registry you want to resolve to
versionuint256version 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

NameTypeDescription
registryNamebytes32name for the registry

Returns

NameTypeDescription
<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

NameTypeDescription
registryAddressaddressaddress of a registry you want to resolve

Returns

NameTypeDescription
registryNamebytes32name of the resolved registry
versionuint256version of the resolved registry
isLatestboolboolean 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

NameTypeDescription
namebytes32address of the added pool
registryAddressaddressaddress of the registry
versionuint256version of the registry

UpdateRegistry

Update a current registry entry to the master list.

event UpdateRegistry(bytes32 indexed name, address registryAddress, uint256 version);

Parameters

NameTypeDescription
namebytes32address of the added pool
registryAddressaddressaddress of the registry
versionuint256version of the registry