rippled
Loading...
Searching...
No Matches
View.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 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_LEDGER_VIEW_H_INCLUDED
21#define RIPPLE_LEDGER_VIEW_H_INCLUDED
22
23#include <xrpl/beast/utility/Journal.h>
24#include <xrpl/ledger/ApplyView.h>
25#include <xrpl/ledger/OpenView.h>
26#include <xrpl/ledger/ReadView.h>
27#include <xrpl/protocol/Indexes.h>
28#include <xrpl/protocol/MPTIssue.h>
29#include <xrpl/protocol/Protocol.h>
30#include <xrpl/protocol/Rate.h>
31#include <xrpl/protocol/STLedgerEntry.h>
32#include <xrpl/protocol/STObject.h>
33#include <xrpl/protocol/Serializer.h>
34#include <xrpl/protocol/TER.h>
35
36#include <functional>
37#include <initializer_list>
38#include <map>
39#include <utility>
40
41namespace ripple {
42
43enum class WaiveTransferFee : bool { No = false, Yes };
44enum class SkipEntry : bool { No = false, Yes };
45
46//------------------------------------------------------------------------------
47//
48// Observers
49//
50//------------------------------------------------------------------------------
51
73[[nodiscard]] bool
74hasExpired(ReadView const& view, std::optional<std::uint32_t> const& exp);
75
78
81
82[[nodiscard]] bool
83isGlobalFrozen(ReadView const& view, AccountID const& issuer);
84
85[[nodiscard]] bool
86isGlobalFrozen(ReadView const& view, MPTIssue const& mptIssue);
87
88[[nodiscard]] bool
89isGlobalFrozen(ReadView const& view, Asset const& asset);
90
91// Note, depth parameter is used to limit the recursion depth
92[[nodiscard]] bool
94 ReadView const& view,
95 AccountID const& account,
96 MPTIssue const& mptShare,
97 int depth);
98
99[[nodiscard]] bool
101 ReadView const& view,
102 AccountID const& account,
103 Currency const& currency,
104 AccountID const& issuer);
105
106[[nodiscard]] inline bool
108 ReadView const& view,
109 AccountID const& account,
110 Issue const& issue)
111{
112 return isIndividualFrozen(view, account, issue.currency, issue.account);
113}
114
115[[nodiscard]] bool
117 ReadView const& view,
118 AccountID const& account,
119 MPTIssue const& mptIssue);
120
121[[nodiscard]] inline bool
123 ReadView const& view,
124 AccountID const& account,
125 Asset const& asset)
126{
127 return std::visit(
128 [&](auto const& issue) {
129 return isIndividualFrozen(view, account, issue);
130 },
131 asset.value());
132}
133
134[[nodiscard]] bool
136 ReadView const& view,
137 AccountID const& account,
138 Currency const& currency,
139 AccountID const& issuer);
140
141[[nodiscard]] inline bool
143 ReadView const& view,
144 AccountID const& account,
145 Issue const& issue,
146 int = 0 /*ignored*/)
147{
148 return isFrozen(view, account, issue.currency, issue.account);
149}
150
151[[nodiscard]] bool
153 ReadView const& view,
154 AccountID const& account,
155 MPTIssue const& mptIssue,
156 int depth = 0);
157
163[[nodiscard]] inline bool
165 ReadView const& view,
166 AccountID const& account,
167 Asset const& asset,
168 int depth = 0)
169{
170 return std::visit(
171 [&](auto const& issue) {
172 return isFrozen(view, account, issue, depth);
173 },
174 asset.value());
175}
176
177[[nodiscard]] inline TER
178checkFrozen(ReadView const& view, AccountID const& account, Issue const& issue)
179{
180 return isFrozen(view, account, issue) ? (TER)tecFROZEN : (TER)tesSUCCESS;
181}
182
183[[nodiscard]] inline TER
185 ReadView const& view,
186 AccountID const& account,
187 MPTIssue const& mptIssue)
188{
189 return isFrozen(view, account, mptIssue) ? (TER)tecLOCKED : (TER)tesSUCCESS;
190}
191
192[[nodiscard]] inline TER
193checkFrozen(ReadView const& view, AccountID const& account, Asset const& asset)
194{
195 return std::visit(
196 [&](auto const& issue) { return checkFrozen(view, account, issue); },
197 asset.value());
198}
199
200[[nodiscard]] bool
202 ReadView const& view,
203 std::initializer_list<AccountID> const& accounts,
204 MPTIssue const& mptIssue,
205 int depth = 0);
206
207[[nodiscard]] inline bool
209 ReadView const& view,
210 std::initializer_list<AccountID> const& accounts,
211 Issue const& issue)
212{
213 for (auto const& account : accounts)
214 {
215 if (isFrozen(view, account, issue.currency, issue.account))
216 return true;
217 }
218 return false;
219}
220
221[[nodiscard]] inline bool
223 ReadView const& view,
224 std::initializer_list<AccountID> const& accounts,
225 Asset const& asset,
226 int depth = 0)
227{
228 return std::visit(
229 [&]<ValidIssueType TIss>(TIss const& issue) {
230 if constexpr (std::is_same_v<TIss, Issue>)
231 return isAnyFrozen(view, accounts, issue);
232 else
233 return isAnyFrozen(view, accounts, issue, depth);
234 },
235 asset.value());
236}
237
238[[nodiscard]] bool
240 ReadView const& view,
241 AccountID const& account,
242 Currency const& currency,
243 AccountID const& issuer);
244
245[[nodiscard]] bool
247 ReadView const& view,
248 AccountID const& account,
249 Issue const& asset,
250 Issue const& asset2);
251
252// Returns the amount an account can spend without going into debt.
253//
254// <-- saAmount: amount of currency held by account. May be negative.
255[[nodiscard]] STAmount
257 ReadView const& view,
258 AccountID const& account,
259 Currency const& currency,
260 AccountID const& issuer,
261 FreezeHandling zeroIfFrozen,
263
264[[nodiscard]] STAmount
266 ReadView const& view,
267 AccountID const& account,
268 Issue const& issue,
269 FreezeHandling zeroIfFrozen,
271
272[[nodiscard]] STAmount
274 ReadView const& view,
275 AccountID const& account,
276 MPTIssue const& mptIssue,
277 FreezeHandling zeroIfFrozen,
278 AuthHandling zeroIfUnauthorized,
280
281[[nodiscard]] STAmount
283 ReadView const& view,
284 AccountID const& account,
285 Asset const& asset,
286 FreezeHandling zeroIfFrozen,
287 AuthHandling zeroIfUnauthorized,
289
290// Returns the amount an account can spend of the currency type saDefault, or
291// returns saDefault if this account is the issuer of the currency in
292// question. Should be used in favor of accountHolds when questioning how much
293// an account can spend while also allowing currency issuers to spend
294// unlimited amounts of their own currency (since they can always issue more).
295[[nodiscard]] STAmount
297 ReadView const& view,
298 AccountID const& id,
299 STAmount const& saDefault,
300 FreezeHandling freezeHandling,
302
303// Return the account's liquid (not reserved) XRP. Generally prefer
304// calling accountHolds() over this interface. However, this interface
305// allows the caller to temporarily adjust the owner count should that be
306// necessary.
307//
308// @param ownerCountAdj positive to add to count, negative to reduce count.
309[[nodiscard]] XRPAmount
311 ReadView const& view,
312 AccountID const& id,
313 std::int32_t ownerCountAdj,
315
317void
319 ReadView const& view,
320 Keylet const& root,
321 std::function<void(std::shared_ptr<SLE const> const&)> const& f);
322
329bool
331 ReadView const& view,
332 Keylet const& root,
333 uint256 const& after,
334 std::uint64_t const hint,
335 unsigned int limit,
336 std::function<bool(std::shared_ptr<SLE const> const&)> const& f);
337
339inline void
341 ReadView const& view,
342 AccountID const& id,
343 std::function<void(std::shared_ptr<SLE const> const&)> const& f)
344{
345 return forEachItem(view, keylet::ownerDir(id), f);
346}
347
354inline bool
356 ReadView const& view,
357 AccountID const& id,
358 uint256 const& after,
359 std::uint64_t const hint,
360 unsigned int limit,
361 std::function<bool(std::shared_ptr<SLE const> const&)> const& f)
362{
363 return forEachItemAfter(view, keylet::ownerDir(id), after, hint, limit, f);
364}
365
371[[nodiscard]] Rate
372transferRate(ReadView const& view, AccountID const& issuer);
373
379[[nodiscard]] Rate
380transferRate(ReadView const& view, MPTID const& issuanceID);
381
386[[nodiscard]] Rate
387transferRate(ReadView const& view, STAmount const& amount);
388
392[[nodiscard]] bool
393dirIsEmpty(ReadView const& view, Keylet const& k);
394
395// Return the list of enabled amendments
396[[nodiscard]] std::set<uint256>
397getEnabledAmendments(ReadView const& view);
398
399// Return a map of amendments that have achieved majority
401[[nodiscard]] majorityAmendments_t
403
413[[nodiscard]] std::optional<uint256>
414hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal);
415
428inline LedgerIndex
430{
431 return (requested + 255) & (~255);
432}
433
439[[nodiscard]] bool
441 ReadView const& validLedger,
442 ReadView const& testLedger,
444 char const* reason);
445
446[[nodiscard]] bool
448 uint256 const& validHash,
449 LedgerIndex validIndex,
450 ReadView const& testLedger,
452 char const* reason);
453
454//------------------------------------------------------------------------------
455//
456// Modifiers
457//
458//------------------------------------------------------------------------------
459
461void
463 ApplyView& view,
464 std::shared_ptr<SLE> const& sle,
465 std::int32_t amount,
467
483bool
485 ReadView const& view,
486 uint256 const& root,
488 unsigned int& index,
489 uint256& entry);
490
491bool
493 ApplyView& view,
494 uint256 const& root,
496 unsigned int& index,
497 uint256& entry);
515bool
517 ReadView const& view,
518 uint256 const& root,
520 unsigned int& index,
521 uint256& entry);
522
523bool
524dirNext(
525 ApplyView& view,
526 uint256 const& root,
528 unsigned int& index,
529 uint256& entry);
532[[nodiscard]] std::function<void(SLE::ref)>
533describeOwnerDir(AccountID const& account);
534
535[[nodiscard]] TER
536dirLink(ApplyView& view, AccountID const& owner, std::shared_ptr<SLE>& object);
537
539pseudoAccountAddress(ReadView const& view, uint256 const& pseudoOwnerKey);
540
549[[nodiscard]] Expected<std::shared_ptr<SLE>, TER>
551 ApplyView& view,
552 uint256 const& pseudoOwnerKey,
553 SField const& ownerField);
554
555// Returns true iff sleAcct is a pseudo-account.
556//
557// Returns false if sleAcct is
558// * NOT a pseudo-account OR
559// * NOT a ltACCOUNT_ROOT OR
560// * null pointer
561[[nodiscard]] bool
563
564// Returns the list of fields that define an ACCOUNT_ROOT as a pseudo-account if
565// set
566// Pseudo-account designator fields MUST be maintained by including the
567// SField::sMD_PseudoAccount flag in the SField definition. (Don't forget to
568// "| SField::sMD_Default"!) The fields do NOT need to be amendment-gated,
569// since a non-active amendment will not set any field, by definition.
570// Specific properties of a pseudo-account are NOT checked here, that's what
571// InvariantCheck is for.
572[[nodiscard]] std::vector<SField const*> const&
574
575[[nodiscard]] inline bool
576isPseudoAccount(ReadView const& view, AccountID accountId)
577{
578 return isPseudoAccount(view.read(keylet::account(accountId)));
579}
580
581[[nodiscard]] TER
582canAddHolding(ReadView const& view, Asset const& asset);
583
586[[nodiscard]] TER
588 ApplyView& view,
589 AccountID const& accountID,
590 XRPAmount priorBalance,
591 Issue const& issue,
592 beast::Journal journal);
593
594[[nodiscard]] TER
596 ApplyView& view,
597 AccountID const& accountID,
598 XRPAmount priorBalance,
599 MPTIssue const& mptIssue,
600 beast::Journal journal);
601
602[[nodiscard]] inline TER
604 ApplyView& view,
605 AccountID const& accountID,
606 XRPAmount priorBalance,
607 Asset const& asset,
608 beast::Journal journal)
609{
610 return std::visit(
611 [&]<ValidIssueType TIss>(TIss const& issue) -> TER {
612 return addEmptyHolding(
613 view, accountID, priorBalance, issue, journal);
614 },
615 asset.value());
616}
617
618[[nodiscard]] TER
620 ApplyView& view,
621 XRPAmount const& priorBalance,
622 MPTID const& mptIssuanceID,
623 AccountID const& account,
624 beast::Journal journal,
625 std::uint32_t flags = 0,
627
628// VFALCO NOTE Both STAmount parameters should just
629// be "Amount", a unit-less number.
630//
635[[nodiscard]] TER
637 ApplyView& view,
638 bool const bSrcHigh,
639 AccountID const& uSrcAccountID,
640 AccountID const& uDstAccountID,
641 uint256 const& uIndex, // --> ripple state entry
642 SLE::ref sleAccount, // --> the account being set.
643 bool const bAuth, // --> authorize account.
644 bool const bNoRipple, // --> others cannot ripple through
645 bool const bFreeze, // --> funds cannot leave
646 bool bDeepFreeze, // --> can neither receive nor send funds
647 STAmount const& saBalance, // --> balance of account being set.
648 // Issuer should be noAccount()
649 STAmount const& saLimit, // --> limit for account being set.
650 // Issuer should be the account being set.
651 std::uint32_t uSrcQualityIn,
652 std::uint32_t uSrcQualityOut,
654
655[[nodiscard]] TER
657 ApplyView& view,
658 AccountID const& accountID,
659 Issue const& issue,
660 beast::Journal journal);
661
662[[nodiscard]] TER
664 ApplyView& view,
665 AccountID const& accountID,
666 MPTIssue const& mptIssue,
667 beast::Journal journal);
668
669[[nodiscard]] inline TER
671 ApplyView& view,
672 AccountID const& accountID,
673 Asset const& asset,
674 beast::Journal journal)
675{
676 return std::visit(
677 [&]<ValidIssueType TIss>(TIss const& issue) -> TER {
678 return removeEmptyHolding(view, accountID, issue, journal);
679 },
680 asset.value());
681}
682
683[[nodiscard]] TER
685 ApplyView& view,
686 std::shared_ptr<SLE> const& sleRippleState,
687 AccountID const& uLowAccountID,
688 AccountID const& uHighAccountID,
690
697// [[nodiscard]] // nodiscard commented out so Flow, BookTip and others compile.
698TER
699offerDelete(ApplyView& view, std::shared_ptr<SLE> const& sle, beast::Journal j);
700
701//------------------------------------------------------------------------------
702
703//
704// Money Transfers
705//
706
707// Direct send w/o fees:
708// - Redeeming IOUs and/or sending sender's own IOUs.
709// - Create trust line of needed.
710// --> bCheckIssuer : normally require issuer to be involved.
711// [[nodiscard]] // nodiscard commented out so DirectStep.cpp compiles.
712
716TER
718 ApplyView& view,
719 AccountID const& uSenderID,
720 AccountID const& uReceiverID,
721 STAmount const& saAmount,
722 bool bCheckIssuer,
724
725TER
727 ApplyView& view,
728 AccountID const& uGrantorID,
729 STAmount const& saAmount,
731
732TER
734 ApplyView& view,
735 AccountID const& uGrantorID,
736 AccountID const& uGranteeID,
737 STAmount const& netAmount,
738 STAmount const& grossAmount,
740
744[[nodiscard]] TER
746 ApplyView& view,
747 AccountID const& from,
748 AccountID const& to,
749 STAmount const& saAmount,
752
753[[nodiscard]] TER
755 ApplyView& view,
756 AccountID const& account,
757 STAmount const& amount,
758 Issue const& issue,
760
761[[nodiscard]] TER
763 ApplyView& view,
764 AccountID const& account,
765 STAmount const& amount,
766 Issue const& issue,
768
769[[nodiscard]] TER
771 ApplyView& view,
772 AccountID const& from,
773 AccountID const& to,
774 STAmount const& amount,
776
777/* Check if MPToken (for MPT) or trust line (for IOU) exists:
778 * - StrongAuth - before checking if authorization is required
779 * - WeakAuth
780 * for MPT - after checking lsfMPTRequireAuth flag
781 * for IOU - do not check if trust line exists
782 * - Legacy
783 * for MPT - before checking lsfMPTRequireAuth flag i.e. same as StrongAuth
784 * for IOU - do not check if trust line exists i.e. same as WeakAuth
785 */
787
805[[nodiscard]] TER
807 ReadView const& view,
808 Issue const& issue,
809 AccountID const& account,
810 AuthType authType = AuthType::Legacy);
811
834[[nodiscard]] TER
836 ReadView const& view,
837 MPTIssue const& mptIssue,
838 AccountID const& account,
839 AuthType authType = AuthType::Legacy,
840 int depth = 0);
841
842[[nodiscard]] TER inline requireAuth(
843 ReadView const& view,
844 Asset const& asset,
845 AccountID const& account,
846 AuthType authType = AuthType::Legacy)
847{
848 return std::visit(
849 [&]<ValidIssueType TIss>(TIss const& issue_) {
850 return requireAuth(view, issue_, account, authType);
851 },
852 asset.value());
853}
854
878[[nodiscard]] TER
880 ApplyView& view,
881 MPTID const& mptIssuanceID,
882 AccountID const& account,
883 XRPAmount const& priorBalance,
885
890[[nodiscard]] TER
892 ReadView const& view,
893 MPTIssue const& mptIssue,
894 AccountID const& from,
895 AccountID const& to);
896
903 uint256 const&,
912[[nodiscard]] TER
914 ApplyView& view,
915 Keylet const& ownerDirKeylet,
916 EntryDeleter const& deleter,
918 std::optional<std::uint16_t> maxNodesToDelete = std::nullopt);
919
924[[nodiscard]] TER
926 ApplyView& view,
927 std::shared_ptr<SLE> sleState,
928 std::optional<AccountID> const& ammAccountID,
930
931// From the perspective of a vault, return the number of shares to give the
932// depositor when they deposit a fixed amount of assets. Since shares are MPT
933// this number is integral and always truncated in this calculation.
934[[nodiscard]] std::optional<STAmount>
936 std::shared_ptr<SLE const> const& vault,
937 std::shared_ptr<SLE const> const& issuance,
938 STAmount const& assets);
939
940// From the perspective of a vault, return the number of assets to take from
941// depositor when they receive a fixed amount of shares. Note, since shares are
942// MPT, they are always an integral number.
943[[nodiscard]] std::optional<STAmount>
945 std::shared_ptr<SLE const> const& vault,
946 std::shared_ptr<SLE const> const& issuance,
947 STAmount const& shares);
948
949enum class TruncateShares : bool { no = false, yes = true };
950
951// From the perspective of a vault, return the number of shares to demand from
952// the depositor when they ask to withdraw a fixed amount of assets. Since
953// shares are MPT this number is integral, and it will be rounded to nearest
954// unless explicitly requested to be truncated instead.
955[[nodiscard]] std::optional<STAmount>
957 std::shared_ptr<SLE const> const& vault,
958 std::shared_ptr<SLE const> const& issuance,
959 STAmount const& assets,
961
962// From the perspective of a vault, return the number of assets to give the
963// depositor when they redeem a fixed amount of shares. Note, since shares are
964// MPT, they are always an integral number.
965[[nodiscard]] std::optional<STAmount>
967 std::shared_ptr<SLE const> const& vault,
968 std::shared_ptr<SLE const> const& issuance,
969 STAmount const& shares);
970
977bool
979
980} // namespace ripple
981
982#endif
Provide a light-weight way to check active() before string formatting.
Definition Journal.h:205
A generic endpoint for log messages.
Definition Journal.h:60
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:143
constexpr value_type const & value() const
Definition Asset.h:156
A currency issued by an account.
Definition Issue.h:33
AccountID account
Definition Issue.h:36
Currency currency
Definition Issue.h:35
std::chrono::time_point< NetClock > time_point
Definition chrono.h:69
A view into a ledger.
Definition ReadView.h:51
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
std::shared_ptr< STLedgerEntry > const & ref
T is_same_v
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:184
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition Indexes.cpp:374
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:48
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:139
TER checkFrozen(ReadView const &view, AccountID const &account, Issue const &issue)
Definition View.h:178
STAmount accountFunds(ReadView const &view, AccountID const &id, STAmount const &saDefault, FreezeHandling freezeHandling, beast::Journal j)
Definition View.cpp:554
FreezeHandling
Controls the treatment of frozen account balances.
Definition View.h:77
@ fhZERO_IF_FROZEN
Definition View.h:77
@ fhIGNORE_FREEZE
Definition View.h:77
bool areCompatible(ReadView const &validLedger, ReadView const &testLedger, beast::Journal::Stream &s, char const *reason)
Return false if the test ledger is provably incompatible with the valid ledger, that is,...
Definition View.cpp:799
TER rippleLockEscrowMPT(ApplyView &view, AccountID const &uGrantorID, STAmount const &saAmount, beast::Journal j)
Definition View.cpp:2995
LedgerIndex getCandidateLedger(LedgerIndex requested)
Find a ledger index from which we could easily get the requested ledger.
Definition View.h:429
std::optional< STAmount > sharesToAssetsDeposit(std::shared_ptr< SLE const > const &vault, std::shared_ptr< SLE const > const &issuance, STAmount const &shares)
Definition View.cpp:2912
bool isIndividualFrozen(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer)
Definition View.cpp:213
bool dirFirst(ApplyView &view, uint256 const &root, std::shared_ptr< SLE > &page, unsigned int &index, uint256 &entry)
Definition View.cpp:123
base_uint< 256 > uint256
Definition base_uint.h:558
bool dirNext(ApplyView &view, uint256 const &root, std::shared_ptr< SLE > &page, unsigned int &index, uint256 &entry)
Definition View.cpp:134
bool isDeepFrozen(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer)
Definition View.cpp:350
std::optional< uint256 > hashOfSeq(ReadView const &ledger, LedgerIndex seq, beast::Journal journal)
Return the hash of a ledger by sequence.
Definition View.cpp:961
TER redeemIOU(ApplyView &view, AccountID const &account, STAmount const &amount, Issue const &issue, beast::Journal j)
Definition View.cpp:2365
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:64
AuthType
Definition View.h:786
void adjustOwnerCount(ApplyView &view, std::shared_ptr< SLE > const &sle, std::int32_t amount, beast::Journal j)
Adjust the owner count up or down.
Definition View.cpp:1032
std::optional< STAmount > assetsToSharesDeposit(std::shared_ptr< SLE const > const &vault, std::shared_ptr< SLE const > const &issuance, STAmount const &assets)
Definition View.cpp:2884
AuthHandling
Controls the treatment of unauthorized MPT balances.
Definition View.h:80
@ ahZERO_IF_UNAUTHORIZED
Definition View.h:80
@ ahIGNORE_AUTH
Definition View.h:80
std::function< void(SLE::ref)> describeOwnerDir(AccountID const &account)
Definition View.cpp:1050
SkipEntry
Definition View.h:44
std::optional< STAmount > assetsToSharesWithdraw(std::shared_ptr< SLE const > const &vault, std::shared_ptr< SLE const > const &issuance, STAmount const &assets, TruncateShares truncate=TruncateShares::no)
Definition View.cpp:2941
TER transferXRP(ApplyView &view, AccountID const &from, AccountID const &to, STAmount const &amount, beast::Journal j)
Definition View.cpp:2440
TER accountSend(ApplyView &view, AccountID const &from, AccountID const &to, STAmount const &saAmount, beast::Journal j, WaiveTransferFee waiveFee=WaiveTransferFee::No)
Calls static accountSendIOU if saAmount represents Issue.
Definition View.cpp:2191
bool dirIsEmpty(ReadView const &view, Keylet const &k)
Returns true if the directory is empty.
Definition View.cpp:907
TER cleanupOnAccountDelete(ApplyView &view, Keylet const &ownerDirKeylet, EntryDeleter const &deleter, beast::Journal j, std::optional< std::uint16_t > maxNodesToDelete=std::nullopt)
Cleanup owner directory entries on account delete.
bool isFrozen(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer)
Definition View.cpp:247
std::set< uint256 > getEnabledAmendments(ReadView const &view)
Definition View.cpp:921
TER rippleUnlockEscrowMPT(ApplyView &view, AccountID const &uGrantorID, AccountID const &uGranteeID, STAmount const &netAmount, STAmount const &grossAmount, beast::Journal j)
Definition View.cpp:3092
TER requireAuth(ReadView const &view, Issue const &issue, AccountID const &account, AuthType authType=AuthType::Legacy)
Check if the account lacks required authorization.
Definition View.cpp:2485
@ no
Definition Steps.h:45
@ yes
Definition Steps.h:45
std::optional< STAmount > sharesToAssetsWithdraw(std::shared_ptr< SLE const > const &vault, std::shared_ptr< SLE const > const &issuance, STAmount const &shares)
Definition View.cpp:2970
void forEachItem(ReadView const &view, Keylet const &root, std::function< void(std::shared_ptr< SLE const > const &)> const &f)
Iterate all items in the given directory.
Definition View.cpp:656
base_uint< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition UintTypes.h:56
TER canTransfer(ReadView const &view, MPTIssue const &mptIssue, AccountID const &from, AccountID const &to)
Check if the destination account is allowed to receive MPT.
Definition View.cpp:2704
Expected< std::shared_ptr< SLE >, TER > createPseudoAccount(ApplyView &view, uint256 const &pseudoOwnerKey, SField const &ownerField)
Create pseudo-account, storing pseudoOwnerKey into ownerField.
Definition View.cpp:1132
bool hasExpired(ReadView const &view, std::optional< std::uint32_t > const &exp)
Determines whether the given expiration time has passed.
Definition View.cpp:173
bool isVaultPseudoAccountFrozen(ReadView const &view, AccountID const &account, MPTIssue const &mptShare, int depth)
Definition View.cpp:307
TER issueIOU(ApplyView &view, AccountID const &account, STAmount const &amount, Issue const &issue, beast::Journal j)
Definition View.cpp:2265
bool forEachItemAfter(ReadView const &view, Keylet const &root, uint256 const &after, std::uint64_t const hint, unsigned int limit, std::function< bool(std::shared_ptr< SLE const > const &)> const &f)
Iterate all items after an item in the given directory.
Definition View.cpp:684
Rate transferRate(ReadView const &view, AccountID const &issuer)
Returns IOU issuer transfer fee as Rate.
Definition View.cpp:762
WaiveTransferFee
Definition View.h:43
TER trustDelete(ApplyView &view, std::shared_ptr< SLE > const &sleRippleState, AccountID const &uLowAccountID, AccountID const &uHighAccountID, beast::Journal j)
Definition View.cpp:1607
@ tecFROZEN
Definition TER.h:304
@ tecLOCKED
Definition TER.h:359
TER rippleCredit(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, bool bCheckIssuer, beast::Journal j)
Calls static rippleCreditIOU if saAmount represents Issue.
Definition View.cpp:2856
@ tesSUCCESS
Definition TER.h:245
TER addEmptyHolding(ApplyView &view, AccountID const &accountID, XRPAmount priorBalance, Issue const &issue, beast::Journal journal)
Any transactors that call addEmptyHolding() in doApply must call canAddHolding() in preflight with th...
Definition View.cpp:1216
AccountID pseudoAccountAddress(ReadView const &view, uint256 const &pseudoOwnerKey)
Definition View.cpp:1069
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j)
Definition View.cpp:387
bool isLPTokenFrozen(ReadView const &view, AccountID const &account, Issue const &asset, Issue const &asset2)
Definition View.cpp:376
majorityAmendments_t getMajorityAmendments(ReadView const &view)
Definition View.cpp:938
bool cdirFirst(ReadView const &view, uint256 const &root, std::shared_ptr< SLE const > &page, unsigned int &index, uint256 &entry)
Returns the first entry in the directory, advancing the index.
Definition View.cpp:145
LedgerEntryType
Identifiers for on-ledger objects.
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:3266
TER trustCreate(ApplyView &view, bool const bSrcHigh, AccountID const &uSrcAccountID, AccountID const &uDstAccountID, uint256 const &uIndex, SLE::ref sleAccount, bool const bAuth, bool const bNoRipple, bool const bFreeze, bool bDeepFreeze, STAmount const &saBalance, STAmount const &saLimit, std::uint32_t uSrcQualityIn, std::uint32_t uSrcQualityOut, beast::Journal j)
Create a trust line.
Definition View.cpp:1398
TruncateShares
Definition View.h:949
Number root(Number f, unsigned d)
Definition Number.cpp:636
TER deleteAMMTrustLine(ApplyView &view, std::shared_ptr< SLE > sleState, std::optional< AccountID > const &ammAccountID, beast::Journal j)
Delete trustline to AMM.
Definition View.cpp:2806
TER enforceMPTokenAuthorization(ApplyView &view, MPTID const &mptIssuanceID, AccountID const &account, XRPAmount const &priorBalance, beast::Journal j)
Enforce account has MPToken to match its authorization.
Definition View.cpp:2603
TER canAddHolding(ReadView const &view, Asset const &asset)
Definition View.cpp:1206
bool cdirNext(ReadView const &view, uint256 const &root, std::shared_ptr< SLE const > &page, unsigned int &index, uint256 &entry)
Returns the next entry in the directory, advancing the index.
Definition View.cpp:156
bool isAnyFrozen(ReadView const &view, std::initializer_list< AccountID > const &accounts, MPTIssue const &mptIssue, int depth=0)
Definition View.cpp:282
std::vector< SField const * > const & getPseudoAccountFields()
Definition View.cpp:1092
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)
Definition View.cpp:1290
TERSubset< CanCvtToTER > TER
Definition TER.h:649
TER removeEmptyHolding(ApplyView &view, AccountID const &accountID, Issue const &issue, beast::Journal journal)
Definition View.cpp:1517
TER offerDelete(ApplyView &view, std::shared_ptr< SLE > const &sle, beast::Journal j)
Delete an offer.
Definition View.cpp:1647
bool isPseudoAccount(std::shared_ptr< SLE const > sleAcct)
Definition View.cpp:1118
TER dirLink(ApplyView &view, AccountID const &owner, std::shared_ptr< SLE > &object)
Definition View.cpp:1058
XRPAmount xrpLiquid(ReadView const &view, AccountID const &id, std::int32_t ownerCountAdj, beast::Journal j)
Definition View.cpp:618
bool isGlobalFrozen(ReadView const &view, AccountID const &issuer)
Definition View.cpp:182
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:39
T visit(T... args)