rippled
Loading...
Searching...
No Matches
credentials.h
1#ifndef XRPL_TEST_JTX_CREDENTIALS_H_INCLUDED
2#define XRPL_TEST_JTX_CREDENTIALS_H_INCLUDED
3
4#include <test/jtx/Account.h>
5#include <test/jtx/Env.h>
6#include <test/jtx/owners.h>
7
8namespace ripple {
9namespace test {
10namespace jtx {
11
12namespace credentials {
13
14inline Keylet
16 test::jtx::Account const& subject,
17 test::jtx::Account const& issuer,
18 std::string_view credType)
19{
20 return keylet::credential(
21 subject.id(), issuer.id(), Slice(credType.data(), credType.size()));
22}
23
24// Sets the optional URI.
25class uri
26{
27private:
29
30public:
31 explicit uri(std::string_view u) : uri_(strHex(u))
32 {
33 }
34
35 void
37 {
38 jtx.jv[sfURI.jsonName] = uri_;
39 }
40};
41
42// Set credentialsIDs array
43class ids
44{
45private:
47
48public:
49 explicit ids(std::vector<std::string> const& creds) : credentials_(creds)
50 {
51 }
52
53 void
55 {
56 auto& arr(jtx.jv[sfCredentialIDs.jsonName] = Json::arrayValue);
57 for (auto const& hash : credentials_)
58 arr.append(hash);
59 }
60};
61
63create(
64 jtx::Account const& subject,
65 jtx::Account const& issuer,
66 std::string_view credType);
67
69accept(
70 jtx::Account const& subject,
71 jtx::Account const& issuer,
72 std::string_view credType);
73
76 jtx::Account const& acc,
77 jtx::Account const& subject,
78 jtx::Account const& issuer,
79 std::string_view credType);
80
83 jtx::Env& env,
84 jtx::Account const& subject,
85 jtx::Account const& issuer,
86 std::string_view credType);
87
89ledgerEntry(jtx::Env& env, std::string const& credIdx);
90
91} // namespace credentials
92} // namespace jtx
93} // namespace test
94} // namespace ripple
95
96#endif
Represents a JSON value.
Definition json_value.h:130
An immutable linear range of bytes.
Definition Slice.h:27
Immutable cryptographic account descriptor.
Definition Account.h:20
AccountID id() const
Returns the Account ID.
Definition Account.h:92
A transaction testing environment.
Definition Env.h:102
std::vector< std::string > const credentials_
Definition credentials.h:46
ids(std::vector< std::string > const &creds)
Definition credentials.h:49
void operator()(jtx::Env &, jtx::JTx &jtx) const
Definition credentials.h:54
void operator()(jtx::Env &, jtx::JTx &jtx) const
Definition credentials.h:36
T data(T... args)
@ arrayValue
array value (ordered list)
Definition json_value.h:25
Keylet credential(AccountID const &subject, AccountID const &issuer, Slice const &credType) noexcept
Definition Indexes.cpp:534
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
Keylet keylet(test::jtx::Account const &subject, test::jtx::Account const &issuer, std::string_view credType)
Definition credentials.h:15
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
T size(T... args)
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:20
Execution context for applying a JSON transaction.
Definition JTx.h:26
Json::Value jv
Definition JTx.h:27