1#include <xrpld/app/tx/detail/NFTokenMint.h>
3#include <xrpl/basics/Expected.h>
4#include <xrpl/ledger/View.h>
5#include <xrpl/protocol/Feature.h>
6#include <xrpl/protocol/InnerObjectFormats.h>
7#include <xrpl/protocol/Rate.h>
8#include <xrpl/protocol/TxFlags.h>
10#include <boost/endian/conversion.hpp>
61 return nfTokenMintMask;
67 if (
auto const f = ctx.
tx[~sfTransferFee])
79 if (
auto iss = ctx.
tx[~sfIssuer]; iss == ctx.
tx[sfAccount])
82 if (
auto uri = ctx.
tx[~sfURI])
101 ctx.
tx[~sfDestination],
102 ctx.
tx[~sfExpiration],
130 flags = boost::endian::native_to_big(flags);
131 fee = boost::endian::native_to_big(fee);
133 tokenSeq = boost::endian::native_to_big(tokenSeq);
137 auto ptr = buf.
data();
142 ptr +=
sizeof(flags);
148 ptr += issuer.
size();
151 ptr +=
sizeof(taxon);
154 ptr +=
sizeof(tokenSeq);
157 "ripple::NFTokenMint::createNFTokenID : data size matches the buffer");
167 if (
auto issuer = ctx.
tx[~sfIssuer])
174 if (
auto const minter = (*sle)[~sfNFTokenMinter];
175 minter != ctx.
tx[sfAccount])
191 ctx.
tx[~sfIssuer].value_or(ctx.
tx[sfAccount]),
193 ctx.
tx[~sfDestination],
195 ctx.
tx[~sfTransferFee].value_or(0),
229 if (!
root->isFieldPresent(sfFirstNFTokenSequence))
233 root->at(sfFirstNFTokenSequence) =
241 (*root)[~sfMintedNFTokens].value_or(0u);
243 (*root)[sfMintedNFTokens] = mintedNftCnt + 1u;
244 if ((*
root)[sfMintedNFTokens] == 0u)
249 std::uint32_t const offset = (*root)[sfFirstNFTokenSequence];
253 if (tokenSeq + 1u == 0u || tokenSeq < offset)
260 if (!tokenSeq.has_value())
261 return (tokenSeq.error());
270 if (nfTokenTemplate ==
nullptr)
276 ctx_.
tx[~sfTransferFee].value_or(0),
282 *nfTokenTemplate, sfNFToken, [
this, &nftokenID](
STObject&
object) {
283 object.setFieldH256(sfNFTokenID, nftokenID);
285 if (
auto const uri =
ctx_.
tx[~sfURI])
286 object.setFieldVL(sfURI, *uri);
317 if (
auto const ownerCountAfter =
319 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 bool checkExtraFeatures(PreflightContext const &ctx)
static std::uint32_t getFlagsMask(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.
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.
static bool hasOfferFields(PreflightContext const &ctx)
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.
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
@ 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.