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
14keylet(test::jtx::Account const& subject, test::jtx::Account const& issuer, std::string_view credType)
15{
16 return keylet::credential(subject.id(), issuer.id(), Slice(credType.data(), credType.size()));
17}
18
19// Sets the optional URI.
20class uri
21{
22private:
24
25public:
26 explicit uri(std::string_view u) : uri_(strHex(u))
27 {
28 }
29
30 void
32 {
33 jtx.jv[sfURI.jsonName] = uri_;
34 }
35};
36
37// Set credentialsIDs array
38class ids
39{
40private:
42
43public:
44 explicit ids(std::vector<std::string> const& creds) : credentials_(creds)
45 {
46 }
47
48 void
50 {
51 auto& arr(jtx.jv[sfCredentialIDs.jsonName] = Json::arrayValue);
52 for (auto const& hash : credentials_)
53 arr.append(hash);
54 }
55};
56
58create(jtx::Account const& subject, jtx::Account const& issuer, std::string_view credType);
59
61accept(jtx::Account const& subject, jtx::Account const& issuer, std::string_view credType);
62
64deleteCred(jtx::Account const& acc, jtx::Account const& subject, jtx::Account const& issuer, std::string_view credType);
65
67ledgerEntry(jtx::Env& env, jtx::Account const& subject, jtx::Account const& issuer, std::string_view credType);
68
70ledgerEntry(jtx::Env& env, std::string const& credIdx);
71
72} // namespace credentials
73} // namespace jtx
74} // namespace test
75} // 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:119
std::vector< std::string > const credentials_
Definition credentials.h:41
void operator()(jtx::Env &, jtx::JTx &jtx) const
Definition credentials.h:49
ids(std::vector< std::string > const &creds)
Definition credentials.h:44
void operator()(jtx::Env &, jtx::JTx &jtx) const
Definition credentials.h:31
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:486
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:49
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