mirror of
https://github.com/logos-blockchain/logos-blockchain-ui.git
synced 2026-04-01 17:03:31 +00:00
Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
c3bdbb8d8f
commit
fd788ebbcb
@ -70,9 +70,6 @@ endif()
|
||||
# Find Qt packages
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Widgets RemoteObjects Quick QuickWidgets)
|
||||
|
||||
# Get the real path to handle symlinks correctly
|
||||
get_filename_component(REAL_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" REALPATH)
|
||||
|
||||
# Try to find the component-interfaces package first
|
||||
find_package(component-interfaces QUIET)
|
||||
|
||||
@ -115,68 +112,20 @@ if(_cpp_sdk_is_source)
|
||||
)
|
||||
endif()
|
||||
|
||||
# Run Logos C++ generator on metadata before compilation (only for source layout)
|
||||
set(METADATA_JSON "${CMAKE_CURRENT_SOURCE_DIR}/metadata.json")
|
||||
|
||||
# Only run generator for source layout - nix builds already have generated files
|
||||
if(_cpp_sdk_is_source)
|
||||
# Source layout: build and run the generator
|
||||
# Generate into build directory
|
||||
set(PLUGINS_OUTPUT_DIR "${CMAKE_BINARY_DIR}/generated_code")
|
||||
set(CPP_GENERATOR_BUILD_DIR "${LOGOS_CPP_SDK_ROOT}/../build/cpp-generator")
|
||||
set(CPP_GENERATOR "${CPP_GENERATOR_BUILD_DIR}/bin/logos-cpp-generator")
|
||||
|
||||
if(NOT TARGET cpp_generator_build)
|
||||
add_custom_target(cpp_generator_build
|
||||
COMMAND bash "${LOGOS_CPP_SDK_ROOT}/cpp-generator/compile.sh"
|
||||
WORKING_DIRECTORY "${LOGOS_CPP_SDK_ROOT}/.."
|
||||
COMMENT "Building logos-cpp-generator via ${LOGOS_CPP_SDK_ROOT}/cpp-generator/compile.sh"
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
|
||||
add_custom_target(run_cpp_generator_blockchain_ui
|
||||
COMMAND "${CPP_GENERATOR}" --metadata "${METADATA_JSON}" --general-only --output-dir "${PLUGINS_OUTPUT_DIR}"
|
||||
WORKING_DIRECTORY "${LOGOS_CPP_SDK_ROOT}/.."
|
||||
COMMENT "Running logos-cpp-generator on ${METADATA_JSON} with output-dir ${PLUGINS_OUTPUT_DIR}"
|
||||
VERBATIM
|
||||
)
|
||||
add_dependencies(run_cpp_generator_blockchain_ui cpp_generator_build)
|
||||
|
||||
# Add generated logos_sdk.cpp - will be generated by run_cpp_generator_blockchain_ui
|
||||
list(APPEND SOURCES ${PLUGINS_OUTPUT_DIR}/logos_sdk.cpp)
|
||||
# Mark as generated so CMake knows to wait for it
|
||||
set_source_files_properties(
|
||||
${PLUGINS_OUTPUT_DIR}/logos_sdk.cpp
|
||||
PROPERTIES GENERATED TRUE
|
||||
)
|
||||
else()
|
||||
# Installed/nix layout: lib.nix preConfigure populates generated_code before CMake.
|
||||
# May be overridden by -DPLUGINS_OUTPUT_DIR= when source tree is read-only (e.g. Nix sandbox).
|
||||
set(PLUGINS_OUTPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated_code" CACHE PATH "Generated code directory (nix layout)")
|
||||
list(APPEND SOURCES ${PLUGINS_OUTPUT_DIR}/include/logos_sdk.cpp)
|
||||
endif()
|
||||
|
||||
# Create the plugin library
|
||||
add_library(blockchain_ui SHARED ${SOURCES})
|
||||
|
||||
# Set output name without lib prefix and with correct name for generator
|
||||
# Set output name without lib prefix
|
||||
set_target_properties(blockchain_ui PROPERTIES
|
||||
PREFIX ""
|
||||
OUTPUT_NAME "blockchain_ui"
|
||||
)
|
||||
|
||||
# Ensure generator runs before building the plugin (only for source layout)
|
||||
if(_cpp_sdk_is_source)
|
||||
add_dependencies(blockchain_ui run_cpp_generator_blockchain_ui)
|
||||
endif()
|
||||
|
||||
# Include directories
|
||||
target_include_directories(blockchain_ui PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${PLUGINS_OUTPUT_DIR}
|
||||
)
|
||||
|
||||
# Add include directories based on layout type
|
||||
@ -189,16 +138,12 @@ endif()
|
||||
if(_cpp_sdk_is_source)
|
||||
target_include_directories(blockchain_ui PRIVATE
|
||||
${LOGOS_CPP_SDK_ROOT}/cpp
|
||||
${LOGOS_CPP_SDK_ROOT}/cpp/generated
|
||||
)
|
||||
else()
|
||||
# For nix builds, also include the include subdirectory
|
||||
# (lib.nix moves header files to ./generated_code/include/)
|
||||
target_include_directories(blockchain_ui PRIVATE
|
||||
${LOGOS_CPP_SDK_ROOT}/include
|
||||
${LOGOS_CPP_SDK_ROOT}/include/cpp
|
||||
${LOGOS_CPP_SDK_ROOT}/include/core
|
||||
${PLUGINS_OUTPUT_DIR}/include
|
||||
)
|
||||
endif()
|
||||
|
||||
@ -212,10 +157,14 @@ target_link_libraries(blockchain_ui PRIVATE
|
||||
component-interfaces
|
||||
)
|
||||
|
||||
# Link SDK library if using installed layout
|
||||
# When using installed SDK layout (e.g. Nix), link the pre-built SDK library
|
||||
if(NOT _cpp_sdk_is_source)
|
||||
find_library(LOGOS_SDK_LIB logos_sdk PATHS ${LOGOS_CPP_SDK_ROOT}/lib NO_DEFAULT_PATH REQUIRED)
|
||||
target_link_libraries(blockchain_ui PRIVATE ${LOGOS_SDK_LIB})
|
||||
find_library(LOGOS_SDK_LIB logos_sdk PATHS ${LOGOS_CPP_SDK_ROOT}/lib NO_DEFAULT_PATH)
|
||||
if(LOGOS_SDK_LIB)
|
||||
target_link_libraries(blockchain_ui PRIVATE ${LOGOS_SDK_LIB})
|
||||
else()
|
||||
message(FATAL_ERROR "logos_sdk library not found in ${LOGOS_CPP_SDK_ROOT}/lib - required when using installed SDK layout")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Link against Abseil libraries if found
|
||||
@ -260,13 +209,8 @@ install(TARGETS blockchain_ui
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/logos/modules
|
||||
)
|
||||
|
||||
install(FILES ${METADATA_JSON}
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/logos-blockchain-ui-new
|
||||
)
|
||||
|
||||
install(DIRECTORY "${PLUGINS_OUTPUT_DIR}/"
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/logos-blockchain-ui-new/generated
|
||||
OPTIONAL
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/metadata.json
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/logos-blockchain-ui
|
||||
)
|
||||
|
||||
# Print status messages
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
# logos-blockchain-ui-new
|
||||
# logos-blockchain-ui
|
||||
|
||||
A Qt UI plugin for the Logos Blockchain Module, providing a graphical interface to control and monitor the Logos blockchain node.
|
||||
|
||||
@ -62,7 +62,7 @@ After building the app with `nix build '.#app'`, you can run it:
|
||||
./result/bin/logos-blockchain-ui-app
|
||||
```
|
||||
|
||||
The app will automatically load the required modules (capability_module, liblogos_blockchain_module) and the blockchain_ui Qt plugin. All dependencies are bundled in the Nix store layout.
|
||||
The app will automatically load the required modules (capability_module, liblogos-blockchain-module) and the blockchain_ui Qt plugin. All dependencies are bundled in the Nix store layout.
|
||||
|
||||
#### Nix Organization
|
||||
|
||||
@ -95,7 +95,7 @@ result/
|
||||
│ └── Logos/DesignSystem/ # QML design system
|
||||
├── modules/
|
||||
│ ├── capability_module_plugin.dylib
|
||||
│ ├── liblogos_blockchain_module.dylib
|
||||
│ ├── liblogos-blockchain-module.dylib
|
||||
│ └── liblogos_blockchain.dylib
|
||||
└── blockchain_ui.dylib # Qt plugin (loaded by app)
|
||||
```
|
||||
|
||||
@ -15,36 +15,15 @@ if(NOT DEFINED LOGOS_LIBLOGOS_ROOT)
|
||||
message(FATAL_ERROR "LOGOS_LIBLOGOS_ROOT must be defined")
|
||||
endif()
|
||||
|
||||
# Find logos-cpp-sdk
|
||||
if(NOT DEFINED LOGOS_CPP_SDK_ROOT)
|
||||
message(FATAL_ERROR "LOGOS_CPP_SDK_ROOT must be defined")
|
||||
endif()
|
||||
|
||||
message(STATUS "Using logos-liblogos at: ${LOGOS_LIBLOGOS_ROOT}")
|
||||
message(STATUS "Using logos-cpp-sdk at: ${LOGOS_CPP_SDK_ROOT}")
|
||||
|
||||
# Check if logos_sdk library exists
|
||||
if(NOT EXISTS "${LOGOS_CPP_SDK_ROOT}/lib/liblogos_sdk.a" AND NOT EXISTS "${LOGOS_CPP_SDK_ROOT}/lib/liblogos_sdk.dylib" AND NOT EXISTS "${LOGOS_CPP_SDK_ROOT}/lib/liblogos_sdk.so")
|
||||
message(WARNING "logos_sdk library not found in ${LOGOS_CPP_SDK_ROOT}/lib/")
|
||||
message(STATUS "Available files in ${LOGOS_CPP_SDK_ROOT}/lib/:")
|
||||
file(GLOB SDK_LIB_FILES "${LOGOS_CPP_SDK_ROOT}/lib/*")
|
||||
foreach(file ${SDK_LIB_FILES})
|
||||
message(STATUS " ${file}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Include directories - the new structure has headers in /include with subdirectories
|
||||
# Include and link directories (app only uses logos_core from liblogos, not the SDK)
|
||||
include_directories(
|
||||
${LOGOS_LIBLOGOS_ROOT}/include
|
||||
${LOGOS_CPP_SDK_ROOT}/include
|
||||
${LOGOS_CPP_SDK_ROOT}/include/cpp
|
||||
${LOGOS_CPP_SDK_ROOT}/include/core
|
||||
)
|
||||
|
||||
# Link directories
|
||||
link_directories(
|
||||
${LOGOS_LIBLOGOS_ROOT}/lib
|
||||
${LOGOS_CPP_SDK_ROOT}/lib
|
||||
)
|
||||
|
||||
# Set output directories
|
||||
@ -62,7 +41,6 @@ target_link_libraries(logos-blockchain-ui-app PRIVATE
|
||||
Qt${QT_VERSION_MAJOR}::Core
|
||||
Qt${QT_VERSION_MAJOR}::Widgets
|
||||
logos_core
|
||||
logos_sdk
|
||||
)
|
||||
|
||||
# Set RPATH settings for the executable
|
||||
|
||||
@ -28,7 +28,7 @@ int main(int argc, char *argv[])
|
||||
qWarning() << "Failed to load capability_module plugin";
|
||||
}
|
||||
|
||||
if (!logos_core_load_plugin("liblogos_blockchain_module")) {
|
||||
if (!logos_core_load_plugin("liblogos-blockchain-module")) {
|
||||
qWarning() << "Failed to load blockchain module plugin";
|
||||
}
|
||||
|
||||
|
||||
14
flake.lock
generated
14
flake.lock
generated
@ -23,11 +23,11 @@
|
||||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1771256037,
|
||||
"narHash": "sha256-8/sdrRyHYd01pYQwnjL2QWN8zACSUkMd/JPmhAFaaoc=",
|
||||
"lastModified": 1771418281,
|
||||
"narHash": "sha256-9nATUijKs7OCEcepHKghuWdgHu+hq11JbJz2Lv4uyDU=",
|
||||
"owner": "logos-blockchain",
|
||||
"repo": "logos-blockchain",
|
||||
"rev": "fe11562ea895b2d39af9d9c97c561cd14cbcedbe",
|
||||
"rev": "b862e6f640a79097b8a42c072e1f78bc430fa222",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -67,17 +67,17 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1771367673,
|
||||
"narHash": "sha256-te82eiZeM1XNp8qg+BcdPMp0Rful0nIpJCcvPT3gP/A=",
|
||||
"lastModified": 1771423304,
|
||||
"narHash": "sha256-ONurMDUbFhdNzdbQ5r1jPPzFm2bHJBRElwcRNPPFmpM=",
|
||||
"owner": "logos-blockchain",
|
||||
"repo": "logos-blockchain-module",
|
||||
"rev": "0cae35a33bc5d5148096d5aaacb653c2b99da2c4",
|
||||
"rev": "214a87885115296bf4e56fd820f5fbfdf4ee4453",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "logos-blockchain",
|
||||
"repo": "logos-blockchain-module",
|
||||
"rev": "0cae35a33bc5d5148096d5aaacb653c2b99da2c4",
|
||||
"rev": "214a87885115296bf4e56fd820f5fbfdf4ee4453",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
nixpkgs.follows = "logos-liblogos/nixpkgs";
|
||||
logos-cpp-sdk.url = "github:logos-co/logos-cpp-sdk";
|
||||
logos-liblogos.url = "github:logos-co/logos-liblogos";
|
||||
logos-blockchain-module.url = "github:logos-blockchain/logos-blockchain-module/0cae35a33bc5d5148096d5aaacb653c2b99da2c4";
|
||||
logos-blockchain-module.url = "github:logos-blockchain/logos-blockchain-module";
|
||||
logos-capability-module.url = "github:logos-co/logos-capability-module";
|
||||
logos-design-system.url = "github:logos-co/logos-design-system";
|
||||
logos-design-system.inputs.nixpkgs.follows = "nixpkgs";
|
||||
@ -35,12 +35,12 @@
|
||||
|
||||
# Library package (default blockchain-module has lib + include via symlinkJoin)
|
||||
lib = import ./nix/lib.nix {
|
||||
inherit pkgs common src logosBlockchainModule logosSdk;
|
||||
inherit pkgs common src logosBlockchainModule;
|
||||
};
|
||||
|
||||
# App package
|
||||
app = import ./nix/app.nix {
|
||||
inherit pkgs common src logosLiblogos logosSdk logosBlockchainModule logosCapabilityModule logosDesignSystem;
|
||||
inherit pkgs common src logosLiblogos logosBlockchainModule logosCapabilityModule logosDesignSystem;
|
||||
logosBlockchainUI = lib;
|
||||
};
|
||||
in
|
||||
@ -71,11 +71,9 @@
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
export LOGOS_CPP_SDK_ROOT="${logosSdk}"
|
||||
export LOGOS_LIBLOGOS_ROOT="${logosLiblogos}"
|
||||
export LOGOS_DESIGN_SYSTEM_ROOT="${logosDesignSystem}"
|
||||
echo "Logos Blockchain UI development environment"
|
||||
echo "LOGOS_CPP_SDK_ROOT: $LOGOS_CPP_SDK_ROOT"
|
||||
echo "LOGOS_LIBLOGOS_ROOT: $LOGOS_LIBLOGOS_ROOT"
|
||||
'';
|
||||
};
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
"type": "ui",
|
||||
"main": "blockchain_ui",
|
||||
"icon": ":/icons/blockchain.png",
|
||||
"dependencies": ["liblogos_blockchain_module"],
|
||||
"dependencies": ["liblogos-blockchain-module"],
|
||||
"category": "blockchain",
|
||||
"build": {
|
||||
"type": "cmake",
|
||||
|
||||
74
nix/app.nix
74
nix/app.nix
@ -1,15 +1,14 @@
|
||||
# Builds the logos-blockchain-ui-app standalone application
|
||||
{ pkgs, common, src, logosLiblogos, logosSdk, logosBlockchainModule, logosCapabilityModule, logosBlockchainUI, logosDesignSystem }:
|
||||
{ pkgs, common, src, logosLiblogos, logosBlockchainModule, logosCapabilityModule, logosBlockchainUI, logosDesignSystem }:
|
||||
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
pname = "logos-blockchain-ui-app";
|
||||
version = common.version;
|
||||
|
||||
inherit src;
|
||||
inherit (common) buildInputs cmakeFlags meta;
|
||||
inherit (common) buildInputs meta;
|
||||
|
||||
# Add logosSdk to nativeBuildInputs for logos-cpp-generator
|
||||
nativeBuildInputs = common.nativeBuildInputs ++ [ logosSdk pkgs.patchelf pkgs.removeReferencesTo ];
|
||||
nativeBuildInputs = common.nativeBuildInputs ++ [ pkgs.patchelf pkgs.removeReferencesTo ];
|
||||
|
||||
# Provide Qt/GL runtime paths so the wrapper can inject them
|
||||
qtLibPath = pkgs.lib.makeLibraryPath (
|
||||
@ -55,31 +54,7 @@ pkgs.stdenv.mkDerivation rec {
|
||||
|
||||
preConfigure = ''
|
||||
runHook prePreConfigure
|
||||
|
||||
# Set macOS deployment target to match Qt frameworks
|
||||
export MACOSX_DEPLOYMENT_TARGET=12.0
|
||||
|
||||
# Copy logos-cpp-sdk headers to expected location
|
||||
echo "Copying logos-cpp-sdk headers for app..."
|
||||
mkdir -p ./logos-cpp-sdk/include/cpp
|
||||
cp -r ${logosSdk}/include/cpp/* ./logos-cpp-sdk/include/cpp/
|
||||
|
||||
# Also copy core headers
|
||||
echo "Copying core headers..."
|
||||
mkdir -p ./logos-cpp-sdk/include/core
|
||||
cp -r ${logosSdk}/include/core/* ./logos-cpp-sdk/include/core/
|
||||
|
||||
# Copy SDK library files to lib directory
|
||||
echo "Copying SDK library files..."
|
||||
mkdir -p ./logos-cpp-sdk/lib
|
||||
if [ -f "${logosSdk}/lib/liblogos_sdk.dylib" ]; then
|
||||
cp "${logosSdk}/lib/liblogos_sdk.dylib" ./logos-cpp-sdk/lib/
|
||||
elif [ -f "${logosSdk}/lib/liblogos_sdk.so" ]; then
|
||||
cp "${logosSdk}/lib/liblogos_sdk.so" ./logos-cpp-sdk/lib/
|
||||
elif [ -f "${logosSdk}/lib/liblogos_sdk.a" ]; then
|
||||
cp "${logosSdk}/lib/liblogos_sdk.a" ./logos-cpp-sdk/lib/
|
||||
fi
|
||||
|
||||
runHook postPreConfigure
|
||||
'';
|
||||
|
||||
@ -122,16 +97,8 @@ pkgs.stdenv.mkDerivation rec {
|
||||
runHook preConfigure
|
||||
|
||||
echo "Configuring logos-blockchain-ui-app..."
|
||||
echo "liblogos: ${logosLiblogos}"
|
||||
echo "cpp-sdk: ${logosSdk}"
|
||||
echo "blockchain-module: ${logosBlockchainModule}"
|
||||
echo "capability-module: ${logosCapabilityModule}"
|
||||
echo "blockchain-ui: ${logosBlockchainUI}"
|
||||
echo "logos-design-system: ${logosDesignSystem}"
|
||||
|
||||
# Verify that the built components exist
|
||||
|
||||
test -d "${logosLiblogos}" || (echo "liblogos not found" && exit 1)
|
||||
test -d "${logosSdk}" || (echo "cpp-sdk not found" && exit 1)
|
||||
test -d "${logosBlockchainModule}" || (echo "blockchain-module not found" && exit 1)
|
||||
test -d "${logosCapabilityModule}" || (echo "capability-module not found" && exit 1)
|
||||
test -d "${logosBlockchainUI}" || (echo "blockchain-ui not found" && exit 1)
|
||||
@ -144,8 +111,7 @@ pkgs.stdenv.mkDerivation rec {
|
||||
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=FALSE \
|
||||
-DCMAKE_INSTALL_RPATH="" \
|
||||
-DCMAKE_SKIP_BUILD_RPATH=TRUE \
|
||||
-DLOGOS_LIBLOGOS_ROOT=${logosLiblogos} \
|
||||
-DLOGOS_CPP_SDK_ROOT=$(pwd)/logos-cpp-sdk
|
||||
-DLOGOS_LIBLOGOS_ROOT=${logosLiblogos}
|
||||
|
||||
runHook postConfigure
|
||||
'';
|
||||
@ -186,11 +152,6 @@ pkgs.stdenv.mkDerivation rec {
|
||||
cp -L "${logosLiblogos}/lib/"liblogos_core.* "$out/lib/" || true
|
||||
fi
|
||||
|
||||
# Copy SDK library if it exists
|
||||
if ls "${logosSdk}/lib/"liblogos_sdk.* >/dev/null 2>&1; then
|
||||
cp -L "${logosSdk}/lib/"liblogos_sdk.* "$out/lib/" || true
|
||||
fi
|
||||
|
||||
# Determine platform-specific plugin extension
|
||||
OS_EXT="so"
|
||||
case "$(uname -s)" in
|
||||
@ -203,8 +164,8 @@ pkgs.stdenv.mkDerivation rec {
|
||||
if [ -f "${logosCapabilityModule}/lib/capability_module_plugin.$OS_EXT" ]; then
|
||||
cp -L "${logosCapabilityModule}/lib/capability_module_plugin.$OS_EXT" "$out/modules/"
|
||||
fi
|
||||
if [ -f "${logosBlockchainModule}/lib/liblogos_blockchain_module.$OS_EXT" ]; then
|
||||
cp -L "${logosBlockchainModule}/lib/liblogos_blockchain_module.$OS_EXT" "$out/modules/"
|
||||
if [ -f "${logosBlockchainModule}/lib/liblogos-blockchain-module.$OS_EXT" ]; then
|
||||
cp -L "${logosBlockchainModule}/lib/liblogos-blockchain-module.$OS_EXT" "$out/modules/"
|
||||
fi
|
||||
|
||||
# Copy liblogos_blockchain library to modules directory (needed by blockchain module)
|
||||
@ -229,25 +190,20 @@ pkgs.stdenv.mkDerivation rec {
|
||||
echo "Copied Logos.Controls to lib/Logos/Controls/"
|
||||
fi
|
||||
|
||||
# Create a README for reference
|
||||
cat > $out/README.txt <<EOF
|
||||
Logos Blockchain UI App - Build Information
|
||||
============================================
|
||||
Logos Blockchain UI App
|
||||
=======================
|
||||
liblogos: ${logosLiblogos}
|
||||
cpp-sdk: ${logosSdk}
|
||||
blockchain-module: ${logosBlockchainModule}
|
||||
capability-module: ${logosCapabilityModule}
|
||||
blockchain-ui: ${logosBlockchainUI}
|
||||
logos-design-system: ${logosDesignSystem}
|
||||
design-system: ${logosDesignSystem}
|
||||
|
||||
Runtime Layout:
|
||||
- Binary: $out/bin/logos-blockchain-ui-app
|
||||
- Libraries: $out/lib
|
||||
- Modules: $out/modules
|
||||
- Qt Plugin: $out/blockchain_ui.$OS_EXT
|
||||
|
||||
Usage:
|
||||
$out/bin/logos-blockchain-ui-app
|
||||
Layout:
|
||||
bin/logos-blockchain-ui-app
|
||||
lib/
|
||||
modules/
|
||||
blockchain_ui.$OS_EXT
|
||||
EOF
|
||||
|
||||
runHook postInstall
|
||||
|
||||
@ -29,9 +29,7 @@
|
||||
"-DLOGOS_LIBLOGOS_ROOT=${logosLiblogos}"
|
||||
];
|
||||
|
||||
# Environment variables
|
||||
env = {
|
||||
LOGOS_CPP_SDK_ROOT = "${logosSdk}";
|
||||
LOGOS_LIBLOGOS_ROOT = "${logosLiblogos}";
|
||||
};
|
||||
|
||||
|
||||
100
nix/lib.nix
100
nix/lib.nix
@ -1,88 +1,46 @@
|
||||
# Builds the logos-blockchain-ui library
|
||||
{ pkgs, common, src, logosBlockchainModule, logosSdk }:
|
||||
{ pkgs, common, src, logosBlockchainModule }:
|
||||
|
||||
pkgs.stdenv.mkDerivation {
|
||||
pname = "${common.pname}-lib";
|
||||
version = common.version;
|
||||
|
||||
|
||||
inherit src;
|
||||
inherit (common) buildInputs cmakeFlags meta env;
|
||||
|
||||
# Add logosSdk to nativeBuildInputs for logos-cpp-generator
|
||||
nativeBuildInputs = common.nativeBuildInputs ++ [ logosSdk ];
|
||||
|
||||
preConfigure = ''
|
||||
runHook prePreConfigure
|
||||
|
||||
# Create generated_code directory for generated files
|
||||
mkdir -p ./generated_code
|
||||
|
||||
# Copy include files from logos-blockchain-module result
|
||||
echo "Copying include files from logos-blockchain-module..."
|
||||
if [ -d "${logosBlockchainModule}/include" ]; then
|
||||
echo "Found include directory in logos-blockchain-module"
|
||||
cp -r "${logosBlockchainModule}/include"/* ./generated_code/
|
||||
echo "Copied include files:"
|
||||
ls -la ./generated_code/
|
||||
else
|
||||
echo "Warning: No include directory found in logos-blockchain-module"
|
||||
fi
|
||||
|
||||
# Run logos-cpp-generator with metadata.json and --general-only flag
|
||||
echo "Running logos-cpp-generator..."
|
||||
logos-cpp-generator --metadata ${src}/metadata.json --general-only --output-dir ./generated_code
|
||||
|
||||
# Check what was generated by logos-cpp-generator
|
||||
echo "Checking generated files in generated_code:"
|
||||
ls -la ./generated_code/
|
||||
|
||||
# Create include directory and move generated files there if they exist
|
||||
if [ -f "./generated_code/core_manager_api.h" ] || [ -f "./generated_code/logos_sdk.h" ]; then
|
||||
echo "Creating include directory and moving generated files..."
|
||||
mkdir -p ./generated_code/include
|
||||
# Move generated header files to include directory
|
||||
for file in ./generated_code/*.h; do
|
||||
if [ -f "$file" ]; then
|
||||
mv "$file" ./generated_code/include/
|
||||
fi
|
||||
done
|
||||
# Also copy generated .cpp files to include directory
|
||||
for file in ./generated_code/*.cpp; do
|
||||
if [ -f "$file" ]; then
|
||||
cp "$file" ./generated_code/include/
|
||||
fi
|
||||
done
|
||||
echo "Generated include directory:"
|
||||
ls -la ./generated_code/include/
|
||||
else
|
||||
echo "Warning: No header files generated by logos-cpp-generator"
|
||||
fi
|
||||
|
||||
runHook postPreConfigure
|
||||
nativeBuildInputs = common.nativeBuildInputs;
|
||||
|
||||
# Library (Qt plugin), not an app — no Qt wrapper
|
||||
dontWrapQtApps = true;
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
cmake -S . -B build \
|
||||
-GNinja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
''${cmakeFlags}
|
||||
runHook postConfigure
|
||||
'';
|
||||
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
cmake --build build
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
|
||||
mkdir -p $out/lib
|
||||
# We are in build/; library is in build/modules/
|
||||
if [ -f modules/blockchain_ui.dylib ]; then
|
||||
cp modules/blockchain_ui.dylib $out/lib/
|
||||
elif [ -f modules/blockchain_ui.so ]; then
|
||||
cp modules/blockchain_ui.so $out/lib/
|
||||
if [ -f build/modules/blockchain_ui.dylib ]; then
|
||||
cp build/modules/blockchain_ui.dylib $out/lib/
|
||||
elif [ -f build/modules/blockchain_ui.so ]; then
|
||||
cp build/modules/blockchain_ui.so $out/lib/
|
||||
else
|
||||
echo "Error: No library file found"
|
||||
echo "Error: No library file found in build/modules/"
|
||||
ls -la build/modules/ 2>/dev/null || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Also install the generated include files
|
||||
if [ -d "./generated_code/include" ]; then
|
||||
mkdir -p $out/include
|
||||
cp -r ./generated_code/include/* $out/include/
|
||||
echo "Installed generated include files:"
|
||||
ls -la $out/include/
|
||||
fi
|
||||
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
}
|
||||
|
||||
@ -7,9 +7,10 @@
|
||||
#include <QUrl>
|
||||
|
||||
namespace {
|
||||
const char kSettingsOrg[] = "Logos";
|
||||
const char kSettingsApp[] = "BlockchainUI";
|
||||
const char kConfigPathKey[] = "configPath";
|
||||
const char SETTINGS_ORG[] = "Logos";
|
||||
const char SETTINGS_APP[] = "BlockchainUI";
|
||||
const char CONFIG_PATH_KEY[] = "configPath";
|
||||
const QString BLOCKCHAIN_MODULE_NAME = QStringLiteral("liblogos-blockchain-module");
|
||||
}
|
||||
|
||||
BlockchainBackend::BlockchainBackend(LogosAPI* logosAPI, QObject* parent)
|
||||
@ -17,33 +18,38 @@ BlockchainBackend::BlockchainBackend(LogosAPI* logosAPI, QObject* parent)
|
||||
m_status(NotStarted),
|
||||
m_configPath(""),
|
||||
m_logModel(new LogModel(this)),
|
||||
m_logos(nullptr),
|
||||
m_blockchainModule(nullptr)
|
||||
m_logosAPI(nullptr),
|
||||
m_blockchainClient(nullptr)
|
||||
{
|
||||
QSettings s(kSettingsOrg, kSettingsApp);
|
||||
QString saved = s.value(kConfigPathKey).toString();
|
||||
if (!saved.isEmpty()) {
|
||||
m_configPath = saved;
|
||||
} else {
|
||||
m_configPath = QString::fromUtf8(qgetenv("LB_CONFIG_PATH"));
|
||||
QSettings s(SETTINGS_ORG, SETTINGS_APP);
|
||||
const QString envConfigPath = QString::fromUtf8(qgetenv("LB_CONFIG_PATH"));
|
||||
const QString savedConfigPath = s.value(CONFIG_PATH_KEY).toString();
|
||||
|
||||
if (!envConfigPath.isEmpty()) {
|
||||
m_configPath = envConfigPath;
|
||||
} else if (!savedConfigPath.isEmpty()) {
|
||||
m_configPath = savedConfigPath;
|
||||
}
|
||||
|
||||
if (!logosAPI) {
|
||||
logosAPI = new LogosAPI("core", this);
|
||||
logosAPI = new LogosAPI("blockchain_ui", this);
|
||||
}
|
||||
|
||||
m_logos = new LogosModules(logosAPI);
|
||||
m_logosAPI = logosAPI;
|
||||
m_blockchainClient = m_logosAPI->getClient(BLOCKCHAIN_MODULE_NAME);
|
||||
|
||||
if (!m_logos) {
|
||||
if (!m_blockchainClient) {
|
||||
setStatus(ErrorNotInitialized);
|
||||
return;
|
||||
}
|
||||
|
||||
m_blockchainModule = &m_logos->liblogos_blockchain_module;
|
||||
|
||||
if (m_blockchainModule && !m_blockchainModule->on("newBlock", [this](const QVariantList& data) {
|
||||
onNewBlock(data);
|
||||
})) {
|
||||
QObject* replica = m_blockchainClient->requestObject(BLOCKCHAIN_MODULE_NAME);
|
||||
if (replica) {
|
||||
replica->setParent(this);
|
||||
m_blockchainClient->onEvent(replica, this, "newBlock", [this](const QString&, const QVariantList& data) {
|
||||
onNewBlock(data);
|
||||
});
|
||||
} else {
|
||||
setStatus(ErrorSubscribeFailed);
|
||||
}
|
||||
}
|
||||
@ -66,8 +72,8 @@ void BlockchainBackend::setConfigPath(const QString& path)
|
||||
const QString localPath = QUrl::fromUserInput(path).toLocalFile();
|
||||
if (m_configPath != localPath) {
|
||||
m_configPath = localPath;
|
||||
QSettings s(kSettingsOrg, kSettingsApp);
|
||||
s.setValue(kConfigPathKey, m_configPath);
|
||||
QSettings s(SETTINGS_ORG, SETTINGS_APP);
|
||||
s.setValue(CONFIG_PATH_KEY, m_configPath);
|
||||
emit configPathChanged();
|
||||
}
|
||||
}
|
||||
@ -79,39 +85,48 @@ void BlockchainBackend::clearLogs()
|
||||
|
||||
QString BlockchainBackend::getBalance(const QString& addressHex)
|
||||
{
|
||||
if (!m_blockchainModule) {
|
||||
if (!m_blockchainClient) {
|
||||
return QStringLiteral("Error: Module not initialized.");
|
||||
}
|
||||
return m_blockchainModule->wallet_get_balance(addressHex);
|
||||
QVariant result = m_blockchainClient->invokeRemoteMethod(BLOCKCHAIN_MODULE_NAME, "wallet_get_balance", addressHex);
|
||||
return result.isValid() ? result.toString() : QStringLiteral("Error: Call failed.");
|
||||
}
|
||||
|
||||
QString BlockchainBackend::transferFunds(const QString& fromKeyHex, const QString& toKeyHex, const QString& amountStr)
|
||||
{
|
||||
if (!m_blockchainModule) {
|
||||
if (!m_blockchainClient) {
|
||||
return QStringLiteral("Error: Module not initialized.");
|
||||
}
|
||||
QStringList senderAddresses;
|
||||
senderAddresses << fromKeyHex;
|
||||
return m_blockchainModule->wallet_transfer_funds(fromKeyHex, senderAddresses, toKeyHex, amountStr, "");
|
||||
QVariant result = m_blockchainClient->invokeRemoteMethod(
|
||||
BLOCKCHAIN_MODULE_NAME,
|
||||
"wallet_transfer_funds",
|
||||
fromKeyHex,
|
||||
fromKeyHex,
|
||||
toKeyHex,
|
||||
amountStr,
|
||||
QString());
|
||||
return result.isValid() ? result.toString() : QStringLiteral("Error: Call failed.");
|
||||
}
|
||||
|
||||
void BlockchainBackend::startBlockchain()
|
||||
{
|
||||
if (!m_blockchainModule) {
|
||||
if (!m_blockchainClient) {
|
||||
setStatus(ErrorNotInitialized);
|
||||
return;
|
||||
}
|
||||
|
||||
setStatus(Starting);
|
||||
|
||||
int result = m_blockchainModule->start(m_configPath, QString());
|
||||
QVariant result = m_blockchainClient->invokeRemoteMethod(
|
||||
BLOCKCHAIN_MODULE_NAME, "start", m_configPath, QString());
|
||||
int resultCode = result.isValid() ? result.toInt() : -1;
|
||||
|
||||
if (result == 0 || result == 1) {
|
||||
if (resultCode == 0 || resultCode == 1) {
|
||||
setStatus(Running);
|
||||
QTimer::singleShot(500, this, [this]() { refreshKnownAddresses(); });
|
||||
} else if (result == 2) {
|
||||
} else if (resultCode == 2) {
|
||||
setStatus(ErrorConfigMissing);
|
||||
} else if (result == 3) {
|
||||
} else if (resultCode == 3) {
|
||||
setStatus(ErrorStartFailed);
|
||||
} else {
|
||||
setStatus(ErrorStartFailed);
|
||||
@ -120,8 +135,9 @@ void BlockchainBackend::startBlockchain()
|
||||
|
||||
void BlockchainBackend::refreshKnownAddresses()
|
||||
{
|
||||
if (!m_blockchainModule) return;
|
||||
QStringList list = m_blockchainModule->wallet_get_known_addresses();
|
||||
if (!m_blockchainClient) return;
|
||||
QVariant result = m_blockchainClient->invokeRemoteMethod(BLOCKCHAIN_MODULE_NAME, "wallet_get_known_addresses");
|
||||
QStringList list = result.isValid() && result.canConvert<QStringList>() ? result.toStringList() : QStringList();
|
||||
qDebug() << "BlockchainBackend: received from blockchain lib: type=QStringList, count=" << list.size();
|
||||
if (m_knownAddresses != list) {
|
||||
m_knownAddresses = std::move(list);
|
||||
@ -135,16 +151,17 @@ void BlockchainBackend::stopBlockchain()
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_blockchainModule) {
|
||||
if (!m_blockchainClient) {
|
||||
setStatus(ErrorNotInitialized);
|
||||
return;
|
||||
}
|
||||
|
||||
setStatus(Stopping);
|
||||
|
||||
int result = m_blockchainModule->stop();
|
||||
QVariant result = m_blockchainClient->invokeRemoteMethod(BLOCKCHAIN_MODULE_NAME, "stop");
|
||||
int resultCode = result.isValid() ? result.toInt() : -1;
|
||||
|
||||
if (result == 0 || result == 1) {
|
||||
if (resultCode == 0 || resultCode == 1) {
|
||||
setStatus(Stopped);
|
||||
} else {
|
||||
setStatus(ErrorStopFailed);
|
||||
|
||||
@ -3,15 +3,10 @@
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <utility>
|
||||
#include "logos_api.h"
|
||||
#include "logos_api_client.h"
|
||||
#include "logos_sdk.h"
|
||||
#include "LogModel.h"
|
||||
|
||||
// Type of the blockchain module proxy (has start(), stop(), on() etc.)
|
||||
using BlockchainModuleProxy = std::remove_reference_t<decltype(std::declval<LogosModules>().liblogos_blockchain_module)>;
|
||||
|
||||
class BlockchainBackend : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
@ -71,6 +66,6 @@ private:
|
||||
LogModel* m_logModel;
|
||||
QStringList m_knownAddresses;
|
||||
|
||||
LogosModules* m_logos;
|
||||
BlockchainModuleProxy* m_blockchainModule;
|
||||
LogosAPI* m_logosAPI;
|
||||
LogosAPIClient* m_blockchainClient;
|
||||
};
|
||||
|
||||
@ -56,10 +56,6 @@ ColumnLayout {
|
||||
editable: true
|
||||
model: knownAddresses
|
||||
font.pixelSize: Theme.typography.secondaryText
|
||||
onActivated: function(index) {
|
||||
if (index >= 0 && index < knownAddresses.length)
|
||||
currentText = knownAddresses[index]
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
@ -73,21 +69,16 @@ ColumnLayout {
|
||||
onClicked: root.getBalanceRequested(balanceAddressCombo.currentText.trim())
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
LogosButton {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: balanceResultText.height + 2 * Theme.spacing.large
|
||||
color: Theme.palette.backgroundSecondary
|
||||
radius: Theme.spacing.radiusXlarge
|
||||
border.color: Theme.palette.border
|
||||
border.width: 1
|
||||
LogosText {
|
||||
enabled: false
|
||||
padding: Theme.spacing.medium
|
||||
contentItem: Text {
|
||||
id: balanceResultText
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.margins: Theme.spacing.large
|
||||
font.pixelSize: Theme.typography.secondaryText
|
||||
width: parent.width
|
||||
color: Theme.palette.textSecondary
|
||||
font.pixelSize: Theme.typography.secondaryText
|
||||
font.weight: Theme.typography.weightMedium
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
}
|
||||
@ -98,7 +89,7 @@ ColumnLayout {
|
||||
// Transfer funds card
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: transferCol.height
|
||||
Layout.preferredHeight: transferCol.height + 2 * Theme.spacing.large
|
||||
color: Theme.palette.backgroundTertiary
|
||||
radius: Theme.spacing.radiusLarge
|
||||
border.color: Theme.palette.border
|
||||
@ -133,18 +124,31 @@ ColumnLayout {
|
||||
placeholderText: qsTr("Amount")
|
||||
}
|
||||
|
||||
LogosButton {
|
||||
text: qsTr("Transfer")
|
||||
Layout.alignment: Qt.AlignRight
|
||||
onClicked: root.transferRequested(transferFromField.text, transferToField.text, transferAmountField.text)
|
||||
}
|
||||
|
||||
LogosText {
|
||||
id: transferResultText
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
font.pixelSize: Theme.typography.secondaryText
|
||||
color: Theme.palette.textSecondary
|
||||
wrapMode: Text.WordWrap
|
||||
Layout.preferredHeight: transferButton.implicitHeight
|
||||
spacing: Theme.spacing.large
|
||||
|
||||
LogosButton {
|
||||
id: transferButton
|
||||
text: qsTr("Transfer")
|
||||
Layout.alignment: Qt.AlignRight
|
||||
onClicked: root.transferRequested(transferFromField.text, transferToField.text, transferAmountField.text)
|
||||
}
|
||||
|
||||
LogosButton {
|
||||
Layout.fillWidth: true
|
||||
enabled: false
|
||||
padding: Theme.spacing.medium
|
||||
contentItem: Text {
|
||||
id: transferResultText
|
||||
width: parent.width
|
||||
color: Theme.palette.textSecondary
|
||||
font.pixelSize: Theme.typography.secondaryText
|
||||
font.weight: Theme.typography.weightMedium
|
||||
wrapMode: Text.WordWrap
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user