-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tokenFreezeTransaction): Implement JSON-RPC method endpoint for …
…`TokenFreezeTransaction` (#848) Signed-off-by: Rob Walworth <[email protected]> Co-authored-by: gsstoykov <[email protected]>
- Loading branch information
Showing
5 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
#ifndef HIERO_TCK_CPP_FREEZE_TOKEN_PARAMS_H_ | ||
#define HIERO_TCK_CPP_FREEZE_TOKEN_PARAMS_H_ | ||
|
||
#include "common/CommonTransactionParams.h" | ||
#include "json/JsonUtils.h" | ||
|
||
#include <nlohmann/json.hpp> | ||
#include <optional> | ||
#include <string> | ||
|
||
namespace Hiero::TCK::TokenService | ||
{ | ||
/** | ||
* Struct to hold the arguments for a `freezeToken` JSON-RPC method call. | ||
*/ | ||
struct FreezeTokenParams | ||
{ | ||
/** | ||
* The ID of the token to freeze. | ||
*/ | ||
std::optional<std::string> mTokenId; | ||
|
||
/** | ||
* The ID of the account to freeze. | ||
*/ | ||
std::optional<std::string> mAccountId; | ||
|
||
/** | ||
* Any parameters common to all transaction types. | ||
*/ | ||
std::optional<CommonTransactionParams> mCommonTxParams; | ||
}; | ||
|
||
} // namespace Hedera::TCK::TokenService | ||
|
||
namespace nlohmann | ||
{ | ||
/** | ||
* JSON serializer template specialization required to convert FreezeTokenParams arguments properly. | ||
*/ | ||
template<> | ||
struct [[maybe_unused]] adl_serializer<Hiero::TCK::TokenService::FreezeTokenParams> | ||
{ | ||
/** | ||
* Convert a JSON object to a FreezeTokenParams. | ||
* | ||
* @param jsonFrom The JSON object with which to fill the FreezeTokenParams. | ||
* @param params The FreezeTokenParams to fill with the JSON object. | ||
*/ | ||
static void from_json(const json& jsonFrom, Hiero::TCK::TokenService::FreezeTokenParams& params) | ||
{ | ||
params.mTokenId = Hiero::TCK::getOptionalJsonParameter<std::string>(jsonFrom, "tokenId"); | ||
params.mAccountId = Hiero::TCK::getOptionalJsonParameter<std::string>(jsonFrom, "accountId"); | ||
params.mCommonTxParams = | ||
Hiero::TCK::getOptionalJsonParameter<Hiero::TCK::CommonTransactionParams>(jsonFrom, "commonTransactionParams"); | ||
} | ||
}; | ||
|
||
} // namespace nlohmann | ||
|
||
#endif // HIERO_TCK_CPP_FREEZE_TOKEN_PARAMS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters