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#pragma once
21
22#include <test/jtx/Account.h>
23#include <test/jtx/Env.h>
24#include <test/jtx/owners.h>
25
26namespace ripple {
27namespace test {
28namespace jtx {
29
30namespace credentials {
31
32// Sets the optional URI.
33class uri
34{
35private:
37
38public:
39 explicit uri(std::string_view u) : uri_(strHex(u))
40 {
41 }
42
43 void
45 {
46 jtx.jv[sfURI.jsonName] = uri_;
47 }
48};
49
50// Set credentialsIDs array
51class ids
52{
53private:
55
56public:
57 explicit ids(std::vector<std::string> const& creds) : credentials_(creds)
58 {
59 }
60
61 void
63 {
64 auto& arr(jtx.jv[sfCredentialIDs.jsonName] = Json::arrayValue);
65 for (auto const& hash : credentials_)
66 arr.append(hash);
67 }
68};
69
71create(
72 jtx::Account const& subject,
73 jtx::Account const& issuer,
74 std::string_view credType);
75
77accept(
78 jtx::Account const& subject,
79 jtx::Account const& issuer,
80 std::string_view credType);
81
84 jtx::Account const& acc,
85 jtx::Account const& subject,
86 jtx::Account const& issuer,
87 std::string_view credType);
88
91 jtx::Env& env,
92 jtx::Account const& subject,
93 jtx::Account const& issuer,
94 std::string_view credType);
95
97ledgerEntry(jtx::Env& env, std::string const& credIdx);
98
99} // namespace credentials
100
101} // namespace jtx
102
103} // namespace test
104} // namespace ripple
Represents a JSON value.
Definition: json_value.h:147
Immutable cryptographic account descriptor.
Definition: Account.h:38
A transaction testing environment.
Definition: Env.h:117
std::vector< std::string > const credentials_
Definition: credentials.h:54
ids(std::vector< std::string > const &creds)
Definition: credentials.h:57
void operator()(jtx::Env &, jtx::JTx &jtx) const
Definition: credentials.h:62
void operator()(jtx::Env &, jtx::JTx &jtx) const
Definition: credentials.h:44
@ arrayValue
array value (ordered list)
Definition: json_value.h:42
Json::Value create(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition: credentials.cpp:31
Json::Value accept(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition: credentials.cpp:49
Json::Value deleteCred(jtx::Account const &acc, jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition: credentials.cpp:65
Json::Value ledgerEntry(jtx::Env &env, jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition: credentials.cpp:82
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:44
Json::Value jv
Definition: JTx.h:45