From 084c0d28288a44b8268abe86a22a8b690862385f Mon Sep 17 00:00:00 2001 From: Eduardo Menges Mattje Date: Mon, 18 Nov 2024 10:11:24 -0300 Subject: [PATCH 1/4] Added `GetBlocks` --- src/GeniusSDK.cpp | 23 +++++++++++++++++++++++ src/GeniusSDK.h | 1 + 2 files changed, 24 insertions(+) diff --git a/src/GeniusSDK.cpp b/src/GeniusSDK.cpp index 3295226..885a1f1 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; } @@ -152,6 +169,12 @@ void GeniusSDKFreeTransactions( GeniusMatrix matrix ) free( matrix.ptr ); } +GeniusMatrix GeniusSDKGetBlocks() +{ + auto blocks = GeniusNodeInstance->GetBlocks(); + return matrix_from_buffer( blocks ); +} + void GeniusSDKMintTokens( uint64_t amount ) { GeniusNodeInstance->MintTokens( amount ); diff --git a/src/GeniusSDK.h b/src/GeniusSDK.h index c41f25e..36ff8c5 100644 --- a/src/GeniusSDK.h +++ b/src/GeniusSDK.h @@ -57,6 +57,7 @@ GNUS_VISIBILITY_DEFAULT void GeniusSDKProcess( const ImagePath_t path, Pa GNUS_VISIBILITY_DEFAULT uint64_t GeniusSDKGetBalance(); GNUS_VISIBILITY_DEFAULT GeniusMatrix GeniusSDKGetTransactions(); GNUS_VISIBILITY_DEFAULT void GeniusSDKFreeTransactions( GeniusMatrix matrix ); +GNUS_VISIBILITY_DEFAULT GeniusMatrix GeniusSDKGetBlocks(); GNUS_VISIBILITY_DEFAULT void GeniusSDKMintTokens( uint64_t amount ); GNUS_VISIBILITY_DEFAULT GeniusAddress GeniusSDKGetAddress(); GNUS_VISIBILITY_DEFAULT bool GeniusSDKTransferTokens( uint64_t amount, GeniusAddress *dest ); From b8f02ccbe0884f09481990206afcbcca35a68857 Mon Sep 17 00:00:00 2001 From: itsafuu Date: Mon, 25 Nov 2024 18:15:03 -0500 Subject: [PATCH 2/4] Added get cost --- src/GeniusSDK.cpp | 9 +++++++-- src/GeniusSDK.h | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/GeniusSDK.cpp b/src/GeniusSDK.cpp index 885a1f1..9657e8c 100644 --- a/src/GeniusSDK.cpp +++ b/src/GeniusSDK.cpp @@ -145,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() @@ -197,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 36ff8c5..ff3f55c 100644 --- a/src/GeniusSDK.h +++ b/src/GeniusSDK.h @@ -49,11 +49,11 @@ 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 ); @@ -61,6 +61,7 @@ GNUS_VISIBILITY_DEFAULT GeniusMatrix GeniusSDKGetBlocks(); GNUS_VISIBILITY_DEFAULT void GeniusSDKMintTokens( uint64_t amount ); 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 From f2837479afb1ac6b248b276b55c44a7eb8a21236 Mon Sep 17 00:00:00 2001 From: itsafuu Date: Mon, 2 Dec 2024 16:08:25 -0500 Subject: [PATCH 3/4] Added transaction hash and chain id values, changed vulkan linking --- cmake/CommonBuildParameters.cmake | 10 +++++++++- src/GeniusSDK.cpp | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) 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 9657e8c..911b384 100644 --- a/src/GeniusSDK.cpp +++ b/src/GeniusSDK.cpp @@ -175,9 +175,9 @@ GeniusMatrix GeniusSDKGetBlocks() return matrix_from_buffer( blocks ); } -void GeniusSDKMintTokens( uint64_t amount ) +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() From 221ae2b08cc82d821faf7f9e2d46934ef757fa47 Mon Sep 17 00:00:00 2001 From: itsafuu Date: Mon, 2 Dec 2024 16:43:40 -0500 Subject: [PATCH 4/4] Define mint in header --- src/GeniusSDK.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GeniusSDK.h b/src/GeniusSDK.h index ff3f55c..5a3b08c 100644 --- a/src/GeniusSDK.h +++ b/src/GeniusSDK.h @@ -58,7 +58,7 @@ GNUS_VISIBILITY_DEFAULT uint64_t GeniusSDKGetBalance(); GNUS_VISIBILITY_DEFAULT GeniusMatrix GeniusSDKGetTransactions(); GNUS_VISIBILITY_DEFAULT void GeniusSDKFreeTransactions( GeniusMatrix matrix ); GNUS_VISIBILITY_DEFAULT GeniusMatrix GeniusSDKGetBlocks(); -GNUS_VISIBILITY_DEFAULT void GeniusSDKMintTokens( uint64_t amount ); +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 );