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