rippled
Loading...
Searching...
No Matches
credentials.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2024 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_TEST_JTX_CREDENTIALS_H_INCLUDED
21#define RIPPLE_TEST_JTX_CREDENTIALS_H_INCLUDED
22
23#include <test/jtx/Account.h>
24#include <test/jtx/Env.h>
25#include <test/jtx/owners.h>
26
27namespace ripple {
28namespace test {
29namespace jtx {
30
31namespace credentials {
32
33// Sets the optional URI.
34class uri
35{
36private:
38
39public:
40 explicit uri(std::string_view u) : uri_(strHex(u))
41 {
42 }
43
44 void
46 {
47 jtx.jv[sfURI.jsonName] = uri_;
48 }
49};
50
51// Set credentialsIDs array
52class ids
53{
54private:
56
57public:
58 explicit ids(std::vector<std::string> const& creds) : credentials_(creds)
59 {
60 }
61
62 void
64 {
65 auto& arr(jtx.jv[sfCredentialIDs.jsonName] = Json::arrayValue);
66 for (auto const& hash : credentials_)
67 arr.append(hash);
68 }
69};
70
72create(
73 jtx::Account const& subject,
74 jtx::Account const& issuer,
75 std::string_view credType);
76
78accept(
79 jtx::Account const& subject,
80 jtx::Account const& issuer,
81 std::string_view credType);
82
85 jtx::Account const& acc,
86 jtx::Account const& subject,
87 jtx::Account const& issuer,
88 std::string_view credType);
89
92 jtx::Env& env,
93 jtx::Account const& subject,
94 jtx::Account const& issuer,
95 std::string_view credType);
96
98ledgerEntry(jtx::Env& env, std::string const& credIdx);
99
100} // namespace credentials
101} // namespace jtx
102} // namespace test
103} // namespace ripple
104
105#endif
Represents a JSON value.
Definition: json_value.h:148
Immutable cryptographic account descriptor.
Definition: Account.h:39
A transaction testing environment.
Definition: Env.h:120
std::vector< std::string > const credentials_
Definition: credentials.h:55
ids(std::vector< std::string > const &creds)
Definition: credentials.h:58
void operator()(jtx::Env &, jtx::JTx &jtx) const
Definition: credentials.h:63
void operator()(jtx::Env &, jtx::JTx &jtx) const
Definition: credentials.h:45
@ arrayValue
array value (ordered list)
Definition: json_value.h:43
Json::Value create(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition: credentials.cpp:32
Json::Value accept(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition: credentials.cpp:50
Json::Value deleteCred(jtx::Account const &acc, jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition: credentials.cpp:66
Json::Value ledgerEntry(jtx::Env &env, jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition: credentials.cpp:83
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
std::string strHex(FwdIt begin, FwdIt end)
Definition: strHex.h:30
Execution context for applying a JSON transaction.
Definition: JTx.h:45
Json::Value jv
Definition: JTx.h:46