3#include <xrpld/rpc/detail/RPCHelpers.h>
5#include <xrpl/basics/Blob.h>
6#include <xrpl/basics/StringUtilities.h>
7#include <xrpl/basics/base_uint.h>
8#include <xrpl/beast/core/LexicalCast.h>
9#include <xrpl/json/json_value.h>
10#include <xrpl/protocol/AccountID.h>
11#include <xrpl/protocol/Asset.h>
12#include <xrpl/protocol/ErrorCodes.h>
13#include <xrpl/protocol/jss.h>
29 json[jss::error] = err.value_or(
"malformedRequest");
39 json[jss::error] = err;
49 json[jss::error] = err;
51 json[jss::error_message] = message;
55inline std::expected<bool, json::Value>
61 for (
auto const field : fields)
76std::expected<T, json::Value>
87 if (
auto obj =
parse<T>(params[fieldName]))
102 if (!account || account->isZero())
110inline std::expected<AccountID, json::Value>
126 if (!blob || blob->empty() || blob->size() > maxLength)
132inline std::expected<Blob, json::Value>
143 if (
auto blob =
parseHexBlob(params[fieldName], maxLength))
167inline std::expected<std::uint32_t, json::Value>
189inline std::expected<UInt256, json::Value>
211inline std::expected<UInt192, json::Value>
234inline std::expected<Asset, json::Value>
Lightweight wrapper to tag static string.
constexpr char const * cStr() const
bool isNull() const
isNull() tests to see if this field is null.
std::string asString() const
Returns the unquoted string value.
bool isMember(char const *key) const
Return true if the object has a member named key.
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
constexpr bool lexicalCastChecked(Out &out, In in)
Intelligently convert from one type to another.
JSON (JavaScript Object Notation).
@ Object
object value (collection of name/value pairs).
std::optional< T > parse(json::Value const ¶m)
std::expected< AccountID, json::Value > requiredAccountID(json::Value const ¶ms, json::StaticString const fieldName, std::string const &err)
std::expected< UInt192, json::Value > requiredUInt192(json::Value const ¶ms, json::StaticString const fieldName, std::string const &err)
std::expected< Asset, json::Value > requiredAsset(json::Value const ¶ms, json::StaticString const fieldName, std::string const &err)
std::expected< Blob, json::Value > requiredHexBlob(json::Value const ¶ms, json::StaticString const fieldName, std::size_t maxLength, std::string const &err)
std::expected< T, json::Value > required(json::Value const ¶ms, json::StaticString const fieldName, std::string const &err, std::string const &expectedType)
std::unexpected< json::Value > malformedError(std::string const &err, std::string const &message)
std::expected< std::uint32_t, json::Value > requiredUInt32(json::Value const ¶ms, json::StaticString const fieldName, std::string const &err)
std::expected< UInt256, json::Value > requiredUInt256(json::Value const ¶ms, json::StaticString const fieldName, std::string const &err)
std::optional< Blob > parseHexBlob(json::Value const ¶m, std::size_t maxLength)
std::unexpected< json::Value > missingFieldError(json::StaticString const field, std::optional< std::string > err=std::nullopt)
std::unexpected< json::Value > invalidFieldError(std::string const &err, json::StaticString const field, std::string const &type)
std::expected< bool, json::Value > hasRequired(json::Value const ¶ms, std::initializer_list< json::StaticString > fields, std::optional< std::string > err=std::nullopt)
std::string expectedFieldMessage(std::string const &name, std::string const &type)
std::string missingFieldMessage(std::string const &name)
std::optional< AccountID > parseBase58(std::string const &s)
Parse AccountID from checked, base58 string.
std::optional< Blob > strUnHex(std::size_t strSize, Iterator begin, Iterator end)
Asset assetFromJson(json::Value const &jv)