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
27#include <xrpl/basics/strHex.h>
28
29#include <initializer_list>
30
31namespace ripple {
32namespace test {
33namespace jtx {
34
35namespace token {
36
39mint(jtx::Account const& account, std::uint32_t tokenTaxon = 0);
40
43{
44private:
46
47public:
49 {
50 }
51
52 void
53 operator()(Env&, JTx& jtx) const;
54};
55
57class issuer
58{
59private:
61
62public:
63 explicit issuer(jtx::Account const& issue) : issuer_(issue.human())
64 {
65 }
66
67 void
68 operator()(Env&, JTx& jtx) const;
69};
70
72class uri
73{
74private:
76
77public:
78 explicit uri(std::string const& u) : uri_(strHex(u))
79 {
80 }
81
82 void
83 operator()(Env&, JTx& jtx) const;
84};
85
87class amount
88{
89private:
91
92public:
93 explicit amount(STAmount const amount) : amount_(amount)
94 {
95 }
96
97 void
98 operator()(Env&, JTx& jtx) const;
99};
100
104 jtx::Env const& env,
105 jtx::Account const& account,
106 std::uint32_t nftokenTaxon,
108 std::uint16_t xferFee = 0);
109
112getID(
113 jtx::Env const& env,
114 jtx::Account const& account,
115 std::uint32_t tokenTaxon,
116 std::uint32_t nftSeq,
118 std::uint16_t xferFee = 0);
119
122burn(jtx::Account const& account, uint256 const& nftokenID);
123
127 jtx::Account const& account,
128 uint256 const& nftokenID,
129 STAmount const& amount);
130
132class owner
133{
134private:
136
137public:
138 explicit owner(jtx::Account const& ownedBy) : owner_(ownedBy.human())
139 {
140 }
141
142 void
143 operator()(Env&, JTx& jtx) const;
144};
145
148{
149private:
151
152public:
153 explicit expiration(std::uint32_t const& expires) : expires_(expires)
154 {
155 }
156
157 void
158 operator()(Env&, JTx& jtx) const;
159};
160
163{
164private:
166
167public:
168 explicit destination(jtx::Account const& dest) : dest_(dest.human())
169 {
170 }
171
172 void
173 operator()(Env&, JTx& jtx) const;
174};
175
179 jtx::Account const& account,
180 std::initializer_list<uint256> const& nftokenOffers = {});
181
184 jtx::Account const& account,
185 std::vector<uint256> const& nftokenOffers);
186
189{
190private:
192
193public:
194 explicit rootIndex(uint256 const& index) : rootIndex_(to_string(index))
195 {
196 }
197
198 void
199 operator()(Env&, JTx& jtx) const;
200};
201
204acceptBuyOffer(jtx::Account const& account, uint256 const& offerIndex);
205
208acceptSellOffer(jtx::Account const& account, uint256 const& offerIndex);
209
213 jtx::Account const& account,
214 uint256 const& buyOfferIndex,
215 uint256 const& sellOfferIndex);
216
219{
220private:
222
223public:
225 {
226 }
227
228 void
229 operator()(Env&, JTx& jtx) const;
230};
231
234setMinter(jtx::Account const& account, jtx::Account const& minter);
235
238clearMinter(jtx::Account const& account);
239
242modify(jtx::Account const& account, uint256 const& nftokenID);
243
244} // namespace token
245
246} // namespace jtx
247
248} // namespace test
249} // namespace ripple
250
251#endif // RIPPLE_TEST_JTX_NFT_H_INCLUDED
Represents a JSON value.
Definition: json_value.h:150
Immutable cryptographic account descriptor.
Definition: Account.h:39
A transaction testing environment.
Definition: Env.h:121
Set the fee on a JTx.
Definition: fee.h:37
Match set account flags.
Definition: flags.h:125
Sets the optional amount field on an NFTokenMint.
Definition: token.h:88
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:62
STAmount const amount_
Definition: token.h:90
amount(STAmount const amount)
Definition: token.h:93
Sets the optional NFTokenBrokerFee field in a brokerOffer transaction.
Definition: token.h:219
brokerFee(STAmount const fee)
Definition: token.h:224
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:217
Sets the optional Destination field on an NFTokenOffer.
Definition: token.h:163
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:139
destination(jtx::Account const &dest)
Definition: token.h:168
Sets the optional Expiration field on an NFTokenOffer.
Definition: token.h:148
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:133
expiration(std::uint32_t const &expires)
Definition: token.h:153
Sets the optional Issuer on an NFTokenMint.
Definition: token.h:58
issuer(jtx::Account const &issue)
Definition: token.h:63
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:50
Sets the optional Owner on an NFTokenOffer.
Definition: token.h:133
owner(jtx::Account const &ownedBy)
Definition: token.h:138
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:127
Sets the optional RootIndex field when canceling NFTokenOffers.
Definition: token.h:189
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:177
rootIndex(uint256 const &index)
Definition: token.h:194
Sets the optional URI on an NFTokenMint.
Definition: token.h:73
uri(std::string const &u)
Definition: token.h:78
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:56
Sets the optional TransferFee on an NFTokenMint.
Definition: token.h:43
void operator()(Env &, JTx &jtx) const
Definition: token.cpp:44
xferFee(std::uint16_t fee)
Definition: token.h:48
Json::Value clearMinter(jtx::Account const &account)
Clear any authorized minter from an account root.
Definition: token.cpp:231
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:68
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:82
Json::Value setMinter(jtx::Account const &account, jtx::Account const &minter)
Set the authorized minter on an account root.
Definition: token.cpp:223
Json::Value createOffer(jtx::Account const &account, uint256 const &nftokenID, STAmount const &amount)
Create an NFTokenOffer.
Definition: token.cpp:113
Json::Value acceptSellOffer(jtx::Account const &account, uint256 const &offerIndex)
Accept an NFToken sell offer.
Definition: token.cpp:193
Json::Value modify(jtx::Account const &account, uint256 const &nftokenID)
Modify an NFToken.
Definition: token.cpp:237
Json::Value acceptBuyOffer(jtx::Account const &account, uint256 const &offerIndex)
Accept an NFToken buy offer.
Definition: token.cpp:183
Json::Value mint(jtx::Account const &account, std::uint32_t nfTokenTaxon)
Mint an NFToken.
Definition: token.cpp:34
Json::Value burn(jtx::Account const &account, uint256 const &nftokenID)
Burn an NFToken.
Definition: token.cpp:103
Json::Value cancelOffer(jtx::Account const &account, std::initializer_list< uint256 > const &nftokenOffers)
Cancel NFTokenOffers.
Definition: token.cpp:161
Json::Value brokerOffers(jtx::Account const &account, uint256 const &buyOfferIndex, uint256 const &sellOfferIndex)
Broker two NFToken offers.
Definition: token.cpp:203
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:45