rippled
Loading...
Searching...
No Matches
creds.cpp
1#include <test/jtx/credentials.h>
2
3#include <xrpl/protocol/TxFlags.h>
4#include <xrpl/protocol/jss.h>
5
6namespace xrpl {
7namespace test {
8namespace jtx {
9
10namespace credentials {
11
13create(jtx::Account const& subject, jtx::Account const& issuer, std::string_view credType)
14{
15 Json::Value jv;
16 jv[jss::TransactionType] = jss::CredentialCreate;
17
18 jv[jss::Account] = issuer.human();
19 jv[jss::Subject] = subject.human();
20 jv[sfCredentialType.jsonName] = strHex(credType);
21
22 return jv;
23}
24
26accept(jtx::Account const& subject, jtx::Account const& issuer, std::string_view credType)
27{
28 Json::Value jv;
29 jv[jss::TransactionType] = jss::CredentialAccept;
30 jv[jss::Account] = subject.human();
31 jv[jss::Issuer] = issuer.human();
32 jv[sfCredentialType.jsonName] = strHex(credType);
33 return jv;
34}
35
38 jtx::Account const& acc,
39 jtx::Account const& subject,
40 jtx::Account const& issuer,
41 std::string_view credType)
42{
43 Json::Value jv;
44 jv[jss::TransactionType] = jss::CredentialDelete;
45 jv[jss::Account] = acc.human();
46 jv[jss::Subject] = subject.human();
47 jv[jss::Issuer] = issuer.human();
48 jv[sfCredentialType.jsonName] = strHex(credType);
49 return jv;
50}
51
54 jtx::Env& env,
55 jtx::Account const& subject,
56 jtx::Account const& issuer,
57 std::string_view credType)
58{
59 Json::Value jvParams;
60 jvParams[jss::ledger_index] = jss::validated;
61 jvParams[jss::credential][jss::subject] = subject.human();
62 jvParams[jss::credential][jss::issuer] = issuer.human();
63 jvParams[jss::credential][jss::credential_type] = strHex(credType);
64 return env.rpc("json", "ledger_entry", to_string(jvParams));
65}
66
68ledgerEntry(jtx::Env& env, std::string const& credIdx)
69{
70 Json::Value jvParams;
71 jvParams[jss::ledger_index] = jss::validated;
72 jvParams[jss::credential] = credIdx;
73 return env.rpc("json", "ledger_entry", to_string(jvParams));
74}
75
76} // namespace credentials
77
78} // namespace jtx
79
80} // namespace test
81} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
Immutable cryptographic account descriptor.
Definition Account.h:19
std::string const & human() const
Returns the human readable public key.
Definition Account.h:94
A transaction testing environment.
Definition Env.h:121
Json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
Definition Env.h:803
Json::Value accept(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:26
Json::Value deleteCred(jtx::Account const &acc, jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:37
Json::Value ledgerEntry(jtx::Env &env, jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:53
Json::Value create(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:13
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:600
std::string strHex(FwdIt begin, FwdIt end)
Definition strHex.h:10