luna.state
Establishes the structure for managing runtime state in contracts, including storage and retrieval of variables, clause evaluations, and event handling. 'RuntimeState' class provides methods to access and modify contract data, track execution details, and interact with linked contracts and events. It also manages audit logging, tick counting, and termination logic. Additional dataclasses like 'RuntimeStateVariable' and 'RuntimeStateEvaluatedClause' assist in capturing specific state aspects like variable values and clause outputs.
RuntimeState Objects
class RuntimeState()
Manages the runtime state in contracts, including variables, clause evaluations, and event handling.
Attributes:
contract_id
(str): The unique identifier of the contract.engine_handle
(EngineHandle): A handle to the engine for managing contract operations.clock
(Clock): A clock instance for tracking time within the contract.template
(Template): The contract's template instance.logger
(Logger): Logger instance for audit logging.
The RuntimeState class provides methods to access and modify contract data, track execution details, interact with linked contracts and events, manage audit logging, count ticks, and handle contract termination.
for_contract
def for_contract(contract_id: str, template: "Template") -> RuntimeState
Copies the current RuntimeState
object but for the given contract_id
and template
instead.
Return the new RuntimeState
object.
put_event
def put_event(event: EventData) -> str
Instantiate a new event in the contract with the given event data.
:param event: The EventData instance containing the event details. :return: The unique identifier of the created event.