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/Issue.h>
14#include <xrpl/protocol/STXChainBridge.h>
15#include <xrpl/protocol/jss.h>
31 json[jss::error] = err.value_or(
"malformedRequest");
41 json[jss::error] = err;
51 json[jss::error] = err;
53 json[jss::error_message] = message;
57inline std::expected<bool, json::Value>
63 for (
auto const field : fields)
78std::expected<T, json::Value>
89 if (
auto obj =
parse<T>(params[fieldName]))
104 if (!account || account->isZero())
112inline std::expected<AccountID, json::Value>
128 if (!blob || blob->empty() || blob->size() > maxLength)
134inline std::expected<Blob, json::Value>
145 if (
auto blob =
parseHexBlob(params[fieldName], maxLength))
169inline std::expected<std::uint32_t, json::Value>
191inline std::expected<uint256, json::Value>
213inline std::expected<uint192, json::Value>
236inline std::expected<Asset, json::Value>
242inline std::expected<STXChainBridge, json::Value>
247 {jss::LockingChainDoor,
248 jss::LockingChainIssue,
249 jss::IssuingChainDoor,
250 jss::IssuingChainIssue});
256 auto const lockingChainDoor =
258 if (!lockingChainDoor)
263 auto const issuingChainDoor =
265 if (!issuingChainDoor)
270 Issue lockingChainIssue;
273 lockingChainIssue =
issueFromJson(params[jss::LockingChainIssue]);
280 Issue issuingChainIssue;
283 issuingChainIssue =
issueFromJson(params[jss::IssuingChainIssue]);
291 *lockingChainDoor, lockingChainIssue, *issuingChainDoor, issuingChainIssue);
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.
A currency issued by an account.
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< STXChainBridge, json::Value > parseBridgeFields(json::Value const ¶ms)
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< uint256, json::Value > requiredUInt256(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::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)
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)