1#include <test/jtx/permissioned_domains.h>
3#include <test/jtx/Account.h>
4#include <test/jtx/Env.h>
6#include <xrpl/basics/StringUtilities.h>
7#include <xrpl/basics/base_uint.h>
8#include <xrpl/basics/contract.h>
9#include <xrpl/json/json_value.h>
10#include <xrpl/json/to_string.h>
11#include <xrpl/protocol/AccountID.h>
12#include <xrpl/protocol/SField.h>
13#include <xrpl/protocol/STObject.h>
14#include <xrpl/protocol/jss.h>
33 jv[sfTransactionType] = jss::PermissionedDomainSet;
42 object[sfCredential] = credential.toJson();
43 acceptedCredentials.
append(std::move(
object));
46 jv[sfAcceptedCredentials] = acceptedCredentials;
55 jv[sfTransactionType] = jss::PermissionedDomainDelete;
67 params[jss::account] = account.human();
69 params[jss::type] = jss::permissioned_domain;
71 auto const& resp = env.
rpc(
"json",
"account_objects",
to_string(params));
73 objects = resp[jss::result][jss::account_objects];
74 for (
auto const&
object : objects)
76 if (
object[
"LedgerEntryType"] !=
"PermissionedDomain")
81 "Invalid object type: " +
82 object[
"LedgerEntryType"].asString());
88 std::ignore = index.parseHex(
object[jss::index].asString());
102 auto const result = env.
rpc(
"json",
"ledger_entry",
to_string(params))[
"result"];
104 if ((result[
"status"] ==
"error") && (result[
"error"] ==
"entryNotFound"))
107 if ((result[
"node"][
"LedgerEntryType"] != jss::PermissionedDomain))
110 if (result[
"status"] ==
"success")
128 obj = credential[jss::Credential];
129 auto const& issuer = obj[jss::Issuer];
130 auto const& credentialType = obj[
"CredentialType"];
132 auto blob =
strUnHex(credentialType.asString()).value();
134 {.issuer = human2Acc.
at(issuer.asString()),
135 .credType =
std::string(blob.begin(), blob.end())});
146 for (
auto const& credential : input)
147 credentialsSet.
insert(credential);
148 return {credentialsSet.
begin(), credentialsSet.
end()};
157 a = metaJson[
"AffectedNodes"];
159 for (
auto const& node : a)
161 if (!node.isMember(
"CreatedNode") ||
162 node[
"CreatedNode"][
"LedgerEntryType"] !=
"PermissionedDomain")
166 std::ignore = ret.
parseHex(node[
"CreatedNode"][
"LedgerIndex"].asString());
Value & append(Value const &value)
Append value to array at the end.
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
Immutable cryptographic account descriptor.
A transaction testing environment.
json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
@ Array
array value (ordered list)
@ Object
object value (collection of name/value pairs).
std::vector< Credential > Credentials
Credentials credentialsFromJson(json::Value const &object, std::unordered_map< std::string, Account > const &human2Acc)
std::map< uint256, json::Value > getObjects(Account const &account, Env &env, bool withType)
json::Value setTx(AccountID const &account, Credentials const &credentials, std::optional< uint256 > domain)
json::Value deleteTx(AccountID const &account, uint256 const &domain)
uint256 getNewDomain(std::shared_ptr< STObject const > const &meta)
Credentials sortCredentials(Credentials const &input)
bool objectExists(uint256 const &objID, Env &env)
std::string to_string(BaseUInt< Bits, Tag > const &a)
std::optional< Blob > strUnHex(std::size_t strSize, Iterator begin, Iterator end)
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)