Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
AccountMPTokenIssuances.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_mptoken_issuances/Types.hpp>
10#include <xrpl/protocol/AccountID.h>
11#include <xrpl/protocol/STLedgerEntry.h>
12
13#include <cstdint>
14#include <memory>
15#include <optional>
16#include <string>
17#include <utility>
18#include <vector>
19
20namespace rpc {
21
27 : public rpc::HandlerFor<rpc::spec::handlers::account_mptoken_issuances::Input> {
28 // dependencies
29 std::shared_ptr<BackendInterface> sharedPtrBackend_;
30
31public:
35 static constexpr auto kLimitMin = rpc::spec::handlers::account_mptoken_issuances::kLimitMin;
39 static constexpr auto kLimitMax = rpc::spec::handlers::account_mptoken_issuances::kLimitMax;
43 static constexpr auto kLimitDefault =
44 rpc::spec::handlers::account_mptoken_issuances::kLimitDefault;
45
50 std::string mpTokenIssuanceId;
51 std::string issuer;
52 uint32_t sequence{};
53
54 std::optional<uint16_t> transferFee;
55 std::optional<uint8_t> assetScale;
56
57 std::optional<std::uint64_t> maximumAmount;
58 std::optional<std::uint64_t> outstandingAmount;
59 std::optional<std::uint64_t> lockedAmount;
60 std::optional<std::string> mptokenMetadata;
61 std::optional<std::string> domainID;
62
63 std::optional<bool> mptLocked;
64 std::optional<bool> mptCanLock;
65 std::optional<bool> mptRequireAuth;
66 std::optional<bool> mptCanEscrow;
67 std::optional<bool> mptCanTrade;
68 std::optional<bool> mptCanTransfer;
69 std::optional<bool> mptCanClawback;
70
71 std::optional<bool> mptImmutableCanLock;
72 std::optional<bool> mptImmutableRequireAuth;
73 std::optional<bool> mptImmutableCanEscrow;
74 std::optional<bool> mptImmutableCanTrade;
75 std::optional<bool> mptImmutableCanTransfer;
76 std::optional<bool> mptImmutableCanClawback;
81 std::optional<bool> mptImmutableMetadata;
82 std::optional<bool> mptImmutableTransferFee;
83
87 std::optional<bool> mptCanHoldConfidentialBalance;
91 std::optional<std::uint64_t> confidentialOutstandingAmount;
92 std::optional<std::string> issuerEncryptionKey;
93 std::optional<std::string> auditorEncryptionKey;
94 };
95
99 struct Output {
100 std::string account;
101 std::vector<MPTokenIssuanceResponse> issuances;
102 std::string ledgerHash;
103 uint32_t ledgerIndex{};
104 bool validated = true;
105 std::optional<std::string> marker;
106 uint32_t limit{};
107 };
108
113
119 AccountMPTokenIssuancesHandler(std::shared_ptr<BackendInterface> sharedPtrBackend)
120 : sharedPtrBackend_(std::move(sharedPtrBackend))
121 {
122 }
123
131 [[nodiscard]] Result
132 process(Input const& input, Context const& ctx) const;
133
134private:
135 static void
136 addMPTokenIssuance(
137 std::vector<MPTokenIssuanceResponse>& issuances,
138 xrpl::SLE const& sle,
139 xrpl::AccountID const& account
140 );
141
142private:
149 friend void
150 tag_invoke(boost::json::value_from_tag, boost::json::value& jv, Output const& output);
151
158 friend void
160 boost::json::value_from_tag,
161 boost::json::value& jv,
162 MPTokenIssuanceResponse const& issuance
163 );
164};
165
166} // namespace rpc
static constexpr auto kLimitMin
Minimum accepted value for the limit request field.
Definition AccountMPTokenIssuances.hpp:35
static constexpr auto kLimitDefault
Value of limit used when the request does not specify one.
Definition AccountMPTokenIssuances.hpp:43
HandlerReturnType< Output > Result
The result type of the command: the Output on success or an error Status.
Definition AccountMPTokenIssuances.hpp:112
AccountMPTokenIssuancesHandler(std::shared_ptr< BackendInterface > sharedPtrBackend)
Construct a new AccountMPTokenIssuancesHandler object.
Definition AccountMPTokenIssuances.hpp:119
static constexpr auto kLimitMax
Maximum accepted value for the limit request field.
Definition AccountMPTokenIssuances.hpp:39
Result process(Input const &input, Context const &ctx) const
Process the AccountMPTokenIssuances command.
Definition AccountMPTokenIssuances.cpp:118
friend void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, Output const &output)
Convert the Output to a JSON object.
Definition AccountMPTokenIssuances.cpp:181
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 MPTokenIssuance response.
Definition AccountMPTokenIssuances.hpp:49
std::optional< uint16_t > transferFee
Fee charged on transfers, if set.
Definition AccountMPTokenIssuances.hpp:54
std::optional< bool > mptImmutableRequireAuth
Set if the require-auth flag is immutable.
Definition AccountMPTokenIssuances.hpp:72
std::optional< bool > mptCanHoldConfidentialBalance
Set if confidential balances are allowed.
Definition AccountMPTokenIssuances.hpp:87
std::optional< std::uint64_t > confidentialOutstandingAmount
Confidential outstanding amount.
Definition AccountMPTokenIssuances.hpp:91
std::optional< std::string > issuerEncryptionKey
Issuer encryption key, hex-encoded.
Definition AccountMPTokenIssuances.hpp:92
std::optional< std::string > auditorEncryptionKey
Auditor encryption key, hex-encoded.
Definition AccountMPTokenIssuances.hpp:93
std::optional< std::uint64_t > outstandingAmount
Amount currently held by holders.
Definition AccountMPTokenIssuances.hpp:58
std::optional< bool > mptRequireAuth
Set if holders need issuer authorization.
Definition AccountMPTokenIssuances.hpp:65
std::optional< bool > mptImmutableCanTrade
Set if the can-trade flag is immutable.
Definition AccountMPTokenIssuances.hpp:74
std::optional< bool > mptImmutableCanEscrow
Set if the can-escrow flag is immutable.
Definition AccountMPTokenIssuances.hpp:73
std::string mpTokenIssuanceId
ID of the MPTokenIssuance.
Definition AccountMPTokenIssuances.hpp:50
std::optional< std::string > mptokenMetadata
Arbitrary metadata, hex-encoded.
Definition AccountMPTokenIssuances.hpp:60
std::optional< uint8_t > assetScale
Decimal scale of the MPT, if set.
Definition AccountMPTokenIssuances.hpp:55
std::optional< bool > mptLocked
Set if the issuance is locked.
Definition AccountMPTokenIssuances.hpp:63
std::string issuer
Account that issued the MPT.
Definition AccountMPTokenIssuances.hpp:51
uint32_t sequence
Sequence number used to create the issuance.
Definition AccountMPTokenIssuances.hpp:52
std::optional< bool > mptCanLock
Set if the issuer can lock the MPT.
Definition AccountMPTokenIssuances.hpp:64
std::optional< bool > mptCanTrade
Set if the MPT can be traded on the DEX.
Definition AccountMPTokenIssuances.hpp:67
std::optional< bool > mptImmutableCanTransfer
Set if the can-transfer flag is immutable.
Definition AccountMPTokenIssuances.hpp:75
std::optional< std::uint64_t > maximumAmount
Maximum amount that can be issued.
Definition AccountMPTokenIssuances.hpp:57
std::optional< bool > mptCanClawback
Set if the issuer can claw back the MPT.
Definition AccountMPTokenIssuances.hpp:69
std::optional< bool > mptCanTransfer
Set if the MPT can be transferred between holders.
Definition AccountMPTokenIssuances.hpp:68
std::optional< std::uint64_t > lockedAmount
Amount currently locked (e.g. escrowed).
Definition AccountMPTokenIssuances.hpp:59
std::optional< bool > mptImmutableCanHoldConfidentialBalance
Set if the can-hold-confidential-balance flag is immutable.
Definition AccountMPTokenIssuances.hpp:80
std::optional< bool > mptImmutableTransferFee
Set if the transfer fee is immutable.
Definition AccountMPTokenIssuances.hpp:82
std::optional< bool > mptImmutableCanClawback
Set if the can-clawback flag is immutable.
Definition AccountMPTokenIssuances.hpp:76
std::optional< bool > mptImmutableCanLock
Set if the can-lock flag is immutable.
Definition AccountMPTokenIssuances.hpp:71
std::optional< bool > mptCanEscrow
Set if the MPT can be escrowed.
Definition AccountMPTokenIssuances.hpp:66
std::optional< std::string > domainID
Permissioned domain ID, hex-encoded.
Definition AccountMPTokenIssuances.hpp:61
std::optional< bool > mptImmutableMetadata
Set if the metadata is immutable.
Definition AccountMPTokenIssuances.hpp:81
A struct to hold the output data of the command.
Definition AccountMPTokenIssuances.hpp:99
uint32_t limit
Maximum number of issuances requested.
Definition AccountMPTokenIssuances.hpp:106
uint32_t ledgerIndex
Sequence of the ledger used for the request.
Definition AccountMPTokenIssuances.hpp:103
std::optional< std::string > marker
Pagination marker to resume from, if more results.
Definition AccountMPTokenIssuances.hpp:105
std::string account
The issuer account that was queried.
Definition AccountMPTokenIssuances.hpp:100
std::string ledgerHash
Hash of the ledger used for the request.
Definition AccountMPTokenIssuances.hpp:102
std::vector< MPTokenIssuanceResponse > issuances
Issuances created by the account.
Definition AccountMPTokenIssuances.hpp:101
bool validated
Whether the ledger is validated.
Definition AccountMPTokenIssuances.hpp:104
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