Skip to content
Draft
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
71 changes: 26 additions & 45 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ endif()
# Find required packages
find_package(Threads REQUIRED)
find_package(absl QUIET)
find_library(LIBWALLET_PATH
NAMES libgowalletsdk.so libgowalletsdk.dylib libgowalletsdk.dll
find_library(LIBGOWALLETSDK
NAMES libgowalletsdk.a libgowalletsdk.lib
PATHS
${CMAKE_CURRENT_SOURCE_DIR}/lib
NO_DEFAULT_PATH
)

if(NOT LIBWALLET_PATH)
message(WARNING "Wallet C library not found in lib/. Build it via build_wallet_lib.sh before linking.")
if(NOT LIBGOWALLETSDK)
message(WARNING "go-wallet-sdk C library not found in lib/. Build it before linking.")
endif()

# Plugin sources
Expand Down Expand Up @@ -207,9 +207,24 @@ if(absl_FOUND)
)
endif()

# Link the wallet C library if present
if(LIBWALLET_PATH)
target_link_libraries(wallet_module_plugin PRIVATE ${LIBWALLET_PATH})
# Link against macos frameworks
if(APPLE)
target_link_libraries(wallet_module_plugin PUBLIC "-framework CoreFoundation")
target_link_libraries(wallet_module_plugin PUBLIC "-framework Security")
Comment on lines +212 to +213
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The macOS frameworks CoreFoundation and Security are linked with PUBLIC visibility, which exports these dependencies to consumers of wallet_module_plugin. Since this appears to be a plugin library and these frameworks are implementation details needed for the static go-wallet-sdk library, consider using PRIVATE visibility instead to avoid exposing these dependencies unnecessarily.

Suggested change
target_link_libraries(wallet_module_plugin PUBLIC "-framework CoreFoundation")
target_link_libraries(wallet_module_plugin PUBLIC "-framework Security")
target_link_libraries(wallet_module_plugin PRIVATE "-framework CoreFoundation")
target_link_libraries(wallet_module_plugin PRIVATE "-framework Security")

Copilot uses AI. Check for mistakes.
set_target_properties(wallet_module_plugin PROPERTIES LINK_FLAGS "-Wl,-F/Library/Frameworks")
endif()

# Link the go-wallet-sdk C library if present
if(LIBGOWALLETSDK)
target_link_libraries(wallet_module_plugin PRIVATE ${LIBGOWALLETSDK})

if(APPLE)
# macOS specific settings
target_link_options(wallet_module_plugin PRIVATE -Wl,-force_load ${LIBGOWALLETSDK})
else()
# Linux specific settings
target_link_options(wallet_module_plugin PRIVATE -Wl,--whole-archive ${LIBGOWALLETSDK} -Wl,--no-whole-archive)
endif()
Comment on lines +219 to +227
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The static library is linked twice: once on line 219 via target_link_libraries, and again via target_link_options with whole-archive flags on lines 223/226. This redundant linking should be removed. Consider removing line 219 and keeping only the whole-archive linking, or use only the basic linking if the whole-archive approach is not needed.

Copilot uses AI. Check for mistakes.
endif()

# Include directories
Expand Down Expand Up @@ -256,42 +271,15 @@ if(APPLE)
INSTALL_NAME_DIR "@rpath"
BUILD_WITH_INSTALL_NAME_DIR TRUE)

# If libgowalletsdk exists, copy and fix install names
if(LIBWALLET_PATH)
add_custom_command(TARGET wallet_module_plugin PRE_LINK
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${LIBWALLET_PATH}
${CMAKE_BINARY_DIR}/modules/libgowalletsdk.dylib
COMMENT "Copying libgowalletsdk to modules directory"
VERBATIM
)

