Skip to content
Merged
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
110,889 changes: 97,927 additions & 12,962 deletions apps/amm/flake.lock

Large diffs are not rendered by default.

58 changes: 31 additions & 27 deletions apps/amm/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,56 @@
};

# Core wallet module (the LEZ wallet FFI Qt plugin). The input name must
# match the metadata.json `dependencies` entry so the builder can resolve
# it as a module dependency. This revision exposes generic transaction
# submission by deployed program ID.
lez_core = {
url = "github:logos-blockchain/logos-execution-zone-module?rev=d70225ced646934d2294fd9e8f8b03615c104b80";
# match the metadata.json `dependencies` entry so the builder can resolve it
# as a module dependency. Same ref the repo-root flake and the amm_module
# flake pin (the QtRO byte-string `instruction` fix).
lez_core.url = "github:logos-blockchain/logos-execution-zone-module?ref=byte-string-fix";

# The module pins the monorepo at v0.2.0-rc6 (e37876a), which owns the
# xcrun wrapper in its flake.nix. Override that transitive input to the
# head of PR #629 (fix(macos): nuke xcrun cache) so the Metal/xcrun build
# works on macOS. Note: #629 branches off `dev`, so this also pulls dev's
# drift from rc6 — if the wallet_ffi ABI mismatches the module build, fall
# back to cherry-picking #629's one line onto e37876a and pin that commit.
inputs.logos-execution-zone.url =
"github:logos-blockchain/logos-execution-zone?rev=a7e06a660940a00093b1760560d37ff84aff5a05";
# The AMM core module, resolved as the metadata.json `amm_module` dependency
# (the builder reads its .lidl to generate modules().amm_module). Built from
# the sibling flake; force its wallet to the SAME lez_core so the UI and the
# core module resolve one shared wallet instance.
amm_module = {
url = "path:../../modules/amm";
inputs.lez_core.follows = "lez_core";
};
};

# NOTE: this flake is no longer built standalone; the repo-root flake.nix
# builds the UI directly (src = ./apps/amm). The UI links no external lib of
# its own — the AMM logic lives in the amm_ffi crate, which the amm_module
# core module links; the UI reaches it via modules().amm_module (declared in
# metadata.json `dependencies`). The repo-root flake exposes the UI as a named
# attribute (there is no bare `default`): run it with `nix run .#amm-ui`, and
# build the AMM logic crate with `nix build .#amm_ffi`.
# Self-contained so the release CI can build it as its own module
# (module_path=apps/amm, `nix build .#lgx-portable`). The UI links no external
# lib of its own — the AMM logic lives in amm_ffi, linked by the amm_module
# core module, which the UI reaches via modules().amm_module. Kept in sync with
# the repo-root flake's appOutputs (preConfigure + the Basecamp-safe wallet
# staging in postInstall).
outputs = inputs@{ logos-module-builder, shared_wallet, ... }:
logos-module-builder.lib.mkLogosQmlModule {
src = ./.;
configFile = ./metadata.json;
flakeInputs = inputs;
externalLibInputs = { };
preConfigure = ''
cmakeFlagsArray+=("-DLOGOS_WALLET_SOURCE_DIR=${shared_wallet}")
cmakeFlagsArray+=("-DLOGOS_WALLET_GENERATED_DIR=$PWD/generated_code/include")
'';
externalLibInputs = { };
# Stage Logos.Wallet at the plugin ROOT as PURE QML (strip every
# plugin/resource directive) so Basecamp's QML sandbox accepts it — it
# rejects `prefer :/qt/qml/...` with "Invalid null URL", and keeping the
# module at the root (never under qml/) avoids leaking qml/NavBar.qml et al.
# into Basecamp's shared import path where it would collide with other
# plugins' identically-named types. Keep in sync with the repo-root flake.
postInstall = ''
# The builder installs the view under lib/qml after this hook. Its
# import descriptor points back to this compiled shared QML module.
test -f ${./qml}/Logos/Wallet/qmldir

walletQmlDir="shared-wallet/qml/Logos/Wallet"
if [ ! -d "$walletQmlDir" ]; then
walletQmlDescriptor="$(find "$PWD" -type f -path '*/shared-wallet/qml/Logos/Wallet/qmldir' -print -quit)"
if [ -z "$walletQmlDescriptor" ]; then
echo "Built Logos.Wallet QML module not found"
exit 1
fi
walletQmlDir="$(dirname "$walletQmlDescriptor")"
walletQmlInstallDir="$out/lib/Logos/Wallet"
mkdir -p "$walletQmlInstallDir"
cp -r "$walletQmlDir/." "$walletQmlInstallDir/"
grep -vE '^(linktarget|optional plugin|plugin|classname|typeinfo|prefer)([[:space:]]|$)' \
"$walletQmlInstallDir/qmldir" > "$walletQmlInstallDir/qmldir.pureqml"
mv "$walletQmlInstallDir/qmldir.pureqml" "$walletQmlInstallDir/qmldir"
test -f "$walletQmlInstallDir/qmldir"
'';
};
Expand Down
23 changes: 16 additions & 7 deletions apps/amm/tests/testnet/setup-amm-testnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,22 @@ restore_test_wallet() {
mkdir -p "$TEST_WALLET_HOME"

# The sequencer + poll config is written by write_wallet_config() before this
# runs (v0.2.1 schema; `wallet config set` can't set the sequencer). restore-keys
# is the first STORAGE command on a fresh home and rewrites it from the mnemonic.

# restore-keys reads the mnemonic then the password from stdin (non-interactive)
# and REWRITES storage — so the wallet's password becomes $TEST_WALLET_PASSWORD.
log "${DIM}\$ printf '<mnemonic>\\n<password>\\n' | wallet restore-keys --depth $TEST_WALLET_DEPTH${RST}"
printf '%s\n%s\n' "$TEST_MNEMONIC" "$TEST_WALLET_PASSWORD" \
# runs (v0.2.1 schema; `wallet config set` can't set the sequencer).

# On a FRESH home (no storage.json) `wallet` runs a first-run setup BEFORE the
# subcommand: main.rs reads a password (`Input password:`), auto-generates a
# throwaway wallet, stores it, and only THEN runs `restore-keys`, which reads the
# recovery phrase (`Input recovery phrase:`) and its own password. So a fresh home
# consumes THREE stdin lines in this order — setup-password, recovery-phrase,
# restore-password — not two. (An already-initialised home skips the setup read
# and takes only two, which is why re-running a failed bootstrap "worked".)
#
# Force the deterministic fresh-home path by clearing storage, then feed all three
# lines. restore-keys REWRITES storage, so the final wallet is the deterministic
# $TEST_MNEMONIC one with password $TEST_WALLET_PASSWORD.
rm -f "$TEST_WALLET_HOME/storage.json" "$TEST_WALLET_HOME/statistics.json"
log "${DIM}\$ printf '<password>\\n<mnemonic>\\n<password>\\n' | wallet restore-keys --depth $TEST_WALLET_DEPTH${RST}"
printf '%s\n%s\n%s\n' "$TEST_WALLET_PASSWORD" "$TEST_MNEMONIC" "$TEST_WALLET_PASSWORD" \
| wallet restore-keys --depth "$TEST_WALLET_DEPTH" \
|| die "wallet restore-keys failed"
}
Expand Down
2 changes: 1 addition & 1 deletion flake.lock

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

