rippled
Loading...
Searching...
No Matches
NFTokenCreateOffer.cpp
1#include <xrpld/app/tx/detail/NFTokenCreateOffer.h>
2#include <xrpld/app/tx/detail/NFTokenUtils.h>
3
4#include <xrpl/ledger/View.h>
5#include <xrpl/protocol/Feature.h>
6#include <xrpl/protocol/TxFlags.h>
7
8namespace xrpl {
9
15
18{
19 auto const txFlags = ctx.tx.getFlags();
20
21 auto const nftFlags = nft::getFlags(ctx.tx[sfNFTokenID]);
22
23 // Use implementation shared with NFTokenMint
25 ctx.tx[sfAccount],
26 ctx.tx[sfAmount],
27 ctx.tx[~sfDestination],
28 ctx.tx[~sfExpiration],
29 nftFlags,
30 ctx.rules,
31 ctx.tx[~sfOwner],
32 txFlags);
33 !isTesSuccess(notTec))
34 return notTec;
35
36 return tesSUCCESS;
37}
38
39TER
41{
42 if (hasExpired(ctx.view, ctx.tx[~sfExpiration]))
43 return tecEXPIRED;
44
45 uint256 const nftokenID = ctx.tx[sfNFTokenID];
46 std::uint32_t const txFlags = {ctx.tx.getFlags()};
47
48 if (!nft::findToken(ctx.view, ctx.tx[(txFlags & tfSellNFToken) ? sfAccount : sfOwner], nftokenID))
49 return tecNO_ENTRY;
50
51 // Use implementation shared with NFTokenMint
53 ctx.view,
54 ctx.tx[sfAccount],
55 nft::getIssuer(nftokenID),
56 ctx.tx[sfAmount],
57 ctx.tx[~sfDestination],
58 nft::getFlags(nftokenID),
59 nft::getTransferFee(nftokenID),
60 ctx.j,
61 ctx.tx[~sfOwner],
62 txFlags);
63}
64
65TER
67{
68 // Use implementation shared with NFTokenMint
70 view(),
71 ctx_.tx[sfAccount],
72 ctx_.tx[sfAmount],
73 ctx_.tx[~sfDestination],
74 ctx_.tx[~sfExpiration],
76 ctx_.tx[sfNFTokenID],
78 j_,
79 ctx_.tx.getFlags());
80}
81
82} // namespace xrpl
STTx const & tx
static std::uint32_t getFlagsMask(PreflightContext const &ctx)
static TER preclaim(PreclaimContext const &ctx)
static NotTEC preflight(PreflightContext const &ctx)
std::uint32_t getFlags() const
Definition STObject.cpp:492
SeqProxy getSeqProxy() const
Definition STTx.cpp:193
beast::Journal const j_
Definition Transactor.h:110
ApplyView & view()
Definition Transactor.h:128
XRPAmount mPriorBalance
Definition Transactor.h:113
ApplyContext & ctx_
Definition Transactor.h:108
TER tokenOfferCreatePreclaim(ReadView const &view, AccountID const &acctID, AccountID const &nftIssuer, STAmount const &amount, std::optional< AccountID > const &dest, std::uint16_t nftFlags, std::uint16_t xferFee, beast::Journal j, std::optional< AccountID > const &owner, std::uint32_t txFlags)
Preclaim checks shared by NFTokenCreateOffer and NFTokenMint.
TER tokenOfferCreateApply(ApplyView &view, AccountID const &acctID, STAmount const &amount, std::optional< AccountID > const &dest, std::optional< std::uint32_t > const &expiration, SeqProxy seqProxy, uint256 const &nftokenID, XRPAmount const &priorBalance, beast::Journal j, std::uint32_t txFlags)
doApply implementation shared by NFTokenCreateOffer and NFTokenMint
std::optional< STObject > findToken(ReadView const &view, AccountID const &owner, uint256 const &nftokenID)
Finds the specified token in the owner's token directory.
AccountID getIssuer(uint256 const &id)
Definition nft.h:100
std::uint16_t getTransferFee(uint256 const &id)
Definition nft.h:48
NotTEC tokenOfferCreatePreflight(AccountID const &acctID, STAmount const &amount, std::optional< AccountID > const &dest, std::optional< std::uint32_t > const &expiration, std::uint16_t nftFlags, Rules const &rules, std::optional< AccountID > const &owner, std::uint32_t txFlags)
Preflight checks shared by NFTokenCreateOffer and NFTokenMint.
std::uint16_t getFlags(uint256 const &id)
Definition nft.h:40
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
bool hasExpired(ReadView const &view, std::optional< std::uint32_t > const &exp)
Determines whether the given expiration time has passed.
Definition View.cpp:129
constexpr std::uint32_t const tfNFTokenCreateOfferMask
Definition TxFlags.h:211
bool isTesSuccess(TER x) noexcept
Definition TER.h:649
@ tecNO_ENTRY
Definition TER.h:287
@ tecEXPIRED
Definition TER.h:295
constexpr std::uint32_t const tfSellNFToken
Definition TxFlags.h:210
@ tesSUCCESS
Definition TER.h:225
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:53
ReadView const & view
Definition Transactor.h:56
beast::Journal const j
Definition Transactor.h:61
State information when preflighting a tx.
Definition Transactor.h:15