xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
test
jtx
impl
deposit.cpp
1
#include <test/jtx/deposit.h>
2
3
#include <test/jtx/Account.h>
4
5
#include <xrpl/json/json_value.h>
6
#include <xrpl/protocol/SField.h>
7
#include <xrpl/protocol/jss.h>
8
9
#include <
utility
>
10
#include <
vector
>
11
12
namespace
xrpl::test::jtx::deposit
{
13
14
// Add DepositPreauth.
15
json::Value
16
auth
(
jtx::Account
const
& account,
jtx::Account
const
&
auth
)
17
{
18
json::Value
jv;
19
jv[sfAccount.jsonName] = account.human();
20
jv[sfAuthorize.jsonName] =
auth
.human();
21
jv[sfTransactionType.jsonName] = jss::DepositPreauth;
22
return
jv;
23
}
24
25
// Remove DepositPreauth.
26
json::Value
27
unauth
(
jtx::Account
const
& account,
jtx::Account
const
&
unauth
)
28
{
29
json::Value
jv;
30
jv[sfAccount.jsonName] = account.human();
31
jv[sfUnauthorize.jsonName] =
unauth
.human();
32
jv[sfTransactionType.jsonName] = jss::DepositPreauth;
33
return
jv;
34
}
35
36
// Add DepositPreauth.
37
json::Value
38
authCredentials
(
jtx::Account
const
& account,
std::vector<AuthorizeCredentials>
const
&
auth
)
39
{
40
json::Value
jv;
41
jv[sfAccount.jsonName] = account.human();
42
jv[sfAuthorizeCredentials.jsonName] =
json::ValueType::Array
;
43
auto
& arr(jv[sfAuthorizeCredentials.jsonName]);
44
for
(
auto
const
& o :
auth
)
45
{
46
json::Value
j2;
47
j2[jss::Credential] = o.toJson();
48
arr.
append
(std::move(j2));
49
}
50
jv[sfTransactionType.jsonName] = jss::DepositPreauth;
51
return
jv;
52
}
53
54
// Remove DepositPreauth.
55
json::Value
56
unauthCredentials
(
jtx::Account
const
& account,
std::vector<AuthorizeCredentials>
const
&
auth
)
57
{
58
json::Value
jv;
59
jv[sfAccount.jsonName] = account.human();
60
jv[sfUnauthorizeCredentials.jsonName] =
json::ValueType::Array
;
61
auto
& arr(jv[sfUnauthorizeCredentials.jsonName]);
62
for
(
auto
const
& o :
auth
)
63
{
64
json::Value
j2;
65
j2[jss::Credential] = o.toJson();
66
arr.
append
(std::move(j2));
67
}
68
jv[sfTransactionType.jsonName] = jss::DepositPreauth;
69
return
jv;
70
}
71
72
}
// namespace xrpl::test::jtx::deposit
json::Value
Represents a JSON value.
Definition
json_value.h:117
json::Value::append
Value & append(Value const &value)
Append value to array at the end.
Definition
json_value.cpp:997
xrpl::test::jtx::Account
Immutable cryptographic account descriptor.
Definition
jtx/Account.h:21
json::ValueType::Array
@ Array
array value (ordered list)
Definition
json_value.h:28
xrpl::test::jtx::deposit
Deposit preauthorize operations.
Definition
deposit.h:16
xrpl::test::jtx::deposit::unauthCredentials
json::Value unauthCredentials(jtx::Account const &account, std::vector< AuthorizeCredentials > const &auth)
Definition
deposit.cpp:56
xrpl::test::jtx::deposit::authCredentials
json::Value authCredentials(jtx::Account const &account, std::vector< AuthorizeCredentials > const &auth)
Definition
deposit.cpp:38
xrpl::test::jtx::deposit::auth
json::Value auth(Account const &account, Account const &auth)
Preauthorize for deposit.
Definition
deposit.cpp:16
xrpl::test::jtx::deposit::unauth
json::Value unauth(Account const &account, Account const &unauth)
Remove pre-authorization for deposit.
Definition
deposit.cpp:27
utility
vector
Generated by
1.17.0