mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-25 06:01:11 +00:00
Consolidate wallet account decoding and portfolio handling around the shared Rust IDL decoder. Simplify AMM wallet integration, remove obsolete caches and network plumbing, and cover account selection and live flows.
315 lines
12 KiB
CMake
315 lines
12 KiB
CMake
cmake_minimum_required(VERSION 3.21)
|
|
|
|
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
|
project(LogosWallet LANGUAGES CXX)
|
|
include(CTest)
|
|
endif()
|
|
|
|
option(LOGOS_WALLET_BUILD_QML "Build the Logos.Wallet QML module" ON)
|
|
option(LOGOS_WALLET_BUILD_ACCESS "Build the generated-SDK wallet adapter" ON)
|
|
set(LOGOS_WALLET_GENERATED_DIR "" CACHE PATH "Path to generated Logos SDK sources")
|
|
set(LOGOS_WALLET_IDL_DECODER_LIBRARY "" CACHE FILEPATH
|
|
"wallet_idl_decoder library required by logos_wallet_access")
|
|
|
|
if(LOGOS_WALLET_BUILD_ACCESS
|
|
AND NOT EXISTS "${LOGOS_WALLET_GENERATED_DIR}/logos_sdk.h"
|
|
AND NOT EXISTS "${LOGOS_WALLET_GENERATED_DIR}/include/logos_sdk.h")
|
|
message(FATAL_ERROR
|
|
"logos_wallet_access requires logos_sdk.h; set LOGOS_WALLET_GENERATED_DIR"
|
|
)
|
|
endif()
|
|
|
|
find_package(Qt6 6.8 REQUIRED COMPONENTS Core)
|
|
if(LOGOS_WALLET_BUILD_ACCESS OR BUILD_TESTING)
|
|
find_package(Qt6 6.8 REQUIRED COMPONENTS Network)
|
|
endif()
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
if(LOGOS_WALLET_BUILD_ACCESS)
|
|
if(NOT LOGOS_WALLET_IDL_DECODER_LIBRARY)
|
|
find_library(LOGOS_WALLET_IDL_DECODER_LIBRARY
|
|
NAMES wallet_idl_decoder
|
|
HINTS "$ENV{LOGOS_EXT_ROOT_WALLET_IDL_DECODER}/lib"
|
|
)
|
|
endif()
|
|
if(NOT LOGOS_WALLET_IDL_DECODER_INCLUDE_DIR)
|
|
find_path(LOGOS_WALLET_IDL_DECODER_INCLUDE_DIR
|
|
NAMES wallet_idl_decoder.h
|
|
HINTS
|
|
"$ENV{LOGOS_EXT_ROOT_WALLET_IDL_DECODER}/include"
|
|
"${CMAKE_SOURCE_DIR}/include"
|
|
"${CMAKE_SOURCE_DIR}/lib"
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/../../../tools/wallet-idl-decoder/include"
|
|
)
|
|
endif()
|
|
if(NOT LOGOS_WALLET_IDL_DECODER_LIBRARY
|
|
OR NOT LOGOS_WALLET_IDL_DECODER_INCLUDE_DIR)
|
|
message(FATAL_ERROR
|
|
"logos_wallet_access requires wallet_idl_decoder library and headers"
|
|
)
|
|
endif()
|
|
add_library(logos_wallet_access STATIC
|
|
src/WalletProvider.h
|
|
src/WalletProvider.cpp
|
|
src/LogosWalletProvider.h
|
|
src/LogosWalletProvider.cpp
|
|
src/WalletAccountModel.h
|
|
src/WalletAccountModel.cpp
|
|
src/WalletController.h
|
|
src/WalletController.cpp
|
|
src/WalletIdlDecoder.h
|
|
src/WalletIdlDecoder.cpp
|
|
src/SequencerNetworkContext.h
|
|
src/SequencerNetworkContext.cpp
|
|
src/SequencerNetworkSettings.h
|
|
src/SequencerNetworkSettings.cpp
|
|
src/SequencerIdentityProbe.h
|
|
src/SequencerIdentityProbe.cpp
|
|
src/WalletPortfolioService.h
|
|
src/WalletPortfolioService.cpp
|
|
)
|
|
set_target_properties(logos_wallet_access PROPERTIES
|
|
AUTOMOC ON
|
|
POSITION_INDEPENDENT_CODE ON
|
|
)
|
|
target_compile_features(logos_wallet_access PUBLIC cxx_std_17)
|
|
target_include_directories(logos_wallet_access
|
|
PUBLIC
|
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
|
|
PRIVATE
|
|
"${LOGOS_WALLET_GENERATED_DIR}"
|
|
"${LOGOS_WALLET_GENERATED_DIR}/include"
|
|
"${LOGOS_WALLET_IDL_DECODER_INCLUDE_DIR}"
|
|
)
|
|
target_link_libraries(logos_wallet_access
|
|
PUBLIC Qt6::Core
|
|
PRIVATE
|
|
Qt6::Network
|
|
"${LOGOS_WALLET_IDL_DECODER_LIBRARY}"
|
|
)
|
|
qt_add_resources(logos_wallet_access logos_wallet_access_network_data
|
|
PREFIX "/wallet"
|
|
FILES
|
|
config/networks.json
|
|
)
|
|
endif()
|
|
|
|
if(LOGOS_WALLET_BUILD_QML)
|
|
find_package(Qt6 6.8 REQUIRED COMPONENTS Qml Quick QuickControls2)
|
|
qt_policy(SET QTP0004 NEW)
|
|
|
|
set(wallet_qml_output_dir "${CMAKE_CURRENT_BINARY_DIR}/qml/Logos/Wallet")
|
|
set(wallet_internal_qml
|
|
qml/internal/WalletIconButton.qml
|
|
qml/internal/AccountDelegate.qml
|
|
qml/internal/CreateAccountDialog.qml
|
|
qml/internal/CreateWalletDialog.qml
|
|
qml/internal/WalletMessageDialog.qml
|
|
)
|
|
set(wallet_public_qml
|
|
qml/internal/CopyButton.qml
|
|
qml/WalletControl.qml
|
|
qml/ProgramAccountSelector.qml
|
|
qml/TransactionConfirmationDialog.qml
|
|
qml/SubmittedTransaction.qml
|
|
)
|
|
set(wallet_icons
|
|
qml/internal/icons/account.svg
|
|
qml/internal/icons/back.svg
|
|
qml/internal/icons/checkmark.svg
|
|
qml/internal/icons/copy.svg
|
|
qml/internal/icons/power.svg
|
|
)
|
|
foreach(qml_file IN LISTS wallet_public_qml wallet_internal_qml)
|
|
get_filename_component(qml_name "${qml_file}" NAME)
|
|
set_source_files_properties("${qml_file}" PROPERTIES QT_RESOURCE_ALIAS "${qml_name}")
|
|
endforeach()
|
|
foreach(icon IN LISTS wallet_icons)
|
|
get_filename_component(icon_name "${icon}" NAME)
|
|
set_source_files_properties("${icon}" PROPERTIES QT_RESOURCE_ALIAS "icons/${icon_name}")
|
|
endforeach()
|
|
set_source_files_properties(${wallet_internal_qml} PROPERTIES QT_QML_INTERNAL_TYPE TRUE)
|
|
|
|
qt_add_library(logos_wallet_qml SHARED)
|
|
qt_add_qml_module(logos_wallet_qml
|
|
URI Logos.Wallet
|
|
VERSION 1.0
|
|
RESOURCE_PREFIX /qt/qml
|
|
OUTPUT_DIRECTORY "${wallet_qml_output_dir}"
|
|
TYPEINFO plugins.qmltypes
|
|
QML_FILES
|
|
${wallet_public_qml}
|
|
${wallet_internal_qml}
|
|
RESOURCES
|
|
${wallet_icons}
|
|
)
|
|
target_link_libraries(logos_wallet_qml PRIVATE
|
|
Qt6::Core
|
|
Qt6::Qml
|
|
Qt6::Quick
|
|
Qt6::QuickControls2
|
|
)
|
|
# Resolve the sibling liblogos_wallet_qml.dylib/.so next to the plugin.
|
|
# macOS dyld does not expand the ELF "$ORIGIN" token — it uses @loader_path.
|
|
if(APPLE)
|
|
set(wallet_qml_rpath "@loader_path")
|
|
else()
|
|
set(wallet_qml_rpath "$ORIGIN")
|
|
endif()
|
|
set_target_properties(logos_wallet_qml logos_wallet_qmlplugin PROPERTIES
|
|
LIBRARY_OUTPUT_DIRECTORY "${wallet_qml_output_dir}"
|
|
RUNTIME_OUTPUT_DIRECTORY "${wallet_qml_output_dir}"
|
|
BUILD_WITH_INSTALL_RPATH ON
|
|
INSTALL_RPATH "${wallet_qml_rpath}"
|
|
)
|
|
|
|
set(wallet_qml_install_dir "lib/qml/Logos/Wallet")
|
|
install(TARGETS logos_wallet_qml logos_wallet_qmlplugin
|
|
LIBRARY DESTINATION "${wallet_qml_install_dir}"
|
|
RUNTIME DESTINATION "${wallet_qml_install_dir}"
|
|
)
|
|
install(FILES
|
|
"${wallet_qml_output_dir}/qmldir"
|
|
"${wallet_qml_output_dir}/plugins.qmltypes"
|
|
DESTINATION "${wallet_qml_install_dir}"
|
|
OPTIONAL
|
|
)
|
|
endif()
|
|
|
|
if(BUILD_TESTING)
|
|
find_package(Qt6 6.8 REQUIRED COMPONENTS Test)
|
|
|
|
add_executable(logos_wallet_access_test
|
|
tests/cpp/LogosWalletProviderTest.cpp
|
|
src/WalletProvider.cpp
|
|
src/LogosWalletProvider.cpp
|
|
src/WalletAccountModel.cpp
|
|
src/WalletAccountModel.h
|
|
src/WalletController.cpp
|
|
src/WalletController.h
|
|
)
|
|
set_target_properties(logos_wallet_access_test PROPERTIES AUTOMOC ON)
|
|
target_compile_features(logos_wallet_access_test PRIVATE cxx_std_17)
|
|
target_include_directories(logos_wallet_access_test PRIVATE
|
|
tests/cpp/fixtures
|
|
tests/support
|
|
src
|
|
)
|
|
target_link_libraries(logos_wallet_access_test PRIVATE
|
|
Qt6::Core
|
|
Qt6::Network
|
|
Qt6::Test
|
|
)
|
|
add_test(NAME logos_wallet_access COMMAND logos_wallet_access_test)
|
|
|
|
if(LOGOS_WALLET_BUILD_ACCESS)
|
|
add_executable(logos_wallet_idl_decoder_link_test
|
|
tests/cpp/WalletIdlDecoderLinkTest.cpp
|
|
)
|
|
target_compile_features(logos_wallet_idl_decoder_link_test PRIVATE cxx_std_17)
|
|
target_link_libraries(logos_wallet_idl_decoder_link_test PRIVATE
|
|
Qt6::Core
|
|
Qt6::Test
|
|
logos_wallet_access
|
|
)
|
|
add_test(NAME logos_wallet_idl_decoder_link
|
|
COMMAND logos_wallet_idl_decoder_link_test)
|
|
endif()
|
|
|
|
add_executable(logos_wallet_sequencer_network_context_test
|
|
tests/cpp/SequencerNetworkContextTest.cpp
|
|
src/SequencerNetworkContext.h
|
|
src/SequencerNetworkContext.cpp
|
|
)
|
|
set_target_properties(logos_wallet_sequencer_network_context_test PROPERTIES AUTOMOC ON)
|
|
target_compile_features(logos_wallet_sequencer_network_context_test PRIVATE cxx_std_17)
|
|
target_include_directories(logos_wallet_sequencer_network_context_test PRIVATE src)
|
|
target_link_libraries(logos_wallet_sequencer_network_context_test PRIVATE
|
|
Qt6::Core
|
|
Qt6::Test
|
|
)
|
|
add_test(NAME logos_wallet_sequencer_network_context
|
|
COMMAND logos_wallet_sequencer_network_context_test)
|
|
|
|
add_executable(logos_wallet_sequencer_network_settings_test
|
|
tests/cpp/SequencerNetworkSettingsTest.cpp
|
|
src/SequencerNetworkContext.h
|
|
src/SequencerNetworkContext.cpp
|
|
src/SequencerNetworkSettings.h
|
|
src/SequencerNetworkSettings.cpp
|
|
)
|
|
set_target_properties(logos_wallet_sequencer_network_settings_test PROPERTIES AUTOMOC ON)
|
|
target_compile_features(logos_wallet_sequencer_network_settings_test PRIVATE cxx_std_17)
|
|
target_include_directories(logos_wallet_sequencer_network_settings_test PRIVATE src)
|
|
target_link_libraries(logos_wallet_sequencer_network_settings_test PRIVATE
|
|
Qt6::Core
|
|
Qt6::Test
|
|
)
|
|
qt_add_resources(logos_wallet_sequencer_network_settings_test
|
|
logos_wallet_access_network_data
|
|
PREFIX "/wallet"
|
|
FILES
|
|
config/networks.json
|
|
)
|
|
add_test(NAME logos_wallet_sequencer_network_settings
|
|
COMMAND logos_wallet_sequencer_network_settings_test)
|
|
|
|
add_executable(logos_wallet_sequencer_identity_probe_test
|
|
tests/cpp/SequencerIdentityProbeTest.cpp
|
|
src/SequencerIdentityProbe.h
|
|
src/SequencerIdentityProbe.cpp
|
|
src/SequencerNetworkContext.h
|
|
src/SequencerNetworkContext.cpp
|
|
)
|
|
set_target_properties(logos_wallet_sequencer_identity_probe_test PROPERTIES AUTOMOC ON)
|
|
target_compile_features(logos_wallet_sequencer_identity_probe_test PRIVATE cxx_std_17)
|
|
target_include_directories(logos_wallet_sequencer_identity_probe_test PRIVATE src)
|
|
target_link_libraries(logos_wallet_sequencer_identity_probe_test PRIVATE
|
|
Qt6::Core
|
|
Qt6::Network
|
|
Qt6::Test
|
|
)
|
|
add_test(NAME logos_wallet_sequencer_identity_probe
|
|
COMMAND logos_wallet_sequencer_identity_probe_test)
|
|
|
|
add_executable(logos_wallet_portfolio_service_test
|
|
tests/cpp/WalletPortfolioServiceTest.cpp
|
|
src/WalletPortfolioService.h
|
|
src/WalletPortfolioService.cpp
|
|
src/WalletProvider.cpp
|
|
)
|
|
set_target_properties(logos_wallet_portfolio_service_test PROPERTIES AUTOMOC ON)
|
|
target_compile_features(logos_wallet_portfolio_service_test PRIVATE cxx_std_17)
|
|
target_include_directories(logos_wallet_portfolio_service_test PRIVATE
|
|
src
|
|
)
|
|
target_link_libraries(logos_wallet_portfolio_service_test PRIVATE
|
|
Qt6::Core
|
|
Qt6::Test
|
|
)
|
|
add_test(NAME logos_wallet_portfolio_service
|
|
COMMAND logos_wallet_portfolio_service_test)
|
|
|
|
if(LOGOS_WALLET_BUILD_QML)
|
|
find_package(Qt6 6.8 REQUIRED COMPONENTS QuickTest)
|
|
add_executable(logos_wallet_qml_test tests/qml/main.cpp)
|
|
target_compile_definitions(logos_wallet_qml_test PRIVATE
|
|
QUICK_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/tests/qml"
|
|
)
|
|
target_link_libraries(logos_wallet_qml_test PRIVATE Qt6::QuickTest)
|
|
add_dependencies(logos_wallet_qml_test logos_wallet_qmlplugin)
|
|
add_test(NAME logos_wallet_qml COMMAND logos_wallet_qml_test)
|
|
get_target_property(wallet_qml_library Qt6::Qml IMPORTED_LOCATION)
|
|
get_filename_component(wallet_qml_library_dir "${wallet_qml_library}" DIRECTORY)
|
|
get_filename_component(wallet_qml_prefix "${wallet_qml_library_dir}" DIRECTORY)
|
|
set(wallet_qml_test_import_paths
|
|
"${CMAKE_CURRENT_BINARY_DIR}/qml"
|
|
"${wallet_qml_prefix}/${QT6_INSTALL_QML}"
|
|
)
|
|
string(JOIN ":" wallet_qml_test_import_path ${wallet_qml_test_import_paths})
|
|
set_tests_properties(logos_wallet_qml PROPERTIES ENVIRONMENT
|
|
"QT_QPA_PLATFORM=offscreen;QT_QUICK_BACKEND=software;QML2_IMPORT_PATH=${wallet_qml_test_import_path};QML_IMPORT_PATH=${wallet_qml_test_import_path}"
|
|
)
|
|
endif()
|
|
endif()
|