20 #include <ripple/app/tx/impl/NFTokenAcceptOffer.h>
21 #include <ripple/app/tx/impl/details/NFTokenUtils.h>
22 #include <ripple/ledger/View.h>
23 #include <ripple/protocol/Feature.h>
24 #include <ripple/protocol/Rate.h>
25 #include <ripple/protocol/TxFlags.h>
26 #include <ripple/protocol/st.h>
56 if (*bf <= beast::zero)
83 if ((*offerSLE)[
sfAmount].negative() &&
155 if (brokerFee->issue() != (*bo)[
sfAmount].issue())
194 auto const needed = bo->at(
sfAmount);
206 needed.getCurrency(),
237 auto const needed = so->at(
sfAmount);
243 needed.getCurrency(),
283 if (amount < beast::zero)
314 if (
auto amount = offer->getFieldAmount(
sfAmount); amount != beast::zero)
322 cut != beast::zero && seller != issuer && buyer != issuer)
342 view(), seller, nftokenID, std::move(tokenAndPage->page));
364 JLOG(
j_.
fatal()) <<
"Unable to delete buy offer '"
365 <<
to_string(bo->key()) <<
"': ignoring";
371 JLOG(
j_.
fatal()) <<
"Unable to delete sell offer '"
372 <<
to_string(so->key()) <<
"': ignoring";
402 cut && cut.value() != beast::zero)
404 if (
auto const r =
pay(buyer,
account_, cut.value());
408 amount -= cut.
value();
413 amount != beast::zero && fee != 0)
418 seller != issuer && buyer != issuer)
428 if (amount > beast::zero)
440 view(), seller, nftokenID, std::move(tokenAndPage->page));
NotTEC preflight2(PreflightContext const &ctx)
Checks whether the signature appears valid.
const uint256 fixNFTokenNegOffer
bool enabled(uint256 const &feature) const
Returns true if a feature is enabled.
virtual std::shared_ptr< SLE > peek(Keylet const &k)=0
Prepare to modify the SLE associated with key.
const SF_ACCOUNT sfDestination
constexpr const std::uint32_t tfNFTokenAcceptOfferMask
const SF_UINT256 sfNFTokenID
std::optional< TokenAndPage > findTokenAndPage(ApplyView &view, AccountID const &owner, uint256 const &nftokenID)
TER pay(AccountID const &from, AccountID const &to, STAmount const &amount)
Rate transferFeeAsRate(std::uint16_t fee)
Given a transfer fee (in basis points) convert it to a transfer rate.
static NotTEC preflight(PreflightContext const &ctx)
STAmount accountHolds(ReadView const &view, AccountID const &account, Currency const ¤cy, AccountID const &issuer, FreezeHandling zeroIfFrozen, beast::Journal j)
Keylet nftoffer(AccountID const &owner, std::uint32_t seq)
An offer from an account to buy or sell an NFT.
static TER preclaim(PreclaimContext const &ctx)
bool hasExpired(ReadView const &view, std::optional< std::uint32_t > const &exp)
Determines whether the given expiration time has passed.
std::optional< STObject > findToken(ReadView const &view, AccountID const &owner, uint256 const &nftokenID)
Finds the specified token in the owner's token directory.
@ tecCANT_ACCEPT_OWN_NFTOKEN_OFFER
TER removeToken(ApplyView &view, AccountID const &owner, uint256 const &nftokenID)
Remove the token from the owner's token directory.
NotTEC preflight1(PreflightContext const &ctx)
Performs early sanity checks on the account and fee fields.
const SF_UINT32 sfExpiration
AccountID getIssuer(uint256 const &id)
@ tecNFTOKEN_OFFER_TYPE_MISMATCH
STAmount const & value() const noexcept
TER accountSend(ApplyView &view, AccountID const &uSenderID, AccountID const &uReceiverID, STAmount const &saAmount, beast::Journal j)
std::uint32_t getFlags() const
TER acceptOffer(std::shared_ptr< SLE > const &offer)
virtual std::shared_ptr< SLE const > read(Keylet const &k) const =0
Return the state item associated with a key.
STAmount accountFunds(ReadView const &view, AccountID const &id, STAmount const &saDefault, FreezeHandling freezeHandling, beast::Journal j)
STAmount multiply(STAmount const &amount, Rate const &rate)
State information when determining if a tx is likely to claim a fee.
const SF_UINT256 sfNFTokenBuyOffer
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
const uint256 featureNonFungibleTokensV1
@ tecNFTOKEN_BUY_SELL_MISMATCH
@ tecINSUFFICIENT_PAYMENT
virtual Rules const & rules() const =0
Returns the tx processing rules.
std::string to_string(Manifest const &m)
Format the specified manifest to a string for debugging purposes.
const SF_ACCOUNT sfAccount
const uint256 fixNonFungibleTokensV1_2
std::uint16_t getTransferFee(uint256 const &id)
State information when preflighting a tx.
const SF_UINT256 sfNFTokenSellOffer
TER insertToken(ApplyView &view, AccountID owner, STObject &&nft)
Insert the token in the owner's token directory.
bool deleteTokenOffer(ApplyView &view, std::shared_ptr< SLE > const &offer)
Deletes the given token offer.
const SF_AMOUNT sfNFTokenBrokerFee
TERSubset< CanCvtToNotTEC > NotTEC