ParameterRegistry

Git Source

Inherits: IParameterRegistry, Migratable, Initializable

A parameter registry is a contract that stores key-value pairs of parameters used by a protocol. Keys should be globally unique and human-readable strings, for easier parsing and indexing. Keys can be set by admins, and whether an account is an admin is itself a key-value pair in the registry, which means that admins can be added and removed by other admins, and the parameter registry can be orphaned.

State Variables

_PARAMETER_REGISTRY_STORAGE_LOCATION

bytes32 internal constant _PARAMETER_REGISTRY_STORAGE_LOCATION =
    0xefab3f4eb315eafaa267b58974a509c07c739fbfe8e62b4eff49c4ced6985000;

Functions

_getParameterRegistryStorage

function _getParameterRegistryStorage() internal pure returns (ParameterRegistryStorage storage $);

onlyAdmin

modifier onlyAdmin();

constructor

Constructor for the implementation contract, such that the implementation cannot be initialized.

constructor();

initialize

Initializes the parameter registry, as used by a proxy contract.

Whether an account is an admin is tracked as a key-value pair in the registry itself.

function initialize(address[] calldata admins_) external initializer;

Parameters

NameTypeDescription
admins_address[]The addresses of the admins that can set parameters.

set

Sets several parameters.

The length of the keys_ and values_ arrays must be the same.

function set(string[] calldata keys_, bytes32[] calldata values_) external onlyAdmin;

Parameters

NameTypeDescription
keys_string[]The keys of each parameter to set.
values_bytes32[]The values of each parameter.

set

Sets several parameters.

The length of the keys_ and values_ arrays must be the same.

function set(string calldata key_, bytes32 value_) external onlyAdmin;

Parameters

NameTypeDescription
key_string
value_bytes32

migrate

Initiates a migration of the proxy, in a way defined by the implementation.

Normally, the implementation has a way of determining the migrator that needs to be delegatecalled.

function migrate() external;

migratorParameterKey

The parameter registry key used to fetch the migrator.

Uniquely, the parameter registry uses itself, so the key-value pair is stored in the contract itself.

function migratorParameterKey() public pure virtual returns (string memory key_);

Returns

NameTypeDescription
key_stringThe key of the migrator parameter.

adminParameterKey

The parameter registry key used to fetch the status of an admin.

Uniquely, the parameter registry uses itself, so the key-value pair is stored in the contract itself.

function adminParameterKey() public pure virtual returns (string memory key_);

Returns

NameTypeDescription
key_stringThe key of the admin parameter, which is a component of the full key, when prefixing an address.

isAdmin

Returns whether an account is an admin (i.e. an account that can set parameters).

function isAdmin(address account_) public view returns (bool isAdmin_);

Parameters

NameTypeDescription
account_addressThe address of the account to check.

Returns

NameTypeDescription
isAdmin_boolTrue if the account is an admin, false otherwise.

get

Gets the values of several parameters.

The default value for each parameter is bytes32(0).

function get(string[] calldata keys_) external view returns (bytes32[] memory values_);

Parameters

NameTypeDescription
keys_string[]The keys of each parameter to get.

Returns

NameTypeDescription
values_bytes32[]The values of each parameter.

get

Gets the values of several parameters.

The default value for each parameter is bytes32(0).

function get(string calldata key_) external view returns (bytes32 value_);

Parameters

NameTypeDescription
key_string

Returns

NameTypeDescription
value_bytes32values_ The values of each parameter.

_setParameter

function _setParameter(ParameterRegistryStorage storage $, string memory key_, bytes32 value_) internal;

_getAdminKey

Returns the admin-specific key used to query to parameter registry to determine if an account is an admin. The admin-specific key is the concatenation of the admin parameter key and the address of the admin. For example, if the admin parameter key is "pr.isAdmin", then the key for admin 0x1234567890123456789012345678901234567890 is "pr.isAdmin.0x1234567890123456789012345678901234567890".

function _getAdminKey(string memory adminParameterKey_, address account_) internal pure returns (string memory key_);

_getRegistryParameter

function _getRegistryParameter(string memory key_) internal view returns (bytes32 value_);

_revertIfNotAdmin

function _revertIfNotAdmin() internal view;

Structs

ParameterRegistryStorage

The UUPS storage for the parameter registry.

Note: storage-location: erc7201:xmtp.storage.ParameterRegistry

struct ParameterRegistryStorage {
    mapping(string key => bytes32 value) parameters;
}

Properties

NameTypeDescription
parametersmapping(string key => bytes32 value)A mapping of key-value pairs of parameters.