-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathTokenTransferParams.h
More file actions
65 lines (55 loc) · 1.74 KB
/
TokenTransferParams.h
File metadata and controls
65 lines (55 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// SPDX-License-Identifier: Apache-2.0
#ifndef HIERO_TCK_CPP_TOKEN_TRANSFER_PARAMS_H_
#define HIERO_TCK_CPP_TOKEN_TRANSFER_PARAMS_H_
#include "json/JsonUtils.h"
#include <optional>
#include <string>
namespace Hiero::TCK::AccountService
{
/**
* Struct that contains the parameters of a token transfer.
*/
struct TokenTransferParams
{
/**
* The ID of the account associated with the transfer.
*/
std::string mAccountId;
/**
* The ID of the token associated with the transfer.
*/
std::string mTokenId;
/**
* The amount of token to be transferred.
*/
std::string mAmount;
/**
* The decimals of the token to be transferred.
*/
std::optional<uint32_t> mDecimals;
};
} // namespace Hiero::TCK::AccountService
namespace nlohmann
{
/**
* JSON serializer template specialization required to convert TokenTransferParams arguments properly.
*/
template<>
struct [[maybe_unused]] adl_serializer<Hiero::TCK::AccountService::TokenTransferParams>
{
/**
* Convert a JSON object to a TokenTransferParams.
*
* @param jsonFrom The JSON object with which to fill the TokenTransferParams.
* @param params The TokenTransferParams to fill with the JSON object.
*/
static void from_json(const json& jsonFrom, Hiero::TCK::AccountService::TokenTransferParams& params)
{
params.mAccountId = Hiero::TCK::getRequiredJsonParameter<std::string>(jsonFrom, "accountId");
params.mTokenId = Hiero::TCK::getRequiredJsonParameter<std::string>(jsonFrom, "tokenId");
params.mAmount = Hiero::TCK::getRequiredJsonParameter<std::string>(jsonFrom, "amount");
params.mDecimals = Hiero::TCK::getOptionalJsonParameter<uint32_t>(jsonFrom, "decimals");
}
};
} // namespace nlohmann
#endif // HIERO_TCK_CPP_TOKEN_TRANSFER_PARAMS_H_