34 changes: 21 additions & 13 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,20 @@
# match the metadata.json `dependencies` entry so the builder can resolve it
# as a module dependency.
#
# Upstream logos-blockchain/logos-execution-zone-module, fix/generic-tx-instruction-bstr
# Upstream logos-blockchain/logos-execution-zone-module, `byte-string-fix`
# branch: carries the QtRO serialization fix — send_generic_public_transaction's
# `instruction` uses a byte-string IPC type so the args survive the cross-process
# boundary (the fix is NOT on `main`; see docs/amm-swap-qtro-serialization-bug.md).
# boundary (see docs/amm-swap-qtro-serialization-bug.md).
#
# No LEZ override: the branch natively pins logos-execution-zone v0.2.2, which is the
# deployed sequencer's version — the wallet-ffi and sequencer must agree on the
# JSON-RPC API and the wallet-config schema (v0.2.1 introduced the `sequencers` list).
# Keeping the native pin also means this is the exact derivation upstream CI built, so
# the wallet-ffi is fetched from the Logos nix binary cache instead of compiling `ring`
# locally (which fails under the nix cc-wrapper on Apple Silicon).
lez_core.url = "github:logos-blockchain/logos-execution-zone-module?ref=fix/generic-tx-instruction-bstr";
# Deliberately NOT on `main`: main's transitive logos-execution-zone (the
# wallet-ffi) has moved ahead of the deployed sequencer + the local `wallet`/
# `spel` CLI (v0.2.4), and its wallet-storage/config format no longer matches
# them — the app opens but can't load a wallet the v0.2.4 CLI wrote. This branch
# stays on the compatible LEZ version. The wallet-ffi and sequencer must agree on
# the JSON-RPC API and wallet-config schema, so keep this in sync with the
# deployed sequencer's version. (Also builds from the Logos nix cache, so `ring`
# isn't compiled locally — it fails under the nix cc-wrapper on Apple Silicon.)
lez_core.url = "github:logos-blockchain/logos-execution-zone-module?ref=byte-string-fix";

};

Expand Down Expand Up @@ -283,12 +285,15 @@
ammModulePkgs = ammModuleOutputs.packages or { };

# Alias the AMM core module's Basecamp install artifacts (explicit
# `amm-module-lgx` / `amm-module-install`), same collision reason as the
# token module aliases below.
# `amm-module-lgx{,-portable}` / `amm-module-install{,-portable}`), same
# collision reason as the token module aliases below. The portable variants
# are the ones you distribute (self-contained, no /nix/store refs).
ammModuleAliases = builtins.mapAttrs (
system: attrs:
(if attrs ? lgx then { amm-module-lgx = attrs.lgx; } else { })
// (if attrs ? lgx-portable then { amm-module-lgx-portable = attrs.lgx-portable; } else { })
// (if attrs ? install then { amm-module-install = attrs.install; } else { })
// (if attrs ? install-portable then { amm-module-install-portable = attrs.install-portable; } else { })
) ammModulePkgs;

# Token core module (modules/token): complete Token Program inspection
Expand All @@ -310,12 +315,15 @@

# Alias the token core module's Basecamp install artifacts. The bare
# `lgx` / `install` attrs collide across builders in the merged package
# set (last write wins), so expose an explicit `token-module-lgx` /
# `token-module-install` that resolves unambiguously.
# set (last write wins), so expose an explicit `token-module-lgx{,-portable}`
# / `token-module-install{,-portable}` that resolves unambiguously. The
# portable variants are the ones you distribute.
tokenModuleAliases = builtins.mapAttrs (
system: attrs:
(if attrs ? lgx then { token-module-lgx = attrs.lgx; } else { })
// (if attrs ? lgx-portable then { token-module-lgx-portable = attrs.lgx-portable; } else { })
// (if attrs ? install then { token-module-install = attrs.install; } else { })
// (if attrs ? install-portable then { token-module-install-portable = attrs.install-portable; } else { })
) tokenModulePkgs;

# Stablecoin core module (modules/stablecoin): singleton discovery,
Expand Down
Loading
Loading