Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
AccountMPTokens.hpp
1#pragma once
2
3#include "data/BackendInterface.hpp"
4#include "rpc/common/SpecBackend.hpp"
5#include "rpc/common/Types.hpp"
6
7#include <boost/json/conversion.hpp>
8#include <boost/json/value.hpp>
9#include <rpcspec/handlers/account_mptokens/Types.hpp>
10#include <xrpl/protocol/STLedgerEntry.h>
11
12#include <cstdint>
13#include <memory>
14#include <optional>
15#include <string>
16#include <utility>
17#include <vector>
18
19namespace rpc {
20
26 : public rpc::HandlerFor<rpc::spec::handlers::account_mptokens::Input> {
27 // dependencies
28 std::shared_ptr<BackendInterface> sharedPtrBackend_;
29
30public:
34 static constexpr auto kLimitMin = rpc::spec::handlers::account_mptokens::kLimitMin;
38 static constexpr auto kLimitMax = rpc::spec::handlers::account_mptokens::kLimitMax;
42 static constexpr auto kLimitDefault = rpc::spec::handlers::account_mptokens::kLimitDefault;
43
48 std::string mpTokenId;
49 std::string account;
50 std::string mpTokenIssuanceId;
51 uint64_t mptAmount{};
52 std::optional<uint64_t> lockedAmount;
53
54 std::optional<bool> mptLocked;
55 std::optional<bool> mptAuthorized;
56
57 std::optional<std::string> confidentialBalanceInbox;
61 std::optional<std::string> confidentialBalanceSpending;
62 std::optional<uint32_t> confidentialBalanceVersion;
63 std::optional<std::string> issuerEncryptedBalance;
64 std::optional<std::string> auditorEncryptedBalance;
65 std::optional<std::string> holderEncryptionKey;
66 };
67
71 struct Output {
72 std::string account;
73 std::vector<MPTokenResponse> mpts;
74 std::string ledgerHash;
75 uint32_t ledgerIndex{};
76 bool validated = true;
77 std::optional<std::string> marker;
78 uint32_t limit{};
79 };
80
85
91 AccountMPTokensHandler(std::shared_ptr<BackendInterface> sharedPtrBackend)
92 : sharedPtrBackend_(std::move(sharedPtrBackend))
93 {
94 }
95
103 [[nodiscard]] Result
104 process(Input const& input, Context const& ctx) const;
105
106private:
107 static void
108 addMPToken(std::vector<MPTokenResponse>& mpts, xrpl::SLE const& sle);
109
110private:
117 friend void
118 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output);
119
126 friend void
127 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, MPTokenResponse const& mptoken);
128};
129
130} // namespace rpc
HandlerReturnType< Output > Result
The result type of the command: the Output on success or an error Status.
Definition AccountMPTokens.hpp:84
AccountMPTokensHandler(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new AccountMPTokensHandler object.
Definition AccountMPTokens.hpp:91
Result process(Input const &input, Context const &ctx) const
Process the AccountMPTokens command.
Definition AccountMPTokens.cpp:82
static constexpr auto kLimitMax
Maximum accepted value for the limit request field.
Definition AccountMPTokens.hpp:38
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition AccountMPTokens.cpp:145
static constexpr auto kLimitMin
Minimum accepted value for the limit request field.
Definition AccountMPTokens.hpp:34
static constexpr auto kLimitDefault
Value of limit used when the request does not specify one.
Definition AccountMPTokens.hpp:42
This namespace contains all the RPC logic and handlers.
Definition AMMHelpers.cpp:17
std::expected< OutputType, Status > HandlerReturnType
Return type for each individual handler.
Definition Types.hpp:63
spec::HandlerFor< InputT, boost::json::value > HandlerFor
The spec-driven base every typed handler inherits.
Definition SpecBackend.hpp:24
A struct to hold data for one MPToken response.
Definition AccountMPTokens.hpp:47
std::string account
Account holding the MPToken.
Definition AccountMPTokens.hpp:49
std::optional< bool > mptAuthorized
Set if the issuer authorized the holder.
Definition AccountMPTokens.hpp:55
std::optional< std::string > confidentialBalanceSpending
Encrypted spending balance, hex.
Definition AccountMPTokens.hpp:61
std::optional< std::string > auditorEncryptedBalance
Balance encrypted for auditor, hex.
Definition AccountMPTokens.hpp:64
std::string mpTokenIssuanceId
ID of the MPTokenIssuance this token belongs to.
Definition AccountMPTokens.hpp:50
std::optional< uint32_t > confidentialBalanceVersion
Confidential balance version.
Definition AccountMPTokens.hpp:62
std::optional< bool > mptLocked
Set if the holder's MPToken is locked.
Definition AccountMPTokens.hpp:54
std::optional< std::string > confidentialBalanceInbox
Encrypted inbox balance, hex.
Definition AccountMPTokens.hpp:57
std::string mpTokenId
Ledger key of the MPToken object (hex).
Definition AccountMPTokens.hpp:48
std::optional< uint64_t > lockedAmount
Amount currently locked (e.g. escrowed).
Definition AccountMPTokens.hpp:52
std::optional< std::string > holderEncryptionKey
Holder encryption key, hex.
Definition AccountMPTokens.hpp:65
uint64_t mptAmount
Amount of the MPT held.
Definition AccountMPTokens.hpp:51
std::optional< std::string > issuerEncryptedBalance
Balance encrypted for issuer, hex.
Definition AccountMPTokens.hpp:63
A struct to hold the output data of the command.
Definition AccountMPTokens.hpp:71
std::optional< std::string > marker
Pagination marker to resume from, if more results.
Definition AccountMPTokens.hpp:77
bool validated
Whether the ledger is validated.
Definition AccountMPTokens.hpp:76
uint32_t limit
Maximum number of MPTokens requested.
Definition AccountMPTokens.hpp:78
uint32_t ledgerIndex
Sequence of the ledger used for the request.
Definition AccountMPTokens.hpp:75
std::vector< MPTokenResponse > mpts
MPTokens held by the account.
Definition AccountMPTokens.hpp:73
std::string ledgerHash
Hash of the ledger used for the request.
Definition AccountMPTokens.hpp:74
std::string account
The holder account that was queried.
Definition AccountMPTokens.hpp:72
Context of an RPC call.
Definition Types.hpp:102
Result type used to return responses or error statuses to the Webserver subsystem.
Definition Types.hpp:132