rippled
Loading...
Searching...
No Matches
PermissionedDomainDelete.cpp
1#include <xrpld/app/tx/detail/PermissionedDomainDelete.h>
2
3#include <xrpl/ledger/View.h>
4#include <xrpl/protocol/TxFlags.h>
5
6namespace ripple {
7
10{
11 auto const domain = ctx.tx.getFieldH256(sfDomainID);
12 if (domain == beast::zero)
13 return temMALFORMED;
14
15 return tesSUCCESS;
16}
17
18TER
20{
21 auto const domain = ctx.tx.getFieldH256(sfDomainID);
22 auto const sleDomain = ctx.view.read({ltPERMISSIONED_DOMAIN, domain});
23
24 if (!sleDomain)
25 return tecNO_ENTRY;
26
27 XRPL_ASSERT(
28 sleDomain->isFieldPresent(sfOwner) && ctx.tx.isFieldPresent(sfAccount),
29 "ripple::PermissionedDomainDelete::preclaim : required fields present");
30 if (sleDomain->getAccountID(sfOwner) != ctx.tx.getAccountID(sfAccount))
31 return tecNO_PERMISSION;
32
33 return tesSUCCESS;
34}
35
37TER
39{
40 XRPL_ASSERT(
41 ctx_.tx.isFieldPresent(sfDomainID),
42 "ripple::PermissionedDomainDelete::doApply : required field present");
43
44 auto const slePd =
45 view().peek({ltPERMISSIONED_DOMAIN, ctx_.tx.at(sfDomainID)});
46 auto const page = (*slePd)[sfOwnerNode];
47
48 if (!view().dirRemove(keylet::ownerDir(account_), page, slePd->key(), true))
49 {
50 // LCOV_EXCL_START
51 JLOG(j_.fatal())
52 << "Unable to delete permissioned domain directory entry.";
53 return tefBAD_LEDGER;
54 // LCOV_EXCL_STOP
55 }
56
57 auto const ownerSle = view().peek(keylet::account(account_));
58 XRPL_ASSERT(
59 ownerSle && ownerSle->getFieldU32(sfOwnerCount) > 0,
60 "ripple::PermissionedDomainDelete::doApply : nonzero owner count");
61 adjustOwnerCount(view(), ownerSle, -1, ctx_.journal);
62 view().erase(slePd);
63
64 return tesSUCCESS;
65}
66
67} // namespace ripple
Stream fatal() const
Definition Journal.h:333
beast::Journal const journal
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
virtual void erase(std::shared_ptr< SLE > const &sle)=0
Remove a peeked SLE.
TER doApply() override
Attempt to delete the Permissioned Domain.
static TER preclaim(PreclaimContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
AccountID getAccountID(SField const &field) const
Definition STObject.cpp:638
T::value_type at(TypedField< T > const &f) const
Get the value of a field.
Definition STObject.h:1028
bool isFieldPresent(SField const &field) const
Definition STObject.cpp:465
uint256 getFieldH256(SField const &field) const
Definition STObject.cpp:626
AccountID const account_
Definition Transactor.h:128
ApplyView & view()
Definition Transactor.h:144
beast::Journal const j_
Definition Transactor.h:126
ApplyContext & ctx_
Definition Transactor.h:124
Keylet account(AccountID const &id) noexcept
AccountID root.
Definition Indexes.cpp:165
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Definition Indexes.cpp:355
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
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:1013
@ tefBAD_LEDGER
Definition TER.h:151
@ tecNO_ENTRY
Definition TER.h:288
@ tecNO_PERMISSION
Definition TER.h:287
@ tesSUCCESS
Definition TER.h:226
TERSubset< CanCvtToNotTEC > NotTEC
Definition TER.h:590
@ temMALFORMED
Definition TER.h:68
uint256 key
Definition Keylet.h:21
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:61
ReadView const & view
Definition Transactor.h:64
State information when preflighting a tx.
Definition Transactor.h:16