Skip to main content

ContractRegistryAdmin

Git Source

Inherits: Policy, RolesConsumer

Title: ContractRegistryAdmin

This policy is used to register and deregister contracts in the RGSTY module.

This contract utilises the following roles:

  • contract_registry_admin: Can register and deregister contracts This policy provides permissioned access to the state-changing functions on the RGSTY module. The view functions can be called directly on the module.

State Variables

RGSTY

The RGSTY module

The value is set when the policy is activated

RGSTYv1 internal RGSTY

CONTRACT_REGISTRY_ADMIN_ROLE

The role for the contract registry admin

bytes32 public constant CONTRACT_REGISTRY_ADMIN_ROLE = "contract_registry_admin"

Functions

constructor

constructor(address kernel_) Policy(Kernel(kernel_));

configureDependencies

Define module dependencies for this policy.

function configureDependencies() external override returns (Keycode[] memory dependencies);

Returns

NameTypeDescription
dependenciesKeycode[]- Keycode array of module dependencies.

requestPermissions

Function called by kernel to set module function permissions.

function requestPermissions() external pure override returns (Permissions[] memory permissions);

Returns

NameTypeDescription
permissionsPermissions[]requests - Array of keycodes and function selectors for requested permissions.

VERSION

The version of the policy

function VERSION() external pure returns (uint8);

onlyPolicyActive

Modifier to check that the contract is activated as a policy

modifier onlyPolicyActive() ;

registerImmutableContract

Register an immutable contract in the contract registry

This function will revert if:

  • This contract is not activated as a policy
  • The caller does not have the required role
  • The RGSTY module reverts
function registerImmutableContract(bytes5 name_, address contractAddress_)
external
onlyPolicyActive
onlyRole(CONTRACT_REGISTRY_ADMIN_ROLE);

Parameters

NameTypeDescription
name_bytes5The name of the contract
contractAddress_addressThe address of the contract

registerContract

Register a contract in the contract registry

This function will revert if:

  • This contract is not activated as a policy
  • The caller does not have the required role
  • The RGSTY module reverts
function registerContract(bytes5 name_, address contractAddress_)
external
onlyPolicyActive
onlyRole(CONTRACT_REGISTRY_ADMIN_ROLE);

Parameters

NameTypeDescription
name_bytes5The name of the contract
contractAddress_addressThe address of the contract

updateContract

Update a contract in the contract registry

This function will revert if:

  • This contract is not activated as a policy
  • The caller does not have the required role
  • The RGSTY module reverts
function updateContract(bytes5 name_, address contractAddress_)
external
onlyPolicyActive
onlyRole(CONTRACT_REGISTRY_ADMIN_ROLE);

Parameters

NameTypeDescription
name_bytes5The name of the contract
contractAddress_addressThe address of the contract

deregisterContract

Deregister a contract in the contract registry

This function will revert if:

  • This contract is not activated as a policy
  • The caller does not have the required role
  • The RGSTY module reverts
function deregisterContract(bytes5 name_) external onlyPolicyActive onlyRole(CONTRACT_REGISTRY_ADMIN_ROLE);

Parameters

NameTypeDescription
name_bytes5The name of the contract

Errors

Params_InvalidAddress

Thrown when the address is invalid

error Params_InvalidAddress();

OnlyPolicyActive

Thrown when the contract is not activated as a policy

error OnlyPolicyActive();