20#include <xrpld/app/tx/detail/NFTokenMint.h>
21#include <xrpld/ledger/View.h>
22#include <xrpl/basics/Expected.h>
23#include <xrpl/basics/Log.h>
24#include <xrpl/protocol/Feature.h>
25#include <xrpl/protocol/InnerObjectFormats.h>
26#include <xrpl/protocol/Rate.h>
27#include <xrpl/protocol/TxFlags.h>
28#include <xrpl/protocol/st.h>
29#include <boost/endian/conversion.hpp>
50 if (!ctx.
rules.
enabled(featureNFTokenMintOffer) && hasOfferFields)
81 if (
auto const f = ctx.
tx[~sfTransferFee])
93 if (
auto iss = ctx.
tx[~sfIssuer]; iss == ctx.
tx[sfAccount])
96 if (
auto uri = ctx.
tx[~sfURI])
115 ctx.
tx[~sfDestination],
116 ctx.
tx[~sfExpiration],
144 flags = boost::endian::native_to_big(flags);
145 fee = boost::endian::native_to_big(fee);
147 tokenSeq = boost::endian::native_to_big(tokenSeq);
151 auto ptr = buf.
data();
156 ptr +=
sizeof(flags);
162 ptr += issuer.
size();
165 ptr +=
sizeof(taxon);
168 ptr +=
sizeof(tokenSeq);
171 "ripple::NFTokenMint::createNFTokenID : data size matches the buffer");
181 if (
auto issuer = ctx.
tx[~sfIssuer])
188 if (
auto const minter = (*sle)[~sfNFTokenMinter];
189 minter != ctx.
tx[sfAccount])
205 ctx.
tx[~sfIssuer].value_or(ctx.
tx[sfAccount]),
207 ctx.
tx[~sfDestination],
209 ctx.
tx[~sfTransferFee].value_or(0),
232 (*root)[~sfMintedNFTokens].value_or(0);
235 if (nextTokenSeq < tokenSeq)
238 (*root)[sfMintedNFTokens] = nextTokenSeq;
261 if (!
root->isFieldPresent(sfFirstNFTokenSequence))
265 root->at(sfFirstNFTokenSequence) =
273 (*root)[~sfMintedNFTokens].value_or(0u);
275 (*root)[sfMintedNFTokens] = mintedNftCnt + 1u;
276 if ((*
root)[sfMintedNFTokens] == 0u)
281 std::uint32_t const offset = (*root)[sfFirstNFTokenSequence];
285 if (tokenSeq + 1u == 0u || tokenSeq < offset)
292 if (!tokenSeq.has_value())
293 return (tokenSeq.error());
302 if (nfTokenTemplate ==
nullptr)
308 ctx_.
tx[~sfTransferFee].value_or(0),
314 *nfTokenTemplate, sfNFToken, [
this, &nftokenID](
STObject&
object) {
315 object.setFieldH256(sfNFTokenID, nftokenID);
317 if (
auto const uri =
ctx_.
tx[~sfURI])
318 object.setFieldVL(sfURI, *uri);
349 if (
auto const ownerCountAfter =
351 ownerCountAfter > ownerCountBefore)
353 if (
auto const reserve =
view().fees().accountReserve(ownerCountAfter);
virtual void update(std::shared_ptr< SLE > const &sle)=0
Indicate changes to a peeked SLE.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
static NotTEC preflight(PreflightContext const &ctx)
static uint256 createNFTokenID(std::uint16_t flags, std::uint16_t fee, AccountID const &issuer, nft::Taxon taxon, std::uint32_t tokenSeq)
static TER preclaim(PreclaimContext const &ctx)
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
virtual Rules const & rules() const =0
Returns the tx processing rules.
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
Defines the fields and their attributes within a STObject.
bool isFlag(std::uint32_t) const
bool isFieldPresent(SField const &field) const
std::uint32_t getFlags() const
SeqProxy getSeqProxy() const
constexpr bool isTicket() const
static base_uint fromVoid(void const *data)
static constexpr std::size_t size()
A type-safe wrap around standard integral types.
Keylet account(AccountID const &id) noexcept
AccountID root.
std::uint32_t toUInt32(Taxon t)
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
Taxon cipheredTaxon(std::uint32_t tokenSeq, Taxon taxon)
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 insertToken(ApplyView &view, AccountID owner, STObject &&nft)
Insert the token in the owner's token directory.
Taxon toTaxon(std::uint32_t i)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
constexpr std::uint32_t const tfNFTokenMintOldMaskWithMutable
constexpr std::uint32_t const tfNFTokenMintMaskWithMutable
constexpr std::uint32_t const tfNFTokenMintOldMask
std::uint16_t constexpr maxTransferFee
The maximum token transfer fee allowed.
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
std::size_t constexpr maxTokenURILength
The maximum length of a URI inside an NFT.
@ tecMAX_SEQUENCE_REACHED
@ tecINSUFFICIENT_RESERVE
Number root(Number f, unsigned d)
bool hasExpired(ReadView const &view, std::optional< std::uint32_t > const &exp)
Determines whether the given expiration time has passed.
static std::uint16_t extractNFTokenFlagsFromTxFlags(std::uint32_t txFlags)
constexpr std::uint32_t const tfTransferable
constexpr std::uint32_t const tfNFTokenMintMask
TERSubset< CanCvtToNotTEC > NotTEC
@ temBAD_NFTOKEN_TRANSFER_FEE
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.