IParameterRegistry

Git Source

Inherits: IMigratable, IParameterKeysErrors, IRegistryParametersErrors

A parameter registry allows admins to set parameters, including whether an account is an admin, and allows any account/contract to query the values of parameters.

Functions

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;

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.

The caller must be an admin.

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

Parameters

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

set

Sets a parameter.

The caller must be an admin.

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

Parameters

NameTypeDescription
key_stringThe key of the parameter to set.
value_bytes32The value of the parameter.

isAdmin

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

function isAdmin(address account_) external 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 value of a parameter.

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

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

Parameters

NameTypeDescription
key_stringThe key of the parameter to get.

Returns

NameTypeDescription
value_bytes32The value of the parameter.

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() external pure 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() external pure 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.

Events

ParameterSet

Emitted when a parameter is set.

Values that are not value types (e.g. bytes, arrays, structs, etc.) must be the hash of their contents.

When passing the key as the first argument when emitting this event, it is automatically hashed since reference types are not indexable, and the hash is thus the indexable value.

event ParameterSet(string indexed keyHash, string key, bytes32 value);

Parameters

NameTypeDescription
keyHashstringThe hash of the key of the parameter.
keystringThe key of the parameter (which is generally a human-readable string, for clarity).
valuebytes32The value of the parameter (which can represent any value type).

Errors

NotAdmin

Thrown when the caller is not an admin (e.g. when setting a parameter).

error NotAdmin();

NoKeys

Thrown when no keys are provided (e.g. when setting or getting parameters).

error NoKeys();

ArrayLengthMismatch

Thrown when the array length mismatch (e.g. when setting multiple parameters).

error ArrayLengthMismatch();

EmptyAdmins

Thrown when the array of admins is empty.

error EmptyAdmins();

ZeroAdmin

Thrown when an admin is the zero address.

error ZeroAdmin();