20#include <xrpld/app/tx/detail/NFTokenMint.h>
22#include <xrpl/basics/Expected.h>
23#include <xrpl/ledger/View.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>
29#include <boost/endian/conversion.hpp>
51 if (!ctx.
rules.
enabled(featureNFTokenMintOffer) && hasOfferFields)
82 if (
auto const f = ctx.
tx[~sfTransferFee])
94 if (
auto iss = ctx.
tx[~sfIssuer]; iss == ctx.
tx[sfAccount])
97 if (
auto uri = ctx.
tx[~sfURI])
116 ctx.
tx[~sfDestination],
117 ctx.
tx[~sfExpiration],
145 flags = boost::endian::native_to_big(flags);
146 fee = boost::endian::native_to_big(fee);
148 tokenSeq = boost::endian::native_to_big(tokenSeq);
152 auto ptr = buf.
data();
157 ptr +=
sizeof(flags);
163 ptr += issuer.
size();
166 ptr +=
sizeof(taxon);
169 ptr +=
sizeof(tokenSeq);
172 "ripple::NFTokenMint::createNFTokenID : data size matches the buffer");
182 if (
auto issuer = ctx.
tx[~sfIssuer])
189 if (
auto const minter = (*sle)[~sfNFTokenMinter];
190 minter != ctx.
tx[sfAccount])
206 ctx.
tx[~sfIssuer].value_or(ctx.
tx[sfAccount]),
208 ctx.
tx[~sfDestination],
210 ctx.
tx[~sfTransferFee].value_or(0),
233 (*root)[~sfMintedNFTokens].value_or(0);
236 if (nextTokenSeq < tokenSeq)
239 (*root)[sfMintedNFTokens] = nextTokenSeq;
262 if (!
root->isFieldPresent(sfFirstNFTokenSequence))
266 root->at(sfFirstNFTokenSequence) =
274 (*root)[~sfMintedNFTokens].value_or(0u);
276 (*root)[sfMintedNFTokens] = mintedNftCnt + 1u;
277 if ((*
root)[sfMintedNFTokens] == 0u)
282 std::uint32_t const offset = (*root)[sfFirstNFTokenSequence];
286 if (tokenSeq + 1u == 0u || tokenSeq < offset)
293 if (!tokenSeq.has_value())
294 return (tokenSeq.error());
303 if (nfTokenTemplate ==
nullptr)
309 ctx_.
tx[~sfTransferFee].value_or(0),
315 *nfTokenTemplate, sfNFToken, [
this, &nftokenID](
STObject&
object) {
316 object.setFieldH256(sfNFTokenID, nftokenID);
318 if (
auto const uri =
ctx_.
tx[~sfURI])
319 object.setFieldVL(sfURI, *uri);
350 if (
auto const ownerCountAfter =
352 ownerCountAfter > ownerCountBefore)
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 Fees const & fees() const =0
Returns the fees for the base ledger.
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.
bool hasExpired(ReadView const &view, std::optional< std::uint32_t > const &exp)
Determines whether the given expiration time has passed.
std::size_t constexpr maxTokenURILength
The maximum length of a URI inside an NFT.
@ tecMAX_SEQUENCE_REACHED
@ tecINSUFFICIENT_RESERVE
bool isTesSuccess(TER x) noexcept
Number root(Number f, unsigned d)
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
XRPAmount accountReserve(std::size_t ownerCount) const
Returns the account reserve given the owner count, in drops.
State information when determining if a tx is likely to claim a fee.
State information when preflighting a tx.