Account channel (#519)

Fixes #523
This commit is contained in:
cyan317
2023-02-24 09:34:29 +00:00
committed by GitHub
parent f6c2008540
commit 7d4e5ff0bd
12 changed files with 1412 additions and 15 deletions

View File

@@ -18,6 +18,7 @@
//==============================================================================
#include <ripple/basics/base_uint.h>
#include <rpc/RPCHelpers.h>
#include <rpc/common/Validators.h>
#include <boost/json/value.hpp>
@@ -126,4 +127,42 @@ CustomValidator LedgerIndexValidator = CustomValidator{
return MaybeError{};
}};
CustomValidator AccountValidator = CustomValidator{
[](boost::json::value const& value, std::string_view key) -> MaybeError {
if (!value.is_string())
{
return Error{RPC::Status{
RPC::RippledError::rpcINVALID_PARAMS,
std::string(key) + "NotString"}};
}
// TODO: we are using accountFromStringStrict from RPCHelpers, after we
// remove all old handler, this function can be moved to here
if (!RPC::accountFromStringStrict(value.as_string().c_str()))
{
return Error{RPC::Status{
RPC::RippledError::rpcINVALID_PARAMS,
std::string(key) + "Malformed"}};
}
return MaybeError{};
}};
CustomValidator MarkerValidator = CustomValidator{
[](boost::json::value const& value, std::string_view key) -> MaybeError {
if (!value.is_string())
{
return Error{RPC::Status{
RPC::RippledError::rpcINVALID_PARAMS,
std::string(key) + "NotString"}};
}
// TODO: we are using parseAccountCursor from RPCHelpers, after we
// remove all old handler, this function can be moved to here
if (!RPC::parseAccountCursor(value.as_string().c_str()))
{
// align with the current error message
return Error{RPC::Status{
RPC::RippledError::rpcINVALID_PARAMS, "Malformed cursor"}};
}
return MaybeError{};
}};
} // namespace RPCng::validation