mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-04 20:05:51 +00:00
@@ -41,6 +41,7 @@
|
|||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/parse.hpp>
|
#include <boost/json/parse.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <grpcpp/grpcpp.h>
|
#include <grpcpp/grpcpp.h>
|
||||||
#include <ripple/basics/base_uint.h>
|
#include <ripple/basics/base_uint.h>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
@@ -320,11 +321,13 @@ private:
|
|||||||
|
|
||||||
data::LedgerObject stateObject = {};
|
data::LedgerObject stateObject = {};
|
||||||
|
|
||||||
if (!stateObject.key.parseHex(obj.at("index").as_string().c_str())) {
|
if (!stateObject.key.parseHex(boost::json::value_to<std::string>(obj.at("index")))) {
|
||||||
LOG(log_.error()) << "failed to parse object id";
|
LOG(log_.error()) << "failed to parse object id";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
boost::algorithm::unhex(obj.at("data").as_string().c_str(), std::back_inserter(stateObject.blob));
|
boost::algorithm::unhex(
|
||||||
|
boost::json::value_to<std::string>(obj.at("data")), std::back_inserter(stateObject.blob)
|
||||||
|
);
|
||||||
objects.push_back(std::move(stateObject));
|
objects.push_back(std::move(stateObject));
|
||||||
}
|
}
|
||||||
cache_.get().update(objects, ledgerIndex, true);
|
cache_.get().update(objects, ledgerIndex, true);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <boost/asio/spawn.hpp>
|
#include <boost/asio/spawn.hpp>
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -74,9 +75,9 @@ ForwardCache::get(boost::json::object const& request) const
|
|||||||
{
|
{
|
||||||
std::optional<std::string> command = {};
|
std::optional<std::string> command = {};
|
||||||
if (request.contains("command") && !request.contains("method") && request.at("command").is_string()) {
|
if (request.contains("command") && !request.contains("method") && request.at("command").is_string()) {
|
||||||
command = request.at("command").as_string().c_str();
|
command = boost::json::value_to<std::string>(request.at("command"));
|
||||||
} else if (request.contains("method") && !request.contains("command") && request.at("method").is_string()) {
|
} else if (request.contains("method") && !request.contains("command") && request.at("method").is_string()) {
|
||||||
command = request.at("method").as_string().c_str();
|
command = boost::json::value_to<std::string>(request.at("method"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!command)
|
if (!command)
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include <boost/json/array.hpp>
|
#include <boost/json/array.hpp>
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/protocol/ErrorCodes.h>
|
#include <ripple/protocol/ErrorCodes.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@@ -67,7 +68,7 @@ make_WsContext(
|
|||||||
if (!apiVersion)
|
if (!apiVersion)
|
||||||
return Error{{ClioError::rpcINVALID_API_VERSION, apiVersion.error()}};
|
return Error{{ClioError::rpcINVALID_API_VERSION, apiVersion.error()}};
|
||||||
|
|
||||||
string const command = commandValue.as_string().c_str();
|
auto const command = boost::json::value_to<std::string>(commandValue);
|
||||||
return web::Context(yc, command, *apiVersion, request, session, tagFactory, range, clientIp, session->isAdmin());
|
return web::Context(yc, command, *apiVersion, request, session, tagFactory, range, clientIp, session->isAdmin());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@ make_HttpContext(
|
|||||||
if (request.at("method").as_string().empty())
|
if (request.at("method").as_string().empty())
|
||||||
return Error{{ClioError::rpcCOMMAND_IS_EMPTY}};
|
return Error{{ClioError::rpcCOMMAND_IS_EMPTY}};
|
||||||
|
|
||||||
string const command = request.at("method").as_string().c_str();
|
auto const command = boost::json::value_to<std::string>(request.at("method"));
|
||||||
|
|
||||||
if (command == "subscribe" || command == "unsubscribe")
|
if (command == "subscribe" || command == "unsubscribe")
|
||||||
return Error{{RippledError::rpcBAD_SYNTAX, "Subscribe and unsubscribe are only allowed or websocket."}};
|
return Error{{RippledError::rpcBAD_SYNTAX, "Subscribe and unsubscribe are only allowed or websocket."}};
|
||||||
|
|||||||
@@ -19,8 +19,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "util/JsonUtils.hpp"
|
|
||||||
|
|
||||||
#include <ripple/protocol/jss.h>
|
#include <ripple/protocol/jss.h>
|
||||||
|
|
||||||
/** @brief Helper macro for borrowing from ripple::jss static (J)son (S)trings. */
|
/** @brief Helper macro for borrowing from ripple::jss static (J)son (S)trings. */
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
#include <boost/json/parse.hpp>
|
#include <boost/json/parse.hpp>
|
||||||
#include <boost/json/string.hpp>
|
#include <boost/json/string.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/lexical_cast/bad_lexical_cast.hpp>
|
#include <boost/lexical_cast/bad_lexical_cast.hpp>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
@@ -410,7 +411,7 @@ ledgerInfoFromRequest(std::shared_ptr<data::BackendInterface const> const& backe
|
|||||||
return Status{RippledError::rpcINVALID_PARAMS, "ledgerHashNotString"};
|
return Status{RippledError::rpcINVALID_PARAMS, "ledgerHashNotString"};
|
||||||
|
|
||||||
ripple::uint256 ledgerHash;
|
ripple::uint256 ledgerHash;
|
||||||
if (!ledgerHash.parseHex(hashValue.as_string().c_str()))
|
if (!ledgerHash.parseHex(boost::json::value_to<std::string>(hashValue)))
|
||||||
return Status{RippledError::rpcINVALID_PARAMS, "ledgerHashMalformed"};
|
return Status{RippledError::rpcINVALID_PARAMS, "ledgerHashMalformed"};
|
||||||
|
|
||||||
auto lgrInfo = backend->fetchLedgerByHash(ledgerHash, ctx.yield);
|
auto lgrInfo = backend->fetchLedgerByHash(ledgerHash, ctx.yield);
|
||||||
@@ -426,11 +427,11 @@ ledgerInfoFromRequest(std::shared_ptr<data::BackendInterface const> const& backe
|
|||||||
std::optional<std::uint32_t> ledgerSequence = {};
|
std::optional<std::uint32_t> ledgerSequence = {};
|
||||||
if (!indexValue.is_null()) {
|
if (!indexValue.is_null()) {
|
||||||
if (indexValue.is_string()) {
|
if (indexValue.is_string()) {
|
||||||
boost::json::string const& stringIndex = indexValue.as_string();
|
auto const stringIndex = boost::json::value_to<std::string>(indexValue);
|
||||||
if (stringIndex == "validated") {
|
if (stringIndex == "validated") {
|
||||||
ledgerSequence = ctx.range.maxSequence;
|
ledgerSequence = ctx.range.maxSequence;
|
||||||
} else {
|
} else {
|
||||||
ledgerSequence = parseStringAsUInt(stringIndex.c_str());
|
ledgerSequence = parseStringAsUInt(stringIndex);
|
||||||
}
|
}
|
||||||
} else if (indexValue.is_int64())
|
} else if (indexValue.is_int64())
|
||||||
ledgerSequence = indexValue.as_int64();
|
ledgerSequence = indexValue.as_int64();
|
||||||
@@ -784,7 +785,7 @@ parseRippleLibSeed(boost::json::value const& value)
|
|||||||
if (!value.is_string())
|
if (!value.is_string())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
auto const result = ripple::decodeBase58Token(value.as_string().c_str(), ripple::TokenType::None);
|
auto const result = ripple::decodeBase58Token(boost::json::value_to<std::string>(value), ripple::TokenType::None);
|
||||||
|
|
||||||
static std::size_t constexpr SEED_SIZE = 18;
|
static std::size_t constexpr SEED_SIZE = 18;
|
||||||
static std::array<std::uint8_t, 2> constexpr SEED_PREFIX = {0xE1, 0x4B};
|
static std::array<std::uint8_t, 2> constexpr SEED_PREFIX = {0xE1, 0x4B};
|
||||||
@@ -831,7 +832,7 @@ keypairFromRequst(boost::json::object const& request)
|
|||||||
if (!request.at("key_type").is_string())
|
if (!request.at("key_type").is_string())
|
||||||
return Status{RippledError::rpcINVALID_PARAMS, "keyTypeNotString"};
|
return Status{RippledError::rpcINVALID_PARAMS, "keyTypeNotString"};
|
||||||
|
|
||||||
std::string const key_type = request.at("key_type").as_string().c_str();
|
auto const key_type = boost::json::value_to<std::string>(request.at("key_type"));
|
||||||
keyType = ripple::keyTypeFromString(key_type);
|
keyType = ripple::keyTypeFromString(key_type);
|
||||||
|
|
||||||
if (!keyType)
|
if (!keyType)
|
||||||
@@ -865,7 +866,7 @@ keypairFromRequst(boost::json::object const& request)
|
|||||||
if (!request.at(secretType).is_string())
|
if (!request.at(secretType).is_string())
|
||||||
return Status{RippledError::rpcINVALID_PARAMS, "secret value must be string"};
|
return Status{RippledError::rpcINVALID_PARAMS, "secret value must be string"};
|
||||||
|
|
||||||
std::string const key = request.at(secretType).as_string().c_str();
|
auto const key = boost::json::value_to<std::string>(request.at(secretType));
|
||||||
|
|
||||||
if (secretType == "seed") {
|
if (secretType == "seed") {
|
||||||
seed = ripple::parseBase58<ripple::Seed>(key);
|
seed = ripple::parseBase58<ripple::Seed>(key);
|
||||||
@@ -880,7 +881,7 @@ keypairFromRequst(boost::json::object const& request)
|
|||||||
if (!request.at("secret").is_string())
|
if (!request.at("secret").is_string())
|
||||||
return Status{RippledError::rpcINVALID_PARAMS, "field secret should be a string"};
|
return Status{RippledError::rpcINVALID_PARAMS, "field secret should be a string"};
|
||||||
|
|
||||||
std::string const secret = request.at("secret").as_string().c_str();
|
auto const secret = boost::json::value_to<std::string>(request.at("secret"));
|
||||||
seed = ripple::parseGenericSeed(secret);
|
seed = ripple::parseGenericSeed(secret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -903,7 +904,7 @@ getAccountsFromTransaction(boost::json::object const& transaction)
|
|||||||
auto inObject = getAccountsFromTransaction(value.as_object());
|
auto inObject = getAccountsFromTransaction(value.as_object());
|
||||||
accounts.insert(accounts.end(), inObject.begin(), inObject.end());
|
accounts.insert(accounts.end(), inObject.begin(), inObject.end());
|
||||||
} else if (value.is_string()) {
|
} else if (value.is_string()) {
|
||||||
auto account = ripple::parseBase58<ripple::AccountID>(value.as_string().c_str());
|
auto const account = ripple::parseBase58<ripple::AccountID>(boost::json::value_to<std::string>(value));
|
||||||
if (account) {
|
if (account) {
|
||||||
accounts.push_back(*account);
|
accounts.push_back(*account);
|
||||||
}
|
}
|
||||||
@@ -1265,11 +1266,11 @@ parseBook(boost::json::object const& request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ripple::Currency pay_currency;
|
ripple::Currency pay_currency;
|
||||||
if (!ripple::to_currency(pay_currency, taker_pays.at("currency").as_string().c_str()))
|
if (!ripple::to_currency(pay_currency, boost::json::value_to<std::string>(taker_pays.at("currency"))))
|
||||||
return Status{RippledError::rpcSRC_CUR_MALFORMED};
|
return Status{RippledError::rpcSRC_CUR_MALFORMED};
|
||||||
|
|
||||||
ripple::Currency get_currency;
|
ripple::Currency get_currency;
|
||||||
if (!ripple::to_currency(get_currency, taker_gets["currency"].as_string().c_str()))
|
if (!ripple::to_currency(get_currency, boost::json::value_to<std::string>(taker_gets["currency"])))
|
||||||
return Status{RippledError::rpcDST_AMT_MALFORMED};
|
return Status{RippledError::rpcDST_AMT_MALFORMED};
|
||||||
|
|
||||||
ripple::AccountID pay_issuer;
|
ripple::AccountID pay_issuer;
|
||||||
@@ -1277,7 +1278,7 @@ parseBook(boost::json::object const& request)
|
|||||||
if (!taker_pays.at("issuer").is_string())
|
if (!taker_pays.at("issuer").is_string())
|
||||||
return Status{RippledError::rpcINVALID_PARAMS, "takerPaysIssuerNotString"};
|
return Status{RippledError::rpcINVALID_PARAMS, "takerPaysIssuerNotString"};
|
||||||
|
|
||||||
if (!ripple::to_issuer(pay_issuer, taker_pays.at("issuer").as_string().c_str()))
|
if (!ripple::to_issuer(pay_issuer, boost::json::value_to<std::string>(taker_pays.at("issuer"))))
|
||||||
return Status{RippledError::rpcSRC_ISR_MALFORMED};
|
return Status{RippledError::rpcSRC_ISR_MALFORMED};
|
||||||
|
|
||||||
if (pay_issuer == ripple::noAccount())
|
if (pay_issuer == ripple::noAccount())
|
||||||
@@ -1307,7 +1308,7 @@ parseBook(boost::json::object const& request)
|
|||||||
if (!taker_gets["issuer"].is_string())
|
if (!taker_gets["issuer"].is_string())
|
||||||
return Status{RippledError::rpcINVALID_PARAMS, "taker_gets.issuer should be string"};
|
return Status{RippledError::rpcINVALID_PARAMS, "taker_gets.issuer should be string"};
|
||||||
|
|
||||||
if (!ripple::to_issuer(get_issuer, taker_gets.at("issuer").as_string().c_str()))
|
if (!ripple::to_issuer(get_issuer, boost::json::value_to<std::string>(taker_gets.at("issuer"))))
|
||||||
return Status{RippledError::rpcDST_ISR_MALFORMED, "Invalid field 'taker_gets.issuer', bad issuer."};
|
return Status{RippledError::rpcDST_ISR_MALFORMED, "Invalid field 'taker_gets.issuer', bad issuer."};
|
||||||
|
|
||||||
if (get_issuer == ripple::noAccount()) {
|
if (get_issuer == ripple::noAccount()) {
|
||||||
@@ -1344,7 +1345,7 @@ parseTaker(boost::json::value const& taker)
|
|||||||
if (!taker.is_string())
|
if (!taker.is_string())
|
||||||
return {Status{RippledError::rpcINVALID_PARAMS, "takerNotString"}};
|
return {Status{RippledError::rpcINVALID_PARAMS, "takerNotString"}};
|
||||||
|
|
||||||
takerID = accountFromStringStrict(taker.as_string().c_str());
|
takerID = accountFromStringStrict(boost::json::value_to<std::string>(taker));
|
||||||
|
|
||||||
if (!takerID)
|
if (!takerID)
|
||||||
return Status{RippledError::rpcBAD_ISSUER, "invalidTakerAccount"};
|
return Status{RippledError::rpcBAD_ISSUER, "invalidTakerAccount"};
|
||||||
@@ -1356,9 +1357,9 @@ parseIssue(boost::json::object const& issue)
|
|||||||
{
|
{
|
||||||
Json::Value jv;
|
Json::Value jv;
|
||||||
if (issue.contains(JS(issuer)) && issue.at(JS(issuer)).is_string())
|
if (issue.contains(JS(issuer)) && issue.at(JS(issuer)).is_string())
|
||||||
jv["issuer"] = issue.at(JS(issuer)).as_string().c_str();
|
jv["issuer"] = boost::json::value_to<std::string>(issue.at(JS(issuer)));
|
||||||
if (issue.contains(JS(currency)) && issue.at(JS(currency)).is_string())
|
if (issue.contains(JS(currency)) && issue.at(JS(currency)).is_string())
|
||||||
jv["currency"] = issue.at(JS(currency)).as_string().c_str();
|
jv["currency"] = boost::json::value_to<std::string>(issue.at(JS(currency)));
|
||||||
|
|
||||||
return ripple::issueFromJson(jv);
|
return ripple::issueFromJson(jv);
|
||||||
}
|
}
|
||||||
@@ -1369,7 +1370,7 @@ specifiesCurrentOrClosedLedger(boost::json::object const& request)
|
|||||||
if (request.contains("ledger_index")) {
|
if (request.contains("ledger_index")) {
|
||||||
auto indexValue = request.at("ledger_index");
|
auto indexValue = request.at("ledger_index");
|
||||||
if (indexValue.is_string()) {
|
if (indexValue.is_string()) {
|
||||||
std::string const index = indexValue.as_string().c_str();
|
auto const index = boost::json::value_to<std::string>(indexValue);
|
||||||
return index == "current" || index == "closed";
|
return index == "current" || index == "closed";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1386,7 +1387,7 @@ getNFTID(boost::json::object const& request)
|
|||||||
return Status{RippledError::rpcINVALID_PARAMS, "tokenIDNotString"};
|
return Status{RippledError::rpcINVALID_PARAMS, "tokenIDNotString"};
|
||||||
|
|
||||||
ripple::uint256 tokenid;
|
ripple::uint256 tokenid;
|
||||||
if (!tokenid.parseHex(request.at(JS(nft_id)).as_string().c_str()))
|
if (!tokenid.parseHex(boost::json::value_to<std::string>(request.at(JS(nft_id)))))
|
||||||
return Status{RippledError::rpcINVALID_PARAMS, "malformedTokenID"};
|
return Status{RippledError::rpcINVALID_PARAMS, "malformedTokenID"};
|
||||||
|
|
||||||
return tokenid;
|
return tokenid;
|
||||||
|
|||||||
@@ -23,7 +23,9 @@
|
|||||||
#include "util/JsonUtils.hpp"
|
#include "util/JsonUtils.hpp"
|
||||||
|
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
namespace rpc::modifiers {
|
namespace rpc::modifiers {
|
||||||
@@ -92,7 +94,8 @@ struct ToLower final {
|
|||||||
if (not value.as_object().at(key.data()).is_string())
|
if (not value.as_object().at(key.data()).is_string())
|
||||||
return {}; // ignore for non-string types
|
return {}; // ignore for non-string types
|
||||||
|
|
||||||
value.as_object()[key.data()] = util::toLower(value.as_object().at(key.data()).as_string().c_str());
|
value.as_object()[key.data()] =
|
||||||
|
util::toLower(boost::json::value_to<std::string>(value.as_object().at(key.data())));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <ripple/basics/base_uint.h>
|
#include <ripple/basics/base_uint.h>
|
||||||
#include <ripple/protocol/AccountID.h>
|
#include <ripple/protocol/AccountID.h>
|
||||||
@@ -75,7 +76,7 @@ CustomValidator Uint256HexStringValidator =
|
|||||||
return Error{Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "NotString"}};
|
return Error{Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "NotString"}};
|
||||||
|
|
||||||
ripple::uint256 ledgerHash;
|
ripple::uint256 ledgerHash;
|
||||||
if (!ledgerHash.parseHex(value.as_string().c_str()))
|
if (!ledgerHash.parseHex(boost::json::value_to<std::string>(value)))
|
||||||
return Error{Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "Malformed"}};
|
return Error{Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "Malformed"}};
|
||||||
|
|
||||||
return MaybeError{};
|
return MaybeError{};
|
||||||
@@ -88,7 +89,8 @@ CustomValidator LedgerIndexValidator =
|
|||||||
if (!value.is_string() && !(value.is_uint64() || value.is_int64()))
|
if (!value.is_string() && !(value.is_uint64() || value.is_int64()))
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (value.is_string() && value.as_string() != "validated" && !checkIsU32Numeric(value.as_string().c_str()))
|
if (value.is_string() && value.as_string() != "validated" &&
|
||||||
|
!checkIsU32Numeric(boost::json::value_to<std::string>(value)))
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
return MaybeError{};
|
return MaybeError{};
|
||||||
@@ -101,7 +103,7 @@ CustomValidator AccountValidator =
|
|||||||
|
|
||||||
// TODO: we are using accountFromStringStrict from RPCHelpers, after we
|
// TODO: we are using accountFromStringStrict from RPCHelpers, after we
|
||||||
// remove all old handler, this function can be moved to here
|
// remove all old handler, this function can be moved to here
|
||||||
if (!accountFromStringStrict(value.as_string().c_str()))
|
if (!accountFromStringStrict(boost::json::value_to<std::string>(value)))
|
||||||
return Error{Status{RippledError::rpcACT_MALFORMED, std::string(key) + "Malformed"}};
|
return Error{Status{RippledError::rpcACT_MALFORMED, std::string(key) + "Malformed"}};
|
||||||
|
|
||||||
return MaybeError{};
|
return MaybeError{};
|
||||||
@@ -112,7 +114,7 @@ CustomValidator AccountBase58Validator =
|
|||||||
if (!value.is_string())
|
if (!value.is_string())
|
||||||
return Error{Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "NotString"}};
|
return Error{Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "NotString"}};
|
||||||
|
|
||||||
auto const account = ripple::parseBase58<ripple::AccountID>(value.as_string().c_str());
|
auto const account = ripple::parseBase58<ripple::AccountID>(boost::json::value_to<std::string>(value));
|
||||||
if (!account || account->isZero())
|
if (!account || account->isZero())
|
||||||
return Error{Status{ClioError::rpcMALFORMED_ADDRESS}};
|
return Error{Status{ClioError::rpcMALFORMED_ADDRESS}};
|
||||||
|
|
||||||
@@ -126,7 +128,7 @@ CustomValidator AccountMarkerValidator =
|
|||||||
|
|
||||||
// TODO: we are using parseAccountCursor from RPCHelpers, after we
|
// TODO: we are using parseAccountCursor from RPCHelpers, after we
|
||||||
// remove all old handler, this function can be moved to here
|
// remove all old handler, this function can be moved to here
|
||||||
if (!parseAccountCursor(value.as_string().c_str())) {
|
if (!parseAccountCursor(boost::json::value_to<std::string>(value))) {
|
||||||
// align with the current error message
|
// align with the current error message
|
||||||
return Error{Status{RippledError::rpcINVALID_PARAMS, "Malformed cursor."}};
|
return Error{Status{RippledError::rpcINVALID_PARAMS, "Malformed cursor."}};
|
||||||
}
|
}
|
||||||
@@ -140,7 +142,7 @@ CustomValidator CurrencyValidator =
|
|||||||
return Error{Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "NotString"}};
|
return Error{Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "NotString"}};
|
||||||
|
|
||||||
ripple::Currency currency;
|
ripple::Currency currency;
|
||||||
if (!ripple::to_currency(currency, value.as_string().c_str()))
|
if (!ripple::to_currency(currency, boost::json::value_to<std::string>(value)))
|
||||||
return Error{Status{ClioError::rpcMALFORMED_CURRENCY, "malformedCurrency"}};
|
return Error{Status{ClioError::rpcMALFORMED_CURRENCY, "malformedCurrency"}};
|
||||||
|
|
||||||
return MaybeError{};
|
return MaybeError{};
|
||||||
@@ -154,7 +156,7 @@ CustomValidator IssuerValidator =
|
|||||||
ripple::AccountID issuer;
|
ripple::AccountID issuer;
|
||||||
|
|
||||||
// TODO: need to align with the error
|
// TODO: need to align with the error
|
||||||
if (!ripple::to_issuer(issuer, value.as_string().c_str()))
|
if (!ripple::to_issuer(issuer, boost::json::value_to<std::string>(value)))
|
||||||
return Error{Status{RippledError::rpcINVALID_PARAMS, fmt::format("Invalid field '{}', bad issuer.", key)}};
|
return Error{Status{RippledError::rpcINVALID_PARAMS, fmt::format("Invalid field '{}', bad issuer.", key)}};
|
||||||
|
|
||||||
if (issuer == ripple::noAccount()) {
|
if (issuer == ripple::noAccount()) {
|
||||||
@@ -182,10 +184,10 @@ CustomValidator SubscribeStreamValidator =
|
|||||||
if (!v.is_string())
|
if (!v.is_string())
|
||||||
return Error{Status{RippledError::rpcINVALID_PARAMS, "streamNotString"}};
|
return Error{Status{RippledError::rpcINVALID_PARAMS, "streamNotString"}};
|
||||||
|
|
||||||
if (reportingNotSupportStreams.contains(v.as_string().c_str()))
|
if (reportingNotSupportStreams.contains(boost::json::value_to<std::string>(v)))
|
||||||
return Error{Status{RippledError::rpcREPORTING_UNSUPPORTED}};
|
return Error{Status{RippledError::rpcREPORTING_UNSUPPORTED}};
|
||||||
|
|
||||||
if (not validStreams.contains(v.as_string().c_str()))
|
if (not validStreams.contains(boost::json::value_to<std::string>(v)))
|
||||||
return Error{Status{RippledError::rpcSTREAM_MALFORMED}};
|
return Error{Status{RippledError::rpcSTREAM_MALFORMED}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <date/date.h>
|
#include <date/date.h>
|
||||||
#include <ripple/basics/base_uint.h>
|
#include <ripple/basics/base_uint.h>
|
||||||
#include <ripple/basics/chrono.h>
|
#include <ripple/basics/chrono.h>
|
||||||
@@ -222,7 +223,7 @@ AMMInfoHandler::spec([[maybe_unused]] uint32_t apiVersion)
|
|||||||
return Error{Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "NotString"}};
|
return Error{Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "NotString"}};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ripple::issueFromJson(value.as_string().c_str());
|
ripple::issueFromJson(boost::json::value_to<std::string>(value));
|
||||||
} catch (std::runtime_error const&) {
|
} catch (std::runtime_error const&) {
|
||||||
return Error{Status{RippledError::rpcISSUE_MALFORMED}};
|
return Error{Status{RippledError::rpcISSUE_MALFORMED}};
|
||||||
}
|
}
|
||||||
@@ -294,13 +295,13 @@ tag_invoke(boost::json::value_to_tag<AMMInfoHandler::Input>, boost::json::value
|
|||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jv.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jv.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jv.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jv.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -311,9 +312,9 @@ tag_invoke(boost::json::value_to_tag<AMMInfoHandler::Input>, boost::json::value
|
|||||||
input.issue2 = parseIssue(jsonObject.at(JS(asset2)).as_object());
|
input.issue2 = parseIssue(jsonObject.at(JS(asset2)).as_object());
|
||||||
|
|
||||||
if (jsonObject.contains(JS(account)))
|
if (jsonObject.contains(JS(account)))
|
||||||
input.accountID = accountFromStringStrict(jsonObject.at(JS(account)).as_string().c_str());
|
input.accountID = accountFromStringStrict(boost::json::value_to<std::string>(jsonObject.at(JS(account))));
|
||||||
if (jsonObject.contains(JS(amm_account)))
|
if (jsonObject.contains(JS(amm_account)))
|
||||||
input.ammAccount = accountFromStringStrict(jsonObject.at(JS(amm_account)).as_string().c_str());
|
input.ammAccount = accountFromStringStrict(boost::json::value_to<std::string>(jsonObject.at(JS(amm_account))));
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/base_uint.h>
|
#include <ripple/basics/base_uint.h>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
#include <ripple/protocol/AccountID.h>
|
#include <ripple/protocol/AccountID.h>
|
||||||
@@ -137,25 +138,25 @@ tag_invoke(boost::json::value_to_tag<AccountChannelsHandler::Input>, boost::json
|
|||||||
auto input = AccountChannelsHandler::Input{};
|
auto input = AccountChannelsHandler::Input{};
|
||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
input.account = jv.at(JS(account)).as_string().c_str();
|
input.account = boost::json::value_to<std::string>(jv.at(JS(account)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(limit)))
|
if (jsonObject.contains(JS(limit)))
|
||||||
input.limit = jv.at(JS(limit)).as_int64();
|
input.limit = jv.at(JS(limit)).as_int64();
|
||||||
|
|
||||||
if (jsonObject.contains(JS(marker)))
|
if (jsonObject.contains(JS(marker)))
|
||||||
input.marker = jv.at(JS(marker)).as_string().c_str();
|
input.marker = boost::json::value_to<std::string>(jv.at(JS(marker)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jv.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jv.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(destination_account)))
|
if (jsonObject.contains(JS(destination_account)))
|
||||||
input.destinationAccount = jv.at(JS(destination_account)).as_string().c_str();
|
input.destinationAccount = boost::json::value_to<std::string>(jv.at(JS(destination_account)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jv.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jv.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
#include <ripple/protocol/ErrorCodes.h>
|
#include <ripple/protocol/ErrorCodes.h>
|
||||||
#include <ripple/protocol/Indexes.h>
|
#include <ripple/protocol/Indexes.h>
|
||||||
@@ -121,16 +122,16 @@ tag_invoke(boost::json::value_to_tag<AccountCurrenciesHandler::Input>, boost::js
|
|||||||
auto input = AccountCurrenciesHandler::Input{};
|
auto input = AccountCurrenciesHandler::Input{};
|
||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
input.account = jv.at(JS(account)).as_string().c_str();
|
input.account = boost::json::value_to<std::string>(jv.at(JS(account)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jv.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jv.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jv.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jv.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -188,19 +188,19 @@ tag_invoke(boost::json::value_to_tag<AccountInfoHandler::Input>, boost::json::va
|
|||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ident)))
|
if (jsonObject.contains(JS(ident)))
|
||||||
input.ident = jsonObject.at(JS(ident)).as_string().c_str();
|
input.ident = boost::json::value_to<std::string>(jsonObject.at(JS(ident)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(account)))
|
if (jsonObject.contains(JS(account)))
|
||||||
input.account = jsonObject.at(JS(account)).as_string().c_str();
|
input.account = boost::json::value_to<std::string>(jsonObject.at(JS(account)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jsonObject.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jsonObject.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jsonObject.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jsonObject.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
#include <ripple/protocol/AccountID.h>
|
#include <ripple/protocol/AccountID.h>
|
||||||
#include <ripple/protocol/ErrorCodes.h>
|
#include <ripple/protocol/ErrorCodes.h>
|
||||||
@@ -183,18 +184,18 @@ tag_invoke(boost::json::value_to_tag<AccountLinesHandler::Input>, boost::json::v
|
|||||||
auto input = AccountLinesHandler::Input{};
|
auto input = AccountLinesHandler::Input{};
|
||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
input.account = jv.at(JS(account)).as_string().c_str();
|
input.account = boost::json::value_to<std::string>(jv.at(JS(account)));
|
||||||
if (jsonObject.contains(JS(limit)))
|
if (jsonObject.contains(JS(limit)))
|
||||||
input.limit = jv.at(JS(limit)).as_int64();
|
input.limit = jv.at(JS(limit)).as_int64();
|
||||||
|
|
||||||
if (jsonObject.contains(JS(marker)))
|
if (jsonObject.contains(JS(marker)))
|
||||||
input.marker = jv.at(JS(marker)).as_string().c_str();
|
input.marker = boost::json::value_to<std::string>(jv.at(JS(marker)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jv.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jv.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(peer)))
|
if (jsonObject.contains(JS(peer)))
|
||||||
input.peer = jv.at(JS(peer)).as_string().c_str();
|
input.peer = boost::json::value_to<std::string>(jv.at(JS(peer)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ignore_default)))
|
if (jsonObject.contains(JS(ignore_default)))
|
||||||
input.ignoreDefault = jv.at(JS(ignore_default)).as_bool();
|
input.ignoreDefault = jv.at(JS(ignore_default)).as_bool();
|
||||||
@@ -203,7 +204,7 @@ tag_invoke(boost::json::value_to_tag<AccountLinesHandler::Input>, boost::json::v
|
|||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jv.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jv.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/base_uint.h>
|
#include <ripple/basics/base_uint.h>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
#include <ripple/protocol/AccountID.h>
|
#include <ripple/protocol/AccountID.h>
|
||||||
@@ -143,16 +144,16 @@ tag_invoke(boost::json::value_to_tag<AccountNFTsHandler::Input>, boost::json::va
|
|||||||
auto input = AccountNFTsHandler::Input{};
|
auto input = AccountNFTsHandler::Input{};
|
||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
input.account = jsonObject.at(JS(account)).as_string().c_str();
|
input.account = boost::json::value_to<std::string>(jsonObject.at(JS(account)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jsonObject.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jsonObject.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jsonObject.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jsonObject.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +161,7 @@ tag_invoke(boost::json::value_to_tag<AccountNFTsHandler::Input>, boost::json::va
|
|||||||
input.limit = jsonObject.at(JS(limit)).as_int64();
|
input.limit = jsonObject.at(JS(limit)).as_int64();
|
||||||
|
|
||||||
if (jsonObject.contains(JS(marker)))
|
if (jsonObject.contains(JS(marker)))
|
||||||
input.marker = jsonObject.at(JS(marker)).as_string().c_str();
|
input.marker = boost::json::value_to<std::string>(jsonObject.at(JS(marker)));
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <boost/json/array.hpp>
|
#include <boost/json/array.hpp>
|
||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
#include <ripple/protocol/ErrorCodes.h>
|
#include <ripple/protocol/ErrorCodes.h>
|
||||||
#include <ripple/protocol/Indexes.h>
|
#include <ripple/protocol/Indexes.h>
|
||||||
@@ -145,27 +146,27 @@ tag_invoke(boost::json::value_to_tag<AccountObjectsHandler::Input>, boost::json:
|
|||||||
auto input = AccountObjectsHandler::Input{};
|
auto input = AccountObjectsHandler::Input{};
|
||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
input.account = jv.at(JS(account)).as_string().c_str();
|
input.account = boost::json::value_to<std::string>(jv.at(JS(account)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jv.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jv.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jv.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jv.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.contains(JS(type)))
|
if (jsonObject.contains(JS(type)))
|
||||||
input.type = util::getLedgerEntryTypeFromStr(jv.at(JS(type)).as_string().c_str());
|
input.type = util::getLedgerEntryTypeFromStr(boost::json::value_to<std::string>(jv.at(JS(type))));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(limit)))
|
if (jsonObject.contains(JS(limit)))
|
||||||
input.limit = jv.at(JS(limit)).as_int64();
|
input.limit = jv.at(JS(limit)).as_int64();
|
||||||
|
|
||||||
if (jsonObject.contains(JS(marker)))
|
if (jsonObject.contains(JS(marker)))
|
||||||
input.marker = jv.at(JS(marker)).as_string().c_str();
|
input.marker = boost::json::value_to<std::string>(jv.at(JS(marker)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(deletion_blockers_only)))
|
if (jsonObject.contains(JS(deletion_blockers_only)))
|
||||||
input.deletionBlockersOnly = jsonObject.at(JS(deletion_blockers_only)).as_bool();
|
input.deletionBlockersOnly = jsonObject.at(JS(deletion_blockers_only)).as_bool();
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
#include <boost/json/value_from.hpp>
|
#include <boost/json/value_from.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
#include <ripple/protocol/AccountID.h>
|
#include <ripple/protocol/AccountID.h>
|
||||||
#include <ripple/protocol/ErrorCodes.h>
|
#include <ripple/protocol/ErrorCodes.h>
|
||||||
@@ -161,16 +162,16 @@ tag_invoke(boost::json::value_to_tag<AccountOffersHandler::Input>, boost::json::
|
|||||||
auto input = AccountOffersHandler::Input{};
|
auto input = AccountOffersHandler::Input{};
|
||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
input.account = jsonObject.at(JS(account)).as_string().c_str();
|
input.account = boost::json::value_to<std::string>(jsonObject.at(JS(account)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash))) {
|
if (jsonObject.contains(JS(ledger_hash))) {
|
||||||
input.ledgerHash = jsonObject.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jsonObject.at(JS(ledger_hash)));
|
||||||
}
|
}
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jsonObject.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jsonObject.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +179,7 @@ tag_invoke(boost::json::value_to_tag<AccountOffersHandler::Input>, boost::json::
|
|||||||
input.limit = jsonObject.at(JS(limit)).as_int64();
|
input.limit = jsonObject.at(JS(limit)).as_int64();
|
||||||
|
|
||||||
if (jsonObject.contains(JS(marker)))
|
if (jsonObject.contains(JS(marker)))
|
||||||
input.marker = jsonObject.at(JS(marker)).as_string().c_str();
|
input.marker = boost::json::value_to<std::string>(jsonObject.at(JS(marker)));
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,8 @@ AccountTxHandler::process(AccountTxHandler::Input input, Context const& ctx) con
|
|||||||
auto [txn, meta] = toExpandedJson(txnPlusMeta, ctx.apiVersion, NFTokenjson::ENABLE);
|
auto [txn, meta] = toExpandedJson(txnPlusMeta, ctx.apiVersion, NFTokenjson::ENABLE);
|
||||||
|
|
||||||
if (txn.contains(JS(TransactionType)) && input.transactionTypeInLowercase.has_value() &&
|
if (txn.contains(JS(TransactionType)) && input.transactionTypeInLowercase.has_value() &&
|
||||||
util::toLower(txn[JS(TransactionType)].as_string().c_str()) != input.transactionTypeInLowercase.value())
|
util::toLower(boost::json::value_to<std::string>(txn[JS(TransactionType)])) !=
|
||||||
|
input.transactionTypeInLowercase.value())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!input.binary) {
|
if (!input.binary) {
|
||||||
@@ -229,7 +230,7 @@ tag_invoke(boost::json::value_to_tag<AccountTxHandler::Input>, boost::json::valu
|
|||||||
auto input = AccountTxHandler::Input{};
|
auto input = AccountTxHandler::Input{};
|
||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
input.account = jsonObject.at(JS(account)).as_string().c_str();
|
input.account = boost::json::value_to<std::string>(jsonObject.at(JS(account)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index_min)) && jsonObject.at(JS(ledger_index_min)).as_int64() != -1)
|
if (jsonObject.contains(JS(ledger_index_min)) && jsonObject.at(JS(ledger_index_min)).as_int64() != -1)
|
||||||
input.ledgerIndexMin = jsonObject.at(JS(ledger_index_min)).as_int64();
|
input.ledgerIndexMin = jsonObject.at(JS(ledger_index_min)).as_int64();
|
||||||
@@ -238,13 +239,13 @@ tag_invoke(boost::json::value_to_tag<AccountTxHandler::Input>, boost::json::valu
|
|||||||
input.ledgerIndexMax = jsonObject.at(JS(ledger_index_max)).as_int64();
|
input.ledgerIndexMax = jsonObject.at(JS(ledger_index_max)).as_int64();
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jsonObject.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jsonObject.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jsonObject.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jsonObject.at(JS(ledger_index))));
|
||||||
} else {
|
} else {
|
||||||
// could not get the latest validated ledger seq here, using this flag to indicate that
|
// could not get the latest validated ledger seq here, using this flag to indicate that
|
||||||
input.usingValidatedLedger = true;
|
input.usingValidatedLedger = true;
|
||||||
@@ -268,7 +269,7 @@ tag_invoke(boost::json::value_to_tag<AccountTxHandler::Input>, boost::json::valu
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.contains("tx_type"))
|
if (jsonObject.contains("tx_type"))
|
||||||
input.transactionTypeInLowercase = jsonObject.at("tx_type").as_string().c_str();
|
input.transactionTypeInLowercase = boost::json::value_to<std::string>(jsonObject.at("tx_type"));
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/base_uint.h>
|
#include <ripple/basics/base_uint.h>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
#include <ripple/protocol/LedgerHeader.h>
|
#include <ripple/protocol/LedgerHeader.h>
|
||||||
@@ -85,13 +86,13 @@ tag_invoke(boost::json::value_to_tag<BookChangesHandler::Input>, boost::json::va
|
|||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jv.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jv.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jv.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jv.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
#include <ripple/beast/utility/Zero.h>
|
#include <ripple/beast/utility/Zero.h>
|
||||||
#include <ripple/protocol/AccountID.h>
|
#include <ripple/protocol/AccountID.h>
|
||||||
@@ -90,28 +91,38 @@ tag_invoke(boost::json::value_to_tag<BookOffersHandler::Input>, boost::json::val
|
|||||||
auto input = BookOffersHandler::Input{};
|
auto input = BookOffersHandler::Input{};
|
||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
ripple::to_currency(input.getsCurrency, jv.at(JS(taker_gets)).as_object().at(JS(currency)).as_string().c_str());
|
ripple::to_currency(
|
||||||
ripple::to_currency(input.paysCurrency, jv.at(JS(taker_pays)).as_object().at(JS(currency)).as_string().c_str());
|
input.getsCurrency, boost::json::value_to<std::string>(jv.at(JS(taker_gets)).as_object().at(JS(currency)))
|
||||||
|
);
|
||||||
|
ripple::to_currency(
|
||||||
|
input.paysCurrency, boost::json::value_to<std::string>(jv.at(JS(taker_pays)).as_object().at(JS(currency)))
|
||||||
|
);
|
||||||
|
|
||||||
if (jv.at(JS(taker_gets)).as_object().contains(JS(issuer)))
|
if (jv.at(JS(taker_gets)).as_object().contains(JS(issuer))) {
|
||||||
ripple::to_issuer(input.getsID, jv.at(JS(taker_gets)).as_object().at(JS(issuer)).as_string().c_str());
|
ripple::to_issuer(
|
||||||
|
input.getsID, boost::json::value_to<std::string>(jv.at(JS(taker_gets)).as_object().at(JS(issuer)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (jv.at(JS(taker_pays)).as_object().contains(JS(issuer)))
|
if (jv.at(JS(taker_pays)).as_object().contains(JS(issuer))) {
|
||||||
ripple::to_issuer(input.paysID, jv.at(JS(taker_pays)).as_object().at(JS(issuer)).as_string().c_str());
|
ripple::to_issuer(
|
||||||
|
input.paysID, boost::json::value_to<std::string>(jv.at(JS(taker_pays)).as_object().at(JS(issuer)))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jv.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jv.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jv.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jv.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.contains(JS(taker)))
|
if (jsonObject.contains(JS(taker)))
|
||||||
input.taker = accountFromStringStrict(jv.at(JS(taker)).as_string().c_str());
|
input.taker = accountFromStringStrict(boost::json::value_to<std::string>(jv.at(JS(taker))));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(limit)))
|
if (jsonObject.contains(JS(limit)))
|
||||||
input.limit = jv.at(JS(limit)).as_int64();
|
input.limit = jv.at(JS(limit)).as_int64();
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
#include <ripple/protocol/ErrorCodes.h>
|
#include <ripple/protocol/ErrorCodes.h>
|
||||||
#include <ripple/protocol/Indexes.h>
|
#include <ripple/protocol/Indexes.h>
|
||||||
@@ -101,17 +102,17 @@ tag_invoke(boost::json::value_to_tag<DepositAuthorizedHandler::Input>, boost::js
|
|||||||
auto input = DepositAuthorizedHandler::Input{};
|
auto input = DepositAuthorizedHandler::Input{};
|
||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
input.sourceAccount = jv.at(JS(source_account)).as_string().c_str();
|
input.sourceAccount = boost::json::value_to<std::string>(jv.at(JS(source_account)));
|
||||||
input.destinationAccount = jv.at(JS(destination_account)).as_string().c_str();
|
input.destinationAccount = boost::json::value_to<std::string>(jv.at(JS(destination_account)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jv.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jv.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jv.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jv.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
#include <ripple/beast/utility/Zero.h>
|
#include <ripple/beast/utility/Zero.h>
|
||||||
#include <ripple/protocol/AccountID.h>
|
#include <ripple/protocol/AccountID.h>
|
||||||
@@ -212,29 +213,31 @@ tag_invoke(boost::json::value_to_tag<GatewayBalancesHandler::Input>, boost::json
|
|||||||
auto input = GatewayBalancesHandler::Input{};
|
auto input = GatewayBalancesHandler::Input{};
|
||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
input.account = jv.at(JS(account)).as_string().c_str();
|
input.account = boost::json::value_to<std::string>(jv.at(JS(account)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jv.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jv.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jv.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jv.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.contains(JS(hotwallet))) {
|
if (jsonObject.contains(JS(hotwallet))) {
|
||||||
if (jsonObject.at(JS(hotwallet)).is_string()) {
|
if (jsonObject.at(JS(hotwallet)).is_string()) {
|
||||||
input.hotWallets.insert(*accountFromStringStrict(jv.at(JS(hotwallet)).as_string().c_str()));
|
input.hotWallets.insert(*accountFromStringStrict(boost::json::value_to<std::string>(jv.at(JS(hotwallet)))));
|
||||||
} else {
|
} else {
|
||||||
auto const& hotWallets = jv.at(JS(hotwallet)).as_array();
|
auto const& hotWallets = jv.at(JS(hotwallet)).as_array();
|
||||||
std::transform(
|
std::transform(
|
||||||
hotWallets.begin(),
|
hotWallets.begin(),
|
||||||
hotWallets.end(),
|
hotWallets.end(),
|
||||||
std::inserter(input.hotWallets, input.hotWallets.begin()),
|
std::inserter(input.hotWallets, input.hotWallets.begin()),
|
||||||
[](auto const& hotWallet) { return *accountFromStringStrict(hotWallet.as_string().c_str()); }
|
[](auto const& hotWallet) {
|
||||||
|
return *accountFromStringStrict(boost::json::value_to<std::string>(hotWallet));
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,13 +98,13 @@ public:
|
|||||||
auto const getAccountID = [](auto const& j) -> std::optional<ripple::AccountID> {
|
auto const getAccountID = [](auto const& j) -> std::optional<ripple::AccountID> {
|
||||||
if (j.is_string()) {
|
if (j.is_string()) {
|
||||||
auto const pk = ripple::parseBase58<ripple::PublicKey>(
|
auto const pk = ripple::parseBase58<ripple::PublicKey>(
|
||||||
ripple::TokenType::AccountPublic, j.as_string().c_str()
|
ripple::TokenType::AccountPublic, boost::json::value_to<std::string>(j)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (pk)
|
if (pk)
|
||||||
return ripple::calcAccountID(*pk);
|
return ripple::calcAccountID(*pk);
|
||||||
|
|
||||||
return ripple::parseBase58<ripple::AccountID>(j.as_string().c_str());
|
return ripple::parseBase58<ripple::AccountID>(boost::json::value_to<std::string>(j));
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/string.hpp>
|
#include <boost/json/string.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/chrono.h>
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
#include <ripple/protocol/LedgerHeader.h>
|
#include <ripple/protocol/LedgerHeader.h>
|
||||||
@@ -202,13 +203,13 @@ tag_invoke(boost::json::value_to_tag<LedgerHandler::Input>, boost::json::value c
|
|||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jv.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jv.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jv.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jv.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/base_uint.h>
|
#include <ripple/basics/base_uint.h>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
#include <ripple/protocol/ErrorCodes.h>
|
#include <ripple/protocol/ErrorCodes.h>
|
||||||
@@ -197,25 +198,25 @@ tag_invoke(boost::json::value_to_tag<LedgerDataHandler::Input>, boost::json::val
|
|||||||
|
|
||||||
if (jsonObject.contains("marker")) {
|
if (jsonObject.contains("marker")) {
|
||||||
if (jsonObject.at("marker").is_string()) {
|
if (jsonObject.at("marker").is_string()) {
|
||||||
input.marker = ripple::uint256{jsonObject.at("marker").as_string().c_str()};
|
input.marker = ripple::uint256{boost::json::value_to<std::string>(jsonObject.at("marker")).data()};
|
||||||
} else {
|
} else {
|
||||||
input.diffMarker = jsonObject.at("marker").as_int64();
|
input.diffMarker = jsonObject.at("marker").as_int64();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jsonObject.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jsonObject.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jsonObject.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jsonObject.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.contains(JS(type)))
|
if (jsonObject.contains(JS(type)))
|
||||||
input.type = util::getLedgerEntryTypeFromStr(jsonObject.at(JS(type)).as_string().c_str());
|
input.type = util::getLedgerEntryTypeFromStr(boost::json::value_to<std::string>(jsonObject.at(JS(type))));
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,40 +73,47 @@ LedgerEntryHandler::process(LedgerEntryHandler::Input input, Context const& ctx)
|
|||||||
|
|
||||||
key = std::get<ripple::uint256>(keyOrStatus);
|
key = std::get<ripple::uint256>(keyOrStatus);
|
||||||
} else if (input.offer) {
|
} else if (input.offer) {
|
||||||
auto const id = ripple::parseBase58<ripple::AccountID>(input.offer->at(JS(account)).as_string().c_str());
|
auto const id =
|
||||||
|
ripple::parseBase58<ripple::AccountID>(boost::json::value_to<std::string>(input.offer->at(JS(account))));
|
||||||
key = ripple::keylet::offer(*id, boost::json::value_to<std::uint32_t>(input.offer->at(JS(seq)))).key;
|
key = ripple::keylet::offer(*id, boost::json::value_to<std::uint32_t>(input.offer->at(JS(seq)))).key;
|
||||||
} else if (input.rippleStateAccount) {
|
} else if (input.rippleStateAccount) {
|
||||||
auto const id1 = ripple::parseBase58<ripple::AccountID>(
|
auto const id1 = ripple::parseBase58<ripple::AccountID>(
|
||||||
input.rippleStateAccount->at(JS(accounts)).as_array().at(0).as_string().c_str()
|
boost::json::value_to<std::string>(input.rippleStateAccount->at(JS(accounts)).as_array().at(0))
|
||||||
);
|
);
|
||||||
auto const id2 = ripple::parseBase58<ripple::AccountID>(
|
auto const id2 = ripple::parseBase58<ripple::AccountID>(
|
||||||
input.rippleStateAccount->at(JS(accounts)).as_array().at(1).as_string().c_str()
|
boost::json::value_to<std::string>(input.rippleStateAccount->at(JS(accounts)).as_array().at(1))
|
||||||
);
|
);
|
||||||
auto const currency = ripple::to_currency(input.rippleStateAccount->at(JS(currency)).as_string().c_str());
|
auto const currency =
|
||||||
|
ripple::to_currency(boost::json::value_to<std::string>(input.rippleStateAccount->at(JS(currency))));
|
||||||
|
|
||||||
key = ripple::keylet::line(*id1, *id2, currency).key;
|
key = ripple::keylet::line(*id1, *id2, currency).key;
|
||||||
} else if (input.escrow) {
|
} else if (input.escrow) {
|
||||||
auto const id = ripple::parseBase58<ripple::AccountID>(input.escrow->at(JS(owner)).as_string().c_str());
|
auto const id =
|
||||||
|
ripple::parseBase58<ripple::AccountID>(boost::json::value_to<std::string>(input.escrow->at(JS(owner))));
|
||||||
key = ripple::keylet::escrow(*id, input.escrow->at(JS(seq)).as_int64()).key;
|
key = ripple::keylet::escrow(*id, input.escrow->at(JS(seq)).as_int64()).key;
|
||||||
} else if (input.depositPreauth) {
|
} else if (input.depositPreauth) {
|
||||||
auto const owner =
|
auto const owner = ripple::parseBase58<ripple::AccountID>(
|
||||||
ripple::parseBase58<ripple::AccountID>(input.depositPreauth->at(JS(owner)).as_string().c_str());
|
boost::json::value_to<std::string>(input.depositPreauth->at(JS(owner)))
|
||||||
auto const authorized =
|
);
|
||||||
ripple::parseBase58<ripple::AccountID>(input.depositPreauth->at(JS(authorized)).as_string().c_str());
|
auto const authorized = ripple::parseBase58<ripple::AccountID>(
|
||||||
|
boost::json::value_to<std::string>(input.depositPreauth->at(JS(authorized)))
|
||||||
|
);
|
||||||
|
|
||||||
key = ripple::keylet::depositPreauth(*owner, *authorized).key;
|
key = ripple::keylet::depositPreauth(*owner, *authorized).key;
|
||||||
} else if (input.ticket) {
|
} else if (input.ticket) {
|
||||||
auto const id = ripple::parseBase58<ripple::AccountID>(input.ticket->at(JS(account)).as_string().c_str());
|
auto const id =
|
||||||
|
ripple::parseBase58<ripple::AccountID>(boost::json::value_to<std::string>(input.ticket->at(JS(account))));
|
||||||
|
|
||||||
key = ripple::getTicketIndex(*id, input.ticket->at(JS(ticket_seq)).as_int64());
|
key = ripple::getTicketIndex(*id, input.ticket->at(JS(ticket_seq)).as_int64());
|
||||||
} else if (input.amm) {
|
} else if (input.amm) {
|
||||||
auto const getIssuerFromJson = [](auto const& assetJson) {
|
auto const getIssuerFromJson = [](auto const& assetJson) {
|
||||||
// the field check has been done in validator
|
// the field check has been done in validator
|
||||||
auto const currency = ripple::to_currency(assetJson.at(JS(currency)).as_string().c_str());
|
auto const currency = ripple::to_currency(boost::json::value_to<std::string>(assetJson.at(JS(currency))));
|
||||||
if (ripple::isXRP(currency)) {
|
if (ripple::isXRP(currency)) {
|
||||||
return ripple::xrpIssue();
|
return ripple::xrpIssue();
|
||||||
}
|
}
|
||||||
auto const issuer = ripple::parseBase58<ripple::AccountID>(assetJson.at(JS(issuer)).as_string().c_str());
|
auto const issuer =
|
||||||
|
ripple::parseBase58<ripple::AccountID>(boost::json::value_to<std::string>(assetJson.at(JS(issuer))));
|
||||||
return ripple::Issue{currency, *issuer};
|
return ripple::Issue{currency, *issuer};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -188,11 +195,12 @@ LedgerEntryHandler::composeKeyFromDirectory(boost::json::object const& directory
|
|||||||
directory.contains(JS(sub_index)) ? boost::json::value_to<uint64_t>(directory.at(JS(sub_index))) : 0;
|
directory.contains(JS(sub_index)) ? boost::json::value_to<uint64_t>(directory.at(JS(sub_index))) : 0;
|
||||||
|
|
||||||
if (directory.contains(JS(dir_root))) {
|
if (directory.contains(JS(dir_root))) {
|
||||||
ripple::uint256 const uDirRoot{directory.at(JS(dir_root)).as_string().c_str()};
|
ripple::uint256 const uDirRoot{boost::json::value_to<std::string>(directory.at(JS(dir_root))).data()};
|
||||||
return ripple::keylet::page(uDirRoot, subIndex).key;
|
return ripple::keylet::page(uDirRoot, subIndex).key;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const ownerID = ripple::parseBase58<ripple::AccountID>(directory.at(JS(owner)).as_string().c_str());
|
auto const ownerID =
|
||||||
|
ripple::parseBase58<ripple::AccountID>(boost::json::value_to<std::string>(directory.at(JS(owner))));
|
||||||
return ripple::keylet::page(ripple::keylet::ownerDir(*ownerID), subIndex).key;
|
return ripple::keylet::page(ripple::keylet::ownerDir(*ownerID), subIndex).key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,13 +230,13 @@ tag_invoke(boost::json::value_to_tag<LedgerEntryHandler::Input>, boost::json::va
|
|||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jv.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jv.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jv.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jv.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,10 +261,10 @@ tag_invoke(boost::json::value_to_tag<LedgerEntryHandler::Input>, boost::json::va
|
|||||||
|
|
||||||
auto const parseBridgeFromJson = [](boost::json::value const& bridgeJson) {
|
auto const parseBridgeFromJson = [](boost::json::value const& bridgeJson) {
|
||||||
auto const lockingDoor = *ripple::parseBase58<ripple::AccountID>(
|
auto const lockingDoor = *ripple::parseBase58<ripple::AccountID>(
|
||||||
bridgeJson.at(ripple::sfLockingChainDoor.getJsonName().c_str()).as_string().c_str()
|
boost::json::value_to<std::string>(bridgeJson.at(ripple::sfLockingChainDoor.getJsonName().c_str()))
|
||||||
);
|
);
|
||||||
auto const issuingDoor = *ripple::parseBase58<ripple::AccountID>(
|
auto const issuingDoor = *ripple::parseBase58<ripple::AccountID>(
|
||||||
bridgeJson.at(ripple::sfIssuingChainDoor.getJsonName().c_str()).as_string().c_str()
|
boost::json::value_to<std::string>(bridgeJson.at(ripple::sfIssuingChainDoor.getJsonName().c_str()))
|
||||||
);
|
);
|
||||||
auto const lockingIssue =
|
auto const lockingIssue =
|
||||||
parseIssue(bridgeJson.at(ripple::sfLockingChainIssue.getJsonName().c_str()).as_object());
|
parseIssue(bridgeJson.at(ripple::sfLockingChainIssue.getJsonName().c_str()).as_object());
|
||||||
@@ -273,14 +281,14 @@ tag_invoke(boost::json::value_to_tag<LedgerEntryHandler::Input>, boost::json::va
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (indexFieldType != indexFieldTypeMap.end()) {
|
if (indexFieldType != indexFieldTypeMap.end()) {
|
||||||
input.index = jv.at(indexFieldType->first).as_string().c_str();
|
input.index = boost::json::value_to<std::string>(jv.at(indexFieldType->first));
|
||||||
input.expectedType = indexFieldType->second;
|
input.expectedType = indexFieldType->second;
|
||||||
}
|
}
|
||||||
// check if request for account root
|
// check if request for account root
|
||||||
else if (jsonObject.contains(JS(account_root))) {
|
else if (jsonObject.contains(JS(account_root))) {
|
||||||
input.accountRoot = jv.at(JS(account_root)).as_string().c_str();
|
input.accountRoot = boost::json::value_to<std::string>(jv.at(JS(account_root)));
|
||||||
} else if (jsonObject.contains(JS(did))) {
|
} else if (jsonObject.contains(JS(did))) {
|
||||||
input.did = jv.at(JS(did)).as_string().c_str();
|
input.did = boost::json::value_to<std::string>(jv.at(JS(did)));
|
||||||
}
|
}
|
||||||
// no need to check if_object again, validator only allows string or object
|
// no need to check if_object again, validator only allows string or object
|
||||||
else if (jsonObject.contains(JS(directory))) {
|
else if (jsonObject.contains(JS(directory))) {
|
||||||
@@ -300,7 +308,7 @@ tag_invoke(boost::json::value_to_tag<LedgerEntryHandler::Input>, boost::json::va
|
|||||||
} else if (jsonObject.contains(JS(bridge))) {
|
} else if (jsonObject.contains(JS(bridge))) {
|
||||||
input.bridge.emplace(parseBridgeFromJson(jv.at(JS(bridge))));
|
input.bridge.emplace(parseBridgeFromJson(jv.at(JS(bridge))));
|
||||||
if (jsonObject.contains(JS(bridge_account)))
|
if (jsonObject.contains(JS(bridge_account)))
|
||||||
input.bridgeAccount = jv.at(JS(bridge_account)).as_string().c_str();
|
input.bridgeAccount = boost::json::value_to<std::string>(jv.at(JS(bridge_account)));
|
||||||
} else if (jsonObject.contains(JS(xchain_owned_claim_id))) {
|
} else if (jsonObject.contains(JS(xchain_owned_claim_id))) {
|
||||||
input.bridge.emplace(parseBridgeFromJson(jv.at(JS(xchain_owned_claim_id))));
|
input.bridge.emplace(parseBridgeFromJson(jv.at(JS(xchain_owned_claim_id))));
|
||||||
input.chainClaimId =
|
input.chainClaimId =
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/base_uint.h>
|
#include <ripple/basics/base_uint.h>
|
||||||
#include <ripple/protocol/AccountID.h>
|
#include <ripple/protocol/AccountID.h>
|
||||||
#include <ripple/protocol/ErrorCodes.h>
|
#include <ripple/protocol/ErrorCodes.h>
|
||||||
@@ -113,8 +114,10 @@ public:
|
|||||||
return Error{Status{RippledError::rpcINVALID_PARAMS, "malformedAccounts"}};
|
return Error{Status{RippledError::rpcINVALID_PARAMS, "malformedAccounts"}};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const id1 = ripple::parseBase58<ripple::AccountID>(value.as_array()[0].as_string().c_str());
|
auto const id1 =
|
||||||
auto const id2 = ripple::parseBase58<ripple::AccountID>(value.as_array()[1].as_string().c_str());
|
ripple::parseBase58<ripple::AccountID>(boost::json::value_to<std::string>(value.as_array()[0]));
|
||||||
|
auto const id2 =
|
||||||
|
ripple::parseBase58<ripple::AccountID>(boost::json::value_to<std::string>(value.as_array()[1]));
|
||||||
|
|
||||||
if (!id1 || !id2)
|
if (!id1 || !id2)
|
||||||
return Error{Status{ClioError::rpcMALFORMED_ADDRESS, "malformedAddresses"}};
|
return Error{Status{ClioError::rpcMALFORMED_ADDRESS, "malformedAddresses"}};
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
#include <boost/json/value_from.hpp>
|
#include <boost/json/value_from.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/base_uint.h>
|
#include <ripple/basics/base_uint.h>
|
||||||
#include <ripple/basics/chrono.h>
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
@@ -199,7 +200,7 @@ tag_invoke(boost::json::value_to_tag<NFTHistoryHandler::Input>, boost::json::val
|
|||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
auto input = NFTHistoryHandler::Input{};
|
auto input = NFTHistoryHandler::Input{};
|
||||||
|
|
||||||
input.nftID = jsonObject.at(JS(nft_id)).as_string().c_str();
|
input.nftID = boost::json::value_to<std::string>(jsonObject.at(JS(nft_id)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index_min)) && jsonObject.at(JS(ledger_index_min)).as_int64() != -1)
|
if (jsonObject.contains(JS(ledger_index_min)) && jsonObject.at(JS(ledger_index_min)).as_int64() != -1)
|
||||||
input.ledgerIndexMin = jsonObject.at(JS(ledger_index_min)).as_int64();
|
input.ledgerIndexMin = jsonObject.at(JS(ledger_index_min)).as_int64();
|
||||||
@@ -208,13 +209,13 @@ tag_invoke(boost::json::value_to_tag<NFTHistoryHandler::Input>, boost::json::val
|
|||||||
input.ledgerIndexMax = jsonObject.at(JS(ledger_index_max)).as_int64();
|
input.ledgerIndexMax = jsonObject.at(JS(ledger_index_max)).as_int64();
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jsonObject.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jsonObject.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jsonObject.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jsonObject.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/base_uint.h>
|
#include <ripple/basics/base_uint.h>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
#include <ripple/protocol/AccountID.h>
|
#include <ripple/protocol/AccountID.h>
|
||||||
@@ -108,16 +109,16 @@ tag_invoke(boost::json::value_to_tag<NFTInfoHandler::Input>, boost::json::value
|
|||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
auto input = NFTInfoHandler::Input{};
|
auto input = NFTInfoHandler::Input{};
|
||||||
|
|
||||||
input.nftID = jsonObject.at(JS(nft_id)).as_string().c_str();
|
input.nftID = boost::json::value_to<std::string>(jsonObject.at(JS(nft_id)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jsonObject.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jsonObject.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jsonObject.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jsonObject.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/base_uint.h>
|
#include <ripple/basics/base_uint.h>
|
||||||
#include <ripple/protocol/AccountID.h>
|
#include <ripple/protocol/AccountID.h>
|
||||||
#include <ripple/protocol/ErrorCodes.h>
|
#include <ripple/protocol/ErrorCodes.h>
|
||||||
@@ -192,21 +193,21 @@ tag_invoke(boost::json::value_to_tag<NFTOffersHandlerBase::Input>, boost::json::
|
|||||||
auto input = NFTOffersHandlerBase::Input{};
|
auto input = NFTOffersHandlerBase::Input{};
|
||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
input.nftID = jsonObject.at(JS(nft_id)).as_string().c_str();
|
input.nftID = boost::json::value_to<std::string>(jsonObject.at(JS(nft_id)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jsonObject.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jsonObject.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jsonObject.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jsonObject.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jsonObject.contains(JS(marker)))
|
if (jsonObject.contains(JS(marker)))
|
||||||
input.marker = jsonObject.at(JS(marker)).as_string().c_str();
|
input.marker = boost::json::value_to<std::string>(jsonObject.at(JS(marker)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(limit)))
|
if (jsonObject.contains(JS(limit)))
|
||||||
input.limit = jsonObject.at(JS(limit)).as_int64();
|
input.limit = jsonObject.at(JS(limit)).as_int64();
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/base_uint.h>
|
#include <ripple/basics/base_uint.h>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
#include <ripple/protocol/AccountID.h>
|
#include <ripple/protocol/AccountID.h>
|
||||||
@@ -127,16 +128,16 @@ tag_invoke(boost::json::value_to_tag<NFTsByIssuerHandler::Input>, boost::json::v
|
|||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
NFTsByIssuerHandler::Input input;
|
NFTsByIssuerHandler::Input input;
|
||||||
|
|
||||||
input.issuer = jsonObject.at(JS(issuer)).as_string().c_str();
|
input.issuer = boost::json::value_to<std::string>(jsonObject.at(JS(issuer)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jsonObject.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jsonObject.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jsonObject.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jsonObject.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,7 +148,7 @@ tag_invoke(boost::json::value_to_tag<NFTsByIssuerHandler::Input>, boost::json::v
|
|||||||
input.nftTaxon = jsonObject.at("nft_taxon").as_int64();
|
input.nftTaxon = jsonObject.at("nft_taxon").as_int64();
|
||||||
|
|
||||||
if (jsonObject.contains(JS(marker)))
|
if (jsonObject.contains(JS(marker)))
|
||||||
input.marker = jsonObject.at(JS(marker)).as_string().c_str();
|
input.marker = boost::json::value_to<std::string>(jsonObject.at(JS(marker)));
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ tag_invoke(boost::json::value_to_tag<NoRippleCheckHandler::Input>, boost::json::
|
|||||||
auto input = NoRippleCheckHandler::Input{};
|
auto input = NoRippleCheckHandler::Input{};
|
||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
input.account = jsonObject.at(JS(account)).as_string().c_str();
|
input.account = boost::json::value_to<std::string>(jsonObject.at(JS(account)));
|
||||||
input.roleGateway = jsonObject.at(JS(role)).as_string() == "gateway";
|
input.roleGateway = jsonObject.at(JS(role)).as_string() == "gateway";
|
||||||
|
|
||||||
if (jsonObject.contains(JS(limit)))
|
if (jsonObject.contains(JS(limit)))
|
||||||
@@ -192,13 +192,13 @@ tag_invoke(boost::json::value_to_tag<NoRippleCheckHandler::Input>, boost::json::
|
|||||||
input.transactions = boost::json::value_to<JsonBool>(jsonObject.at(JS(transactions)));
|
input.transactions = boost::json::value_to<JsonBool>(jsonObject.at(JS(transactions)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jsonObject.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jsonObject.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jsonObject.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jsonObject.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jsonObject.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/beast/utility/Zero.h>
|
#include <ripple/beast/utility/Zero.h>
|
||||||
#include <ripple/protocol/Book.h>
|
#include <ripple/protocol/Book.h>
|
||||||
#include <ripple/protocol/ErrorCodes.h>
|
#include <ripple/protocol/ErrorCodes.h>
|
||||||
@@ -294,20 +295,20 @@ private:
|
|||||||
if (auto const& streams = jsonObject.find(JS(streams)); streams != jsonObject.end()) {
|
if (auto const& streams = jsonObject.find(JS(streams)); streams != jsonObject.end()) {
|
||||||
input.streams = std::vector<std::string>();
|
input.streams = std::vector<std::string>();
|
||||||
for (auto const& stream : streams->value().as_array())
|
for (auto const& stream : streams->value().as_array())
|
||||||
input.streams->push_back(stream.as_string().c_str());
|
input.streams->push_back(boost::json::value_to<std::string>(stream));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto const& accounts = jsonObject.find(JS(accounts)); accounts != jsonObject.end()) {
|
if (auto const& accounts = jsonObject.find(JS(accounts)); accounts != jsonObject.end()) {
|
||||||
input.accounts = std::vector<std::string>();
|
input.accounts = std::vector<std::string>();
|
||||||
for (auto const& account : accounts->value().as_array())
|
for (auto const& account : accounts->value().as_array())
|
||||||
input.accounts->push_back(account.as_string().c_str());
|
input.accounts->push_back(boost::json::value_to<std::string>(account));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto const& accountsProposed = jsonObject.find(JS(accounts_proposed));
|
if (auto const& accountsProposed = jsonObject.find(JS(accounts_proposed));
|
||||||
accountsProposed != jsonObject.end()) {
|
accountsProposed != jsonObject.end()) {
|
||||||
input.accountsProposed = std::vector<std::string>();
|
input.accountsProposed = std::vector<std::string>();
|
||||||
for (auto const& account : accountsProposed->value().as_array())
|
for (auto const& account : accountsProposed->value().as_array())
|
||||||
input.accountsProposed->push_back(account.as_string().c_str());
|
input.accountsProposed->push_back(boost::json::value_to<std::string>(account));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto const& books = jsonObject.find(JS(books)); books != jsonObject.end()) {
|
if (auto const& books = jsonObject.find(JS(books)); books != jsonObject.end()) {
|
||||||
@@ -317,7 +318,7 @@ private:
|
|||||||
auto const& bookObject = book.as_object();
|
auto const& bookObject = book.as_object();
|
||||||
|
|
||||||
if (auto const& taker = bookObject.find(JS(taker)); taker != bookObject.end())
|
if (auto const& taker = bookObject.find(JS(taker)); taker != bookObject.end())
|
||||||
internalBook.taker = taker->value().as_string().c_str();
|
internalBook.taker = boost::json::value_to<std::string>(taker->value());
|
||||||
|
|
||||||
if (auto const& both = bookObject.find(JS(both)); both != bookObject.end())
|
if (auto const& both = bookObject.find(JS(both)); both != bookObject.end())
|
||||||
internalBook.both = both->value().as_bool();
|
internalBook.both = both->value().as_bool();
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <ripple/basics/base_uint.h>
|
#include <ripple/basics/base_uint.h>
|
||||||
#include <ripple/basics/chrono.h>
|
#include <ripple/basics/chrono.h>
|
||||||
#include <ripple/basics/strHex.h>
|
#include <ripple/basics/strHex.h>
|
||||||
@@ -102,16 +103,16 @@ tag_invoke(boost::json::value_to_tag<TransactionEntryHandler::Input>, boost::jso
|
|||||||
auto input = TransactionEntryHandler::Input{};
|
auto input = TransactionEntryHandler::Input{};
|
||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
input.txHash = jv.at(JS(tx_hash)).as_string().c_str();
|
input.txHash = boost::json::value_to<std::string>(jv.at(JS(tx_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_hash)))
|
if (jsonObject.contains(JS(ledger_hash)))
|
||||||
input.ledgerHash = jv.at(JS(ledger_hash)).as_string().c_str();
|
input.ledgerHash = boost::json::value_to<std::string>(jv.at(JS(ledger_hash)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ledger_index))) {
|
if (jsonObject.contains(JS(ledger_index))) {
|
||||||
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
if (!jsonObject.at(JS(ledger_index)).is_string()) {
|
||||||
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
input.ledgerIndex = jv.at(JS(ledger_index)).as_int64();
|
||||||
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
} else if (jsonObject.at(JS(ledger_index)).as_string() != "validated") {
|
||||||
input.ledgerIndex = std::stoi(jv.at(JS(ledger_index)).as_string().c_str());
|
input.ledgerIndex = std::stoi(boost::json::value_to<std::string>(jv.at(JS(ledger_index))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -289,10 +289,10 @@ private:
|
|||||||
auto const& jsonObject = jv.as_object();
|
auto const& jsonObject = jv.as_object();
|
||||||
|
|
||||||
if (jsonObject.contains(JS(transaction)))
|
if (jsonObject.contains(JS(transaction)))
|
||||||
input.transaction = jv.at(JS(transaction)).as_string().c_str();
|
input.transaction = boost::json::value_to<std::string>(jv.at(JS(transaction)));
|
||||||
|
|
||||||
if (jsonObject.contains(JS(ctid))) {
|
if (jsonObject.contains(JS(ctid))) {
|
||||||
input.ctid = jv.at(JS(ctid)).as_string().c_str();
|
input.ctid = boost::json::value_to<std::string>(jv.at(JS(ctid)));
|
||||||
input.ctid = util::toUpper(*input.ctid);
|
input.ctid = util::toUpper(*input.ctid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -194,18 +194,18 @@ private:
|
|||||||
if (auto const& streams = jsonObject.find(JS(streams)); streams != jsonObject.end()) {
|
if (auto const& streams = jsonObject.find(JS(streams)); streams != jsonObject.end()) {
|
||||||
input.streams = std::vector<std::string>();
|
input.streams = std::vector<std::string>();
|
||||||
for (auto const& stream : streams->value().as_array())
|
for (auto const& stream : streams->value().as_array())
|
||||||
input.streams->push_back(stream.as_string().c_str());
|
input.streams->push_back(boost::json::value_to<std::string>(stream));
|
||||||
}
|
}
|
||||||
if (auto const& accounts = jsonObject.find(JS(accounts)); accounts != jsonObject.end()) {
|
if (auto const& accounts = jsonObject.find(JS(accounts)); accounts != jsonObject.end()) {
|
||||||
input.accounts = std::vector<std::string>();
|
input.accounts = std::vector<std::string>();
|
||||||
for (auto const& account : accounts->value().as_array())
|
for (auto const& account : accounts->value().as_array())
|
||||||
input.accounts->push_back(account.as_string().c_str());
|
input.accounts->push_back(boost::json::value_to<std::string>(account));
|
||||||
}
|
}
|
||||||
if (auto const& accountsProposed = jsonObject.find(JS(accounts_proposed));
|
if (auto const& accountsProposed = jsonObject.find(JS(accounts_proposed));
|
||||||
accountsProposed != jsonObject.end()) {
|
accountsProposed != jsonObject.end()) {
|
||||||
input.accountsProposed = std::vector<std::string>();
|
input.accountsProposed = std::vector<std::string>();
|
||||||
for (auto const& account : accountsProposed->value().as_array())
|
for (auto const& account : accountsProposed->value().as_array())
|
||||||
input.accountsProposed->push_back(account.as_string().c_str());
|
input.accountsProposed->push_back(boost::json::value_to<std::string>(account));
|
||||||
}
|
}
|
||||||
if (auto const& books = jsonObject.find(JS(books)); books != jsonObject.end()) {
|
if (auto const& books = jsonObject.find(JS(books)); books != jsonObject.end()) {
|
||||||
input.books = std::vector<OrderBook>();
|
input.books = std::vector<OrderBook>();
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include <boost/json/conversion.hpp>
|
#include <boost/json/conversion.hpp>
|
||||||
#include <boost/json/parse.hpp>
|
#include <boost/json/parse.hpp>
|
||||||
#include <boost/json/value.hpp>
|
#include <boost/json/value.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@@ -201,7 +202,7 @@ struct Custom {
|
|||||||
{
|
{
|
||||||
ASSERT(value.is_object(), "Value must be an object");
|
ASSERT(value.is_object(), "Value must be an object");
|
||||||
auto const& obj = value.as_object();
|
auto const& obj = value.as_object();
|
||||||
return {obj.at("str").as_string().c_str(), obj.at("int").as_int64(), obj.at("bool").as_bool()};
|
return {boost::json::value_to<std::string>(obj.at("str")), obj.at("int").as_int64(), obj.at("bool").as_bool()};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,13 @@
|
|||||||
#include "util/MockPrometheus.hpp"
|
#include "util/MockPrometheus.hpp"
|
||||||
#include "util/prometheus/Counter.hpp"
|
#include "util/prometheus/Counter.hpp"
|
||||||
|
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ripple/protocol/jss.h>
|
#include <ripple/protocol/jss.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace rpc;
|
using namespace rpc;
|
||||||
|
|
||||||
@@ -59,47 +61,49 @@ TEST_F(RPCCountersTest, CheckThatCountersAddUp)
|
|||||||
auto const report = counters.report();
|
auto const report = counters.report();
|
||||||
auto const& rpc = report.at(JS(rpc)).as_object();
|
auto const& rpc = report.at(JS(rpc)).as_object();
|
||||||
|
|
||||||
EXPECT_STREQ(rpc.at("error").as_object().at(JS(started)).as_string().c_str(), "512");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("error").as_object().at(JS(started))), "512");
|
||||||
EXPECT_STREQ(rpc.at("error").as_object().at(JS(finished)).as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("error").as_object().at(JS(finished))), "0");
|
||||||
EXPECT_STREQ(rpc.at("error").as_object().at(JS(errored)).as_string().c_str(), "512");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("error").as_object().at(JS(errored))), "512");
|
||||||
EXPECT_STREQ(rpc.at("error").as_object().at("forwarded").as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("error").as_object().at("forwarded")), "0");
|
||||||
EXPECT_STREQ(rpc.at("error").as_object().at("failed_forward").as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("error").as_object().at("failed_forward")), "0");
|
||||||
EXPECT_STREQ(rpc.at("error").as_object().at(JS(failed)).as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("error").as_object().at(JS(failed))), "0");
|
||||||
|
|
||||||
EXPECT_STREQ(rpc.at("complete").as_object().at(JS(started)).as_string().c_str(), "512");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("complete").as_object().at(JS(started))), "512");
|
||||||
EXPECT_STREQ(rpc.at("complete").as_object().at(JS(finished)).as_string().c_str(), "512");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("complete").as_object().at(JS(finished))), "512");
|
||||||
EXPECT_STREQ(rpc.at("complete").as_object().at(JS(errored)).as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("complete").as_object().at(JS(errored))), "0");
|
||||||
EXPECT_STREQ(rpc.at("complete").as_object().at("forwarded").as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("complete").as_object().at("forwarded")), "0");
|
||||||
EXPECT_STREQ(rpc.at("complete").as_object().at("failed_forward").as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("complete").as_object().at("failed_forward")), "0");
|
||||||
EXPECT_STREQ(rpc.at("complete").as_object().at(JS(failed)).as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("complete").as_object().at(JS(failed))), "0");
|
||||||
EXPECT_STREQ(rpc.at("complete").as_object().at(JS(duration_us)).as_string().c_str(), "512000"); // 1000 per call
|
EXPECT_EQ(
|
||||||
|
boost::json::value_to<std::string>(rpc.at("complete").as_object().at(JS(duration_us))), "512000"
|
||||||
|
); // 1000 per call
|
||||||
|
|
||||||
EXPECT_STREQ(rpc.at("forward").as_object().at(JS(started)).as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("forward").as_object().at(JS(started))), "0");
|
||||||
EXPECT_STREQ(rpc.at("forward").as_object().at(JS(finished)).as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("forward").as_object().at(JS(finished))), "0");
|
||||||
EXPECT_STREQ(rpc.at("forward").as_object().at(JS(errored)).as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("forward").as_object().at(JS(errored))), "0");
|
||||||
EXPECT_STREQ(rpc.at("forward").as_object().at("forwarded").as_string().c_str(), "512");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("forward").as_object().at("forwarded")), "512");
|
||||||
EXPECT_STREQ(rpc.at("forward").as_object().at("failed_forward").as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("forward").as_object().at("failed_forward")), "0");
|
||||||
EXPECT_STREQ(rpc.at("forward").as_object().at(JS(failed)).as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("forward").as_object().at(JS(failed))), "0");
|
||||||
|
|
||||||
EXPECT_STREQ(rpc.at("failed").as_object().at(JS(started)).as_string().c_str(), "512");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("failed").as_object().at(JS(started))), "512");
|
||||||
EXPECT_STREQ(rpc.at("failed").as_object().at(JS(finished)).as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("failed").as_object().at(JS(finished))), "0");
|
||||||
EXPECT_STREQ(rpc.at("failed").as_object().at(JS(errored)).as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("failed").as_object().at(JS(errored))), "0");
|
||||||
EXPECT_STREQ(rpc.at("failed").as_object().at("forwarded").as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("failed").as_object().at("forwarded")), "0");
|
||||||
EXPECT_STREQ(rpc.at("failed").as_object().at("failed_forward").as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("failed").as_object().at("failed_forward")), "0");
|
||||||
EXPECT_STREQ(rpc.at("failed").as_object().at(JS(failed)).as_string().c_str(), "512");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("failed").as_object().at(JS(failed))), "512");
|
||||||
|
|
||||||
EXPECT_STREQ(rpc.at("failedToForward").as_object().at(JS(started)).as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("failedToForward").as_object().at(JS(started))), "0");
|
||||||
EXPECT_STREQ(rpc.at("failedToForward").as_object().at(JS(finished)).as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("failedToForward").as_object().at(JS(finished))), "0");
|
||||||
EXPECT_STREQ(rpc.at("failedToForward").as_object().at(JS(errored)).as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("failedToForward").as_object().at(JS(errored))), "0");
|
||||||
EXPECT_STREQ(rpc.at("failedToForward").as_object().at("forwarded").as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("failedToForward").as_object().at("forwarded")), "0");
|
||||||
EXPECT_STREQ(rpc.at("failedToForward").as_object().at("failed_forward").as_string().c_str(), "512");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("failedToForward").as_object().at("failed_forward")), "512");
|
||||||
EXPECT_STREQ(rpc.at("failedToForward").as_object().at(JS(failed)).as_string().c_str(), "0");
|
EXPECT_EQ(boost::json::value_to<std::string>(rpc.at("failedToForward").as_object().at(JS(failed))), "0");
|
||||||
|
|
||||||
EXPECT_STREQ(report.at("too_busy_errors").as_string().c_str(), "512");
|
EXPECT_EQ(boost::json::value_to<std::string>(report.at("too_busy_errors")), "512");
|
||||||
EXPECT_STREQ(report.at("not_ready_errors").as_string().c_str(), "512");
|
EXPECT_EQ(boost::json::value_to<std::string>(report.at("not_ready_errors")), "512");
|
||||||
EXPECT_STREQ(report.at("bad_syntax_errors").as_string().c_str(), "512");
|
EXPECT_EQ(boost::json::value_to<std::string>(report.at("bad_syntax_errors")), "512");
|
||||||
EXPECT_STREQ(report.at("unknown_command_errors").as_string().c_str(), "512");
|
EXPECT_EQ(boost::json::value_to<std::string>(report.at("unknown_command_errors")), "512");
|
||||||
EXPECT_STREQ(report.at("internal_errors").as_string().c_str(), "512");
|
EXPECT_EQ(boost::json::value_to<std::string>(report.at("internal_errors")), "512");
|
||||||
|
|
||||||
EXPECT_EQ(report.at("work_queue"), queue.report()); // Counters report includes queue report
|
EXPECT_EQ(report.at("work_queue"), queue.report()); // Counters report includes queue report
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,11 +19,14 @@
|
|||||||
|
|
||||||
#include "rpc/Errors.hpp"
|
#include "rpc/Errors.hpp"
|
||||||
|
|
||||||
|
#include <boost/json/fwd.hpp>
|
||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <ripple/protocol/ErrorCodes.h>
|
#include <ripple/protocol/ErrorCodes.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
using namespace rpc;
|
using namespace rpc;
|
||||||
@@ -45,12 +48,12 @@ check(boost::json::object const& j, std::string_view error, uint32_t errorCode,
|
|||||||
EXPECT_TRUE(j.at("status").is_string());
|
EXPECT_TRUE(j.at("status").is_string());
|
||||||
EXPECT_TRUE(j.at("type").is_string());
|
EXPECT_TRUE(j.at("type").is_string());
|
||||||
|
|
||||||
EXPECT_STREQ(j.at("status").as_string().c_str(), "error");
|
EXPECT_EQ(boost::json::value_to<std::string>(j.at("status")), "error");
|
||||||
EXPECT_STREQ(j.at("type").as_string().c_str(), "response");
|
EXPECT_EQ(boost::json::value_to<std::string>(j.at("type")), "response");
|
||||||
|
|
||||||
EXPECT_STREQ(j.at("error").as_string().c_str(), error.data());
|
EXPECT_EQ(boost::json::value_to<std::string>(j.at("error")), error.data());
|
||||||
EXPECT_EQ(j.at("error_code").as_uint64(), errorCode);
|
EXPECT_EQ(j.at("error_code").as_uint64(), errorCode);
|
||||||
EXPECT_STREQ(j.at("error_message").as_string().c_str(), errorMessage.data());
|
EXPECT_EQ(boost::json::value_to<std::string>(j.at("error_message")), errorMessage.data());
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@@ -89,7 +92,7 @@ TEST(RPCErrorsTest, RippledErrorToJSON)
|
|||||||
TEST(RPCErrorsTest, RippledErrorFromStringToJSON)
|
TEST(RPCErrorsTest, RippledErrorFromStringToJSON)
|
||||||
{
|
{
|
||||||
auto const j = makeError(Status{"veryCustomError"});
|
auto const j = makeError(Status{"veryCustomError"});
|
||||||
EXPECT_STREQ(j.at("error").as_string().c_str(), "veryCustomError");
|
EXPECT_EQ(boost::json::value_to<std::string>(j.at("error")), "veryCustomError");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(RPCErrorsTest, RippledErrorToJSONCustomMessage)
|
TEST(RPCErrorsTest, RippledErrorToJSONCustomMessage)
|
||||||
@@ -137,7 +140,7 @@ TEST(RPCErrorsTest, WarningToJSON)
|
|||||||
EXPECT_TRUE(j.at("message").is_string());
|
EXPECT_TRUE(j.at("message").is_string());
|
||||||
|
|
||||||
EXPECT_EQ(j.at("id").as_int64(), static_cast<uint32_t>(WarningCode::warnRPC_OUTDATED));
|
EXPECT_EQ(j.at("id").as_int64(), static_cast<uint32_t>(WarningCode::warnRPC_OUTDATED));
|
||||||
EXPECT_STREQ(j.at("message").as_string().c_str(), "This server may be out of date");
|
EXPECT_EQ(boost::json::value_to<std::string>(j.at("message")), "This server may be out of date");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(RPCErrorsTest, InvalidWarningToJSON)
|
TEST(RPCErrorsTest, InvalidWarningToJSON)
|
||||||
|
|||||||
@@ -539,7 +539,7 @@ TEST_F(RPCAccountChannelsHandlerTest, UseLimit)
|
|||||||
ASSERT_TRUE(output);
|
ASSERT_TRUE(output);
|
||||||
|
|
||||||
EXPECT_EQ((*output).as_object().at("channels").as_array().size(), 20);
|
EXPECT_EQ((*output).as_object().at("channels").as_array().size(), 20);
|
||||||
EXPECT_THAT((*output).as_object().at("marker").as_string().c_str(), EndsWith(",0"));
|
EXPECT_THAT(boost::json::value_to<std::string>((*output).as_object().at("marker")), EndsWith(",0"));
|
||||||
});
|
});
|
||||||
|
|
||||||
runSpawn([this](auto yield) {
|
runSpawn([this](auto yield) {
|
||||||
@@ -811,7 +811,10 @@ TEST_F(RPCAccountChannelsHandlerTest, MarkerOutput)
|
|||||||
auto handler = AnyHandler{AccountChannelsHandler{this->backend}};
|
auto handler = AnyHandler{AccountChannelsHandler{this->backend}};
|
||||||
auto const output = handler.process(input, Context{yield});
|
auto const output = handler.process(input, Context{yield});
|
||||||
ASSERT_TRUE(output);
|
ASSERT_TRUE(output);
|
||||||
EXPECT_EQ((*output).as_object().at("marker").as_string().c_str(), fmt::format("{},{}", INDEX1, nextPage));
|
EXPECT_EQ(
|
||||||
|
boost::json::value_to<std::string>((*output).as_object().at("marker")),
|
||||||
|
fmt::format("{},{}", INDEX1, nextPage)
|
||||||
|
);
|
||||||
EXPECT_EQ((*output).as_object().at("channels").as_array().size(), 15);
|
EXPECT_EQ((*output).as_object().at("channels").as_array().size(), 15);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "util/TestObject.hpp"
|
#include "util/TestObject.hpp"
|
||||||
|
|
||||||
#include <boost/json/parse.hpp>
|
#include <boost/json/parse.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
@@ -37,6 +38,7 @@
|
|||||||
#include <ripple/protocol/STObject.h>
|
#include <ripple/protocol/STObject.h>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using namespace rpc;
|
using namespace rpc;
|
||||||
@@ -587,7 +589,7 @@ TEST_F(RPCAccountLinesHandlerTest, UseLimit)
|
|||||||
ASSERT_TRUE(output);
|
ASSERT_TRUE(output);
|
||||||
|
|
||||||
EXPECT_EQ((*output).as_object().at("lines").as_array().size(), 20);
|
EXPECT_EQ((*output).as_object().at("lines").as_array().size(), 20);
|
||||||
EXPECT_THAT((*output).as_object().at("marker").as_string().c_str(), EndsWith(",0"));
|
EXPECT_THAT(boost::json::value_to<std::string>((*output).as_object().at("marker")), EndsWith(",0"));
|
||||||
});
|
});
|
||||||
|
|
||||||
runSpawn([this](auto yield) {
|
runSpawn([this](auto yield) {
|
||||||
@@ -863,7 +865,10 @@ TEST_F(RPCAccountLinesHandlerTest, MarkerOutput)
|
|||||||
auto handler = AnyHandler{AccountLinesHandler{this->backend}};
|
auto handler = AnyHandler{AccountLinesHandler{this->backend}};
|
||||||
auto const output = handler.process(input, Context{yield});
|
auto const output = handler.process(input, Context{yield});
|
||||||
ASSERT_TRUE(output);
|
ASSERT_TRUE(output);
|
||||||
EXPECT_EQ((*output).as_object().at("marker").as_string().c_str(), fmt::format("{},{}", INDEX1, nextPage));
|
EXPECT_EQ(
|
||||||
|
boost::json::value_to<std::string>((*output).as_object().at("marker")),
|
||||||
|
fmt::format("{},{}", INDEX1, nextPage)
|
||||||
|
);
|
||||||
EXPECT_EQ((*output).as_object().at("lines").as_array().size(), 15);
|
EXPECT_EQ((*output).as_object().at("lines").as_array().size(), 15);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "util/TestObject.hpp"
|
#include "util/TestObject.hpp"
|
||||||
|
|
||||||
#include <boost/json/parse.hpp>
|
#include <boost/json/parse.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
@@ -2155,7 +2156,10 @@ TEST_P(RPCLedgerEntryNormalPathTest, NormalPath)
|
|||||||
output.value().at("node_binary").as_string(),
|
output.value().at("node_binary").as_string(),
|
||||||
ripple::strHex(testBundle.mockedEntity.getSerializer().peekData())
|
ripple::strHex(testBundle.mockedEntity.getSerializer().peekData())
|
||||||
);
|
);
|
||||||
EXPECT_EQ(ripple::uint256(output.value().at("index").as_string().c_str()), testBundle.expectedIndex);
|
EXPECT_EQ(
|
||||||
|
ripple::uint256(boost::json::value_to<std::string>(output.value().at("index")).data()),
|
||||||
|
testBundle.expectedIndex
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include <boost/asio/spawn.hpp>
|
#include <boost/asio/spawn.hpp>
|
||||||
#include <boost/json/parse.hpp>
|
#include <boost/json/parse.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
@@ -36,6 +37,7 @@
|
|||||||
#include <ripple/protocol/STObject.h>
|
#include <ripple/protocol/STObject.h>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using namespace rpc;
|
using namespace rpc;
|
||||||
@@ -484,8 +486,9 @@ TEST_F(RPCNFTBuyOffersHandlerTest, MultipleResultsWithMarkerAndLimitOutput)
|
|||||||
ASSERT_TRUE(output);
|
ASSERT_TRUE(output);
|
||||||
EXPECT_EQ(output->at("offers").as_array().size(), 50);
|
EXPECT_EQ(output->at("offers").as_array().size(), 50);
|
||||||
EXPECT_EQ(output->at("limit").as_uint64(), 50);
|
EXPECT_EQ(output->at("limit").as_uint64(), 50);
|
||||||
EXPECT_STREQ(
|
EXPECT_EQ(
|
||||||
output->at("marker").as_string().c_str(), "E6DBAFC99223B42257915A63DFC6B0C032D4070F9A574B255AD97466726FC353"
|
boost::json::value_to<std::string>(output->at("marker")),
|
||||||
|
"E6DBAFC99223B42257915A63DFC6B0C032D4070F9A574B255AD97466726FC353"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -544,8 +547,9 @@ TEST_F(RPCNFTBuyOffersHandlerTest, ResultsForInputWithMarkerAndLimit)
|
|||||||
EXPECT_EQ(output->at("offers").as_array().size(), 50);
|
EXPECT_EQ(output->at("offers").as_array().size(), 50);
|
||||||
EXPECT_EQ(output->at("limit").as_uint64(), 50);
|
EXPECT_EQ(output->at("limit").as_uint64(), 50);
|
||||||
// marker also progressed by 50
|
// marker also progressed by 50
|
||||||
EXPECT_STREQ(
|
EXPECT_EQ(
|
||||||
output->at("marker").as_string().c_str(), "E6DBAFC99223B42257915A63DFC6B0C032D4070F9A574B255AD97466726FC385"
|
boost::json::value_to<std::string>(output->at("marker")),
|
||||||
|
"E6DBAFC99223B42257915A63DFC6B0C032D4070F9A574B255AD97466726FC385"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include <boost/asio/spawn.hpp>
|
#include <boost/asio/spawn.hpp>
|
||||||
#include <boost/json/parse.hpp>
|
#include <boost/json/parse.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
@@ -36,6 +37,7 @@
|
|||||||
#include <ripple/protocol/STObject.h>
|
#include <ripple/protocol/STObject.h>
|
||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using namespace rpc;
|
using namespace rpc;
|
||||||
@@ -484,8 +486,9 @@ TEST_F(RPCNFTSellOffersHandlerTest, MultipleResultsWithMarkerAndLimitOutput)
|
|||||||
ASSERT_TRUE(output);
|
ASSERT_TRUE(output);
|
||||||
EXPECT_EQ(output->at("offers").as_array().size(), 50);
|
EXPECT_EQ(output->at("offers").as_array().size(), 50);
|
||||||
EXPECT_EQ(output->at("limit").as_uint64(), 50);
|
EXPECT_EQ(output->at("limit").as_uint64(), 50);
|
||||||
EXPECT_STREQ(
|
EXPECT_EQ(
|
||||||
output->at("marker").as_string().c_str(), "E6DBAFC99223B42257915A63DFC6B0C032D4070F9A574B255AD97466726FC353"
|
boost::json::value_to<std::string>(output->at("marker")),
|
||||||
|
"E6DBAFC99223B42257915A63DFC6B0C032D4070F9A574B255AD97466726FC353"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -544,8 +547,9 @@ TEST_F(RPCNFTSellOffersHandlerTest, ResultsForInputWithMarkerAndLimit)
|
|||||||
EXPECT_EQ(output->at("offers").as_array().size(), 50);
|
EXPECT_EQ(output->at("offers").as_array().size(), 50);
|
||||||
EXPECT_EQ(output->at("limit").as_uint64(), 50);
|
EXPECT_EQ(output->at("limit").as_uint64(), 50);
|
||||||
// marker also progressed by 50
|
// marker also progressed by 50
|
||||||
EXPECT_STREQ(
|
EXPECT_EQ(
|
||||||
output->at("marker").as_string().c_str(), "E6DBAFC99223B42257915A63DFC6B0C032D4070F9A574B255AD97466726FC385"
|
boost::json::value_to<std::string>(output->at("marker")),
|
||||||
|
"E6DBAFC99223B42257915A63DFC6B0C032D4070F9A574B255AD97466726FC385"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,11 +31,13 @@
|
|||||||
#include <boost/json/object.hpp>
|
#include <boost/json/object.hpp>
|
||||||
#include <boost/json/parse.hpp>
|
#include <boost/json/parse.hpp>
|
||||||
#include <boost/json/serialize.hpp>
|
#include <boost/json/serialize.hpp>
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
#include <gmock/gmock.h>
|
#include <gmock/gmock.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace rpc;
|
using namespace rpc;
|
||||||
namespace json = boost::json;
|
namespace json = boost::json;
|
||||||
@@ -81,7 +83,7 @@ protected:
|
|||||||
|
|
||||||
auto const& info = result.at("info").as_object();
|
auto const& info = result.at("info").as_object();
|
||||||
EXPECT_TRUE(info.contains("complete_ledgers"));
|
EXPECT_TRUE(info.contains("complete_ledgers"));
|
||||||
EXPECT_STREQ(info.at("complete_ledgers").as_string().c_str(), "10-30");
|
EXPECT_EQ(boost::json::value_to<std::string>(info.at("complete_ledgers")), "10-30");
|
||||||
EXPECT_TRUE(info.contains("load_factor"));
|
EXPECT_TRUE(info.contains("load_factor"));
|
||||||
EXPECT_TRUE(info.contains("clio_version"));
|
EXPECT_TRUE(info.contains("clio_version"));
|
||||||
EXPECT_TRUE(info.contains("libxrpl_version"));
|
EXPECT_TRUE(info.contains("libxrpl_version"));
|
||||||
@@ -93,7 +95,7 @@ protected:
|
|||||||
EXPECT_TRUE(validated.contains("age"));
|
EXPECT_TRUE(validated.contains("age"));
|
||||||
EXPECT_EQ(validated.at("age").as_uint64(), 3u);
|
EXPECT_EQ(validated.at("age").as_uint64(), 3u);
|
||||||
EXPECT_TRUE(validated.contains("hash"));
|
EXPECT_TRUE(validated.contains("hash"));
|
||||||
EXPECT_STREQ(validated.at("hash").as_string().c_str(), LEDGERHASH);
|
EXPECT_EQ(boost::json::value_to<std::string>(validated.at("hash")), LEDGERHASH);
|
||||||
EXPECT_TRUE(validated.contains("seq"));
|
EXPECT_TRUE(validated.contains("seq"));
|
||||||
EXPECT_EQ(validated.at("seq").as_uint64(), 30u);
|
EXPECT_EQ(validated.at("seq").as_uint64(), 30u);
|
||||||
EXPECT_TRUE(validated.contains("base_fee_xrp"));
|
EXPECT_TRUE(validated.contains("base_fee_xrp"));
|
||||||
@@ -135,7 +137,7 @@ protected:
|
|||||||
EXPECT_TRUE(info.contains("validation_quorum"));
|
EXPECT_TRUE(info.contains("validation_quorum"));
|
||||||
EXPECT_EQ(info.at("validation_quorum").as_int64(), 456);
|
EXPECT_EQ(info.at("validation_quorum").as_int64(), 456);
|
||||||
EXPECT_TRUE(info.contains("rippled_version"));
|
EXPECT_TRUE(info.contains("rippled_version"));
|
||||||
EXPECT_STREQ(info.at("rippled_version").as_string().c_str(), "1234");
|
EXPECT_EQ(boost::json::value_to<std::string>(info.at("rippled_version")), "1234");
|
||||||
EXPECT_TRUE(info.contains("network_id"));
|
EXPECT_TRUE(info.contains("network_id"));
|
||||||
EXPECT_EQ(info.at("network_id").as_int64(), 2);
|
EXPECT_EQ(info.at("network_id").as_int64(), 2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ tag_invoke(boost::json::value_to_tag<TestInput>, boost::json::value const& jv)
|
|||||||
if (jv.as_object().contains("limit"))
|
if (jv.as_object().contains("limit"))
|
||||||
optLimit = jv.at("limit").as_int64();
|
optLimit = jv.at("limit").as_int64();
|
||||||
|
|
||||||
return {jv.as_object().at("hello").as_string().c_str(), optLimit};
|
return {boost::json::value_to<std::string>(jv.as_object().at("hello")), optLimit};
|
||||||
}
|
}
|
||||||
|
|
||||||
// must be implemented as per rpc/common/Concepts.h
|
// must be implemented as per rpc/common/Concepts.h
|
||||||
@@ -145,7 +145,7 @@ struct InOutFake {
|
|||||||
inline InOutFake
|
inline InOutFake
|
||||||
tag_invoke(boost::json::value_to_tag<InOutFake>, boost::json::value const& jv)
|
tag_invoke(boost::json::value_to_tag<InOutFake>, boost::json::value const& jv)
|
||||||
{
|
{
|
||||||
return {jv.as_object().at("something").as_string().c_str()};
|
return {boost::json::value_to<std::string>(jv.as_object().at("something"))};
|
||||||
}
|
}
|
||||||
|
|
||||||
// must be implemented as per rpc/common/Concepts.h
|
// must be implemented as per rpc/common/Concepts.h
|
||||||
|
|||||||
Reference in New Issue
Block a user