3#include <xrpld/rpc/detail/RPCHelpers.h>
5#include <xrpl/basics/StringUtilities.h>
6#include <xrpl/basics/strHex.h>
7#include <xrpl/beast/core/LexicalCast.h>
8#include <xrpl/json/json_errors.h>
9#include <xrpl/protocol/ErrorCodes.h>
10#include <xrpl/protocol/Indexes.h>
11#include <xrpl/protocol/RPCErr.h>
12#include <xrpl/protocol/STXChainBridge.h>
13#include <xrpl/protocol/jss.h>
24 json[jss::error] = err.value_or(
"malformedRequest");
34 json[jss::error] = err;
44 json[jss::error] = err;
46 json[jss::error_message] = message;
50inline std::expected<bool, json::Value>
56 for (
auto const field : fields)
71std::expected<T, json::Value>
82 if (
auto obj =
parse<T>(params[fieldName]))
97 if (!account || account->isZero())
105inline std::expected<AccountID, json::Value>
121 if (!blob || blob->empty() || blob->size() > maxLength)
127inline std::expected<Blob, json::Value>
138 if (
auto blob =
parseHexBlob(params[fieldName], maxLength))
162inline std::expected<std::uint32_t, json::Value>
184inline std::expected<uint256, json::Value>
206inline std::expected<uint192, json::Value>
229inline std::expected<Asset, json::Value>
235inline std::expected<STXChainBridge, json::Value>
240 {jss::LockingChainDoor,
241 jss::LockingChainIssue,
242 jss::IssuingChainDoor,
243 jss::IssuingChainIssue});
249 auto const lockingChainDoor =
251 if (!lockingChainDoor)
256 auto const issuingChainDoor =
258 if (!issuingChainDoor)
263 Issue lockingChainIssue;
266 lockingChainIssue =
issueFromJson(params[jss::LockingChainIssue]);
273 Issue issuingChainIssue;
276 issuingChainIssue =
issueFromJson(params[jss::IssuingChainIssue]);
284 *lockingChainDoor, lockingChainIssue, *issuingChainDoor, issuingChainIssue);
Lightweight wrapper to tag static string.
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.
A currency issued by an account.
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< 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::expected< T, json::Value > required(json::Value const ¶ms, json::StaticString const fieldName, std::string const &err, std::string const &expectedType)
std::expected< uint256, json::Value > requiredUInt256(json::Value const ¶ms, json::StaticString const fieldName, std::string const &err)
std::expected< STXChainBridge, json::Value > parseBridgeFields(json::Value const ¶ms)
std::optional< T > parse(json::Value const ¶m)
std::unexpected< json::Value > malformedError(std::string const &err, std::string const &message)
std::expected< Blob, json::Value > requiredHexBlob(json::Value const ¶ms, json::StaticString const fieldName, std::size_t maxLength, std::string const &err)
std::unexpected< json::Value > invalidFieldError(std::string const &err, json::StaticString const field, std::string const &type)
std::expected< Asset, json::Value > requiredAsset(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< std::uint32_t, json::Value > requiredUInt32(json::Value const ¶ms, json::StaticString const fieldName, std::string const &err)
std::expected< AccountID, json::Value > requiredAccountID(json::Value const ¶ms, json::StaticString const fieldName, std::string const &err)
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 missingFieldMessage(std::string const &name)
std::string expectedFieldMessage(std::string const &name, std::string const &type)
Issue issueFromJson(json::Value const &v)
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)