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
37deleteCred(jtx::Account const& acc, jtx::Account const& subject, jtx::Account const& issuer, std::string_view credType)
38{
39 Json::Value jv;
40 jv[jss::TransactionType] = jss::CredentialDelete;
41 jv[jss::Account] = acc.human();
42 jv[jss::Subject] = subject.human();
43 jv[jss::Issuer] = issuer.human();
44 jv[sfCredentialType.jsonName] = strHex(credType);
45 return jv;
46}
47
49ledgerEntry(jtx::Env& env, jtx::Account const& subject, jtx::Account const& issuer, std::string_view credType)
50{
51 Json::Value jvParams;
52 jvParams[jss::ledger_index] = jss::validated;
53 jvParams[jss::credential][jss::subject] = subject.human();
54 jvParams[jss::credential][jss::issuer] = issuer.human();
55 jvParams[jss::credential][jss::credential_type] = strHex(credType);
56 return env.rpc("json", "ledger_entry", to_string(jvParams));
57}
58
60ledgerEntry(jtx::Env& env, std::string const& credIdx)
61{
62 Json::Value jvParams;
63 jvParams[jss::ledger_index] = jss::validated;
64 jvParams[jss::credential] = credIdx;
65 return env.rpc("json", "ledger_entry", to_string(jvParams));
66}
67
68} // namespace credentials
69
70} // namespace jtx
71
72} // namespace test
73} // 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:119
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:792
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:49
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:597
std::string strHex(FwdIt begin, FwdIt end)
Definition strHex.h:10