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[[nodiscard]] inline bool
565isPseudoAccount(ReadView const& view, AccountID accountId)
566{
567 return isPseudoAccount(view.read(keylet::account(accountId)));
568}
569
570[[nodiscard]] TER
572 ApplyView& view,
573 AccountID const& accountID,
574 XRPAmount priorBalance,
575 Issue const& issue,
576 beast::Journal journal);
577
578[[nodiscard]] TER
580 ApplyView& view,
581 AccountID const& accountID,
582 XRPAmount priorBalance,
583 MPTIssue const& mptIssue,
584 beast::Journal journal);
585
586[[nodiscard]] inline TER
588 ApplyView& view,
589 AccountID const& accountID,
590 XRPAmount priorBalance,
591 Asset const& asset,
592 beast::Journal journal)
593{
594 return std::visit(
595 [&]<ValidIssueType TIss>(TIss const& issue) -> TER {
596 return addEmptyHolding(
597 view, accountID, priorBalance, issue, journal);
598 },
599 asset.value());
600}
601
602[[nodiscard]] TER
604 ApplyView& view,
605 XRPAmount const& priorBalance,
606 MPTID const& mptIssuanceID,
607 AccountID const& account,
608 beast::Journal journal,
609 std::uint32_t flags = 0,
611
612// VFALCO NOTE Both STAmount parameters should just
613// be "Amount", a unit-less number.
614//
619[[nodiscard]] TER
621 ApplyView& view,
622 bool const bSrcHigh,
623 AccountID const& uSrcAccountID,
624 AccountID const& uDstAccountID,
625 uint256 const& uIndex, // --> ripple state entry
626 SLE::ref sleAccount, // --> the account being set.
627 bool const bAuth, // --> authorize account.
628 bool const bNoRipple, // --> others cannot ripple through
629 bool const bFreeze, // --> funds cannot leave
630 bool bDeepFreeze, // --> can neither receive nor send funds
631 STAmount const& saBalance, // --> balance of account being set.
632 // Issuer should be noAccount()
633 STAmount const& saLimit, // --> limit for account being set.
634 // Issuer should be the account being set.
635 std::uint32_t uSrcQualityIn,
636 std::uint32_t uSrcQualityOut,
638
639[[nodiscard]] TER
641 ApplyView& view,
642 AccountID const& accountID,
643 Issue const& issue,
644 beast::Journal journal);
645
646[[nodiscard]] TER
648 ApplyView& view,
649 AccountID const& accountID,
650 MPTIssue const& mptIssue,
651 beast::Journal journal);
652
653[[nodiscard]] inline TER
655 ApplyView& view,
656 AccountID const& accountID,
657 Asset const& asset,
658 beast::Journal journal)
659{
660 return std::visit(
661 [&]<ValidIssueType TIss>(TIss const& issue) -> TER {
662 return removeEmptyHolding(view, accountID, issue, journal);
663 },
664 asset.value());
665}
666
667[[nodiscard]] TER
669 ApplyView& view,
670 std::shared_ptr<SLE> const& sleRippleState,
671 AccountID const& uLowAccountID,
672 AccountID const& uHighAccountID,
674
681// [[nodiscard]] // nodiscard commented out so Flow, BookTip and others compile.
682TER
683offerDelete(ApplyView& view, std::shared_ptr<SLE> const& sle, beast::Journal j);
684
685//------------------------------------------------------------------------------
686
687//
688// Money Transfers
689//
690
691// Direct send w/o fees:
692// - Redeeming IOUs and/or sending sender's own IOUs.
693// - Create trust line of needed.
694// --> bCheckIssuer : normally require issuer to be involved.
695// [[nodiscard]] // nodiscard commented out so DirectStep.cpp compiles.
696
700TER
702 ApplyView& view,
703 AccountID const& uSenderID,
704 AccountID const& uReceiverID,
705 STAmount const& saAmount,
706 bool bCheckIssuer,
708
709TER
711 ApplyView& view,
712 AccountID const& uGrantorID,
713 STAmount const& saAmount,
715
716TER
718 ApplyView& view,
719 AccountID const& uGrantorID,
720 AccountID const& uGranteeID,
721 STAmount const& netAmount,
722 STAmount const& grossAmount,
724
728[[nodiscard]] TER
730 ApplyView& view,
731 AccountID const& from,
732 AccountID const& to,
733 STAmount const& saAmount,
736
737[[nodiscard]] TER
739 ApplyView& view,
740 AccountID const& account,
741 STAmount const& amount,
742 Issue const& issue,
744
745[[nodiscard]] TER
747 ApplyView& view,
748 AccountID const& account,
749 STAmount const& amount,
750 Issue const& issue,
752
753[[nodiscard]] TER
755 ApplyView& view,
756 AccountID const& from,
757 AccountID const& to,
758 STAmount const& amount,
760
761/* Check if MPToken (for MPT) or trust line (for IOU) exists:
762 * - StrongAuth - before checking if authorization is required
763 * - WeakAuth
764 * for MPT - after checking lsfMPTRequireAuth flag
765 * for IOU - do not check if trust line exists
766 * - Legacy
767 * for MPT - before checking lsfMPTRequireAuth flag i.e. same as StrongAuth
768 * for IOU - do not check if trust line exists i.e. same as WeakAuth
769 */
771
789[[nodiscard]] TER
791 ReadView const& view,
792 Issue const& issue,
793 AccountID const& account,
794 AuthType authType = AuthType::Legacy);
795
818[[nodiscard]] TER
820 ReadView const& view,
821 MPTIssue const& mptIssue,
822 AccountID const& account,
823 AuthType authType = AuthType::Legacy,
824 int depth = 0);
825
826[[nodiscard]] TER inline requireAuth(
827 ReadView const& view,
828 Asset const& asset,
829 AccountID const& account,
830 AuthType authType = AuthType::Legacy)
831{
832 return std::visit(
833 [&]<ValidIssueType TIss>(TIss const& issue_) {
834 return requireAuth(view, issue_, account, authType);
835 },
836 asset.value());
837}
838
862[[nodiscard]] TER
864 ApplyView& view,
865 MPTID const& mptIssuanceID,
866 AccountID const& account,
867 XRPAmount const& priorBalance,
869
874[[nodiscard]] TER
876 ReadView const& view,
877 MPTIssue const& mptIssue,
878 AccountID const& from,
879 AccountID const& to);
880
887 uint256 const&,
896[[nodiscard]] TER
898 ApplyView& view,
899 Keylet const& ownerDirKeylet,
900 EntryDeleter const& deleter,
902 std::optional<std::uint16_t> maxNodesToDelete = std::nullopt);
903
908[[nodiscard]] TER
910 ApplyView& view,
911 std::shared_ptr<SLE> sleState,
912 std::optional<AccountID> const& ammAccountID,
914
915// From the perspective of a vault, return the number of shares to give the
916// depositor when they deposit a fixed amount of assets. Since shares are MPT
917// this number is integral and always truncated in this calculation.
918[[nodiscard]] std::optional<STAmount>
920 std::shared_ptr<SLE const> const& vault,
921 std::shared_ptr<SLE const> const& issuance,
922 STAmount const& assets);
923
924// From the perspective of a vault, return the number of assets to take from
925// depositor when they receive a fixed amount of shares. Note, since shares are
926// MPT, they are always an integral number.
927[[nodiscard]] std::optional<STAmount>
929 std::shared_ptr<SLE const> const& vault,
930 std::shared_ptr<SLE const> const& issuance,
931 STAmount const& shares);
932
933enum class TruncateShares : bool { no = false, yes = true };
934
935// From the perspective of a vault, return the number of shares to demand from
936// the depositor when they ask to withdraw a fixed amount of assets. Since
937// shares are MPT this number is integral, and it will be rounded to nearest
938// unless explicitly requested to be truncated instead.
939[[nodiscard]] std::optional<STAmount>
941 std::shared_ptr<SLE const> const& vault,
942 std::shared_ptr<SLE const> const& issuance,
943 STAmount const& assets,
945
946// From the perspective of a vault, return the number of assets to give the
947// depositor when they redeem a fixed amount of shares. Note, since shares are
948// MPT, they are always an integral number.
949[[nodiscard]] std::optional<STAmount>
951 std::shared_ptr<SLE const> const& vault,
952 std::shared_ptr<SLE const> const& issuance,
953 STAmount const& shares);
954
961bool
963
964} // namespace ripple
965
966#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:137
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:551
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:796
TER rippleLockEscrowMPT(ApplyView &view, AccountID const &uGrantorID, STAmount const &saAmount, beast::Journal j)
Definition View.cpp:2907
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:2824
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:347
std::optional< uint256 > hashOfSeq(ReadView const &ledger, LedgerIndex seq, beast::Journal journal)
Return the hash of a ledger by sequence.
Definition View.cpp:958
TER redeemIOU(ApplyView &view, AccountID const &account, STAmount const &amount, Issue const &issue, beast::Journal j)
Definition View.cpp:2287
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:770
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:1029
std::optional< STAmount > assetsToSharesDeposit(std::shared_ptr< SLE const > const &vault, std::shared_ptr< SLE const > const &issuance, STAmount const &assets)
Definition View.cpp:2796
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:1047
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:2853
TER transferXRP(ApplyView &view, AccountID const &from, AccountID const &to, STAmount const &amount, beast::Journal j)
Definition View.cpp:2360
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:2113
bool dirIsEmpty(ReadView const &view, Keylet const &k)
Returns true if the directory is empty.
Definition View.cpp:904
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:918
TER rippleUnlockEscrowMPT(ApplyView &view, AccountID const &uGrantorID, AccountID const &uGranteeID, STAmount const &netAmount, STAmount const &grossAmount, beast::Journal j)
Definition View.cpp:3004
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:2403
@ 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:2882
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:653
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:2621
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:1093
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:2187
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:681
Rate transferRate(ReadView const &view, AccountID const &issuer)
Returns IOU issuer transfer fee as Rate.
Definition View.cpp:759
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:1533
@ tecFROZEN
Definition TER.h:303
@ tecLOCKED
Definition TER.h:358
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:2768
@ tesSUCCESS
Definition TER.h:244
TER addEmptyHolding(ApplyView &view, AccountID const &accountID, XRPAmount priorBalance, Issue const &issue, beast::Journal journal)
Definition View.cpp:1152
AccountID pseudoAccountAddress(ReadView const &view, uint256 const &pseudoOwnerKey)
Definition View.cpp:1066
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const &currency, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j)
Definition View.cpp:384
bool isLPTokenFrozen(ReadView const &view, AccountID const &account, Issue const &asset, Issue const &asset2)
Definition View.cpp:373
majorityAmendments_t getMajorityAmendments(ReadView const &view)
Definition View.cpp:935
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:3178
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:1328
TruncateShares
Definition View.h:933
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:2719
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:2521
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
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:1220
TERSubset< CanCvtToTER > TER
Definition TER.h:645
TER removeEmptyHolding(ApplyView &view, AccountID const &accountID, Issue const &issue, beast::Journal journal)
Definition View.cpp:1447
TER offerDelete(ApplyView &view, std::shared_ptr< SLE > const &sle, beast::Journal j)
Delete an offer.
Definition View.cpp:1573
bool isPseudoAccount(std::shared_ptr< SLE const > sleAcct)
Definition View.cpp:1138
TER dirLink(ApplyView &view, AccountID const &owner, std::shared_ptr< SLE > &object)
Definition View.cpp:1055
XRPAmount xrpLiquid(ReadView const &view, AccountID const &id, std::int32_t ownerCountAdj, beast::Journal j)
Definition View.cpp:615
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)