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 ripple {
7namespace test {
8namespace jtx {
9
10namespace credentials {
11
14 jtx::Account const& subject,
15 jtx::Account const& issuer,
16 std::string_view credType)
17{
18 Json::Value jv;
19 jv[jss::TransactionType] = jss::CredentialCreate;
20
21 jv[jss::Account] = issuer.human();
22 jv[jss::Subject] = subject.human();
23 jv[sfCredentialType.jsonName] = strHex(credType);
24
25 return jv;
26}
27
30 jtx::Account const& subject,
31 jtx::Account const& issuer,
32 std::string_view credType)
33{
34 Json::Value jv;
35 jv[jss::TransactionType] = jss::CredentialAccept;
36 jv[jss::Account] = subject.human();
37 jv[jss::Issuer] = issuer.human();
38 jv[sfCredentialType.jsonName] = strHex(credType);
39 return jv;
40}
41
44 jtx::Account const& acc,
45 jtx::Account const& subject,
46 jtx::Account const& issuer,
47 std::string_view credType)
48{
49 Json::Value jv;
50 jv[jss::TransactionType] = jss::CredentialDelete;
51 jv[jss::Account] = acc.human();
52 jv[jss::Subject] = subject.human();
53 jv[jss::Issuer] = issuer.human();
54 jv[sfCredentialType.jsonName] = strHex(credType);
55 return jv;
56}
57
60 jtx::Env& env,
61 jtx::Account const& subject,
62 jtx::Account const& issuer,
63 std::string_view credType)
64{
65 Json::Value jvParams;
66 jvParams[jss::ledger_index] = jss::validated;
67 jvParams[jss::credential][jss::subject] = subject.human();
68 jvParams[jss::credential][jss::issuer] = issuer.human();
69 jvParams[jss::credential][jss::credential_type] = strHex(credType);
70 return env.rpc("json", "ledger_entry", to_string(jvParams));
71}
72
74ledgerEntry(jtx::Env& env, std::string const& credIdx)
75{
76 Json::Value jvParams;
77 jvParams[jss::ledger_index] = jss::validated;
78 jvParams[jss::credential] = credIdx;
79 return env.rpc("json", "ledger_entry", to_string(jvParams));
80}
81
82} // namespace credentials
83
84} // namespace jtx
85
86} // namespace test
87} // namespace ripple
Represents a JSON value.
Definition json_value.h:130
Immutable cryptographic account descriptor.
Definition Account.h:20
std::string const & human() const
Returns the human readable public key.
Definition Account.h:99
A transaction testing environment.
Definition Env.h:102
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:772
Json::Value create(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:13
Json::Value accept(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:29
Json::Value deleteCred(jtx::Account const &acc, jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:43
Json::Value ledgerEntry(jtx::Env &env, jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:59
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
std::string strHex(FwdIt begin, FwdIt end)
Definition strHex.h:11
std::string to_string(base_uint< Bits, Tag > const &a)
Definition base_uint.h:611