rippled
Loading...
Searching...
No Matches
credentials.h
1#pragma once
2
3#include <test/jtx/Account.h>
4#include <test/jtx/Env.h>
5#include <test/jtx/owners.h>
6
7namespace xrpl {
8namespace test {
9namespace jtx {
10
11namespace credentials {
12
13inline Keylet
15 test::jtx::Account const& subject,
16 test::jtx::Account const& issuer,
17 std::string_view credType)
18{
19 return keylet::credential(subject.id(), issuer.id(), Slice(credType.data(), credType.size()));
20}
21
22// Sets the optional URI.
23class uri
24{
25private:
27
28public:
29 explicit uri(std::string_view u) : uri_(strHex(u))
30 {
31 }
32
33 void
35 {
36 jtx.jv[sfURI.jsonName] = uri_;
37 }
38};
39
40// Set credentialsIDs array
41class ids
42{
43private:
45
46public:
47 explicit ids(std::vector<std::string> const& creds) : credentials_(creds)
48 {
49 }
50
51 void
53 {
54 auto& arr(jtx.jv[sfCredentialIDs.jsonName] = Json::arrayValue);
55 for (auto const& hash : credentials_)
56 arr.append(hash);
57 }
58};
59
61create(jtx::Account const& subject, jtx::Account const& issuer, std::string_view credType);
62
64accept(jtx::Account const& subject, jtx::Account const& issuer, std::string_view credType);
65
68 jtx::Account const& acc,
69 jtx::Account const& subject,
70 jtx::Account const& issuer,
71 std::string_view credType);
72
75 jtx::Env& env,
76 jtx::Account const& subject,
77 jtx::Account const& issuer,
78 std::string_view credType);
79
81ledgerEntry(jtx::Env& env, std::string const& credIdx);
82
83} // namespace credentials
84} // namespace jtx
85} // namespace test
86} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
An immutable linear range of bytes.
Definition Slice.h:26
Immutable cryptographic account descriptor.
Definition Account.h:19
AccountID id() const
Returns the Account ID.
Definition Account.h:87
A transaction testing environment.
Definition Env.h:122
std::vector< std::string > const credentials_
Definition credentials.h:44
void operator()(jtx::Env &, jtx::JTx &jtx) const
Definition credentials.h:52
ids(std::vector< std::string > const &creds)
Definition credentials.h:47
void operator()(jtx::Env &, jtx::JTx &jtx) const
Definition credentials.h:34
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:498
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
Keylet keylet(test::jtx::Account const &subject, test::jtx::Account const &issuer, std::string_view credType)
Definition credentials.h:14
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
std::string strHex(FwdIt begin, FwdIt end)
Definition strHex.h:10
T size(T... args)
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:19
Execution context for applying a JSON transaction.
Definition JTx.h:25
Json::Value jv
Definition JTx.h:26