diff --git a/.github/workflows/zxc-build-library.yaml b/.github/workflows/zxc-build-library.yaml index c31ee52fa..967ca0dd7 100644 --- a/.github/workflows/zxc-build-library.yaml +++ b/.github/workflows/zxc-build-library.yaml @@ -174,7 +174,7 @@ jobs: solo node keys -i node1 --gossip-keys --tls-keys solo cluster setup solo network deploy -i node1 -n solo-e2e - solo node setup -i node1 -n solo-e2e -t v0.59.0 + solo node setup -i node1 -n solo-e2e -t v0.60.0-alpha.0 solo node start -i node1 -n solo-e2e kubectl port-forward svc/haproxy-node1-svc -n "${SOLO_NAMESPACE}" 50211:50211 & solo mirror-node deploy -n "${SOLO_NAMESPACE}" --pinger true diff --git a/HieroApi.cmake b/HieroApi.cmake index 2c539cf57..eac748180 100644 --- a/HieroApi.cmake +++ b/HieroApi.cmake @@ -1,7 +1,7 @@ -set(HAPI_VERSION_TAG "v0.59.0" CACHE STRING "Use the configured version tag for the Hiero API protobufs") +set(HAPI_VERSION_TAG "v0.60.0-alpha.0" CACHE STRING "Use the configured version tag for the Hiero API protobufs") if (HAPI_VERSION_TAG STREQUAL "") - set(HAPI_VERSION_TAG "v0.59.0") + set(HAPI_VERSION_TAG "v0.60.0-alpha.0") endif () # Fetch the protobuf definitions diff --git a/proto/CMakeLists.txt b/proto/CMakeLists.txt index 499aa8663..5c8338b91 100644 --- a/proto/CMakeLists.txt +++ b/proto/CMakeLists.txt @@ -110,6 +110,10 @@ set(PROTO_FILES util_prng.proto util_service.proto + auxiliary/hints/crs_publication.proto + auxiliary/hints/hints_key_publication.proto + auxiliary/hints/hints_partial_signature.proto + auxiliary/hints/hints_preprocessing_vote.proto auxiliary/history/history_proof_signature.proto auxiliary/history/history_proof_key_publication.proto auxiliary/history/history_proof_vote.proto @@ -118,6 +122,7 @@ set(PROTO_FILES event/state_signature_transaction.proto + state/hints/hints_types.proto state/history/history_types.proto mirror/consensus_service.proto diff --git a/src/sdk/main/include/TokenCreateTransaction.h b/src/sdk/main/include/TokenCreateTransaction.h index d20ff4c2a..54d144b61 100644 --- a/src/sdk/main/include/TokenCreateTransaction.h +++ b/src/sdk/main/include/TokenCreateTransaction.h @@ -154,6 +154,12 @@ class TokenCreateTransaction : public Transaction /** * Set the desired expiration time for the new token. * + * If autoRenewPeriod is set - this value will be ignored and the expiration + * time will be calculated based on: autoRenewPeriod + currentTime + * + * Setting this value will clear the autoRenewPeriod as the autoRenewPeriod period has + * a default value of 7890000 seconds and leaving it set will override the expiration time. + * * @param expiration The desired expiration time for the new token. * @return A reference to this TokenCreateTransaction with the newly-set default expiration time. */ @@ -170,6 +176,9 @@ class TokenCreateTransaction : public Transaction /** * Set the desired auto-renew period for the new token. * + * If expirationTime is set - autoRenewPeriod will be effectively ignored and + * it's effect will be replaced by expirationTime + * * @param period The desired auto-renew period for the new token. * @return A reference to this TokenCreateTransaction with the newly-set auto-renew period. */ diff --git a/src/sdk/main/src/TokenCreateTransaction.cc b/src/sdk/main/src/TokenCreateTransaction.cc index a7a112581..d4ffcbbf2 100644 --- a/src/sdk/main/src/TokenCreateTransaction.cc +++ b/src/sdk/main/src/TokenCreateTransaction.cc @@ -252,6 +252,12 @@ void TokenCreateTransaction::validateChecksums(const Client& client) const void TokenCreateTransaction::addToBody(proto::TransactionBody& body) const { body.set_allocated_tokencreation(build()); + + if (body.has_transactionid() && !body.tokencreation().has_autorenewaccount()) + { + std::unique_ptr accountId = std::make_unique(body.transactionid().accountid()); + body.mutable_tokencreation()->set_allocated_autorenewaccount(accountId.release()); + } } //----- diff --git a/src/sdk/main/src/TopicCreateTransaction.cc b/src/sdk/main/src/TopicCreateTransaction.cc index dbee0f42b..11ab4bc50 100644 --- a/src/sdk/main/src/TopicCreateTransaction.cc +++ b/src/sdk/main/src/TopicCreateTransaction.cc @@ -126,6 +126,12 @@ void TopicCreateTransaction::validateChecksums(const Client& client) const void TopicCreateTransaction::addToBody(proto::TransactionBody& body) const { body.set_allocated_consensuscreatetopic(build()); + + if (body.has_transactionid() && !body.consensuscreatetopic().has_autorenewaccount()) + { + std::unique_ptr accountId = std::make_unique(body.transactionid().accountid()); + body.mutable_consensuscreatetopic()->set_allocated_autorenewaccount(accountId.release()); + } } //----- diff --git a/src/sdk/tests/integration/TokenCreateTransactionIntegrationTests.cc b/src/sdk/tests/integration/TokenCreateTransactionIntegrationTests.cc index 33020faad..2c601dc7a 100644 --- a/src/sdk/tests/integration/TokenCreateTransactionIntegrationTests.cc +++ b/src/sdk/tests/integration/TokenCreateTransactionIntegrationTests.cc @@ -11,6 +11,8 @@ #include "PrivateKey.h" #include "TokenCreateTransaction.h" #include "TokenDeleteTransaction.h" +#include "TokenInfo.h" +#include "TokenInfoQuery.h" #include "TransactionReceipt.h" #include "TransactionResponse.h" #include "exceptions/PrecheckStatusException.h" @@ -448,4 +450,67 @@ TEST_F(TokenCreateTransactionIntegrationTests, CanCreateNftWithRoyaltyFee) // Clean up ASSERT_NO_THROW(txReceipt = TokenDeleteTransaction().setTokenId(tokenId).execute(getTestClient()).getReceipt(getTestClient())); -} \ No newline at end of file +} + +//----- +TEST_F(TokenCreateTransactionIntegrationTests, AutoSetAutoRenewAccount) +{ + // Given / When + TokenId tokenId; + EXPECT_NO_THROW(tokenId = TokenCreateTransaction() + .setTokenName("ffff") + .setTokenSymbol("F") + .setTreasuryAccountId(AccountId(2ULL)) + .execute(getTestClient()) + .getReceipt(getTestClient()) + .mTokenId.value()); + + // Then + TokenInfo tokenInfo; + EXPECT_NO_THROW(tokenInfo = TokenInfoQuery().setTokenId(tokenId).execute(getTestClient())); + + ASSERT_EQ(tokenInfo.mAutoRenewAccountId, AccountId(2ULL)); +} + +//----- +TEST_F(TokenCreateTransactionIntegrationTests, DoesNotAutoSetAutoRenewAccount) +{ + // Given + std::shared_ptr operatorKey; + ASSERT_NO_THROW( + operatorKey = std::shared_ptr( + ED25519PrivateKey::fromString( + "302e020100300506032b65700422042091132178e72057a1d7528025956fe39b0b847f200ab59b2fdd367017f3087137") + .release())); + + std::shared_ptr accountKey; + ASSERT_NO_THROW(accountKey = ED25519PrivateKey::generatePrivateKey()); + + AccountId accountId; + ASSERT_NO_THROW(accountId = AccountCreateTransaction() + .setKeyWithoutAlias(accountKey) + .setInitialBalance(Hbar(5LL)) + .execute(getTestClient()) + .getReceipt(getTestClient()) + .mAccountId.value()); + + // When + TokenId tokenId; + EXPECT_NO_THROW(tokenId = TokenCreateTransaction() + .setTokenName("ffff") + .setTokenSymbol("F") + .setAutoRenewAccountId(accountId) + .setTreasuryAccountId(AccountId(2ULL)) + .freezeWith(&getTestClient()) + .sign(accountKey) + .sign(operatorKey) + .execute(getTestClient()) + .getReceipt(getTestClient()) + .mTokenId.value()); + + // Then + TokenInfo tokenInfo; + EXPECT_NO_THROW(tokenInfo = TokenInfoQuery().setTokenId(tokenId).execute(getTestClient())); + + ASSERT_EQ(tokenInfo.mAutoRenewAccountId, accountId); +} diff --git a/src/sdk/tests/integration/TopicCreateTransactionIntegrationTests.cc b/src/sdk/tests/integration/TopicCreateTransactionIntegrationTests.cc index 3de52fa16..f0163009e 100644 --- a/src/sdk/tests/integration/TopicCreateTransactionIntegrationTests.cc +++ b/src/sdk/tests/integration/TopicCreateTransactionIntegrationTests.cc @@ -1,4 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 +#include "AccountCreateTransaction.h" #include "AccountDeleteTransaction.h" #include "BaseIntegrationTest.h" #include "CustomFixedFee.h" @@ -158,3 +159,78 @@ TEST_F(TopicCreateTransactionIntegrationTests, RevenueGeneratingTopicCannotCreat .getReceipt(getTestClient()), ReceiptStatusException); // MAX_ENTRIES_FOR_FEE_EXEMPT_KEY_LIST_EXCEEDED } + +//----- +TEST_F(TopicCreateTransactionIntegrationTests, AutoSetAutoRenewAccount) +{ + // Given + const std::string memo = "topic create test memo"; + const std::chrono::system_clock::duration autoRenewPeriod = DEFAULT_AUTO_RENEW_PERIOD + std::chrono::hours(10); + + std::shared_ptr operatorKey; + ASSERT_NO_THROW( + operatorKey = ED25519PrivateKey::fromString( + "302e020100300506032b65700422042091132178e72057a1d7528025956fe39b0b847f200ab59b2fdd367017f3087137")); + + // When + TransactionReceipt txReceipt; + EXPECT_NO_THROW(txReceipt = TopicCreateTransaction() + .setMemo(memo) + .setAdminKey(operatorKey) + .setSubmitKey(operatorKey) + .setAutoRenewPeriod(autoRenewPeriod) + .execute(getTestClient()) + .getReceipt(getTestClient())); + + // Then + TopicInfo topicInfo; + ASSERT_NO_THROW(topicInfo = TopicInfoQuery().setTopicId(txReceipt.mTopicId.value()).execute(getTestClient())); + + ASSERT_TRUE(topicInfo.mAutoRenewAccountId.has_value()); + EXPECT_EQ(topicInfo.mAutoRenewAccountId.value(), AccountId(2ULL)); +} + +//----- +TEST_F(TopicCreateTransactionIntegrationTests, DoesNotAutoSetAutoRenewAccount) +{ + // Given + const std::string memo = "topic create test memo"; + const std::chrono::system_clock::duration autoRenewPeriod = DEFAULT_AUTO_RENEW_PERIOD + std::chrono::hours(10); + + std::shared_ptr operatorKey; + ASSERT_NO_THROW( + operatorKey = ED25519PrivateKey::fromString( + "302e020100300506032b65700422042091132178e72057a1d7528025956fe39b0b847f200ab59b2fdd367017f3087137")); + + std::shared_ptr accountKey; + ASSERT_NO_THROW(accountKey = ED25519PrivateKey::generatePrivateKey()); + + AccountId accountId; + ASSERT_NO_THROW(accountId = AccountCreateTransaction() + .setKeyWithoutAlias(accountKey) + .setInitialBalance(Hbar(5LL)) + .execute(getTestClient()) + .getReceipt(getTestClient()) + .mAccountId.value()); + + // When + TransactionReceipt txReceipt; + EXPECT_NO_THROW(txReceipt = TopicCreateTransaction() + .setMemo(memo) + .setAdminKey(operatorKey) + .setSubmitKey(operatorKey) + .setAutoRenewPeriod(autoRenewPeriod) + .setAutoRenewAccountId(accountId) + .freezeWith(&getTestClient()) + .sign(operatorKey) + .sign(accountKey) + .execute(getTestClient()) + .getReceipt(getTestClient())); + + // Then + TopicInfo topicInfo; + ASSERT_NO_THROW(topicInfo = TopicInfoQuery().setTopicId(txReceipt.mTopicId.value()).execute(getTestClient())); + + ASSERT_TRUE(topicInfo.mAutoRenewAccountId.has_value()); + EXPECT_EQ(topicInfo.mAutoRenewAccountId.value(), accountId); +} \ No newline at end of file