20#include <xrpld/rpc/detail/RPCHelpers.h>
22#include <xrpl/basics/StringUtilities.h>
23#include <xrpl/basics/strHex.h>
24#include <xrpl/beast/core/LexicalCast.h>
25#include <xrpl/json/json_errors.h>
26#include <xrpl/protocol/ErrorCodes.h>
27#include <xrpl/protocol/Indexes.h>
28#include <xrpl/protocol/RPCErr.h>
29#include <xrpl/protocol/STXChainBridge.h>
30#include <xrpl/protocol/jss.h>
36namespace LedgerEntryHelpers {
45 json[jss::error] = err.value_or(
"malformedRequest");
47 json[jss::error_message] = std::move(error);
59 json[jss::error] = err;
61 json[jss::error_message] = std::move(error);
69 json[jss::error] = err;
71 json[jss::error_message] = message;
81 for (
auto const field : fields)
107 if (
auto obj = parse<T>(params[fieldName]))
121 auto const account = parseBase58<AccountID>(param.
asString());
122 if (!account || account->isZero())
136 return required<AccountID>(params, fieldName, err,
"AccountID");
146 if (!blob || blob->empty() || blob->size() > maxLength)
163 if (
auto blob =
parseHexBlob(params[fieldName], maxLength))
193 return required<std::uint32_t>(params, fieldName, err,
"number");
215 return required<uint256>(params, fieldName, err,
"Hash256");
237 return required<uint192>(params, fieldName, err,
"Hash192");
245 {jss::LockingChainDoor,
246 jss::LockingChainIssue,
247 jss::IssuingChainDoor,
248 jss::IssuingChainIssue});
255 params, jss::LockingChainDoor,
"malformedLockingChainDoor");
256 if (!lockingChainDoor)
262 params, jss::IssuingChainDoor,
"malformedIssuingChainDoor");
263 if (!issuingChainDoor)
268 Issue lockingChainIssue;
271 lockingChainIssue =
issueFromJson(params[jss::LockingChainIssue]);
276 "malformedIssue", jss::LockingChainIssue,
"Issue");
279 Issue issuingChainIssue;
282 issuingChainIssue =
issueFromJson(params[jss::IssuingChainIssue]);
287 "malformedIssue", jss::IssuingChainIssue,
"Issue");
Lightweight wrapper to tag static string.
std::string asString() const
Returns the unquoted string value.
bool isNull() const
isNull() tests to see if this field is null.
bool isMember(char const *key) const
Return true if the object has a member named key.
A currency issued by an account.
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
@ objectValue
object value (collection of name/value pairs).
bool lexicalCastChecked(Out &out, In in)
Intelligently convert from one type to another.
std::optional< Blob > parseHexBlob(Json::Value const ¶m, std::size_t maxLength)
Expected< T, Json::Value > required(Json::Value const ¶ms, Json::StaticString const fieldName, std::string const &err, std::string const &expectedType)
Expected< STXChainBridge, Json::Value > parseBridgeFields(Json::Value const ¶ms)
Unexpected< Json::Value > malformedError(std::string const &err, std::string const &message)
Unexpected< Json::Value > invalidFieldError(std::string const &err, Json::StaticString const field, std::string const &type)
std::optional< T > parse(Json::Value const ¶m)
Expected< uint256, Json::Value > requiredUInt256(Json::Value const ¶ms, Json::StaticString const fieldName, std::string const &err)
Unexpected< Json::Value > missingFieldError(Json::StaticString const field, std::optional< std::string > err=std::nullopt)
Expected< bool, Json::Value > hasRequired(Json::Value const ¶ms, std::initializer_list< Json::StaticString > fields, std::optional< std::string > err=std::nullopt)
Expected< AccountID, Json::Value > requiredAccountID(Json::Value const ¶ms, Json::StaticString const fieldName, std::string const &err)
Expected< std::uint32_t, Json::Value > requiredUInt32(Json::Value const ¶ms, Json::StaticString const fieldName, std::string const &err)
Expected< uint192, Json::Value > requiredUInt192(Json::Value const ¶ms, Json::StaticString const fieldName, std::string const &err)
Expected< Blob, Json::Value > requiredHexBlob(Json::Value const ¶ms, Json::StaticString const fieldName, std::size_t maxLength, std::string const &err)
std::string missing_field_message(std::string const &name)
std::string expected_field_message(std::string const &name, std::string const &type)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::optional< Blob > strUnHex(std::size_t strSize, Iterator begin, Iterator end)
Issue issueFromJson(Json::Value const &v)