xrpld
Loading...
Searching...
No Matches
permissioned_dex.cpp
1
2#include <test/jtx/permissioned_dex.h>
3
4#include <test/jtx/Account.h>
5#include <test/jtx/Env.h>
6#include <test/jtx/amount.h>
7#include <test/jtx/credentials.h>
8#include <test/jtx/pay.h>
9#include <test/jtx/permissioned_domains.h>
10
11#include <xrpl/basics/base_uint.h>
12
13#include <string>
14#include <vector>
15
16namespace xrpl::test::jtx {
17
20 jtx::Env& env,
21 std::vector<jtx::Account> const& accounts,
22 jtx::Account const& domainOwner,
23 std::string const& credType)
24{
25 using namespace jtx;
26 env.fund(XRP(100000), domainOwner);
27 env.close();
28
29 pdomain::Credentials const credentials{{.issuer = domainOwner, .credType = credType}};
30 env(pdomain::setTx(domainOwner, credentials));
31
32 auto const objects = pdomain::getObjects(domainOwner, env);
33 auto const domainID = objects.begin()->first;
34
35 for (auto const& account : accounts)
36 {
37 env(credentials::create(account, domainOwner, credType));
38 env.close();
39 env(credentials::accept(account, domainOwner, credType));
40 env.close();
41 }
42 return domainID;
43}
44
46 : gw("permdex-gateway")
47 , domainOwner("permdex-domainOwner")
48 , alice("permdex-alice")
49 , bob("permdex-bob")
50 , carol("permdex-carol")
51 , usd(gw["USD"])
52 , credType("permdex-abcde")
53{
54 // Fund accounts
55 env.fund(XRP(100000), alice, bob, carol, gw);
56 env.close();
57
59
60 for (auto const& account : {alice, bob, carol, domainOwner})
61 {
62 env.trust(usd(1000), account);
63 env.close();
64
65 env(pay(gw, account, usd(100)));
66 env.close();
67 }
68}
69
70} // namespace xrpl::test::jtx
Immutable cryptographic account descriptor.
Definition jtx/Account.h:17
A transaction testing environment.
Definition Env.h:143
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition Env.cpp:133
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition Env.cpp:296
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Definition Env.cpp:327
json::Value accept(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:29
json::Value create(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:16
std::vector< Credential > Credentials
std::map< uint256, json::Value > getObjects(Account const &account, Env &env, bool withType)
json::Value setTx(AccountID const &account, Credentials const &credentials, std::optional< uint256 > domain)
json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition pay.cpp:14
XrpT const XRP
Converts to XRP Issue or STAmount.
Definition amount.cpp:92
uint256 setupDomain(jtx::Env &env, std::vector< jtx::Account > const &accounts, jtx::Account const &domainOwner, std::string const &credType)
BaseUInt< 256 > uint256
Definition base_uint.h:562