rippled
Loading...
Searching...
No Matches
LedgerStateFix.cpp
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#include <xrpld/app/tx/detail/LedgerStateFix.h>
21#include <xrpld/app/tx/detail/NFTokenUtils.h>
22
23#include <xrpl/ledger/View.h>
24#include <xrpl/protocol/Feature.h>
25#include <xrpl/protocol/Indexes.h>
26#include <xrpl/protocol/TxFlags.h>
27
28namespace ripple {
29
32{
33 switch (ctx.tx[sfLedgerFixType])
34 {
36 if (!ctx.tx.isFieldPresent(sfOwner))
37 return temINVALID;
38 break;
39
40 default:
42 }
43
44 return tesSUCCESS;
45}
46
49{
50 // The fee required for LedgerStateFix is one owner reserve, just like
51 // the fee for AccountDelete.
53}
54
55TER
57{
58 switch (ctx.tx[sfLedgerFixType])
59 {
61 AccountID const owner{ctx.tx[sfOwner]};
62 if (!ctx.view.read(keylet::account(owner)))
64
65 return tesSUCCESS;
66 }
67 }
68
69 // preflight is supposed to verify that only valid FixTypes get to preclaim.
70 return tecINTERNAL; // LCOV_EXCL_LINE
71}
72
73TER
75{
76 switch (ctx_.tx[sfLedgerFixType])
77 {
81
82 return tesSUCCESS;
83 }
84
85 // preflight is supposed to verify that only valid FixTypes get to doApply.
86 return tecINTERNAL; // LCOV_EXCL_LINE
87}
88
89} // namespace ripple
static XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
static NotTEC preflight(PreflightContext const &ctx)
static TER preclaim(PreclaimContext const &ctx)
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.
bool isFieldPresent(SField const &field) const
Definition STObject.cpp:484
ApplyView & view()
Definition Transactor.h:163
static XRPAmount calculateOwnerReserveFee(ReadView const &view, STTx const &tx)
ApplyContext & ctx_
Definition Transactor.h:143
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:184
bool repairNFTokenDirectoryLinks(ApplyView &view, AccountID const &owner)
Repairs the links in an NFTokenPage directory.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
@ tefINVALID_LEDGER_FIX_TYPE
Definition TER.h:187
@ tecOBJECT_NOT_FOUND
Definition TER.h:326
@ tecINTERNAL
Definition TER.h:310
@ tecFAILED_PROCESSING
Definition TER.h:286
@ tesSUCCESS
Definition TER.h:244
TERSubset< CanCvtToNotTEC > NotTEC
Definition TER.h:605
@ temINVALID
Definition TER.h:110
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:80
ReadView const & view
Definition Transactor.h:83
State information when preflighting a tx.
Definition Transactor.h:35