Skip to main content

Kernel

Main contract that acts as a central component registry for the protocol.

The kernel manages modules and policies. The kernel is mutated via predefined Actions,which are input from any address assigned as the executor. The executor can be changed as needed.

Methods

activePolicies

function activePolicies(uint256) external view returns (contract Policy)

List of all active policies

Parameters

NameTypeDescription
_0uint256undefined

Returns

NameTypeDescription
_0contract Policyundefined

allKeycodes

function allKeycodes(uint256) external view returns (Keycode)

Array of all modules currently installed.

Parameters

NameTypeDescription
_0uint256undefined

Returns

NameTypeDescription
_0Keycodeundefined

executeAction

function executeAction(enum Actions action_, address target_) external nonpayable

Main kernel function. Initiates state changes to kernel depending on Action passed in.

Parameters

NameTypeDescription
action_enum Actionsundefined
target_addressundefined

executor

function executor() external view returns (address)

Address that is able to initiate Actions in the kernel. Can be assigned to a multisig or governance contract.

Returns

NameTypeDescription
_0addressundefined

getDependentIndex

function getDependentIndex(Keycode, contract Policy) external view returns (uint256)

Helper for module dependent arrays. Prevents the need to loop through array.

Parameters

NameTypeDescription
_0Keycodeundefined
_1contract Policyundefined

Returns

NameTypeDescription
_0uint256undefined

getKeycodeForModule

function getKeycodeForModule(contract Module) external view returns (Keycode)

Mapping of keycode to module address.

Parameters

NameTypeDescription
_0contract Moduleundefined

Returns

NameTypeDescription
_0Keycodeundefined

getModuleForKeycode

function getModuleForKeycode(Keycode) external view returns (contract Module)

Mapping of module address to keycode.

Parameters

NameTypeDescription
_0Keycodeundefined

Returns

NameTypeDescription
_0contract Moduleundefined

getPolicyIndex

function getPolicyIndex(contract Policy) external view returns (uint256)

Helper to get active policy quickly. Prevents need to loop through array.

Parameters

NameTypeDescription
_0contract Policyundefined

Returns

NameTypeDescription
_0uint256undefined

isPolicyActive

function isPolicyActive(contract Policy policy_) external view returns (bool)

Parameters

NameTypeDescription
policy_contract Policyundefined

Returns

NameTypeDescription
_0boolundefined

moduleDependents

function moduleDependents(Keycode, uint256) external view returns (contract Policy)

Mapping of a keycode to all of its policy dependents. Used to efficiently reconfigure policy dependencies.

Parameters

NameTypeDescription
_0Keycodeundefined
_1uint256undefined

Returns

NameTypeDescription
_0contract Policyundefined

modulePermissions

function modulePermissions(Keycode, contract Policy, bytes4) external view returns (bool)

Module <> Policy Permissions.

Keycode -> Policy -> Function Selector -> bool for permission

Parameters

NameTypeDescription
_0Keycodeundefined
_1contract Policyundefined
_2bytes4undefined

Returns

NameTypeDescription
_0boolundefined

Events

ActionExecuted

event ActionExecuted(enum Actions indexed action_, address indexed target_)

Parameters

NameTypeDescription
action_ indexedenum Actionsundefined
target_ indexedaddressundefined

PermissionsUpdated

event PermissionsUpdated(Keycode indexed keycode_, contract Policy indexed policy_, bytes4 funcSelector_, bool granted_)

Parameters

NameTypeDescription
keycode_ indexedKeycodeundefined
policy_ indexedcontract Policyundefined
funcSelector_bytes4undefined
granted_boolundefined

Errors

InvalidKeycode

error InvalidKeycode(Keycode keycode_)

Parameters

NameTypeDescription
keycode_Keycodeundefined

Kernel_InvalidModuleUpgrade

error Kernel_InvalidModuleUpgrade(Keycode module_)

Parameters

NameTypeDescription
module_Keycodeundefined

Kernel_ModuleAlreadyInstalled

error Kernel_ModuleAlreadyInstalled(Keycode module_)

Parameters

NameTypeDescription
module_Keycodeundefined

Kernel_OnlyExecutor

error Kernel_OnlyExecutor(address caller_)

Parameters

NameTypeDescription
caller_addressundefined

Kernel_PolicyAlreadyActivated

error Kernel_PolicyAlreadyActivated(address policy_)

Parameters

NameTypeDescription
policy_addressundefined

Kernel_PolicyNotActivated

error Kernel_PolicyNotActivated(address policy_)

Parameters

NameTypeDescription
policy_addressundefined

TargetNotAContract

error TargetNotAContract(address target_)

Parameters

NameTypeDescription
target_addressundefined