Skip to main content

luna.kernel.kernel

Kernel Objects

class Kernel(KernelApi)

The Kernel class provides an implementation of the KernelApi, handling various operations such as adding contracts, ticking contracts, fetching template and contract information, validating parameters, and managing events. It effectively bridges Python templates with the engine, enabling interactions between them.

add_contract

def add_contract(req: types.AddContractRequest) -> types.AddContractResponse

Processes and adds a contract based on the given request. This involves parsing the template, validating parameters, and initializing the contract state.

:param req: An instance of AddContractRequest containing contract details. :return: A response object indicating the result of the add contract operation.

tick

def tick(req: types.TickRequest) -> types.TickResponse

Advances the state of a contract based on time and events. The method processes the tick operation by updating the contract state according to the specified tick parameters.

:param req: An instance of TickRequest containing tick details. :return: A response object indicating the result of the tick operation.

template_info

def template_info(
req: types.TemplateInfoRequest) -> types.TemplateInfoResponse

Retrieves detailed information about a specific template. This includes validation of the template and extraction of template metadata.

:param req: An instance of TemplateInfoRequest containing the template definition. :return: A response object with details about the template.

contract_info

def contract_info(
req: types.ContractInfoRequest) -> types.ContractInfoResponse

Fetches detailed information about a specific contract. This includes the contract's current state, parameters, roles, and other metadata.

:param req: An instance of ContractInfoRequest with the contract identifier. :return: A response object with details about the contract.

validate_parameters

def validate_parameters(
req: types.ValidateParametersRequest
) -> types.ValidateParametersResponse

Validates the parameters provided for a template or contract. This includes parsing the parameters according to the template's definitions and checking their validity.

:param req: An instance of ValidateParametersRequest with template definition and parameters. :return: A response object indicating the result of the validation process.

put_event

def put_event(req: types.PutEventRequest) -> types.PutEventResponse

Handles the process of posting an event to a specific contract. This includes parsing the event payload and updating the contract's runtime state accordingly.

:param req: An instance of PutEventRequest containing details about the event. :return: A response object indicating the result of the event processing.