Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 60 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ members = [
"programs/integration_tests",
"tools/idl-gen",
"tools/risc0-packager",
"tools/wallet-idl-decoder",
]
exclude = [
"programs/token/methods/guest",
Expand Down
52 changes: 52 additions & 0 deletions apps/amm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@ set(LOGOS_WALLET_GENERATED_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/generated_code"
CACHE PATH "Path to generated Logos SDK sources"
)
# LogosModule.cmake stages external libraries after this shared target is
# configured. Resolve the decoder from the staged dependency before adding the
# shared wallet module so its static target can link successfully.
if(NOT LOGOS_WALLET_IDL_DECODER_LIBRARY)
set(amm_wallet_decoder_search_path "${CMAKE_CURRENT_SOURCE_DIR}/lib")
if(DEFINED ENV{LOGOS_EXT_ROOT_WALLET_IDL_DECODER})
set(amm_wallet_decoder_search_path
"$ENV{LOGOS_EXT_ROOT_WALLET_IDL_DECODER}/lib")
endif()
find_library(AMM_WALLET_IDL_DECODER_LIBRARY
NAMES wallet_idl_decoder
PATHS "${amm_wallet_decoder_search_path}"
NO_DEFAULT_PATH
)
if(AMM_WALLET_IDL_DECODER_LIBRARY)
set(LOGOS_WALLET_IDL_DECODER_LIBRARY
"${AMM_WALLET_IDL_DECODER_LIBRARY}"
CACHE FILEPATH
"wallet_idl_decoder library required by logos_wallet_access"
)
endif()
endif()
add_subdirectory("${LOGOS_WALLET_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/shared-wallet")

# ui_qml module with a hand-written C++ backend (QtRO .rep view contract +
Expand All @@ -45,4 +67,34 @@ logos_module(
Qt6::Network
LINK_TARGETS
logos_wallet_access
EXTERNAL_LIBS
wallet_idl_decoder
)

set(LEZ_IDL_ARTIFACTS_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/../../artifacts"
CACHE PATH "Path to committed LEZ program IDL artifacts"
)
set(AMM_TOKEN_IDL "${LEZ_IDL_ARTIFACTS_DIR}/token-idl.json")
set(AMM_IDL "${LEZ_IDL_ARTIFACTS_DIR}/amm-idl.json")

foreach(idl_file IN ITEMS "${AMM_TOKEN_IDL}" "${AMM_IDL}")
if(NOT EXISTS "${idl_file}")
message(FATAL_ERROR "Committed IDL artifact not found: ${idl_file}")
endif()
endforeach()

set_source_files_properties(
"${AMM_TOKEN_IDL}"
PROPERTIES QT_RESOURCE_ALIAS "idl/token-idl.json"
)
set_source_files_properties(
"${AMM_IDL}"
PROPERTIES QT_RESOURCE_ALIAS "idl/amm-idl.json"
)
qt_add_resources(amm_ui_module_plugin amm_ui_wallet_data
PREFIX "/amm"
FILES
"${AMM_TOKEN_IDL}"
"${AMM_IDL}"
)
33 changes: 25 additions & 8 deletions apps/amm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,23 @@ nix run .#amm-ui
Without `AMM_PROGRAM_BIN` the Swap and Liquidity views stay disabled; without
`TOKENS_CONFIG` the token picker is empty. Each is detailed below.

### Network identity

The shared wallet verifies the sequencer before it enables network-dependent
portfolio data or AMM quotes. Testnet uses the bundled checkpoint identity. For
devnet, provide the channel identity emitted by the local sequencer:

```bash
LOGOS_WALLET_NETWORK=devnet \
LOGOS_WALLET_DEVNET_FILE=/abs/path/to/devnet.json \
nix run .#amm-ui
```

`devnet.json` must contain a 64-character lowercase-hex `channelId`. The
legacy `AMM_UI_NETWORK` and `AMM_UI_DEVNET_FILE` names remain accepted. AMM
deployment and token selection stay app-specific through `AMM_PROGRAM_BIN` and
`TOKENS_CONFIG`.

### AMM program binary (required for swaps and liquidity)

To execute a swap, the app must submit a transaction against the **exact AMM
Expand Down Expand Up @@ -291,7 +308,7 @@ New Position validation commands and acceptance criteria live in

## Running the UI tests

The UI tests live in `apps/amm/tests/` (e.g. `swap.mjs`). They drive the running
The live-chain UI tests live in `apps/amm/tests/e2e/`. They drive the running
app through a QML inspector: each test connects to the inspector's TCP server,
finds elements, clicks them, and asserts on the resulting state. `swap.mjs`
selects two tokens, enters a sell amount, submits a swap end-to-end, and then
Expand All @@ -309,8 +326,7 @@ import from `test-framework/framework.mjs` — comes from the
It isn't vendored here; the `nix build .#test-framework` step below materializes
it (Nix resolves it via this app's flake inputs, pinned in `flake.lock`).

Run everything **from the repository root** (the `apps/amm` flake can't resolve
`amm_client_ffi` on its own).
Run everything **from the repository root**.

**Prerequisites** for the swap test to complete:

Expand All @@ -324,31 +340,32 @@ Run everything **from the repository root** (the `apps/amm` flake can't resolve

```bash
# 1. Build the JS test framework once. The -o path is where the tests expect it
# (apps/amm/tests/swap.mjs imports ../result-mcp); or set LOGOS_QT_MCP instead.
# (apps/amm/tests/e2e/swap.mjs imports ../../result-mcp); or set LOGOS_QT_MCP.
nix build .#test-framework -o apps/amm/result-mcp

# 2. Terminal 1 — launch the AMM UI with a real, visible window. The inspector
# listens on localhost:3768. Absolute paths ($(pwd)/…) because nix run may
# not preserve the working directory.
AMM_DEBUG=1 \
AMM_PROGRAM_BIN=$(pwd)/programs/amm/methods/guest/target/riscv32im-risc0-zkvm-elf/docker/amm.bin \
AMM_PROGRAM_BIN=$(pwd)/target/guest/amm.bin \
TOKENS_CONFIG=$(pwd)/apps/amm/amm-tokens.json \
nix run .#amm-ui

# 3. Terminal 2 — run a test against the running app; watch it drive the UI.
node apps/amm/tests/swap.mjs
node apps/amm/tests/e2e/swap.mjs
```

On failure the test prints the relevant `SwapCard` state and saves screenshot
PNGs next to the test (`apps/amm/tests/swap-*.png`, git-ignored) for inspection.
PNGs next to the test (`apps/amm/tests/e2e/swap-*.png`, git-ignored) for inspection.

**Headless CI variant** (no window, launches the app itself, pass/fail only):

```bash
nix build .#integration-test -L
```

It runs every `*.mjs` under `apps/amm/tests/` with `QT_QPA_PLATFORM=offscreen`.
It runs the hermetic UI smoke test with `QT_QPA_PLATFORM=offscreen`. The
live-chain tests remain in `apps/amm/tests/e2e/` and use the isolated setup above.

## Updating Dependencies

Expand Down
2 changes: 1 addition & 1 deletion apps/amm/VALIDATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Run from the repository root:
cargo +1.94.0 test -p amm_ffi
cargo +1.94.0 clippy -p amm_ffi --all-targets -- -D warnings
logos_qml=$(nix build github:logos-co/logos-design-system/6176f0d7a5dfeb64a7f0f98e7ca2bf71a4804772 --no-link --print-out-paths)
amm_qml=$(nix build ./apps/amm#packages.x86_64-linux.default --no-link --print-out-paths)
amm_qml=$(nix build .#amm-ui --no-link --print-out-paths)
qt_qml=$(nix-store --query --requisites "$amm_qml" | rg -m1 -- '-qtdeclarative-[0-9]')
qt_svg=$(nix-store --query --requisites "$amm_qml" | rg -m1 -- '-qtsvg-[0-9]')
export QT_QPA_PLATFORM=offscreen QT_QUICK_BACKEND=software QT_PLUGIN_PATH="$qt_svg/lib/qt-6/plugins"
Expand Down
Loading
Loading