diff --git a/packages/komodo_defi_framework/app_build/build_config.json b/packages/komodo_defi_framework/app_build/build_config.json index 765bd92..f479b6c 100644 --- a/packages/komodo_defi_framework/app_build/build_config.json +++ b/packages/komodo_defi_framework/app_build/build_config.json @@ -62,7 +62,7 @@ "coins": { "fetch_at_build_enabled": true, "update_commit_on_build": true, - "bundled_coins_repo_commit": "642abea7172b81db24b16bffc13783b9a0e400f5", + "bundled_coins_repo_commit": "78be0d03414110e38f27521bd8b5a85e24cee3a0", "coins_repo_api_url": "https://api.github.com/repos/KomodoPlatform/coins", "coins_repo_content_url": "https://komodoplatform.github.io/coins", "coins_repo_branch": "master", diff --git a/packages/komodo_defi_framework/lib/src/operations/kdf_operations_local_executable.dart b/packages/komodo_defi_framework/lib/src/operations/kdf_operations_local_executable.dart index e281723..3dbd2db 100644 --- a/packages/komodo_defi_framework/lib/src/operations/kdf_operations_local_executable.dart +++ b/packages/komodo_defi_framework/lib/src/operations/kdf_operations_local_executable.dart @@ -109,9 +109,13 @@ class KdfOperationsLocalExecutable implements IKdfOperations { final appSupportParentDir = Directory(p.dirname(appSupportDir.path)); final appSupportGrandParentDir = Directory(p.dirname(appSupportParentDir.path)); + final homeDir = Platform.environment['HOME'] ?? ''; + final files = [ '/usr/local/bin/kdf', '/usr/bin/kdf', + '$homeDir/.local/bin/kdf', + '$homeDir/bin/kdf', p.join(Directory.current.path, 'kdf'), p.join(Directory.current.path, 'kdf.exe'), p.join(appSupportDir.path, 'kdf'), diff --git a/packages/komodo_defi_framework/linux/CMakeLists.txt b/packages/komodo_defi_framework/linux/CMakeLists.txt index 04c705c..b1f4cf0 100644 --- a/packages/komodo_defi_framework/linux/CMakeLists.txt +++ b/packages/komodo_defi_framework/linux/CMakeLists.txt @@ -18,6 +18,17 @@ target_include_directories(${PLUGIN_NAME} INTERFACE target_link_libraries(${PLUGIN_NAME} PRIVATE flutter) target_link_libraries(${PLUGIN_NAME} PRIVATE PkgConfig::GTK) +# Copy kdf binary to $HOME/.local/bin/kdf to make it accessible +set(FINAL_INSTALL_DIR "$ENV{HOME}/.local/bin") +set(KDF_PATH "${CMAKE_CURRENT_SOURCE_DIR}/bin/kdf") + +add_custom_command( + TARGET ${PLUGIN_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${KDF_PATH} + "${FINAL_INSTALL_DIR}/kdf" +) + # List of absolute paths to libraries that should be bundled with the plugin set(mm2_bundled_libraries "${CMAKE_CURRENT_SOURCE_DIR}/libmm2.so" diff --git a/packages/komodo_defi_framework/linux/mm2_plugin.cc b/packages/komodo_defi_framework/linux/mm2_plugin.cc new file mode 100644 index 0000000..3fc4b77 --- /dev/null +++ b/packages/komodo_defi_framework/linux/mm2_plugin.cc @@ -0,0 +1,40 @@ +#include + +#include "mm2_plugin.h" + +struct _Mm2Plugin { + GObject parent_instance; +}; + +G_DEFINE_TYPE(Mm2Plugin, mm2_plugin, g_object_get_type()) + +static void mm2_plugin_dispose(GObject* object) { + G_OBJECT_CLASS(mm2_plugin_parent_class)->dispose(object); +} + +static void mm2_plugin_class_init(Mm2PluginClass* klass) { + G_OBJECT_CLASS(klass)->dispose = mm2_plugin_dispose; +} + +static void mm2_plugin_init(Mm2Plugin* self) {} + +static void method_call_cb(FlMethodChannel* channel, FlMethodCall* method_call, + gpointer user_data) { + // Handle method calls here +} + +void mm2_plugin_register_with_registrar(FlPluginRegistrar* registrar) { + Mm2Plugin* plugin = MM2_PLUGIN( + g_object_new(mm2_plugin_get_type(), nullptr)); + + g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new(); + g_autoptr(FlMethodChannel) channel = + fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar), + "mm2", + FL_METHOD_CODEC(codec)); + fl_method_channel_set_method_call_handler(channel, method_call_cb, + g_object_ref(plugin), + g_object_unref); + + g_object_unref(plugin); +} \ No newline at end of file diff --git a/packages/komodo_defi_framework/linux/mm2_plugin.h b/packages/komodo_defi_framework/linux/mm2_plugin.h new file mode 100644 index 0000000..c1b709f --- /dev/null +++ b/packages/komodo_defi_framework/linux/mm2_plugin.h @@ -0,0 +1,16 @@ +#ifndef FLUTTER_PLUGIN_MM2_PLUGIN_H_ +#define FLUTTER_PLUGIN_MM2_PLUGIN_H_ + +#include + +G_BEGIN_DECLS + +#define MM2_TYPE_PLUGIN (mm2_plugin_get_type()) + +G_DECLARE_FINAL_TYPE(Mm2Plugin, mm2_plugin, MM2, PLUGIN, GObject) + +void mm2_plugin_register_with_registrar(FlPluginRegistrar* registrar); + +G_END_DECLS + +#endif // FLUTTER_PLUGIN_MM2_PLUGIN_H_ \ No newline at end of file diff --git a/packages/komodo_wallet_build_transformer/lib/src/steps/fetch_defi_api_build_step.dart b/packages/komodo_wallet_build_transformer/lib/src/steps/fetch_defi_api_build_step.dart index 2f39f4d..a88acd2 100644 --- a/packages/komodo_wallet_build_transformer/lib/src/steps/fetch_defi_api_build_step.dart +++ b/packages/komodo_wallet_build_transformer/lib/src/steps/fetch_defi_api_build_step.dart @@ -492,11 +492,23 @@ class FetchDefiApiStep extends BuildStep { // file build size or if it is required for cache-busting. } if (_isBinaryExecutable(platform)) { + _renameExecutable(destinationFolder); _setExecutablePermissions(destinationFolder); } return Future.value(); } + /// if executable is named "mm2" or "mm2.exe", then rename to "kdf" + void _renameExecutable(String destinationFolder) { + final executableName = Platform.isWindows ? 'mm2.exe' : 'mm2'; + final executablePath = path.join(destinationFolder, executableName); + if (FileSystemEntity.isFileSync(executablePath)) { + final newExecutablePath = path.join(destinationFolder, 'kdf'); + File(executablePath).renameSync(newExecutablePath); + _log.info('Renamed executable from $executableName to kdf'); + } + } + Future _extractZipFile( String zipFilePath, String destinationFolder,