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:
31 static constexpr auto kLimitMin = rpc::spec::handlers::account_mptokens::kLimitMin;
32 static constexpr auto kLimitMax = rpc::spec::handlers::account_mptokens::kLimitMax;
33 static constexpr auto kLimitDefault = rpc::spec::handlers::account_mptokens::kLimitDefault;
34
39 std::string mpTokenId;
40 std::string account;
41 std::string mpTokenIssuanceId;
42 uint64_t mptAmount{};
43 std::optional<uint64_t> lockedAmount;
44
45 std::optional<bool> mptLocked;
46 std::optional<bool> mptAuthorized;
47
48 std::optional<std::string> confidentialBalanceInbox;
49 std::optional<std::string> confidentialBalanceSpending;
50 std::optional<uint32_t> confidentialBalanceVersion;
51 std::optional<std::string> issuerEncryptedBalance;
52 std::optional<std::string> auditorEncryptedBalance;
53 std::optional<std::string> holderEncryptionKey;
54 };
55
59 struct Output {
60 std::string account;
61 std::vector<MPTokenResponse> mpts;
62 std::string ledgerHash;
63 uint32_t ledgerIndex{};
64 bool validated = true;
65 std::optional<std::string> marker;
66 uint32_t limit{};
67 };
68
69 using Result = HandlerReturnType<Output>;
70
76 AccountMPTokensHandler(std::shared_ptr<BackendInterface> sharedPtrBackend)
77 : sharedPtrBackend_(std::move(sharedPtrBackend))
78 {
79 }
80
88 [[nodiscard]] Result
89 process(Input const& input, Context const& ctx) const;
90
91private:
92 static void
93 addMPToken(std::vector<MPTokenResponse>& mpts, xrpl::SLE const& sle);
94
95private:
102 friend void
103 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output);
104
111 friend void
112 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, MPTokenResponse const& mptoken);
113};
114
115} // namespace rpc
AccountMPTokensHandler(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new AccountMPTokensHandler object.
Definition AccountMPTokens.hpp:76
Result process(Input const &input, Context const &ctx) const
Process the AccountMPTokens command.
Definition AccountMPTokens.cpp:82
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
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:61
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:38
A struct to hold the output data of the command.
Definition AccountMPTokens.hpp:59
Context of an RPC call.
Definition Types.hpp:98
Result type used to return responses or error statuses to the Webserver subsystem.
Definition Types.hpp:109