rippled
Loading...
Searching...
No Matches
MPTokenHelpers.h
1#pragma once
2
3#include <xrpl/beast/utility/Journal.h>
4#include <xrpl/ledger/ApplyView.h>
5#include <xrpl/ledger/ReadView.h>
6#include <xrpl/ledger/helpers/TokenHelpers.h>
7#include <xrpl/protocol/MPTIssue.h>
8#include <xrpl/protocol/Rate.h>
9#include <xrpl/protocol/STAmount.h>
10#include <xrpl/protocol/TER.h>
11
12#include <initializer_list>
13#include <optional>
14
15namespace xrpl {
16
17//------------------------------------------------------------------------------
18//
19// Freeze checking (MPT-specific)
20//
21//------------------------------------------------------------------------------
22
23[[nodiscard]] bool
24isGlobalFrozen(ReadView const& view, MPTIssue const& mptIssue);
25
26[[nodiscard]] bool
27isIndividualFrozen(ReadView const& view, AccountID const& account, MPTIssue const& mptIssue);
28
29[[nodiscard]] bool
30isFrozen(ReadView const& view, AccountID const& account, MPTIssue const& mptIssue, int depth = 0);
31
32[[nodiscard]] bool
34 ReadView const& view,
36 MPTIssue const& mptIssue,
37 int depth = 0);
38
39//------------------------------------------------------------------------------
40//
41// Transfer rate (MPT-specific)
42//
43//------------------------------------------------------------------------------
44
50[[nodiscard]] Rate
51transferRate(ReadView const& view, MPTID const& issuanceID);
52
53//------------------------------------------------------------------------------
54//
55// Holding checks (MPT-specific)
56//
57//------------------------------------------------------------------------------
58
59[[nodiscard]] TER
60canAddHolding(ReadView const& view, MPTIssue const& mptIssue);
61
62//------------------------------------------------------------------------------
63//
64// Authorization (MPT-specific)
65//
66//------------------------------------------------------------------------------
67
68[[nodiscard]] TER
70 ApplyView& view,
71 XRPAmount const& priorBalance,
72 MPTID const& mptIssuanceID,
73 AccountID const& account,
74 beast::Journal journal,
75 std::uint32_t flags = 0,
77
84[[nodiscard]] TER
86 ReadView const& view,
87 MPTIssue const& mptIssue,
88 AccountID const& account,
89 AuthType authType = AuthType::Legacy,
90 int depth = 0);
91
98[[nodiscard]] TER
100 ApplyView& view,
101 MPTID const& mptIssuanceID,
102 AccountID const& account,
103 XRPAmount const& priorBalance,
105
110[[nodiscard]] TER
112 ReadView const& view,
113 MPTIssue const& mptIssue,
114 AccountID const& from,
115 AccountID const& to);
116
117//------------------------------------------------------------------------------
118//
119// Empty holding operations (MPT-specific)
120//
121//------------------------------------------------------------------------------
122
123[[nodiscard]] TER
125 ApplyView& view,
126 AccountID const& accountID,
127 XRPAmount priorBalance,
128 MPTIssue const& mptIssue,
129 beast::Journal journal);
130
131[[nodiscard]] TER
133 ApplyView& view,
134 AccountID const& accountID,
135 MPTIssue const& mptIssue,
136 beast::Journal journal);
137
138//------------------------------------------------------------------------------
139//
140// Escrow operations (MPT-specific)
141//
142//------------------------------------------------------------------------------
143
144TER
146 ApplyView& view,
147 AccountID const& uGrantorID,
148 STAmount const& saAmount,
150
151TER
153 ApplyView& view,
154 AccountID const& uGrantorID,
155 AccountID const& uGranteeID,
156 STAmount const& netAmount,
157 STAmount const& grossAmount,
159
160} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:40
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
bool isIndividualFrozen(ReadView const &view, AccountID const &account, MPTIssue const &mptIssue)
TER rippleUnlockEscrowMPT(ApplyView &view, AccountID const &uGrantorID, AccountID const &uGranteeID, STAmount const &netAmount, STAmount const &grossAmount, beast::Journal j)
TER addEmptyHolding(ApplyView &view, AccountID const &accountID, XRPAmount priorBalance, MPTIssue const &mptIssue, beast::Journal journal)
bool isAnyFrozen(ReadView const &view, std::initializer_list< AccountID > const &accounts, MPTIssue const &mptIssue, int depth=0)
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:28
TER authorizeMPToken(ApplyView &view, XRPAmount const &priorBalance, MPTID const &mptIssuanceID, AccountID const &account, beast::Journal journal, std::uint32_t flags=0, std::optional< AccountID > holderID=std::nullopt)
bool isGlobalFrozen(ReadView const &view, AccountID const &issuer)
Check if the issuer has the global freeze flag set.
bool isFrozen(ReadView const &view, AccountID const &account, MPTIssue const &mptIssue, int depth=0)
TERSubset< CanCvtToTER > TER
Definition TER.h:622
TER canAddHolding(ReadView const &view, MPTIssue const &mptIssue)
base_uint< 192 > MPTID
MPTID is a 192-bit value representing MPT Issuance ID, which is a concatenation of a 32-bit sequence ...
Definition UintTypes.h:44
Rate transferRate(ReadView const &view, AccountID const &issuer)
Returns IOU issuer transfer fee as Rate.
TER canTransfer(ReadView const &view, MPTIssue const &mptIssue, AccountID const &from, AccountID const &to)
Check if the destination account is allowed to receive MPT.
TER rippleLockEscrowMPT(ApplyView &view, AccountID const &uGrantorID, STAmount const &saAmount, beast::Journal j)
TER enforceMPTokenAuthorization(ApplyView &view, MPTID const &mptIssuanceID, AccountID const &account, XRPAmount const &priorBalance, beast::Journal j)
Enforce account has MPToken to match its authorization.
TER removeEmptyHolding(ApplyView &view, AccountID const &accountID, MPTIssue const &mptIssue, beast::Journal journal)
TER requireAuth(ReadView const &view, MPTIssue const &mptIssue, AccountID const &account, AuthType authType=AuthType::Legacy, int depth=0)
Check if the account lacks required authorization for MPT.