rippled
Loading...
Searching...
No Matches
token.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_TEST_JTX_NFT_H_INCLUDED
21#define RIPPLE_TEST_JTX_NFT_H_INCLUDED
22
23#include <test/jtx/Account.h>
24#include <test/jtx/Env.h>
25#include <test/jtx/owners.h>
26#include <xrpl/basics/strHex.h>
27
28#include <initializer_list>
29
30namespace ripple {
31namespace test {
32namespace jtx {
33
34namespace token {
35
38mint(jtx::Account const& account, std::uint32_t tokenTaxon = 0);
39
42{
43private:
45
46public:
48 {
49 }
50
51 void
52 operator()(Env&, JTx& jtx) const;
53};
54
56class issuer
57{
58private:
60
61public:
62 explicit issuer(jtx::Account const& issue) : issuer_(issue.human())
63 {
64 }
65
66 void
67 operator()(Env&, JTx& jtx) const;
68};
69
71class uri
72{
73private:
75
76public:
77 explicit uri(std::string const& u) : uri_(strHex(u))
78 {
79 }
80
81 void
82 operator()(Env&, JTx& jtx) const;
83};
84
86class amount
87{
88private:
90
91public:
92 explicit amount(STAmount const amount) : amount_(amount)
93 {
94 }
95
96 void
97 operator()(Env&, JTx& jtx) const;
98};
99
103 jtx::Env const& env,
104 jtx::Account const& account,
105 std::uint32_t nftokenTaxon,
107 std::uint16_t xferFee = 0);
108
111getID(
112 jtx::Env const& env,
113 jtx::Account const& account,
114 std::uint32_t tokenTaxon,
115 std::uint32_t nftSeq,
117 std::uint16_t xferFee = 0);
118
121burn(jtx::Account const& account, uint256 const& nftokenID);
122
126 jtx::Account const& account,
127 uint256 const& nftokenID,
128 STAmount const& amount);
129
131class owner
132{
133private:
135
136public:
137 explicit owner(jtx::Account const& ownedBy) : owner_(ownedBy.human())
138 {
139 }
140
141 void
142 operator()(Env&, JTx& jtx) const;
143};
144
147{
148private:
150
151public:
152 explicit expiration(std::uint32_t const& expires) : expires_(expires)
153 {
154 }
155
156 void
157 operator()(Env&, JTx& jtx) const;
158};
159
162{
163private:
165
166public:
167 explicit destination(jtx::Account const& dest) : dest_(dest.human())
168 {
169 }
170
171 void
172 operator()(Env&, JTx& jtx) const;
173};
174
178 jtx::Account const& account,
179 std::initializer_list<uint256> const& nftokenOffers = {});
180
183 jtx::Account const& account,
184 std::vector<uint256> const& nftokenOffers);
185
188{
189private:
191
192public:
193 explicit rootIndex(uint256 const& index) : rootIndex_(to_string(index))
194 {
195 }
196
197 void
198 operator()(Env&, JTx& jtx) const;
199};
200
203acceptBuyOffer(jtx::Account const& account, uint256 const& offerIndex);
204
207acceptSellOffer(jtx::Account const& account, uint256 const& offerIndex);
208
212 jtx::Account const& account,
213 uint256 const& buyOfferIndex,
214 uint256 const& sellOfferIndex);
215
218{
219private:
221
222public:
224 {
225 }
226
227 void
228 operator()(Env&, JTx& jtx) const;
229};
230
233setMinter(jtx::Account const& account, jtx::Account const& minter);
234
237clearMinter(jtx::Account const& account);
238
241modify(jtx::Account const& account, uint256 const& nftokenID);
242
243} // namespace token
244
245} // namespace jtx
246
247} // namespace test
248} // namespace ripple
249
250#endif // RIPPLE_TEST_JTX_NFT_H_INCLUDED
Represents a JSON value.
Definition: json_value.h:148
Immutable cryptographic account descriptor.
Definition: Account.h:39
A transaction testing environment.
Definition: Env.h:118
Set the fee on a JTx.
Definition: fee.h:36
Match set account flags.
Definition: flags.h:112
Sets the optional amount field on an NFTokenMint.
Definition: token.h:87
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:60
STAmount const amount_
Definition: token.h:89
amount(STAmount const amount)
Definition: token.h:92
Sets the optional NFTokenBrokerFee field in a brokerOffer transaction.
Definition: token.h:218
brokerFee(STAmount const fee)
Definition: token.h:223
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:215
Sets the optional Destination field on an NFTokenOffer.
Definition: token.h:162
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:137
destination(jtx::Account const &dest)
Definition: token.h:167
Sets the optional Expiration field on an NFTokenOffer.
Definition: token.h:147
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:131
expiration(std::uint32_t const &expires)
Definition: token.h:152
Sets the optional Issuer on an NFTokenMint.
Definition: token.h:57
issuer(jtx::Account const &issue)
Definition: token.h:62
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:48
Sets the optional Owner on an NFTokenOffer.
Definition: token.h:132
owner(jtx::Account const &ownedBy)
Definition: token.h:137
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:125
Sets the optional RootIndex field when canceling NFTokenOffers.
Definition: token.h:188
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:175
rootIndex(uint256 const &index)
Definition: token.h:193
Sets the optional URI on an NFTokenMint.
Definition: token.h:72
uri(std::string const &u)
Definition: token.h:77
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:54
Sets the optional TransferFee on an NFTokenMint.
Definition: token.h:42
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:42
xferFee(std::uint16_t fee)
Definition: token.h:47
Json::Value clearMinter(jtx::Account const &account)
Clear any authorized minter from an account root.
Definition: token.cpp:229
uint256 getNextID(jtx::Env const &env, jtx::Account const &issuer, std::uint32_t nfTokenTaxon, std::uint16_t flags, std::uint16_t xferFee)
Get the next NFTokenID that will be issued.
Definition: token.cpp:66
uint256 getID(jtx::Env const &env, jtx::Account const &issuer, std::uint32_t nfTokenTaxon, std::uint32_t nftSeq, std::uint16_t flags, std::uint16_t xferFee)
Get the NFTokenID for a particular nftSequence.
Definition: token.cpp:80
Json::Value setMinter(jtx::Account const &account, jtx::Account const &minter)
Set the authorized minter on an account root.
Definition: token.cpp:221
Json::Value createOffer(jtx::Account const &account, uint256 const &nftokenID, STAmount const &amount)
Create an NFTokenOffer.
Definition: token.cpp:111
Json::Value acceptSellOffer(jtx::Account const &account, uint256 const &offerIndex)
Accept an NFToken sell offer.
Definition: token.cpp:191
Json::Value modify(jtx::Account const &account, uint256 const &nftokenID)
Modify an NFToken.
Definition: token.cpp:235
Json::Value acceptBuyOffer(jtx::Account const &account, uint256 const &offerIndex)
Accept an NFToken buy offer.
Definition: token.cpp:181
Json::Value mint(jtx::Account const &account, std::uint32_t nfTokenTaxon)
Mint an NFToken.
Definition: token.cpp:32
Json::Value burn(jtx::Account const &account, uint256 const &nftokenID)
Burn an NFToken.
Definition: token.cpp:101
Json::Value cancelOffer(jtx::Account const &account, std::initializer_list< uint256 > const &nftokenOffers)
Cancel NFTokenOffers.
Definition: token.cpp:159
Json::Value brokerOffers(jtx::Account const &account, uint256 const &buyOfferIndex, uint256 const &sellOfferIndex)
Broker two NFToken offers.
Definition: token.cpp:201
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
std::string strHex(FwdIt begin, FwdIt end)
Definition: strHex.h:30
std::string to_string(base_uint< Bits, Tag > const &a)
Definition: base_uint.h:630
Execution context for applying a JSON transaction.
Definition: JTx.h:44