diff --git a/cmake/CommonBuildParameters.cmake b/cmake/CommonBuildParameters.cmake index 8570798..f689275 100644 --- a/cmake/CommonBuildParameters.cmake +++ b/cmake/CommonBuildParameters.cmake @@ -21,7 +21,15 @@ if(APPLE) set(Vulkan_LIBRARY "${THIRDPARTY_BUILD_DIR}/moltenvk/build/lib/MoltenVK.xcframework") endif() endif() -find_package(Vulkan REQUIRED) +find_package(Vulkan) + +if(NOT TARGET Vulkan::Vulkan) + if(NOT DEFINED $ENV{VULKAN_SDK}) + set(ENV{VULKAN_SDK} "${THIRDPARTY_BUILD_DIR}/Vulkan-Loader") + endif() + + find_package(Vulkan REQUIRED) +endif() if(SHARED_LIB_BUILD) set(LIB_TYPE SHARED) else() diff --git a/src/GeniusSDK.cpp b/src/GeniusSDK.cpp index 3295226..911b384 100644 --- a/src/GeniusSDK.cpp +++ b/src/GeniusSDK.cpp @@ -9,6 +9,7 @@ #include "account/GeniusNode.hpp" #include +#include #include #include #include @@ -100,6 +101,22 @@ namespace return matrix; } + GeniusMatrix matrix_from_buffer( const std::vector &vec ) + { + uint64_t size = vec.size(); + + GeniusMatrix matrix = { size, reinterpret_cast( malloc( size * sizeof( GeniusArray ) ) ) }; + + for ( uint64_t i = 0; i < size; i++ ) + { + matrix.ptr[i] = GeniusArray{ vec[i].size(), + reinterpret_cast( malloc( vec[i].size() * sizeof( uint8_t ) ) ) }; + memcpy( matrix.ptr[i].ptr, vec[i].data(), vec[i].size() * sizeof( uint8_t ) ); + } + + return matrix; + } + std::shared_ptr GeniusNodeInstance; } @@ -128,9 +145,9 @@ const char *GeniusSDKInit( const char *base_path, const char *eth_private_key ) return ret_val.c_str(); } -void GeniusSDKProcess( const ImagePath_t path, const PayAmount_t amount ) +void GeniusSDKProcess( const JsonData_t jsondata ) { - GeniusNodeInstance->ProcessImage( std::string{ path }, amount ); + GeniusNodeInstance->ProcessImage( std::string{ jsondata } ); } uint64_t GeniusSDKGetBalance() @@ -152,9 +169,15 @@ void GeniusSDKFreeTransactions( GeniusMatrix matrix ) free( matrix.ptr ); } -void GeniusSDKMintTokens( uint64_t amount ) +GeniusMatrix GeniusSDKGetBlocks() +{ + auto blocks = GeniusNodeInstance->GetBlocks(); + return matrix_from_buffer( blocks ); +} + +void GeniusSDKMintTokens( uint64_t amount, const char *transaction_hash, const char *chain_id ) { - GeniusNodeInstance->MintTokens( amount ); + GeniusNodeInstance->MintTokens( amount, transaction_hash, chain_id ); } GeniusAddress GeniusSDKGetAddress() @@ -174,3 +197,8 @@ bool GeniusSDKTransferTokens( uint64_t amount, GeniusAddress *dest ) return GeniusNodeInstance->TransferFunds( amount, destination ); } + +uint64_t GeniusSDKGetCost( const JsonData_t jsondata ) +{ + return GeniusNodeInstance->GetProcessCost( jsondata ); +} diff --git a/src/GeniusSDK.h b/src/GeniusSDK.h index c41f25e..5a3b08c 100644 --- a/src/GeniusSDK.h +++ b/src/GeniusSDK.h @@ -49,17 +49,19 @@ typedef struct char address[2 + 256 / 4 + 1]; } GeniusAddress; -typedef char ImagePath_t[1024]; ///< ID/Path of the image to be processed +typedef char JsonData_t[1024]; ///< ID/Path of the image to be processed typedef uint64_t PayAmount_t; ///< Amount to be paid for the processing GNUS_VISIBILITY_DEFAULT const char *GeniusSDKInit( const char *base_path, const char *eth_private_key ); -GNUS_VISIBILITY_DEFAULT void GeniusSDKProcess( const ImagePath_t path, PayAmount_t amount ); +GNUS_VISIBILITY_DEFAULT void GeniusSDKProcess( const JsonData_t jsondata ); GNUS_VISIBILITY_DEFAULT uint64_t GeniusSDKGetBalance(); GNUS_VISIBILITY_DEFAULT GeniusMatrix GeniusSDKGetTransactions(); GNUS_VISIBILITY_DEFAULT void GeniusSDKFreeTransactions( GeniusMatrix matrix ); -GNUS_VISIBILITY_DEFAULT void GeniusSDKMintTokens( uint64_t amount ); +GNUS_VISIBILITY_DEFAULT GeniusMatrix GeniusSDKGetBlocks(); +GNUS_VISIBILITY_DEFAULT void GeniusSDKMintTokens( uint64_t amount, const char *transaction_hash, const char *chain_id ); GNUS_VISIBILITY_DEFAULT GeniusAddress GeniusSDKGetAddress(); GNUS_VISIBILITY_DEFAULT bool GeniusSDKTransferTokens( uint64_t amount, GeniusAddress *dest ); +GNUS_VISIBILITY_DEFAULT uint64_t GeniusSDKGetCost( const JsonData_t jsondata ); GNUS_EXPORT_END