add_custom_command(TARGET wallet_module_plugin POST_BUILD
COMMAND install_name_tool -id "@rpath/wallet_module_plugin.dylib" $<TARGET_FILE:wallet_module_plugin>
COMMAND ${CMAKE_COMMAND} -DWALLET_LIB_PATH=${CMAKE_BINARY_DIR}/modules/libgowalletsdk.dylib -DPLUGIN_PATH=${CMAKE_BINARY_DIR}/modules/wallet_module_plugin.dylib -P ${CMAKE_CURRENT_SOURCE_DIR}/fix_wallet_install_name.cmake
COMMENT "Updating library paths for macOS"
)
else()
add_custom_command(TARGET wallet_module_plugin POST_BUILD
COMMAND install_name_tool -id "@rpath/wallet_module_plugin.dylib" $<TARGET_FILE:wallet_module_plugin>
COMMENT "Updating library paths for macOS (wallet library not found)"
)
endif()
add_custom_command(TARGET wallet_module_plugin POST_BUILD
COMMAND install_name_tool -id "@rpath/wallet_module_plugin.dylib" $<TARGET_FILE:wallet_module_plugin>
COMMENT "Updating library paths for macOS (accounts library not found)"
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment mentions "accounts library not found" but should refer to the wallet library. This appears to be a copy-paste error from another part of the codebase.

Suggested change
COMMENT "Updating library paths for macOS (accounts library not found)"
COMMENT "Updating library paths for macOS (wallet library not found)"

Copilot uses AI. Check for mistakes.
)
else()
# Linux specific settings
set_target_properties(wallet_module_plugin PROPERTIES
INSTALL_RPATH "$ORIGIN"
INSTALL_RPATH_USE_LINK_PATH FALSE)

# First, copy libgowallet.so to the modules directory if present
if(LIBWALLET_PATH)
add_custom_command(TARGET wallet_module_plugin PRE_LINK
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${LIBWALLET_PATH}
${CMAKE_BINARY_DIR}/modules/libgowalletsdk.so
COMMENT "Copying libgowalletsdk.so to modules directory"
)
endif()
endif()

install(TARGETS wallet_module_plugin
Expand All @@ -309,13 +297,6 @@ install(DIRECTORY "${PLUGINS_OUTPUT_DIR}/"
OPTIONAL
)

# Install the wallet library if it exists
if(LIBWALLET_PATH)
install(FILES ${LIBWALLET_PATH}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/logos/modules
)
endif()

# Print status messages
message(STATUS "Wallet Plugin configured successfully")

Expand Down
51 changes: 0 additions & 51 deletions fix_wallet_install_name.cmake

This file was deleted.

8 changes: 4 additions & 4 deletions flake.lock

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

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
logos-cpp-sdk.url = "github:logos-co/logos-cpp-sdk";
logos-liblogos.url = "github:logos-co/logos-liblogos";
go-wallet-sdk = {
url = "github:status-im/go-wallet-sdk/ec80b3239050fa23c5b440a01e7dc476fee47a2c";
url = "github:status-im/go-wallet-sdk/0938a704506b0ff444378045d17be9e19e699d80";
flake = false;
};
};
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"category": "wallet",
"main": "wallet_module_plugin",
"dependencies": [],
"include": ["libgowalletsdk.so", "libgowalletsdk.dylib", "libgowalletsdk.dll"],
"include": [],
"capabilities": []
}

Expand Down
20 changes: 7 additions & 13 deletions nix/lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pkgs.stdenv.mkDerivation {

cd vendor/go-wallet-sdk
echo "Go version: $(go version)"
make shared-library
make static-library
cd ../..

mkdir -p lib
Expand Down Expand Up @@ -98,18 +98,12 @@ pkgs.stdenv.mkDerivation {
fi

# Copy the wallet library if it exists (check both lib/ and modules/ directories)
if [ -f lib/libgowalletsdk.dylib ]; then
cp lib/libgowalletsdk.dylib $out/lib/
echo "Copied libgowalletsdk.dylib from lib/ to $out/lib/"
elif [ -f modules/libgowalletsdk.dylib ]; then
cp modules/libgowalletsdk.dylib $out/lib/
echo "Copied libgowalletsdk.dylib from modules/ to $out/lib/"
elif [ -f lib/libgowalletsdk.so ]; then
cp lib/libgowalletsdk.so $out/lib/
echo "Copied libgowalletsdk.so from lib/ to $out/lib/"
elif [ -f modules/libgowalletsdk.so ]; then
cp modules/libgowalletsdk.so $out/lib/
echo "Copied libgowalletsdk.so from modules/ to $out/lib/"
if [ -f lib/libgowalletsdk.a ]; then
cp lib/libgowalletsdk.a $out/lib/
echo "Copied libgowalletsdk.a from lib/ to $out/lib/"
elif [ -f modules/libgowalletsdk.a ]; then
cp modules/libgowalletsdk.a $out/lib/
echo "Copied libgowalletsdk.a from modules/ to $out/lib/"
else
echo "Warning: No wallet library found in lib/ or modules/"
echo "Contents of lib/:"
Expand Down