rippled
Loading...
Searching...
No Matches
mpt.cpp
1#include <test/jtx.h>
2
3#include <xrpl/protocol/SField.h>
4#include <xrpl/protocol/jss.h>
5
6namespace xrpl {
7namespace test {
8namespace jtx {
9
10void
15
16void
21
22void
24{
25 env.test.expect(cb_());
26}
27
30{
32 for (auto const& h : holders)
33 {
34 if (accounts.find(h.human()) != accounts.cend())
35 Throw<std::runtime_error>("Duplicate holder");
36 accounts.emplace(h.human(), h);
37 }
38 return accounts;
39}
40
41MPTTester::MPTTester(Env& env, Account const& issuer, MPTInit const& arg)
42 : env_(env), issuer_(issuer), holders_(makeHolders(arg.holders)), close_(arg.close)
43{
44 if (arg.fund)
45 {
46 env_.fund(arg.xrp, issuer_);
47 for (auto it : holders_)
48 env_.fund(arg.xrpHolders, it.second);
49 }
50 if (close_)
51 env.close();
52 if (arg.fund)
53 {
55 for (auto it : holders_)
56 {
57 if (issuer_.id() == it.second.id())
58 Throw<std::runtime_error>("Issuer can't be holder");
59 env_.require(owners(it.second, 0));
60 }
61 }
62 if (arg.create)
63 create(*arg.create);
64}
65
66MPTTester::MPTTester(Env& env, Account const& issuer, MPTID const& id, std::vector<Account> const& holders, bool close)
67 : env_(env), issuer_(issuer), holders_(makeHolders(holders)), id_(id), close_(close)
68{
69}
70
71static MPTCreate
73{
74 if (arg.pay)
75 return {
76 .maxAmt = arg.maxAmt,
77 .transferFee = arg.transferFee,
78 .pay = {{arg.holders, *arg.pay}},
79 .flags = arg.flags,
80 .authHolder = arg.authHolder};
81 return {
82 .maxAmt = arg.maxAmt,
83 .transferFee = arg.transferFee,
84 .authorize = arg.holders,
85 .flags = arg.flags,
86 .authHolder = arg.authHolder};
87}
88
90 : MPTTester{arg.env, arg.issuer, MPTInit{.fund = arg.fund, .close = arg.close, .create = makeMPTCreate(arg)}}
91{
92}
93
94MPTTester::operator MPT() const
95{
96 if (!id_)
97 Throw<std::runtime_error>("MPT has not been created");
98 return MPT("", *id_);
99}
100
103{
104 if (!arg.issuer)
105 Throw<std::runtime_error>("MPTTester::createjv: issuer is not set");
106 Json::Value jv;
107 jv[sfAccount] = arg.issuer->human();
108 if (arg.assetScale)
109 jv[sfAssetScale] = *arg.assetScale;
110 if (arg.transferFee)
111 jv[sfTransferFee] = *arg.transferFee;
112 if (arg.metadata)
113 jv[sfMPTokenMetadata] = strHex(*arg.metadata);
114 if (arg.maxAmt)
115 jv[sfMaximumAmount] = std::to_string(*arg.maxAmt);
116 if (arg.domainID)
117 jv[sfDomainID] = to_string(*arg.domainID);
118 if (arg.mutableFlags)
119 jv[sfMutableFlags] = *arg.mutableFlags;
120 jv[sfTransactionType] = jss::MPTokenIssuanceCreate;
121
122 return jv;
123}
124
125void
127{
128 if (id_)
129 Throw<std::runtime_error>("MPT can't be reused");
132 {.issuer = issuer_,
133 .maxAmt = arg.maxAmt,
134 .assetScale = arg.assetScale,
135 .transferFee = arg.transferFee,
136 .metadata = arg.metadata,
137 .mutableFlags = arg.mutableFlags,
138 .domainID = arg.domainID});
139 if (submit(arg, jv) != tesSUCCESS)
140 {
141 // Verify issuance doesn't exist
142 env_.require(requireAny([&]() -> bool { return env_.le(keylet::mptIssuance(*id_)) == nullptr; }));
143
144 id_.reset();
145 }
146 else
147 {
148 env_.require(mptflags(*this, arg.flags.value_or(0)));
149 auto authAndPay = [&](auto const& accts, auto const&& getAcct) {
150 for (auto const& it : accts)
151 {
152 authorize({.account = getAcct(it)});
153 if ((arg.flags.value_or(0) & tfMPTRequireAuth) && arg.authHolder)
154 authorize({.account = issuer_, .holder = getAcct(it)});
155 if (arg.pay && arg.pay->first.empty())
156 pay(issuer_, getAcct(it), arg.pay->second);
157 }
158 if (arg.pay)
159 {
160 for (auto const& p : arg.pay->first)
161 pay(issuer_, p, arg.pay->second);
162 }
163 };
164 if (arg.authorize)
165 {
166 if (arg.authorize->empty())
167 authAndPay(holders_, [](auto const& it) { return it.second; });
168 else
169 authAndPay(*arg.authorize, [](auto const& it) { return it; });
170 }
171 else if (arg.pay)
172 {
173 if (arg.pay->first.empty())
174 authAndPay(holders_, [](auto const& it) { return it.second; });
175 else
176 authAndPay(arg.pay->first, [](auto const& it) { return it; });
177 }
178 }
179}
180
183{
184 Json::Value jv;
185 if (!arg.issuer || !arg.id)
186 Throw<std::runtime_error>("MPTTester::destroyjv: issuer/id is not set");
187 jv[sfAccount] = arg.issuer->human();
188 jv[sfMPTokenIssuanceID] = to_string(*arg.id);
189 jv[sfTransactionType] = jss::MPTokenIssuanceDestroy;
190
191 return jv;
192}
193
194void
196{
197 if (!arg.id && !id_)
198 Throw<std::runtime_error>("MPT has not been created");
199 Json::Value jv = destroyjv({.issuer = arg.issuer ? arg.issuer : issuer_, .id = arg.id ? arg.id : id_});
200 submit(arg, jv);
201}
202
203Account const&
204MPTTester::holder(std::string const& holder_) const
205{
206 auto const& it = holders_.find(holder_);
207 if (it == holders_.cend())
208 Throw<std::runtime_error>("Holder is not found");
209 return it->second;
210}
211
214{
215 Json::Value jv;
216 if (!arg.account || !arg.id)
217 Throw<std::runtime_error>("MPTTester::authorizejv: issuer/id is not set");
218 jv[sfAccount] = arg.account->human();
219 jv[sfMPTokenIssuanceID] = to_string(*arg.id);
220 if (arg.holder)
221 jv[sfHolder] = arg.holder->human();
222 jv[sfTransactionType] = jss::MPTokenAuthorize;
223
224 return jv;
225}
226
227void
229{
230 if (!arg.id && !id_)
231 Throw<std::runtime_error>("MPT has not been created");
233 .account = arg.account ? arg.account : issuer_,
234 .holder = arg.holder,
235 .id = arg.id ? arg.id : id_,
236 });
237 if (auto const result = submit(arg, jv); result == tesSUCCESS)
238 {
239 // Issuer authorizes
240 if (!arg.account || *arg.account == issuer_)
241 {
242 auto const flags = getFlags(arg.holder);
243 // issuer un-authorizes the holder
244 if (arg.flags.value_or(0) == tfMPTUnauthorize)
245 env_.require(mptflags(*this, flags, arg.holder));
246 // issuer authorizes the holder
247 else
249 }
250 // Holder authorizes
251 else if (arg.flags.value_or(0) != tfMPTUnauthorize)
252 {
253 auto const flags = getFlags(arg.account);
254 // holder creates a token
255 env_.require(mptflags(*this, flags, arg.account));
256 env_.require(mptbalance(*this, *arg.account, 0));
257 }
258 else
259 {
260 // Verify that the MPToken doesn't exist.
261 forObject([&](SLEP const& sle) { return env_.test.BEAST_EXPECT(!sle); }, arg.account);
262 }
263 }
264 else if (arg.account && *arg.account != issuer_ && arg.flags.value_or(0) != tfMPTUnauthorize && id_)
265 {
266 if (result == tecDUPLICATE)
267 {
268 // Verify that MPToken already exists
270 requireAny([&]() -> bool { return env_.le(keylet::mptoken(*id_, arg.account->id())) != nullptr; }));
271 }
272 else
273 {
274 // Verify MPToken doesn't exist if holder failed authorizing(unless
275 // it already exists)
277 requireAny([&]() -> bool { return env_.le(keylet::mptoken(*id_, arg.account->id())) == nullptr; }));
278 }
279 }
280}
281
282void
284{
285 for (auto const& holder : holders)
286 {
287 authorize({.account = holder});
288 }
289}
290
293{
294 Json::Value jv;
295 if (!arg.account || !arg.id)
296 Throw<std::runtime_error>("MPTTester::setjv: issuer/id is not set");
297 jv[sfAccount] = arg.account->human();
298 jv[sfMPTokenIssuanceID] = to_string(*arg.id);
299 if (arg.holder)
300 {
302 [&jv]<typename T>(T const& holder) {
303 if constexpr (std::is_same_v<T, Account>)
304 jv[sfHolder] = holder.human();
305 else if constexpr (std::is_same_v<T, AccountID>)
306 jv[sfHolder] = toBase58(holder);
307 },
308 *arg.holder);
309 }
310
311 if (arg.delegate)
312 jv[sfDelegate] = arg.delegate->human();
313 if (arg.domainID)
314 jv[sfDomainID] = to_string(*arg.domainID);
315 if (arg.mutableFlags)
316 jv[sfMutableFlags] = *arg.mutableFlags;
317 if (arg.transferFee)
318 jv[sfTransferFee] = *arg.transferFee;
319 if (arg.metadata)
320 jv[sfMPTokenMetadata] = strHex(*arg.metadata);
321 jv[sfTransactionType] = jss::MPTokenIssuanceSet;
322
323 return jv;
324}
325
326void
328{
329 if (!arg.id && !id_)
330 Throw<std::runtime_error>("MPT has not been created");
331 Json::Value jv = setjv(
332 {.account = arg.account ? arg.account : issuer_,
333 .holder = arg.holder,
334 .id = arg.id ? arg.id : id_,
335 .mutableFlags = arg.mutableFlags,
336 .transferFee = arg.transferFee,
337 .metadata = arg.metadata,
338 .delegate = arg.delegate,
339 .domainID = arg.domainID});
340 if (submit(arg, jv) == tesSUCCESS && (arg.flags.value_or(0) || arg.mutableFlags))
341 {
342 auto require = [&](std::optional<Account> const& holder, bool unchanged) {
343 auto flags = getFlags(holder);
344 if (!unchanged)
345 {
346 if (arg.flags)
347 {
348 if (*arg.flags & tfMPTLock)
350 else if (*arg.flags & tfMPTUnlock)
351 flags &= ~lsfMPTLocked;
352 }
353
354 if (arg.mutableFlags)
355 {
358 else if (*arg.mutableFlags & tmfMPTClearCanLock)
359 flags &= ~lsfMPTCanLock;
360
363 else if (*arg.mutableFlags & tmfMPTClearRequireAuth)
364 flags &= ~lsfMPTRequireAuth;
365
368 else if (*arg.mutableFlags & tmfMPTClearCanEscrow)
369 flags &= ~lsfMPTCanEscrow;
370
373 else if (*arg.mutableFlags & tmfMPTClearCanClawback)
374 flags &= ~lsfMPTCanClawback;
375
378 else if (*arg.mutableFlags & tmfMPTClearCanTrade)
379 flags &= ~lsfMPTCanTrade;
380
383 else if (*arg.mutableFlags & tmfMPTClearCanTransfer)
384 flags &= ~lsfMPTCanTransfer;
385 }
386 }
387 env_.require(mptflags(*this, flags, holder));
388 };
389 if (arg.account)
390 require(std::nullopt, arg.holder.has_value());
391 if (auto const account = (arg.holder ? std::get_if<Account>(&(*arg.holder)) : nullptr))
392 require(*account, false);
393 }
394}
395
396bool
397MPTTester::forObject(std::function<bool(SLEP const& sle)> const& cb, std::optional<Account> const& holder_) const
398{
399 if (!id_)
400 Throw<std::runtime_error>("MPT has not been created");
401 auto const key = holder_ ? keylet::mptoken(*id_, holder_->id()) : keylet::mptIssuance(*id_);
402 if (auto const sle = env_.le(key))
403 return cb(sle);
404 return false;
405}
406
407[[nodiscard]] bool
409{
410 return forObject([&](SLEP const& sle) -> bool {
411 if (sle->isFieldPresent(sfDomainID))
412 return expected == sle->getFieldH256(sfDomainID);
413 return (!expected.has_value());
414 });
415}
416
417[[nodiscard]] bool
418MPTTester::checkMPTokenAmount(Account const& holder_, std::int64_t expectedAmount) const
419{
420 return forObject([&](SLEP const& sle) { return expectedAmount == (*sle)[sfMPTAmount]; }, holder_);
421}
422
423[[nodiscard]] bool
425{
426 return forObject([&](SLEP const& sle) { return expectedAmount == (*sle)[sfOutstandingAmount]; });
427}
428
429[[nodiscard]] bool
430MPTTester::checkFlags(uint32_t const expectedFlags, std::optional<Account> const& holder) const
431{
432 return expectedFlags == getFlags(holder);
433}
434
435[[nodiscard]] bool
437{
438 return forObject([&](SLEP const& sle) -> bool {
439 if (sle->isFieldPresent(sfMPTokenMetadata))
440 return strHex(sle->getFieldVL(sfMPTokenMetadata)) == strHex(metadata);
441 return false;
442 });
443}
444
445[[nodiscard]] bool
447{
448 return forObject([&](SLEP const& sle) -> bool { return sle->isFieldPresent(sfMPTokenMetadata); });
449}
450
451[[nodiscard]] bool
453{
454 return forObject([&](SLEP const& sle) -> bool {
455 if (sle->isFieldPresent(sfTransferFee))
456 return sle->getFieldU16(sfTransferFee) == transferFee;
457 return false;
458 });
459}
460
461[[nodiscard]] bool
463{
464 return forObject([&](SLEP const& sle) -> bool { return sle->isFieldPresent(sfTransferFee); });
465}
466
467void
469 Account const& src,
470 Account const& dest,
474{
475 if (!id_)
476 Throw<std::runtime_error>("MPT has not been created");
477 auto const srcAmt = getBalance(src);
478 auto const destAmt = getBalance(dest);
479 auto const outstnAmt = getBalance(issuer_);
480
481 if (credentials)
482 env_(jtx::pay(src, dest, mpt(amount)), ter(err.value_or(tesSUCCESS)), credentials::ids(*credentials));
483 else
484 env_(jtx::pay(src, dest, mpt(amount)), ter(err.value_or(tesSUCCESS)));
485
486 if (env_.ter() != tesSUCCESS)
487 amount = 0;
488 if (close_)
489 env_.close();
490 if (src == issuer_)
491 {
492 env_.require(mptbalance(*this, src, srcAmt + amount));
493 env_.require(mptbalance(*this, dest, destAmt + amount));
494 }
495 else if (dest == issuer_)
496 {
497 env_.require(mptbalance(*this, src, srcAmt - amount));
498 env_.require(mptbalance(*this, dest, destAmt - amount));
499 }
500 else
501 {
502 STAmount const saAmount = {*id_, amount};
503 auto const actual = multiply(saAmount, transferRate(*env_.current(), *id_)).mpt().value();
504 // Sender pays the transfer fee if any
505 env_.require(mptbalance(*this, src, srcAmt - actual));
506 env_.require(mptbalance(*this, dest, destAmt + amount));
507 // Outstanding amount is reduced by the transfer fee if any
508 env_.require(mptbalance(*this, issuer_, outstnAmt - (actual - amount)));
509 }
510}
511
512void
514{
515 if (!id_)
516 Throw<std::runtime_error>("MPT has not been created");
517 auto const issuerAmt = getBalance(issuer);
518 auto const holderAmt = getBalance(holder);
520 if (env_.ter() != tesSUCCESS)
521 amount = 0;
522 if (close_)
523 env_.close();
524
525 env_.require(mptbalance(*this, issuer, issuerAmt - std::min(holderAmt, amount)));
526 env_.require(mptbalance(*this, holder, holderAmt - std::min(holderAmt, amount)));
527}
528
531{
532 if (!id_)
533 Throw<std::runtime_error>("MPT has not been created");
535}
536
537MPTTester::operator Asset() const
538{
539 if (!id_)
540 Throw<std::runtime_error>("MPT has not been created");
541 return Asset(*id_);
542}
543
545MPTTester::getBalance(Account const& account) const
546{
547 if (!id_)
548 Throw<std::runtime_error>("MPT has not been created");
549 if (account == issuer_)
550 {
551 if (auto const sle = env_.le(keylet::mptIssuance(*id_)))
552 return sle->getFieldU64(sfOutstandingAmount);
553 }
554 else
555 {
556 if (auto const sle = env_.le(keylet::mptoken(*id_, account.id())))
557 return sle->getFieldU64(sfMPTAmount);
558 }
559 return 0;
560}
561
564{
566 if (!forObject(
567 [&](SLEP const& sle) {
568 flags = sle->getFlags();
569 return true;
570 },
571 holder))
572 Throw<std::runtime_error>("Failed to get the flags");
573 return flags;
574}
575
576MPT
578{
579 return MPT(name, issuanceID());
580}
581
584{
585 return MPT("", issuanceID())(amount);
586}
587
588} // namespace jtx
589} // namespace test
590} // namespace xrpl
Represents a JSON value.
Definition json_value.h:131
bool expect(Condition const &shouldBeTrue)
Evaluate a test condition.
Definition suite.h:222
constexpr value_type value() const
Returns the underlying value.
Definition MPTAmount.h:114
MPTAmount mpt() const
Definition STAmount.cpp:279
Immutable cryptographic account descriptor.
Definition Account.h:20
std::string const & human() const
Returns the human readable public key.
Definition Account.h:95
std::string const & name() const
Return the name.
Definition Account.h:64
AccountID id() const
Returns the Account ID.
Definition Account.h:88
A transaction testing environment.
Definition Env.h:98
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition Env.cpp:97
TER ter() const
Return the TER for the last JTx.
Definition Env.h:560
std::shared_ptr< SLE const > le(Account const &account) const
Return an account root.
Definition Env.cpp:248
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition Env.cpp:260
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
Definition Env.cpp:239
beast::unit_test::suite & test
Definition Env.h:100
void require(Args const &... args)
Check a set of requirements.
Definition Env.h:512
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition Env.h:298
std::unordered_map< std::string, Account > const holders_
Definition mpt.h:162
MPTTester(Env &env, Account const &issuer, MPTInit const &constr={})
Definition mpt.cpp:41
bool forObject(std::function< bool(SLEP const &sle)> const &cb, std::optional< Account > const &holder=std::nullopt) const
Definition mpt.cpp:397
void set(MPTSet const &set={})
Definition mpt.cpp:327
bool checkMPTokenAmount(Account const &holder, std::int64_t expectedAmount) const
Definition mpt.cpp:418
std::optional< MPTID > id_
Definition mpt.h:163
void pay(Account const &src, Account const &dest, std::int64_t amount, std::optional< TER > err=std::nullopt, std::optional< std::vector< std::string > > credentials=std::nullopt)
Definition mpt.cpp:468
Account const & holder(std::string const &h) const
Definition mpt.cpp:204
void create(MPTCreate const &arg=MPTCreate{})
Definition mpt.cpp:126
bool isTransferFeePresent() const
Definition mpt.cpp:462
bool checkMetadata(std::string const &metadata) const
Definition mpt.cpp:436
bool checkFlags(uint32_t const expectedFlags, std::optional< Account > const &holder=std::nullopt) const
Definition mpt.cpp:430
bool isMetadataPresent() const
Definition mpt.cpp:446
MPT operator[](std::string const &name) const
Definition mpt.cpp:577
void authorizeHolders(Holders const &holders)
Definition mpt.cpp:283
Account const & issuer() const
Definition mpt.h:229
void authorize(MPTAuthorize const &arg=MPTAuthorize{})
Definition mpt.cpp:228
MPTID const & issuanceID() const
Definition mpt.h:250
std::int64_t getBalance(Account const &account) const
Definition mpt.cpp:545
Account const issuer_
Definition mpt.h:161
void claw(Account const &issuer, Account const &holder, std::int64_t amount, std::optional< TER > err=std::nullopt)
Definition mpt.cpp:513
TER submit(A const &arg, Json::Value const &jv)
Definition mpt.h:276
static Json::Value setjv(MPTSet const &set={})
Definition mpt.cpp:292
static Json::Value destroyjv(MPTDestroy const &arg=MPTDestroy{})
Definition mpt.cpp:182
static Json::Value createjv(MPTCreate const &arg=MPTCreate{})
Definition mpt.cpp:102
PrettyAmount mpt(std::int64_t amount) const
Definition mpt.cpp:530
static Json::Value authorizejv(MPTAuthorize const &arg=MPTAuthorize{})
Definition mpt.cpp:213
void destroy(MPTDestroy const &arg=MPTDestroy{})
Definition mpt.cpp:195
bool checkTransferFee(std::uint16_t transferFee) const
Definition mpt.cpp:452
bool checkDomainID(std::optional< uint256 > expected) const
Definition mpt.cpp:408
PrettyAmount operator()(std::int64_t amount) const
Definition mpt.cpp:583
std::uint32_t getFlags(std::optional< Account > const &holder) const
Definition mpt.cpp:563
static std::unordered_map< std::string, Account > makeHolders(std::vector< Account > const &holders)
Definition mpt.cpp:29
bool checkMPTokenOutstandingAmount(std::int64_t expectedAmount) const
Definition mpt.cpp:424
Converts to MPT Issue or STAmount.
Match set account flags.
Definition flags.h:109
Account const & account_
Definition mpt.h:42
MPTTester const & tester_
Definition mpt.h:41
std::int64_t const amount_
Definition mpt.h:43
void operator()(Env &env) const
Definition mpt.cpp:17
std::uint32_t flags_
Definition mpt.h:24
std::optional< Account > holder_
Definition mpt.h:25
MPTTester & tester_
Definition mpt.h:23
void operator()(Env &env) const
Definition mpt.cpp:11
Match the number of items in the account's owner directory.
Definition owners.h:49
std::function< bool()> cb_
Definition mpt.h:58
void operator()(Env &env) const
Definition mpt.cpp:23
Check a set of conditions.
Definition require.h:47
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition ter.h:16
T emplace(T... args)
T cend(T... args)
T find(T... args)
T is_same_v
T min(T... args)
Keylet mptIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Definition Indexes.cpp:462
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Definition Indexes.cpp:474
Json::Value create(AccountID const &account, AccountID const &to, STAmount const &amount, NetClock::duration const &settleDelay, PublicKey const &pk, std::optional< NetClock::time_point > const &cancelAfter, std::optional< std::uint32_t > const &dstTag)
Json::Value claw(Account const &account, STAmount const &amount, std::optional< Account > const &mptHolder)
Definition trust.cpp:46
static MPTCreate makeMPTCreate(MPTInitDef const &arg)
Definition mpt.cpp:72
void fund(jtx::Env &env, jtx::Account const &gw, std::vector< jtx::Account > const &accounts, std::vector< STAmount > const &amts, Fund how)
Definition AMMTest.cpp:18
Json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition pay.cpp:11
auto const amount
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
constexpr std::uint32_t const tmfMPTClearCanTransfer
Definition TxFlags.h:173
constexpr std::uint32_t const tmfMPTClearCanLock
Definition TxFlags.h:165
constexpr std::uint32_t const tmfMPTClearCanClawback
Definition TxFlags.h:175
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:598
std::string strHex(FwdIt begin, FwdIt end)
Definition strHex.h:11
constexpr std::uint32_t const tfMPTRequireAuth
Definition TxFlags.h:130
constexpr std::uint32_t const tmfMPTClearCanEscrow
Definition TxFlags.h:169
constexpr std::uint32_t const tmfMPTSetRequireAuth
Definition TxFlags.h:166
constexpr std::uint32_t const tmfMPTClearRequireAuth
Definition TxFlags.h:167
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
Definition AccountID.cpp:92
STAmount multiply(STAmount const &amount, Rate const &rate)
Definition Rate2.cpp:34
constexpr std::uint32_t const tfMPTUnlock
Definition TxFlags.h:158
constexpr std::uint32_t const tmfMPTSetCanLock
Definition TxFlags.h:164
constexpr std::uint32_t const tfMPTLock
Definition TxFlags.h:157
Rate transferRate(ReadView const &view, AccountID const &issuer)
Returns IOU issuer transfer fee as Rate.
Definition View.cpp:699
constexpr std::uint32_t const tmfMPTClearCanTrade
Definition TxFlags.h:171
constexpr std::uint32_t const tfMPTUnauthorize
Definition TxFlags.h:153
constexpr std::uint32_t const tmfMPTSetCanTrade
Definition TxFlags.h:170
constexpr std::uint32_t const tmfMPTSetCanClawback
Definition TxFlags.h:174
constexpr std::uint32_t const tmfMPTSetCanEscrow
Definition TxFlags.h:168
@ tecDUPLICATE
Definition TER.h:297
@ lsfMPTCanLock
@ lsfMPTCanEscrow
@ lsfMPTRequireAuth
@ lsfMPTCanTrade
@ lsfMPTLocked
@ lsfMPTAuthorized
@ lsfMPTCanTransfer
@ lsfMPTCanClawback
MPTID makeMptID(std::uint32_t sequence, AccountID const &account)
Definition Indexes.cpp:146
@ tesSUCCESS
Definition TER.h:226
constexpr std::uint32_t const tmfMPTSetCanTransfer
Definition TxFlags.h:172
T has_value(T... args)
std::optional< Account > holder
Definition mpt.h:134
std::optional< Account > account
Definition mpt.h:133
std::optional< MPTID > id
Definition mpt.h:135
std::optional< std::uint32_t > flags
Definition mpt.h:138
std::optional< std::uint8_t > assetScale
Definition mpt.h:76
std::optional< std::uint32_t > mutableFlags
Definition mpt.h:88
std::optional< std::string > metadata
Definition mpt.h:78
std::optional< std::uint32_t > flags
Definition mpt.h:87
std::optional< uint256 > domainID
Definition mpt.h:90
std::optional< std::uint64_t > maxAmt
Definition mpt.h:75
std::optional< Account > issuer
Definition mpt.h:74
std::optional< std::pair< std::vector< Account >, std::uint64_t > > pay
Definition mpt.h:86
std::optional< std::uint16_t > transferFee
Definition mpt.h:77
std::optional< std::vector< Account > > authorize
Definition mpt.h:83
std::optional< Account > issuer
Definition mpt.h:123
std::optional< MPTID > id
Definition mpt.h:124
std::uint16_t transferFee
Definition mpt.h:111
std::uint32_t flags
Definition mpt.h:113
std::optional< std::uint64_t > maxAmt
Definition mpt.h:117
std::optional< std::uint64_t > pay
Definition mpt.h:112
std::optional< MPTCreate > create
Definition mpt.h:102
PrettyAmount const xrp
Definition mpt.h:97
PrettyAmount const xrpHolders
Definition mpt.h:98
std::optional< uint256 > domainID
Definition mpt.h:154
std::optional< Account > account
Definition mpt.h:144
std::optional< MPTID > id
Definition mpt.h:146
std::optional< std::uint16_t > transferFee
Definition mpt.h:151
std::optional< std::uint32_t > flags
Definition mpt.h:149
std::optional< std::variant< Account, AccountID > > holder
Definition mpt.h:145
std::optional< std::uint32_t > mutableFlags
Definition mpt.h:150
std::optional< std::string > metadata
Definition mpt.h:152
std::optional< Account > delegate
Definition mpt.h:153
Represents an XRP or IOU quantity This customizes the string conversion and supports XRP conversions ...
T to_string(T... args)
T value_or(T... args)
T visit(T... args)