View Source Numscriptex (numscriptex v0.2.6)

NumscriptEx is a library that allows its users to run Numscripts via Elixir.

Summary

Functions

To use run/2 your first argument must be your script, and the second must be a %Numscriptex.Run{} (go to Numscriptex.Run module to see more) struct. Ex

version/0 simply shows a map with both Numscript-WASM and NumscriptEx versions. Ex

Types

errors()

@type errors() :: %{:reason => any(), optional(:details) => any()}

run_result()

@type run_result() :: %{
  balances: [Numscriptex.Balance.t()],
  postings: [Numscriptex.Posting.t()],
  accountsMeta: map(),
  txMeta: map()
}

Functions

run(numscript, run_struct)

@spec run(binary(), Numscriptex.Run.t()) :: {:ok, run_result()} | {:error, errors()}

To use run/2 your first argument must be your script, and the second must be a %Numscriptex.Run{} (go to Numscriptex.Run module to see more) struct. Ex:

iex> script = "send [USD/2 100] (source = @foo destination = @bar)"
...> balances = %{"foo" => %{"USD/2" => 500, "EUR/2" => 300}}
...>
...> struct =
...> Numscriptex.Run.new()
...> |> Numscriptex.Run.put!(:balances, balances)
...> |> Numscriptex.Run.put!(:metadata, %{})
...> |> Numscriptex.Run.put!(:variables, %{})
...>
...> Numscriptex.run(script, struct)

version()

@spec version() :: %{numscriptex: binary(), numscript_wasm: binary()}

version/0 simply shows a map with both Numscript-WASM and NumscriptEx versions. Ex:

iex> Numscriptex.version()
%{numscriptex: "v0.2.6", numscript_wasm: "v0.1.0"}