rippled
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 <ripple/basics/base_uint.h>
24 #include <ripple/basics/tagged_integer.h>
25 #include <ripple/ledger/ApplyView.h>
26 #include <ripple/protocol/AccountID.h>
27 #include <ripple/protocol/TER.h>
28 #include <ripple/protocol/nft.h>
29 
30 namespace ripple {
31 
32 namespace nft {
33 
38  ApplyView& view,
39  Keylet const& directory,
40  std::size_t maxDeletableOffers);
41 
43 TER
44 notTooManyOffers(ReadView const& view, uint256 const& nftokenID);
45 
48 findToken(
49  ReadView const& view,
50  AccountID const& owner,
51  uint256 const& nftokenID);
52 
55 {
58 
60  : token(token_), page(std::move(page_))
61  {
62  }
63 };
66  ApplyView& view,
67  AccountID const& owner,
68  uint256 const& nftokenID);
69 
71 TER
72 insertToken(ApplyView& view, AccountID owner, STObject&& nft);
73 
75 TER
76 removeToken(ApplyView& view, AccountID const& owner, uint256 const& nftokenID);
77 
78 TER
80  ApplyView& view,
81  AccountID const& owner,
82  uint256 const& nftokenID,
83  std::shared_ptr<SLE>&& page);
84 
94 bool
96 
97 bool
98 compareTokens(uint256 const& a, uint256 const& b);
99 
100 } // namespace nft
101 
102 } // namespace ripple
103 
104 #endif // RIPPLE_TX_IMPL_DETAILS_NFTOKENUTILS_H_INCLUDED
std::shared_ptr
STL class.
ripple::nft::TokenAndPage::page
std::shared_ptr< SLE > page
Definition: NFTokenUtils.h:57
ripple::nft::findTokenAndPage
std::optional< TokenAndPage > findTokenAndPage(ApplyView &view, AccountID const &owner, uint256 const &nftokenID)
Definition: NFTokenUtils.cpp:505
ripple::nft::TokenAndPage
Finds the token in the owner's token directory.
Definition: NFTokenUtils.h:54
ripple::nft::removeTokenOffersWithLimit
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.
Definition: NFTokenUtils.cpp:528
ripple::nft::notTooManyOffers
TER notTooManyOffers(ReadView const &view, uint256 const &nftokenID)
Returns tesSUCCESS if NFToken has few enough offers that it can be burned.
Definition: NFTokenUtils.cpp:578
ripple::nft::TokenAndPage::token
STObject token
Definition: NFTokenUtils.h:56
ripple::nft::findToken
std::optional< STObject > findToken(ReadView const &view, AccountID const &owner, uint256 const &nftokenID)
Finds the specified token in the owner's token directory.
Definition: NFTokenUtils.cpp:483
ripple::nft::removeToken
TER removeToken(ApplyView &view, AccountID const &owner, uint256 const &nftokenID)
Remove the token from the owner's token directory.
Definition: NFTokenUtils.cpp:349
ripple::nft::compareTokens
bool compareTokens(uint256 const &a, uint256 const &b)
Definition: NFTokenUtils.cpp:227
ripple::ApplyView
Writeable view to a ledger, for applying a transaction.
Definition: ApplyView.h:134
ripple::uint256
base_uint< 256 > uint256
Definition: base_uint.h:550
ripple::base_uint
Integers of any length that is a multiple of 32-bits.
Definition: base_uint.h:82
ripple::nft::TokenAndPage::TokenAndPage
TokenAndPage(STObject const &token_, std::shared_ptr< SLE > page_)
Definition: NFTokenUtils.h:59
ripple::TERSubset< CanCvtToTER >
ripple::TER
TERSubset< CanCvtToTER > TER
Definition: TER.h:580
ripple::STObject
Definition: STObject.h:52
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
std
STL namespace.
std::optional
std::size_t
ripple::nft::insertToken
TER insertToken(ApplyView &view, AccountID owner, STObject &&nft)
Insert the token in the owner's token directory.
Definition: NFTokenUtils.cpp:243
ripple::nft::deleteTokenOffer
bool deleteTokenOffer(ApplyView &view, std::shared_ptr< SLE > const &offer)
Deletes the given token offer.
Definition: NFTokenUtils.cpp:605