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#include <xrpld/ledger/View.h>
23
24#include <xrpl/protocol/Feature.h>
25#include <xrpl/protocol/Indexes.h>
26#include <xrpl/protocol/TxFlags.h>
27
28namespace ripple {
29
32{
33 if (!ctx.rules.enabled(fixNFTokenPageLinks))
34 return temDISABLED;
35
36 if (ctx.tx.getFlags() & tfUniversalMask)
37 return temINVALID_FLAG;
38
39 if (auto const ret = preflight1(ctx); !isTesSuccess(ret))
40 return ret;
41
42 switch (ctx.tx[sfLedgerFixType])
43 {
45 if (!ctx.tx.isFieldPresent(sfOwner))
46 return temINVALID;
47 break;
48
49 default:
51 }
52
53 return preflight2(ctx);
54}
55
58{
59 // The fee required for LedgerStateFix is one owner reserve, just like
60 // the fee for AccountDelete.
61 return view.fees().increment;
62}
63
64TER
66{
67 switch (ctx.tx[sfLedgerFixType])
68 {
70 AccountID const owner{ctx.tx[sfOwner]};
71 if (!ctx.view.read(keylet::account(owner)))
73
74 return tesSUCCESS;
75 }
76 }
77
78 // preflight is supposed to verify that only valid FixTypes get to preclaim.
79 return tecINTERNAL;
80}
81
82TER
84{
85 switch (ctx_.tx[sfLedgerFixType])
86 {
90
91 return tesSUCCESS;
92 }
93
94 // preflight is supposed to verify that only valid FixTypes get to doApply.
95 return tecINTERNAL;
96}
97
98} // 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:52
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
virtual Fees const & fees() const =0
Returns the fees for the base ledger.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
Definition: Rules.cpp:130
bool isFieldPresent(SField const &field) const
Definition: STObject.cpp:484
std::uint32_t getFlags() const
Definition: STObject.cpp:537
ApplyView & view()
Definition: Transactor.h:159
ApplyContext & ctx_
Definition: Transactor.h:140
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
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
Definition: Transactor.cpp:91
@ tefINVALID_LEDGER_FIX_TYPE
Definition: TER.h:187
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
Definition: Transactor.cpp:160
@ tecOBJECT_NOT_FOUND
Definition: TER.h:326
@ tecINTERNAL
Definition: TER.h:310
@ tecFAILED_PROCESSING
Definition: TER.h:286
@ tesSUCCESS
Definition: TER.h:244
bool isTesSuccess(TER x) noexcept
Definition: TER.h:674
constexpr std::uint32_t tfUniversalMask
Definition: TxFlags.h:63
TERSubset< CanCvtToNotTEC > NotTEC
Definition: TER.h:605
@ temINVALID
Definition: TER.h:110
@ temINVALID_FLAG
Definition: TER.h:111
@ temDISABLED
Definition: TER.h:114
XRPAmount increment
Definition: protocol/Fees.h:36
State information when determining if a tx is likely to claim a fee.
Definition: Transactor.h:79
ReadView const & view
Definition: Transactor.h:82
State information when preflighting a tx.
Definition: Transactor.h:34