From 016d2c670461c2d0901781b162141b4efdcda722 Mon Sep 17 00:00:00 2001 From: Rob Walworth Date: Mon, 9 Dec 2024 17:22:01 -0500 Subject: [PATCH] fix: update types to strings Signed-off-by: Rob Walworth --- .../account/params/CreateAccountParams.h | 12 +++++----- .../account/params/UpdateAccountParams.h | 12 +++++----- src/tck/src/account/AccountService.cc | 22 +++++++++++++------ 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/tck/include/account/params/CreateAccountParams.h b/src/tck/include/account/params/CreateAccountParams.h index 77904cb9..2d557cdd 100644 --- a/src/tck/include/account/params/CreateAccountParams.h +++ b/src/tck/include/account/params/CreateAccountParams.h @@ -25,7 +25,7 @@ struct CreateAccountParams /** * The desired initial balance for the account. */ - std::optional mInitialBalance; + std::optional mInitialBalance; /** * Should the new account require a receiver signature? @@ -35,7 +35,7 @@ struct CreateAccountParams /** * The desired amount of time in seconds to renew the new account. */ - std::optional mAutoRenewPeriod; + std::optional mAutoRenewPeriod; /** * The desired memo for the new account. @@ -55,7 +55,7 @@ struct CreateAccountParams /** * The ID of the desired node to which the new account should stake. */ - std::optional mStakedNodeId; + std::optional mStakedNodeId; /** * Should the new account decline staking rewards? @@ -92,15 +92,15 @@ struct [[maybe_unused]] adl_serializer(jsonFrom, "key"); - params.mInitialBalance = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "initialBalance"); + params.mInitialBalance = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "initialBalance"); params.mReceiverSignatureRequired = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "receiverSignatureRequired"); - params.mAutoRenewPeriod = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "autoRenewPeriod"); + params.mAutoRenewPeriod = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "autoRenewPeriod"); params.mMemo = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "memo"); params.mMaxAutoTokenAssociations = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "maxAutoTokenAssociations"); params.mStakedAccountId = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "stakedAccountId"); - params.mStakedNodeId = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "stakedNodeId"); + params.mStakedNodeId = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "stakedNodeId"); params.mDeclineStakingReward = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "declineStakingReward"); params.mAlias = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "alias"); params.mCommonTxParams = diff --git a/src/tck/include/account/params/UpdateAccountParams.h b/src/tck/include/account/params/UpdateAccountParams.h index 5ba36e0c..687cf1a7 100644 --- a/src/tck/include/account/params/UpdateAccountParams.h +++ b/src/tck/include/account/params/UpdateAccountParams.h @@ -30,12 +30,12 @@ struct UpdateAccountParams /** * The desired new amount of time in seconds to renew the account. */ - std::optional mAutoRenewPeriod; + std::optional mAutoRenewPeriod; /** * The new expiration time to which to extend this account. */ - std::optional mExpirationTime; + std::optional mExpirationTime; /** * Should the account now require a receiver signature? @@ -60,7 +60,7 @@ struct UpdateAccountParams /** * The ID of the new desired node to which the account should stake. */ - std::optional mStakedNodeId; + std::optional mStakedNodeId; /** * Should the account now decline staking rewards? @@ -93,15 +93,15 @@ struct [[maybe_unused]] adl_serializer(jsonFrom, "accountId"); params.mKey = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "key"); - params.mAutoRenewPeriod = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "autoRenewPeriod"); - params.mExpirationTime = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "expirationTime"); + params.mAutoRenewPeriod = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "autoRenewPeriod"); + params.mExpirationTime = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "expirationTime"); params.mReceiverSignatureRequired = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "receiverSignatureRequired"); params.mMemo = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "memo"); params.mMaxAutoTokenAssociations = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "maxAutoTokenAssociations"); params.mStakedAccountId = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "stakedAccountId"); - params.mStakedNodeId = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "stakedNodeId"); + params.mStakedNodeId = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "stakedNodeId"); params.mDeclineStakingReward = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "declineStakingReward"); params.mCommonTxParams = Hiero::TCK::getOptionalJsonParameter(jsonFrom, "commonTransactionParams"); diff --git a/src/tck/src/account/AccountService.cc b/src/tck/src/account/AccountService.cc index 3a5533bf..bc6bd667 100644 --- a/src/tck/src/account/AccountService.cc +++ b/src/tck/src/account/AccountService.cc @@ -16,8 +16,10 @@ #include #include #include +#include #include +#include #include #include @@ -36,7 +38,8 @@ nlohmann::json createAccount(const CreateAccountParams& params) if (params.mInitialBalance.has_value()) { - accountCreateTransaction.setInitialBalance(Hbar(params.mInitialBalance.value(), HbarUnit::TINYBAR())); + accountCreateTransaction.setInitialBalance( + Hbar(Hiero::internal::EntityIdHelper::getNum(params.mInitialBalance.value()), HbarUnit::TINYBAR())); } if (params.mReceiverSignatureRequired.has_value()) @@ -46,7 +49,8 @@ nlohmann::json createAccount(const CreateAccountParams& params) if (params.mAutoRenewPeriod.has_value()) { - accountCreateTransaction.setAutoRenewPeriod(std::chrono::seconds(params.mAutoRenewPeriod.value())); + accountCreateTransaction.setAutoRenewPeriod( + std::chrono::seconds(Hiero::internal::EntityIdHelper::getNum(params.mAutoRenewPeriod.value()))); } if (params.mMemo.has_value()) @@ -66,7 +70,8 @@ nlohmann::json createAccount(const CreateAccountParams& params) if (params.mStakedNodeId.has_value()) { - accountCreateTransaction.setStakedNodeId(params.mStakedNodeId.value()); + accountCreateTransaction.setStakedNodeId( + Hiero::internal::EntityIdHelper::getNum(params.mStakedNodeId.value())); } if (params.mDeclineStakingReward.has_value()) @@ -138,13 +143,15 @@ nlohmann::json updateAccount(const UpdateAccountParams& params) if (params.mAutoRenewPeriod.has_value()) { - accountUpdateTransaction.setAutoRenewPeriod(std::chrono::seconds(params.mAutoRenewPeriod.value())); + accountUpdateTransaction.setAutoRenewPeriod( + std::chrono::seconds(Hiero::internal::EntityIdHelper::getNum(params.mAutoRenewPeriod.value()))); } if (params.mExpirationTime.has_value()) { - accountUpdateTransaction.setExpirationTime(std::chrono::system_clock::from_time_t(0) + - std::chrono::seconds(params.mExpirationTime.value())); + accountUpdateTransaction.setExpirationTime( + std::chrono::system_clock::from_time_t(0) + + std::chrono::seconds(Hiero::internal::EntityIdHelper::getNum(params.mExpirationTime.value()))); } if (params.mReceiverSignatureRequired.has_value()) @@ -169,7 +176,8 @@ nlohmann::json updateAccount(const UpdateAccountParams& params) if (params.mStakedNodeId.has_value()) { - accountUpdateTransaction.setStakedNodeId(params.mStakedNodeId.value()); + accountUpdateTransaction.setStakedNodeId( + Hiero::internal::EntityIdHelper::getNum(params.mStakedNodeId.value())); } if (params.mDeclineStakingReward.has_value())