rippled
Loading...
Searching...
No Matches
xrpld
app
tx
detail
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
28
namespace
ripple
{
29
30
NotTEC
31
LedgerStateFix::preflight
(
PreflightContext
const
& ctx)
32
{
33
switch
(ctx.
tx
[sfLedgerFixType])
34
{
35
case
FixType::nfTokenPageLink
:
36
if
(!ctx.
tx
.
isFieldPresent
(sfOwner))
37
return
temINVALID
;
38
break
;
39
40
default
:
41
return
tefINVALID_LEDGER_FIX_TYPE
;
42
}
43
44
return
tesSUCCESS
;
45
}
46
47
XRPAmount
48
LedgerStateFix::calculateBaseFee
(
ReadView
const
& view,
STTx
const
& tx)
49
{
50
// The fee required for LedgerStateFix is one owner reserve, just like
51
// the fee for AccountDelete.
52
return
calculateOwnerReserveFee
(
view
, tx);
53
}
54
55
TER
56
LedgerStateFix::preclaim
(
PreclaimContext
const
& ctx)
57
{
58
switch
(ctx.
tx
[sfLedgerFixType])
59
{
60
case
FixType::nfTokenPageLink
: {
61
AccountID
const
owner{ctx.
tx
[sfOwner]};
62
if
(!ctx.
view
.
read
(
keylet::account
(owner)))
63
return
tecOBJECT_NOT_FOUND
;
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
73
TER
74
LedgerStateFix::doApply
()
75
{
76
switch
(
ctx_
.
tx
[sfLedgerFixType])
77
{
78
case
FixType::nfTokenPageLink
:
79
if
(!
nft::repairNFTokenDirectoryLinks
(
view
(),
ctx_
.
tx
[sfOwner]))
80
return
tecFAILED_PROCESSING
;
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
ripple::ApplyContext::tx
STTx const & tx
Definition
ApplyContext.h:72
ripple::LedgerStateFix::calculateBaseFee
static XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
Definition
LedgerStateFix.cpp:48
ripple::LedgerStateFix::preflight
static NotTEC preflight(PreflightContext const &ctx)
Definition
LedgerStateFix.cpp:31
ripple::LedgerStateFix::preclaim
static TER preclaim(PreclaimContext const &ctx)
Definition
LedgerStateFix.cpp:56
ripple::LedgerStateFix::doApply
TER doApply() override
Definition
LedgerStateFix.cpp:74
ripple::LedgerStateFix::nfTokenPageLink
@ nfTokenPageLink
Definition
LedgerStateFix.h:31
ripple::ReadView
A view into a ledger.
Definition
ReadView.h:51
ripple::ReadView::read
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
ripple::STObject::isFieldPresent
bool isFieldPresent(SField const &field) const
Definition
STObject.cpp:484
ripple::STTx
Definition
STTx.h:48
ripple::TERSubset< CanCvtToTER >
ripple::Transactor::view
ApplyView & view()
Definition
Transactor.h:163
ripple::Transactor::calculateOwnerReserveFee
static XRPAmount calculateOwnerReserveFee(ReadView const &view, STTx const &tx)
Definition
Transactor.cpp:312
ripple::Transactor::ctx_
ApplyContext & ctx_
Definition
Transactor.h:143
ripple::XRPAmount
Definition
XRPAmount.h:43
ripple::base_uint< 160, detail::AccountIDTag >
ripple::keylet::account
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition
Indexes.cpp:184
ripple::nft::repairNFTokenDirectoryLinks
bool repairNFTokenDirectoryLinks(ApplyView &view, AccountID const &owner)
Repairs the links in an NFTokenPage directory.
Definition
NFTokenUtils.cpp:717
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:25
ripple::tefINVALID_LEDGER_FIX_TYPE
@ tefINVALID_LEDGER_FIX_TYPE
Definition
TER.h:187
ripple::tecOBJECT_NOT_FOUND
@ tecOBJECT_NOT_FOUND
Definition
TER.h:326
ripple::tecINTERNAL
@ tecINTERNAL
Definition
TER.h:310
ripple::tecFAILED_PROCESSING
@ tecFAILED_PROCESSING
Definition
TER.h:286
ripple::tesSUCCESS
@ tesSUCCESS
Definition
TER.h:244
ripple::NotTEC
TERSubset< CanCvtToNotTEC > NotTEC
Definition
TER.h:605
ripple::temINVALID
@ temINVALID
Definition
TER.h:110
ripple::PreclaimContext
State information when determining if a tx is likely to claim a fee.
Definition
Transactor.h:80
ripple::PreclaimContext::view
ReadView const & view
Definition
Transactor.h:83
ripple::PreclaimContext::tx
STTx const & tx
Definition
Transactor.h:86
ripple::PreflightContext
State information when preflighting a tx.
Definition
Transactor.h:35
ripple::PreflightContext::tx
STTx const & tx
Definition
Transactor.h:38
Generated by
1.9.8