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 ripple {
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(
49 ctx.view,
50 ctx.tx[(txFlags & tfSellNFToken) ? sfAccount : sfOwner],
51 nftokenID))
52 return tecNO_ENTRY;
53
54 // Use implementation shared with NFTokenMint
56 ctx.view,
57 ctx.tx[sfAccount],
58 nft::getIssuer(nftokenID),
59 ctx.tx[sfAmount],
60 ctx.tx[~sfDestination],
61 nft::getFlags(nftokenID),
62 nft::getTransferFee(nftokenID),
63 ctx.j,
64 ctx.tx[~sfOwner],
65 txFlags);
66}
67
68TER
70{
71 // Use implementation shared with NFTokenMint
73 view(),
74 ctx_.tx[sfAccount],
75 ctx_.tx[sfAmount],
76 ctx_.tx[~sfDestination],
77 ctx_.tx[~sfExpiration],
79 ctx_.tx[sfNFTokenID],
81 j_,
82 ctx_.tx.getFlags());
83}
84
85} // namespace ripple
static NotTEC preflight(PreflightContext const &ctx)
static TER preclaim(PreclaimContext const &ctx)
static std::uint32_t getFlagsMask(PreflightContext const &ctx)
std::uint32_t getFlags() const
Definition STObject.cpp:518
SeqProxy getSeqProxy() const
Definition STTx.cpp:197
ApplyView & view()
Definition Transactor.h:144
beast::Journal const j_
Definition Transactor.h:126
XRPAmount mPriorBalance
Definition Transactor.h:129
ApplyContext & ctx_
Definition Transactor.h:124
std::uint16_t getTransferFee(uint256 const &id)
Definition nft.h:49
std::uint16_t getFlags(uint256 const &id)
Definition nft.h:41
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.
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
AccountID getIssuer(uint256 const &id)
Definition nft.h:101
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.
std::optional< STObject > findToken(ReadView const &view, AccountID const &owner, uint256 const &nftokenID)
Finds the specified token in the owner's token directory.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
constexpr std::uint32_t const tfNFTokenCreateOfferMask
Definition TxFlags.h:212
constexpr std::uint32_t const tfSellNFToken
Definition TxFlags.h:211
bool hasExpired(ReadView const &view, std::optional< std::uint32_t > const &exp)
Determines whether the given expiration time has passed.
Definition View.cpp:154
@ tecNO_ENTRY
Definition TER.h:288
@ tecEXPIRED
Definition TER.h:296
@ tesSUCCESS
Definition TER.h:226
bool isTesSuccess(TER x) noexcept
Definition TER.h:659
State information when determining if a tx is likely to claim a fee.
Definition Transactor.h:61
ReadView const & view
Definition Transactor.h:64
beast::Journal const j
Definition Transactor.h:69
State information when preflighting a tx.
Definition Transactor.h:16