xrpld
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/JTx.h>
6
7#include <xrpl/basics/strHex.h>
8#include <xrpl/json/json_value.h>
9#include <xrpl/protocol/Indexes.h>
10#include <xrpl/protocol/Keylet.h>
11#include <xrpl/protocol/SField.h>
12
13#include <string>
14#include <string_view>
15#include <utility>
16#include <vector>
17
19
20inline Keylet
22 test::jtx::Account const& subject,
23 test::jtx::Account const& issuer,
24 std::string_view credType)
25{
26 return keylet::credential(subject.id(), issuer.id(), Slice(credType.data(), credType.size()));
27}
28
29// Sets the optional URI.
30class Uri
31{
32private:
34
35public:
36 explicit Uri(std::string_view u) : uri_(strHex(u))
37 {
38 }
39
40 void
42 {
43 jtx.jv[sfURI.jsonName] = uri_;
44 }
45};
46
47// Set credentialsIDs array
48class Ids
49{
50private:
52
53public:
54 explicit Ids(std::vector<std::string> creds) : credentials_(std::move(creds))
55 {
56 }
57
58 void
60 {
61 auto& arr(jtx.jv[sfCredentialIDs.jsonName] = json::ValueType::Array);
62 for (auto const& hash : credentials_)
63 arr.append(hash);
64 }
65};
66
68create(jtx::Account const& subject, jtx::Account const& issuer, std::string_view credType);
69
71accept(jtx::Account const& subject, jtx::Account const& issuer, std::string_view credType);
72
75 jtx::Account const& acc,
76 jtx::Account const& subject,
77 jtx::Account const& issuer,
78 std::string_view credType);
79
82 jtx::Env& env,
83 jtx::Account const& subject,
84 jtx::Account const& issuer,
85 std::string_view credType);
86
88ledgerEntry(jtx::Env& env, std::string const& credIdx);
89
90} // namespace xrpl::test::jtx::credentials
Represents a JSON value.
Definition json_value.h:117
An immutable linear range of bytes.
Definition Slice.h:28
Immutable cryptographic account descriptor.
Definition jtx/Account.h:21
AccountID id() const
Returns the Account ID.
A transaction testing environment.
Definition Env.h:161
void operator()(jtx::Env &, jtx::JTx &jtx) const
Definition credentials.h:59
std::vector< std::string > const credentials_
Definition credentials.h:51
Ids(std::vector< std::string > creds)
Definition credentials.h:54
void operator()(jtx::Env &, jtx::JTx &jtx) const
Definition credentials.h:41
T data(T... args)
@ Array
array value (ordered list)
Definition json_value.h:28
STL namespace.
Keylet credential(AccountID const &subject, AccountID const &issuer, Slice const &credType) noexcept
Definition Indexes.cpp:555
json::Value deleteCred(jtx::Account const &acc, jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:40
json::Value accept(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:29
json::Value create(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:16
json::Value ledgerEntry(jtx::Env &env, jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition creds.cpp:56
Keylet keylet(test::jtx::Account const &subject, test::jtx::Account const &issuer, std::string_view credType)
Definition credentials.h:21
std::string strHex(FwdIt begin, FwdIt end)
Definition strHex.h:13
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:27