rippled
Loading...
Searching...
No Matches
NFTokenUtils.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2021 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_TX_IMPL_DETAILS_NFTOKENUTILS_H_INCLUDED
21#define RIPPLE_TX_IMPL_DETAILS_NFTOKENUTILS_H_INCLUDED
22
23#include <xrpld/app/tx/detail/Transactor.h>
24
25#include <xrpl/basics/base_uint.h>
26#include <xrpl/ledger/ApplyView.h>
27#include <xrpl/protocol/AccountID.h>
28#include <xrpl/protocol/TER.h>
29#include <xrpl/protocol/nft.h>
30
31namespace ripple {
32
33namespace nft {
34
39 ApplyView& view,
40 Keylet const& directory,
41 std::size_t maxDeletableOffers);
42
44TER
45notTooManyOffers(ReadView const& view, uint256 const& nftokenID);
46
50 ReadView const& view,
51 AccountID const& owner,
52 uint256 const& nftokenID);
53
56{
59
61 : token(token_), page(std::move(page_))
62 {
63 }
64};
67 ApplyView& view,
68 AccountID const& owner,
69 uint256 const& nftokenID);
70
72TER
73insertToken(ApplyView& view, AccountID owner, STObject&& nft);
74
76TER
77removeToken(ApplyView& view, AccountID const& owner, uint256 const& nftokenID);
78
79TER
81 ApplyView& view,
82 AccountID const& owner,
83 uint256 const& nftokenID,
85
95bool
97
102bool
104
105bool
106compareTokens(uint256 const& a, uint256 const& b);
107
108TER
110 ApplyView& view,
111 AccountID const& owner,
112 uint256 const& nftokenID,
114
116NotTEC
118 AccountID const& acctID,
119 STAmount const& amount,
120 std::optional<AccountID> const& dest,
121 std::optional<std::uint32_t> const& expiration,
122 std::uint16_t nftFlags,
123 Rules const& rules,
125 std::uint32_t txFlags = lsfSellNFToken);
126
128TER
130 ReadView const& view,
131 AccountID const& acctID,
132 AccountID const& nftIssuer,
133 STAmount const& amount,
134 std::optional<AccountID> const& dest,
135 std::uint16_t nftFlags,
136 std::uint16_t xferFee,
139 std::uint32_t txFlags = lsfSellNFToken);
140
142TER
144 ApplyView& view,
145 AccountID const& acctID,
146 STAmount const& amount,
147 std::optional<AccountID> const& dest,
148 std::optional<std::uint32_t> const& expiration,
149 SeqProxy seqProxy,
150 uint256 const& nftokenID,
151 XRPAmount const& priorBalance,
153 std::uint32_t txFlags = lsfSellNFToken);
154
155TER
157 ReadView const& view,
158 AccountID const id,
159 beast::Journal const j,
160 Issue const& issue);
161
162TER
164 ReadView const& view,
165 AccountID const id,
166 beast::Journal const j,
167 Issue const& issue);
168
169} // namespace nft
170
171} // namespace ripple
172
173#endif // RIPPLE_TX_IMPL_DETAILS_NFTOKENUTILS_H_INCLUDED
A generic endpoint for log messages.
Definition Journal.h:60
Writeable view to a ledger, for applying a transaction.
Definition ApplyView.h:143
A currency issued by an account.
Definition Issue.h:33
A view into a ledger.
Definition ReadView.h:51
Rules controlling protocol behavior.
Definition Rules.h:38
A type that represents either a sequence value or a ticket value.
Definition SeqProxy.h:56
T is_same_v
TER removeToken(ApplyView &view, AccountID const &owner, uint256 const &nftokenID)
Remove the token from the owner's token directory.
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
TER checkTrustlineDeepFrozen(ReadView const &view, AccountID const id, beast::Journal const j, Issue const &issue)
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.
bool repairNFTokenDirectoryLinks(ApplyView &view, AccountID const &owner)
Repairs the links in an NFTokenPage directory.
bool deleteTokenOffer(ApplyView &view, std::shared_ptr< SLE > const &offer)
Deletes the given token offer.
std::optional< TokenAndPage > findTokenAndPage(ApplyView &view, AccountID const &owner, uint256 const &nftokenID)
TER insertToken(ApplyView &view, AccountID owner, STObject &&nft)
Insert the token in the owner's token directory.
TER notTooManyOffers(ReadView const &view, uint256 const &nftokenID)
Returns tesSUCCESS if NFToken has few enough offers that it can be burned.
std::optional< STObject > findToken(ReadView const &view, AccountID const &owner, uint256 const &nftokenID)
Finds the specified token in the owner's token directory.
bool compareTokens(uint256 const &a, uint256 const &b)
TER changeTokenURI(ApplyView &view, AccountID const &owner, uint256 const &nftokenID, std::optional< ripple::Slice > const &uri)
std::size_t removeTokenOffersWithLimit(ApplyView &view, Keylet const &directory, std::size_t maxDeletableOffers)
Delete up to a specified number of offers from the specified token offer directory.
TER checkTrustlineAuthorized(ReadView const &view, AccountID const id, beast::Journal const j, Issue const &issue)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:48
base_uint< 256 > uint256
Definition base_uint.h:558
TERSubset< CanCvtToTER > TER
Definition TER.h:645
STL namespace.
Finds the token in the owner's token directory.
TokenAndPage(STObject const &token_, std::shared_ptr< SLE > page_)
std::shared_ptr< SLE > page