xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
test
jtx
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
18
namespace
xrpl::test::jtx::credentials
{
19
20
inline
Keylet
21
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.
30
class
Uri
31
{
32
private
:
33
std::string
const
uri_
;
34
35
public
:
36
explicit
Uri
(
std::string_view
u) :
uri_
(
strHex
(u))
37
{
38
}
39
40
void
41
operator()
(
jtx::Env
&,
jtx::JTx
&
jtx
)
const
42
{
43
jtx
.jv[sfURI.jsonName] =
uri_
;
44
}
45
};
46
47
// Set credentialsIDs array
48
class
Ids
49
{
50
private
:
51
std::vector<std::string>
const
credentials_
;
52
53
public
:
54
explicit
Ids
(
std::vector<std::string>
creds) :
credentials_
(
std
::move(creds))
55
{
56
}
57
58
void
59
operator()
(
jtx::Env
&,
jtx::JTx
&
jtx
)
const
60
{
61
auto
& arr(
jtx
.jv[sfCredentialIDs.jsonName] =
json::ValueType::Array
);
62
for
(
auto
const
& hash :
credentials_
)
63
arr.append(hash);
64
}
65
};
66
67
json::Value
68
create
(
jtx::Account
const
& subject,
jtx::Account
const
& issuer,
std::string_view
credType);
69
70
json::Value
71
accept
(
jtx::Account
const
& subject,
jtx::Account
const
& issuer,
std::string_view
credType);
72
73
json::Value
74
deleteCred
(
75
jtx::Account
const
& acc,
76
jtx::Account
const
& subject,
77
jtx::Account
const
& issuer,
78
std::string_view
credType);
79
80
json::Value
81
ledgerEntry
(
82
jtx::Env
& env,
83
jtx::Account
const
& subject,
84
jtx::Account
const
& issuer,
85
std::string_view
credType);
86
87
json::Value
88
ledgerEntry
(
jtx::Env
& env,
std::string
const
& credIdx);
89
90
}
// namespace xrpl::test::jtx::credentials
std::string
std::string_view
json::Value
Represents a JSON value.
Definition
json_value.h:117
xrpl::Slice
An immutable linear range of bytes.
Definition
Slice.h:28
xrpl::test::jtx::Account
Immutable cryptographic account descriptor.
Definition
jtx/Account.h:21
xrpl::test::jtx::Account::id
AccountID id() const
Returns the Account ID.
Definition
jtx/Account.h:104
xrpl::test::jtx::Env
A transaction testing environment.
Definition
Env.h:161
xrpl::test::jtx::credentials::Ids::operator()
void operator()(jtx::Env &, jtx::JTx &jtx) const
Definition
credentials.h:59
xrpl::test::jtx::credentials::Ids::credentials_
std::vector< std::string > const credentials_
Definition
credentials.h:51
xrpl::test::jtx::credentials::Ids::Ids
Ids(std::vector< std::string > creds)
Definition
credentials.h:54
xrpl::test::jtx::credentials::Uri::Uri
Uri(std::string_view u)
Definition
credentials.h:36
xrpl::test::jtx::credentials::Uri::operator()
void operator()(jtx::Env &, jtx::JTx &jtx) const
Definition
credentials.h:41
xrpl::test::jtx::credentials::Uri::uri_
std::string const uri_
Definition
credentials.h:33
std::string_view::data
T data(T... args)
json::ValueType::Array
@ Array
array value (ordered list)
Definition
json_value.h:28
std
STL namespace.
xrpl::keylet::credential
Keylet credential(AccountID const &subject, AccountID const &issuer, Slice const &credType) noexcept
Definition
Indexes.cpp:585
xrpl::test::jtx::credentials
Definition
credentials.h:18
xrpl::test::jtx::credentials::deleteCred
json::Value deleteCred(jtx::Account const &acc, jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition
creds.cpp:40
xrpl::test::jtx::credentials::accept
json::Value accept(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition
creds.cpp:29
xrpl::test::jtx::credentials::create
json::Value create(jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition
creds.cpp:16
xrpl::test::jtx::credentials::ledgerEntry
json::Value ledgerEntry(jtx::Env &env, jtx::Account const &subject, jtx::Account const &issuer, std::string_view credType)
Definition
creds.cpp:56
xrpl::test::jtx::credentials::keylet
Keylet keylet(test::jtx::Account const &subject, test::jtx::Account const &issuer, std::string_view credType)
Definition
credentials.h:21
xrpl::test::jtx
Definition
Oracle_test.cpp:34
xrpl::strHex
std::string strHex(FwdIt begin, FwdIt end)
Definition
strHex.h:13
std::string_view::size
T size(T... args)
string
string_view
xrpl::Keylet
A pair of SHAMap key and LedgerEntryType.
Definition
Keylet.h:20
xrpl::test::jtx::JTx
Execution context for applying a JSON transaction.
Definition
JTx.h:27
utility
vector
Generated by
1.17.0