luna.contract
Contract Objects
@dataclass
class Contract()
Dataclass representing basic contract information within the system.
id
: The unique identifier of the contract.template
: The template instance associated with the contract.template_id
: The unique identifier of the contract's template.state
: The current runtime state of the contract.template_name
: The name of the contract's template.status
: The current status of the contract.
LinkedContract Objects
@dataclass
class LinkedContract(Contract)
Extends the 'Contract' dataclass by adding a link name attribute for linked contracts.
link_name
: The name of the link associated with the contract.
ContractWrapper Objects
class ContractWrapper()
Provides utility methods to interact with contract instances. Allows operations like ticking the contract and triggering events.
engine
: The engine instance used to interact with the contract.contract
: The contract instance to be wrapped.
tick
def tick(clock_offset: timedelta | None = None) -> TickData
Ticks the contract by advancing its state.
:param clock_offset: The time offset to apply for the tick operation. Defaults to zero seconds if not specified. :return: The tick data resulting from the tick operation.
put_event
def put_event(event_name: str,
source_type: EventSourceType,
source_id: str,
publish_at: datetime | None = None,
payload: PayloadDict | None = None)
Triggers an event on the contract.
:param event_name: The name of the event to trigger. :param payload: The payload dictionary for the event. Optional.
id
@property
def id() -> str
Returns the unique identifier of the contract.
template
@property
def template() -> Template
Returns the template instance associated with the contract.
template_id
@property
def template_id() -> str
Returns the unique identifier of the contract's template.
state
@property
def state() -> RuntimeState
Returns the current runtime state of the contract.