xrpld
Loading...
Searching...
No Matches
test
jtx
impl
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
16
namespace
xrpl::test::jtx
{
17
18
uint256
19
setupDomain
(
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
45
PermissionedDEX::PermissionedDEX
(
Env
& env)
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
58
domainID
=
setupDomain
(env, {
alice
,
bob
,
carol
,
gw
},
domainOwner
,
credType
);
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
std::string
xrpl::test::jtx::Account
Immutable cryptographic account descriptor.
Definition
jtx/Account.h:17
xrpl::test::jtx::Env
A transaction testing environment.
Definition
Env.h:143
xrpl::test::jtx::Env::close
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition
Env.cpp:133
xrpl::test::jtx::Env::fund
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition
Env.cpp:296
xrpl::test::jtx::Env::trust
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
Definition
Env.cpp:327
xrpl::test::jtx::PermissionedDEX::domainOwner
Account domainOwner
Definition
permissioned_dex.h:19
xrpl::test::jtx::PermissionedDEX::gw
Account gw
Definition
permissioned_dex.h:18
xrpl::test::jtx::PermissionedDEX::carol
Account carol
Definition
permissioned_dex.h:22
xrpl::test::jtx::PermissionedDEX::credType
std::string credType
Definition
permissioned_dex.h:25
xrpl::test::jtx::PermissionedDEX::bob
Account bob
Definition
permissioned_dex.h:21
xrpl::test::jtx::PermissionedDEX::usd
IOU usd
Definition
permissioned_dex.h:23
xrpl::test::jtx::PermissionedDEX::PermissionedDEX
PermissionedDEX(Env &env)
Definition
permissioned_dex.cpp:45
xrpl::test::jtx::PermissionedDEX::alice
Account alice
Definition
permissioned_dex.h:20
xrpl::test::jtx::PermissionedDEX::domainID
uint256 domainID
Definition
permissioned_dex.h:24
xrpl::test::jtx::credentials
Definition
credentials.h:7
xrpl::test::jtx::credentials::accept
json::Value accept(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition
creds.cpp:29
xrpl::test::jtx::credentials::create
json::Value create(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition
creds.cpp:16
xrpl::test::jtx::pdomain::Credentials
std::vector< Credential > Credentials
Definition
permissioned_domains.h:11
xrpl::test::jtx::pdomain::getObjects
std::map< uint256, json::Value > getObjects(Account const &account, Env &env, bool withType)
Definition
permissioned_domains.cpp:63
xrpl::test::jtx::pdomain::setTx
json::Value setTx(AccountID const &account, Credentials const &credentials, std::optional< uint256 > domain)
Definition
permissioned_domains.cpp:30
xrpl::test::jtx
Definition
Oracle_test.cpp:34
xrpl::test::jtx::pay
json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition
pay.cpp:14
xrpl::test::jtx::XRP
XrpT const XRP
Converts to XRP Issue or STAmount.
Definition
amount.cpp:92
xrpl::test::jtx::setupDomain
uint256 setupDomain(jtx::Env &env, std::vector< jtx::Account > const &accounts, jtx::Account const &domainOwner, std::string const &credType)
Definition
permissioned_dex.cpp:19
xrpl::uint256
BaseUInt< 256 > uint256
Definition
base_uint.h:562
string
vector
Generated by
1.16.1