mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
Add MPTIssue to STIssue (#5200)
Replace Issue in STIssue with Asset. STIssue with MPTIssue is only used in MPT tests. Will be used in Vault and in transactions with STIssue fields once MPT is integrated into DEX.
This commit is contained in:
committed by
GitHub
parent
eabca8439f
commit
5cd72f2431
@@ -26,10 +26,17 @@
|
||||
|
||||
namespace ripple {
|
||||
|
||||
class Asset;
|
||||
|
||||
template <typename TIss>
|
||||
concept ValidIssueType =
|
||||
std::is_same_v<TIss, Issue> || std::is_same_v<TIss, MPTIssue>;
|
||||
|
||||
template <typename A>
|
||||
concept AssetType =
|
||||
std::is_convertible_v<A, Asset> || std::is_convertible_v<A, Issue> ||
|
||||
std::is_convertible_v<A, MPTIssue> || std::is_convertible_v<A, MPTID>;
|
||||
|
||||
/* Asset is an abstraction of three different issue types: XRP, IOU, MPT.
|
||||
* For historical reasons, two issue types XRP and IOU are wrapped in Issue
|
||||
* type. Many functions and classes there were first written for Issue
|
||||
@@ -37,8 +44,10 @@ concept ValidIssueType =
|
||||
*/
|
||||
class Asset
|
||||
{
|
||||
private:
|
||||
public:
|
||||
using value_type = std::variant<Issue, MPTIssue>;
|
||||
|
||||
private:
|
||||
value_type issue_;
|
||||
|
||||
public:
|
||||
@@ -92,8 +101,8 @@ public:
|
||||
friend constexpr bool
|
||||
operator==(Asset const& lhs, Asset const& rhs);
|
||||
|
||||
friend constexpr bool
|
||||
operator!=(Asset const& lhs, Asset const& rhs);
|
||||
friend constexpr std::weak_ordering
|
||||
operator<=>(Asset const& lhs, Asset const& rhs);
|
||||
|
||||
friend constexpr bool
|
||||
operator==(Currency const& lhs, Asset const& rhs);
|
||||
@@ -151,10 +160,22 @@ operator==(Asset const& lhs, Asset const& rhs)
|
||||
rhs.issue_);
|
||||
}
|
||||
|
||||
constexpr bool
|
||||
operator!=(Asset const& lhs, Asset const& rhs)
|
||||
constexpr std::weak_ordering
|
||||
operator<=>(Asset const& lhs, Asset const& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
return std::visit(
|
||||
[]<ValidIssueType TLhs, ValidIssueType TRhs>(
|
||||
TLhs const& lhs_, TRhs const& rhs_) {
|
||||
if constexpr (std::is_same_v<TLhs, TRhs>)
|
||||
return std::weak_ordering(lhs_ <=> rhs_);
|
||||
else if constexpr (
|
||||
std::is_same_v<TLhs, Issue> && std::is_same_v<TRhs, MPTIssue>)
|
||||
return std::weak_ordering::greater;
|
||||
else
|
||||
return std::weak_ordering::less;
|
||||
},
|
||||
lhs.issue_,
|
||||
rhs.issue_);
|
||||
}
|
||||
|
||||
constexpr bool
|
||||
|
||||
Reference in New Issue
Block a user