Skip to content
Merged
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.15...3.24)
project(hiero-sdk-cpp VERSION 0.1.0 DESCRIPTION "Hiero SDK C++" LANGUAGES CXX)
project(hiero-sdk-cpp VERSION 0.41.0 DESCRIPTION "Hiero SDK C++" LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down
4 changes: 4 additions & 0 deletions src/sdk/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ set(TRANSFER_TOKENS_EXAMPLE_NAME ${PROJECT_NAME}-transfer-tokens-example)
set(TRANSFER_USING_EVM_ADDRESS_EXAMPLE_NAME ${PROJECT_NAME}-transfer-using-evm-address-example)
set(UPDATE_ACCOUNT_PUBLIC_KEY_EXAMPLE_NAME ${PROJECT_NAME}-update-account-public-key-example)
set(VALIDATE_CHECKSUM_EXAMPLE_NAME ${PROJECT_NAME}-validate-checksum-example)
set(VERSION_EXAMPLE_NAME ${PROJECT_NAME}-version-example)
set(ZERO_TOKEN_OPERATIONS_EXAMPLE_NAME ${PROJECT_NAME}-zero-token-operations-example)

add_executable(${ACCOUNT_ALIAS_EXAMPLE_NAME} AccountAliasExample.cc)
Expand Down Expand Up @@ -125,6 +126,7 @@ add_executable(${TRANSFER_TOKENS_EXAMPLE_NAME} TransferTokensExample.cc)
add_executable(${TRANSFER_USING_EVM_ADDRESS_EXAMPLE_NAME} TransferUsingEvmAddressExample.cc)
add_executable(${UPDATE_ACCOUNT_PUBLIC_KEY_EXAMPLE_NAME} UpdateAccountPublicKeyExample.cc)
add_executable(${VALIDATE_CHECKSUM_EXAMPLE_NAME} ValidateChecksumExample.cc)
add_executable(${VERSION_EXAMPLE_NAME} VersionExample.cc)
add_executable(${ZERO_TOKEN_OPERATIONS_EXAMPLE_NAME} ZeroTokenOperationsExample.cc)

file(COPY ${PROJECT_SOURCE_DIR}/addressbook/mainnet.pb
Expand Down Expand Up @@ -207,6 +209,7 @@ target_link_libraries(${TRANSFER_TOKENS_EXAMPLE_NAME} PUBLIC ${PROJECT_NAME})
target_link_libraries(${TRANSFER_USING_EVM_ADDRESS_EXAMPLE_NAME} PUBLIC ${PROJECT_NAME})
target_link_libraries(${UPDATE_ACCOUNT_PUBLIC_KEY_EXAMPLE_NAME} PUBLIC ${PROJECT_NAME})
target_link_libraries(${VALIDATE_CHECKSUM_EXAMPLE_NAME} PUBLIC ${PROJECT_NAME})
target_link_libraries(${VERSION_EXAMPLE_NAME} PUBLIC ${PROJECT_NAME})
target_link_libraries(${ZERO_TOKEN_OPERATIONS_EXAMPLE_NAME} PUBLIC ${PROJECT_NAME})

install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_BUILD_TYPE} DESTINATION examples FILES_MATCHING PATTERN *)
Expand Down Expand Up @@ -267,5 +270,6 @@ install(TARGETS
${TRANSFER_USING_EVM_ADDRESS_EXAMPLE_NAME}
${UPDATE_ACCOUNT_PUBLIC_KEY_EXAMPLE_NAME}
${VALIDATE_CHECKSUM_EXAMPLE_NAME}
${VERSION_EXAMPLE_NAME}
${ZERO_TOKEN_OPERATIONS_EXAMPLE_NAME}
RUNTIME DESTINATION examples)
14 changes: 14 additions & 0 deletions src/sdk/examples/VersionExample.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "version.h"
#include <iostream>

int main()
{
std::cout << "Project Description: ";
std::cout << PROJECT_DESCRIPTION << std::endl;
std::cout << "Project Software Version: ";
std::cout << PROJECT_VERSION_MAJOR << "." << PROJECT_VERSION_MINOR << "." << PROJECT_VERSION_PATCH << std::endl;
std::cout << "Project Version String: ";
std::cout << PROJECT_VERSION_STRING << std::endl;

return 0;
}
6 changes: 6 additions & 0 deletions src/sdk/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ if (WIN32)
set(APR_UTIL_LIBRARIES ${CMAKE_BINARY_DIR}/vcpkg_installed/x64-windows/lib/libaprutil-1.lib)
endif ()

# Configure a header file with the version info
configure_file(
include/impl/version.h.in
${HAPI_LIB_DIR}/version.h
)

FetchContent_MakeAvailable(log4cxx)

add_library(${PROJECT_NAME} STATIC
Expand Down
8 changes: 8 additions & 0 deletions src/sdk/main/include/impl/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,14 @@ class Node : public BaseNode<Node, AccountId>
*/
explicit Node(const Node& node, const BaseNodeAddress& address);

/**
* Set the ClientContext to use to submit a request.
*
* @param context The context to set.
* @param deadline The deadline of the submission attempt.
*/
static void setClientContext(grpc::ClientContext& context, const std::chrono::system_clock::time_point& deadline);

/**
* Derived from BaseNode. Get the TLS credentials of this Node's gRPC channel.
*
Expand Down
10 changes: 10 additions & 0 deletions src/sdk/main/include/impl/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef VERSION_H
#define VERSION_H

#define PROJECT_VERSION_MAJOR @PROJECT_VERSION_MAJOR@
#define PROJECT_VERSION_MINOR @PROJECT_VERSION_MINOR@
#define PROJECT_VERSION_PATCH @PROJECT_VERSION_PATCH@
#define PROJECT_VERSION_STRING "@PROJECT_VERSION@"
#define PROJECT_DESCRIPTION "@PROJECT_DESCRIPTION@"

#endif // VERSION_H
21 changes: 15 additions & 6 deletions src/sdk/main/src/impl/Node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "impl/Node.h"
#include "impl/BaseNodeAddress.h"
#include "impl/HieroCertificateVerifier.h"
#include "version.h"

#include <algorithm>
#include <utility>
Expand All @@ -27,10 +28,10 @@ grpc::Status Node::submitQuery(proto::Query::QueryCase funcEnum,
const std::chrono::system_clock::time_point& deadline,
proto::Response* response)
{
std::unique_lock lock(*getLock());

grpc::ClientContext context;
context.set_deadline(deadline);
setClientContext(context, deadline);

std::unique_lock lock(*getLock());

switch (funcEnum)
{
Expand Down Expand Up @@ -78,10 +79,10 @@ grpc::Status Node::submitTransaction(proto::TransactionBody::DataCase funcEnum,
const std::chrono::system_clock::time_point& deadline,
proto::TransactionResponse* response)
{
std::unique_lock lock(*getLock());

grpc::ClientContext context;
context.set_deadline(deadline);
setClientContext(context, deadline);

std::unique_lock lock(*getLock());

switch (funcEnum)
{
Expand Down Expand Up @@ -238,6 +239,14 @@ Node::Node(const Node& node, const BaseNodeAddress& address)
{
}

//-----
void Node::setClientContext(grpc::ClientContext& context, const std::chrono::system_clock::time_point& deadline)
{
context.set_deadline(deadline);
context.AddMetadata("user-agent-id", "hiero-sdk-cpp");
context.AddMetadata("version", PROJECT_VERSION_STRING);
}

//-----
std::shared_ptr<grpc::ChannelCredentials> Node::getTlsChannelCredentials() const
{
Expand Down
Loading