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 constexpr MPTID const&
46 getMptID() const
47 {
48 return mptID_;
49 }
50
52 getText() const;
53
54 void
55 setJson(Json::Value& jv) const;
56
57 friend constexpr bool
58 operator==(MPTIssue const& lhs, MPTIssue const& rhs);
59
60 friend constexpr std::weak_ordering
61 operator<=>(MPTIssue const& lhs, MPTIssue const& rhs);
62
63 bool
64 native() const
65 {
66 return false;
67 }
68};
69
70constexpr bool
71operator==(MPTIssue const& lhs, MPTIssue const& rhs)
72{
73 return lhs.mptID_ == rhs.mptID_;
74}
75
77operator<=>(MPTIssue const& lhs, MPTIssue const& rhs)
78{
79 return lhs.mptID_ <=> rhs.mptID_;
80}
81
84inline bool
85isXRP(MPTID const&)
86{
87 return false;
88}
89
91to_json(MPTIssue const& mptIssue);
92
94to_string(MPTIssue const& mptIssue);
95
96MPTIssue
98
99} // namespace ripple
100
101#endif // RIPPLE_PROTOCOL_MPTISSUE_H_INCLUDED
Represents a JSON value.
Definition: json_value.h:150
std::string getText() const
Definition: MPTIssue.cpp:52
MPTIssue()=default
friend constexpr std::weak_ordering operator<=>(MPTIssue const &lhs, MPTIssue const &rhs)
Definition: MPTIssue.h:77
AccountID const & getIssuer() const
Definition: MPTIssue.cpp:40
friend constexpr bool operator==(MPTIssue const &lhs, MPTIssue const &rhs)
Definition: MPTIssue.h:71
void setJson(Json::Value &jv) const
Definition: MPTIssue.cpp:58
bool native() const
Definition: MPTIssue.h:64
constexpr MPTID const & getMptID() const
Definition: MPTIssue.h:46
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:78
Json::Value to_json(Asset const &asset)
Definition: Asset.h:123
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