Skip to main content

luna.internal

Defines classes for handling contracts at runtime. 'RuntimeContract' acts as a proxy for contract attributes, forwarding them to the state. 'ContractHandle' provides a lazy access mechanism to a contract's runtime, allowing operations such as reading state and emitting events. It encapsulates contract summary information and manages the retrieval of contract runtime instances.

RuntimeContract Objects

class RuntimeContract()

Acts as a proxy for contract attributes, forwarding them to the contract's state within the Luna runtime environment. This class is designed to facilitate interaction with the contract's runtime attributes, making them accessible as if they were direct attributes of the contract itself.

Attributes:

  • rt (RuntimeTemplate): The runtime template associated with the contract, providing access to the contract's state.

ContractHandle Objects

class ContractHandle()

Provides a lazy access mechanism to a contract's runtime, encapsulating contract summary information and managing the retrieval of contract runtime instances. This class is used to interact with contract instances, allowing operations like reading state and emitting events.

Attributes:

  • contract_id (str): Unique identifier of the contract.
  • template_id (str): Identifier of the contract's template.
  • template_name (str): Name of the contract's template.
  • link_name (str): Name of the link associated with the contract.
  • status (str): Current status of the contract.
  • state (RuntimeState): Runtime state of the contract.

contract

@property
def contract() -> RuntimeContract

Get a runtime of the contract lazily. Having a runtime allows for reading the state.

put_event

def put_event(*,
event_name: str,
publish_at: datetime | None = None,
payload: PayloadDict | None = None)

Emit an event into the contract.