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