Skip to main content

Policy

Git Source

Inherits: KernelAdapter

Policies are application logic and external interface for the kernel and installed modules.

Policies are activated and deactivated in the kernel by the executor.

Module dependencies and function permissions must be defined in appropriate functions.

Functions

constructor

constructor(Kernel kernel_) KernelAdapter(kernel_);

isActive

Easily accessible indicator for if a policy is activated or not.

function isActive() external view returns (bool);

getModuleAddress

Function to grab module address from a given keycode.

function getModuleAddress(Keycode keycode_) internal view returns (address);

configureDependencies

Define module dependencies for this policy.

function configureDependencies() external virtual 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 view virtual returns (Permissions[] memory requests);

Returns

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

Errors

Policy_ModuleDoesNotExist

error Policy_ModuleDoesNotExist(Keycode keycode_);

Policy_WrongModuleVersion

error Policy_WrongModuleVersion(bytes expected_);