Skip to main content

ROLESv1

Methods

INIT

function INIT() external nonpayable

Initialization function for the module

This function is called when the module is installed or upgraded by the kernel.MUST BE GATED BY onlyKernel. Used to encompass any initialization or upgrade logic.

KEYCODE

function KEYCODE() external pure returns (Keycode)

5 byte identifier for a module.

Returns

NameTypeDescription
_0Keycodeundefined

VERSION

function VERSION() external pure returns (uint8 major, uint8 minor)

Returns which semantic version of a module is being implemented.

Returns

NameTypeDescription
majoruint8- Major version upgrade indicates breaking change to the interface.
minoruint8- Minor version change retains backward-compatible interface.

changeKernel

function changeKernel(contract Kernel newKernel_) external nonpayable

Function used by kernel when migrating to a new kernel.

Parameters

NameTypeDescription
newKernel_contract Kernelundefined

ensureValidRole

function ensureValidRole(bytes32 role_) external pure

Function that checks if role is valid (all lower case)

Parameters

NameTypeDescription
role_bytes32undefined

hasRole

function hasRole(address, bytes32) external view returns (bool)

Mapping for if an address has a policy-defined role.

Parameters

NameTypeDescription
_0addressundefined
_1bytes32undefined

Returns

NameTypeDescription
_0boolundefined

kernel

function kernel() external view returns (contract Kernel)

Returns

NameTypeDescription
_0contract Kernelundefined

removeRole

function removeRole(bytes32 role_, address addr_) external nonpayable

Function to revoke policy-defined roles from some address. Can only be called by admin.

Parameters

NameTypeDescription
role_bytes32undefined
addr_addressundefined

requireRole

function requireRole(bytes32 role_, address caller_) external nonpayable

"Modifier" to restrict policy function access to certain addresses with a role.

Roles are defined in the policy and granted by the ROLES admin.

Parameters

NameTypeDescription
role_bytes32undefined
caller_addressundefined

saveRole

function saveRole(bytes32 role_, address addr_) external nonpayable

Function to grant policy-defined roles to some address. Can only be called by admin.

Parameters

NameTypeDescription
role_bytes32undefined
addr_addressundefined

Events

RoleGranted

event RoleGranted(bytes32 indexed role_, address indexed addr_)

Parameters

NameTypeDescription
role_ indexedbytes32undefined
addr_ indexedaddressundefined

RoleRevoked

event RoleRevoked(bytes32 indexed role_, address indexed addr_)

Parameters

NameTypeDescription
role_ indexedbytes32undefined
addr_ indexedaddressundefined

Errors

KernelAdapter_OnlyKernel

error KernelAdapter_OnlyKernel(address caller_)

Parameters

NameTypeDescription
caller_addressundefined

Module_PolicyNotPermitted

error Module_PolicyNotPermitted(address policy_)

Parameters

NameTypeDescription
policy_addressundefined

ROLES_AddressAlreadyHasRole

error ROLES_AddressAlreadyHasRole(address addr_, bytes32 role_)

Parameters

NameTypeDescription
addr_addressundefined
role_bytes32undefined

ROLES_AddressDoesNotHaveRole

error ROLES_AddressDoesNotHaveRole(address addr_, bytes32 role_)

Parameters

NameTypeDescription
addr_addressundefined
role_bytes32undefined

ROLES_InvalidRole

error ROLES_InvalidRole(bytes32 role_)

Parameters

NameTypeDescription
role_bytes32undefined

ROLES_RequireRole

error ROLES_RequireRole(bytes32 role_)

Parameters

NameTypeDescription
role_bytes32undefined

ROLES_RoleDoesNotExist

error ROLES_RoleDoesNotExist(bytes32 role_)

Parameters

NameTypeDescription
role_bytes32undefined