Skip to main content

luna.engine.handle

Provides the abstract class 'EngineHandle' as an interface for engine operations, including methods for audit logging, fetching contract data, and handling variables, secrets, parameters, roles, clauses, and events. 'LocalEngineHandle' and 'RemoteEngineHandle' implement this interface for local and remote engines, respectively. They offer functionalities like adding contracts, ticking, event handling, and executing functions, facilitating interaction between contracts and the engine in both local and remote environments.

EngineHandle Objects

class EngineHandle(ABC)

Class: EngineHandle

Abstract base class representing an interface to an external engine. This class is designed to be implemented by classes that provide interaction with the Luna functionalities remotely.

Key Functionalities:

  • Audit logging
  • Fetching contract data
  • Handling various elements like variables, secrets, parameters, roles, clauses, and events

LocalEngineHandle Objects

class LocalEngineHandle(EngineHandle)

Class: LocalEngineHandle

Concrete implementation of the EngineHandle interface for a local engine environment.

Key Functionalities:

  • Managing audit logs
  • Retrieving and updating contract variables, secrets, and parameters
  • Handling roles, clauses, and events in the context of a local engine
  • Interaction with local engine's API for contract execution and data retrieval

get_event

def get_event(contract_id: str, event_id: str,
template: "Template") -> EventInstance

Retrieves a specific event by ID from a contract in the Luna engine.

RemoteEngineHandle Objects

class RemoteEngineHandle(EngineHandle)

Class: RemoteEngineHandle

Concrete implementation of the EngineHandle interface for remote engine interaction.

Key Functionalities:

  • Facilitates communication with the remote Luna engine via HTTP requests
  • Handles fetching and updating of contract data remotely
  • Manages contract variables, secrets, parameters, and roles remotely
  • Executes functions and retrieves event instances from the remote engine

get_event

def get_event(contract_id: str, event_id: str,
template: "Template") -> EventInstance

Retrieves a specific event by ID from a contract in the Luna engine.

get_evaluated_clause

def get_evaluated_clause(
contract_id: str, name: str,
eval_count: int | None) -> RuntimeStateEvaluatedClause | None

Retrieves evaluated clause data for a specific clause in a contract.

run_function

def run_function(*, tick_id: str, clause: str, name: str, args: dict,
contract_id: str) -> dict

Executes a specified function within a contract and returns the result.

validate

def validate(
contract_id: str, accounts: list[str], participants: list[str],
payment_details: list["ParticipantPaymentDetails"]
) -> types.ValidateResponse

Validates contract data such as accounts and participants to ensure accuracy.