Skip to main content

luna.functions.functions

now

@function()
def now(ctx: Context) -> datetime

Retrieves the current datetime from the contract's execution context.

Arguments:

  • ctx (Context): The execution context of the contract.

Returns:

  • datetime: The current date and time as per the contract's context.

create_balance_sheet_event

@function()
def create_balance_sheet_event(
ctx: Context,
value_datetime: datetime,
event_label: str | None = None) -> BalanceSheetEvent

Creates a new balance sheet event within the contract's context.

Arguments:

  • ctx (Context): The execution context of the contract.
  • value_datetime (datetime): The datetime value associated with the balance sheet event.

Returns:

  • BalanceSheetEvent: An object representing the newly created balance sheet event.

create_balance_sheet_entries

@function()
def create_balance_sheet_entries(ctx: Context,
entry_data: list[BalanceSheetEntry]) -> dict

Creates multiple balance sheet entries based on the provided data.

Arguments:

  • ctx (Context): The execution context of the contract.
  • entry_data (list[BalanceSheetEntry]): A list of balance sheet entries to be created.

Returns:

  • dict: A dictionary indicating the result of the creation process.

create_balance_sheet_account

@function()
def create_balance_sheet_account(
ctx: Context,
name: str,
account_type: BalanceSheetAccountType,
code: str,
unit: str,
participant: Participant,
unit_fractions_base_10: int | None = None) -> BalanceSheetAccount

Creates a balance sheet account with the given details.

Arguments:

  • ctx (Context): The execution context.
  • name (str): The name of the balance sheet account.
  • account_type (BalanceSheetAccountType): The type of the account.
  • code (str): The code associated with the account.
  • unit (str): The unit of measure for the account (e.g., currency).
  • participant (Participant): The participant to whom the account belongs.
  • unit_fractions_base_10 (int): The fractions the balance sheet should use. For example USD10.00 -> 2, ETH = 10^-18 -> 18

Returns:

  • BalanceSheetAccount: The created balance sheet account object.

simple_transfer

@function()
def simple_transfer(ctx: Context, src_participant: Participant,
dst_participant: Participant, amount: Decimal, unit: str)

Facilitates a simple transfer of funds between two participants.

Arguments:

  • ctx (Context): The execution context.
  • src_participant (Participant): The source participant for the transfer.
  • dst_participant (Participant): The destination participant for the transfer.
  • amount (Decimal): The amount to be transferred.
  • unit (str): The unit of the amount (e.g., currency).

create_default_transfer_accounts

@function()
def create_default_transfer_accounts(ctx: Context, participant: Participant,
unit: str)

Sets up default payment accounts for a specified participant.

Arguments:

  • ctx (Context): The execution context.
  • participant (Participant): The participant for whom the accounts are set up.
  • unit (str): The unit of measurement for the accounts (e.g., currency).

get_balance_sheet_account_balance

@function()
def get_balance_sheet_account_balance(ctx: Context, participant: Participant,
lookup: str, value: str,
value_datetime: datetime) -> Decimal

Retrieves the balance of a specified balance sheet account.

Arguments:

  • ctx (Context): The execution context.
  • participant (Participant): The participant whose account balance is being queried.
  • lookup (str): The method of lookup (e.g., account name or code).
  • value (str): The value associated with the lookup method.
  • value_datetime (datetime): The datetime for which the balance is queried.

Returns:

  • Decimal: The balance of the specified account.

get_balance_sheet_account

@function()
def get_balance_sheet_account(ctx: Context, participant: Participant,
lookup: str,
value: str) -> BalanceSheetAccountWithDetails

Fetches details of a specified balance sheet account.

Arguments:

  • ctx (Context): The execution context.
  • participant (Participant): The participant associated with the account.
  • lookup (str): The method of lookup (e.g., id, account name or code).
  • value (str): The value associated with the lookup method.

Returns:

  • BalanceSheetAccountWithDetails: Detailed information about the account.

create_default_payment_entries

@function()
def create_default_payment_entries(ctx: Context, payment_name: str,
amount: Decimal, value_datetime: datetime,
payment_details_id: str,
payment_status: str, payer: Participant,
payee: Participant,
unit: AccountingUnit) -> BalanceSheetEvent

Handles the default create Balance Sheet Entries behaviour for a payment. It accepts all the required arguments which is passes off to core_functions in the Engine.

The logic is managed by the payment_status which determines which Entries are created.

The Engine function also maps the Events to the corresponding payment_details which links Entries to payment Consent and Payment