rippled
Loading...
Searching...
No Matches
MPTIssue.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2024 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_PROTOCOL_MPTISSUE_H_INCLUDED
21#define RIPPLE_PROTOCOL_MPTISSUE_H_INCLUDED
22
23#include <xrpl/protocol/AccountID.h>
24#include <xrpl/protocol/UintTypes.h>
25
26namespace ripple {
27
28/* Adapt MPTID to provide the same interface as Issue. Enables using static
29 * polymorphism by Asset and other classes. MPTID is a 192-bit concatenation
30 * of a 32-bit account sequence and a 160-bit account id.
31 */
33{
34private:
36
37public:
38 MPTIssue() = default;
39
40 explicit MPTIssue(MPTID const& issuanceID);
41
42 AccountID const&
43 getIssuer() const;
44
45 MPTID const&
46 getMptID() const;
47
49 getText() const;
50
51 void
52 setJson(Json::Value& jv) const;
53
54 friend constexpr bool
55 operator==(MPTIssue const& lhs, MPTIssue const& rhs);
56
57 friend constexpr std::weak_ordering
58 operator<=>(MPTIssue const& lhs, MPTIssue const& rhs);
59
60 bool
61 native() const
62 {
63 return false;
64 }
65};
66
67constexpr bool
68operator==(MPTIssue const& lhs, MPTIssue const& rhs)
69{
70 return lhs.mptID_ == rhs.mptID_;
71}
72
74operator<=>(MPTIssue const& lhs, MPTIssue const& rhs)
75{
76 return lhs.mptID_ <=> rhs.mptID_;
77}
78
81inline bool
82isXRP(MPTID const&)
83{
84 return false;
85}
86
88to_json(MPTIssue const& mptIssue);
89
91to_string(MPTIssue const& mptIssue);
92
93MPTIssue
95
96} // namespace ripple
97
98#endif // RIPPLE_PROTOCOL_MPTISSUE_H_INCLUDED
Represents a JSON value.
Definition: json_value.h:148
std::string getText() const
Definition: MPTIssue.cpp:58
MPTIssue()=default
MPTID const & getMptID() const
Definition: MPTIssue.cpp:52
friend constexpr std::weak_ordering operator<=>(MPTIssue const &lhs, MPTIssue const &rhs)
Definition: MPTIssue.h:74
AccountID const & getIssuer() const
Definition: MPTIssue.cpp:40
friend constexpr bool operator==(MPTIssue const &lhs, MPTIssue const &rhs)
Definition: MPTIssue.h:68
void setJson(Json::Value &jv) const
Definition: MPTIssue.cpp:64
bool native() const
Definition: MPTIssue.h:61
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
bool isXRP(AccountID const &c)
Definition: AccountID.h:91
constexpr std::strong_ordering operator<=>(base_uint< Bits, Tag > const &lhs, base_uint< Bits, Tag > const &rhs)
Definition: base_uint.h:563
MPTIssue mptIssueFromJson(Json::Value const &jv)
Definition: MPTIssue.cpp:84
Json::Value to_json(Asset const &asset)
Definition: Asset.cpp:82
std::string to_string(base_uint< Bits, Tag > const &a)
Definition: base_uint.h:630
constexpr bool operator==(base_uint< Bits, Tag > const &lhs, base_uint< Bits, Tag > const &rhs)
Definition: base_uint.h:585