mirror of
https://github.com/XRPLF/clio.git
synced 2026-06-06 10:16:42 +00:00
style: clang-tidy auto fixes (#2958)
Co-authored-by: godexsoft <385326+godexsoft@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
2d6f82c27f
commit
af736717fc
@@ -153,10 +153,11 @@ fetchCredentialArray(
|
||||
if (credentials::checkExpired(sleCred, info))
|
||||
return Error{Status{RippledError::rpcBAD_CREDENTIALS, "credentials are expired"}};
|
||||
|
||||
if (sleCred.getAccountID(ripple::sfSubject) != srcAcc)
|
||||
if (sleCred.getAccountID(ripple::sfSubject) != srcAcc) {
|
||||
return Error{Status{
|
||||
RippledError::rpcBAD_CREDENTIALS, "credentials don't belong to the root account"
|
||||
}};
|
||||
}
|
||||
|
||||
auto credential = ripple::STObject::makeInnerObject(ripple::sfCredential);
|
||||
credential.setAccountID(ripple::sfIssuer, sleCred.getAccountID(ripple::sfIssuer));
|
||||
|
||||
@@ -223,10 +223,11 @@ makeError(Status const& status)
|
||||
auto res = visit(
|
||||
util::OverloadSet{
|
||||
[&status, &wrapOptional](RippledError err) {
|
||||
if (err == ripple::rpcUNKNOWN)
|
||||
if (err == ripple::rpcUNKNOWN) {
|
||||
return boost::json::object{
|
||||
{"error", status.message}, {"type", "response"}, {"status", "error"}
|
||||
};
|
||||
}
|
||||
|
||||
return makeError(err, wrapOptional(status.error), wrapOptional(status.message));
|
||||
},
|
||||
|
||||
@@ -62,10 +62,11 @@ makeWsContext(
|
||||
commandValue = request.at("command");
|
||||
}
|
||||
|
||||
if (!commandValue.is_string())
|
||||
if (!commandValue.is_string()) {
|
||||
return Error{
|
||||
{ClioError::RpcCommandIsMissing, "Method/Command is not specified or is not a string."}
|
||||
};
|
||||
}
|
||||
|
||||
auto const apiVersion = apiVersionParser.get().parse(request);
|
||||
if (!apiVersion)
|
||||
@@ -99,11 +100,12 @@ makeHttpContext(
|
||||
|
||||
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 for websocket."}
|
||||
};
|
||||
}
|
||||
|
||||
if (!request.at("params").is_array())
|
||||
return Error{{ClioError::RpcParamsUnparsable, "Missing params array."}};
|
||||
|
||||
@@ -694,10 +694,11 @@ traverseOwnedNodes(
|
||||
auto const [nextNFTPage, nftsCount] = cursorMaybe.value();
|
||||
|
||||
// if limit reach , we return the next page and max as marker
|
||||
if (nftsCount >= limit)
|
||||
if (nftsCount >= limit) {
|
||||
return AccountCursor{
|
||||
.index = nextNFTPage, .hint = std::numeric_limits<uint32_t>::max()
|
||||
};
|
||||
}
|
||||
|
||||
// adjust limit ,continue traversing owned nodes
|
||||
limit -= nftsCount;
|
||||
@@ -772,10 +773,11 @@ traverseOwnedNodes(
|
||||
for (;;) {
|
||||
auto const ownerDir = backend.fetchLedgerObject(currentIndex.key, sequence, yield);
|
||||
|
||||
if (!ownerDir)
|
||||
if (!ownerDir) {
|
||||
return std::unexpected{
|
||||
Status(ripple::rpcINVALID_PARAMS, "Owner directory not found.")
|
||||
};
|
||||
}
|
||||
|
||||
ripple::SerialIter ownedDirIt{ownerDir->data(), ownerDir->size()};
|
||||
ripple::SLE const ownedDirSle{ownedDirIt, currentIndex.key};
|
||||
@@ -1428,25 +1430,29 @@ parseBook(
|
||||
std::expected<ripple::Book, Status>
|
||||
parseBook(boost::json::object const& request)
|
||||
{
|
||||
if (!request.contains("taker_pays"))
|
||||
if (!request.contains("taker_pays")) {
|
||||
return std::unexpected{
|
||||
Status{RippledError::rpcINVALID_PARAMS, "Missing field 'taker_pays'"}
|
||||
};
|
||||
}
|
||||
|
||||
if (!request.contains("taker_gets"))
|
||||
if (!request.contains("taker_gets")) {
|
||||
return std::unexpected{
|
||||
Status{RippledError::rpcINVALID_PARAMS, "Missing field 'taker_gets'"}
|
||||
};
|
||||
}
|
||||
|
||||
if (!request.at("taker_pays").is_object())
|
||||
if (!request.at("taker_pays").is_object()) {
|
||||
return std::unexpected{
|
||||
Status{RippledError::rpcINVALID_PARAMS, "Field 'taker_pays' is not an object"}
|
||||
};
|
||||
}
|
||||
|
||||
if (!request.at("taker_gets").is_object())
|
||||
if (!request.at("taker_gets").is_object()) {
|
||||
return std::unexpected{
|
||||
Status{RippledError::rpcINVALID_PARAMS, "Field 'taker_gets' is not an object"}
|
||||
};
|
||||
}
|
||||
|
||||
auto takerPays = request.at("taker_pays").as_object();
|
||||
if (!takerPays.contains("currency"))
|
||||
@@ -1482,10 +1488,11 @@ parseBook(boost::json::object const& request)
|
||||
|
||||
ripple::AccountID payIssuer;
|
||||
if (takerPays.contains("issuer")) {
|
||||
if (!takerPays.at("issuer").is_string())
|
||||
if (!takerPays.at("issuer").is_string()) {
|
||||
return std::unexpected{
|
||||
Status{RippledError::rpcINVALID_PARAMS, "takerPaysIssuerNotString"}
|
||||
};
|
||||
}
|
||||
|
||||
if (!ripple::to_issuer(
|
||||
payIssuer, boost::json::value_to<std::string>(takerPays.at("issuer"))
|
||||
@@ -1512,18 +1519,20 @@ parseBook(boost::json::object const& request)
|
||||
}};
|
||||
}
|
||||
|
||||
if ((!isXRP(payCurrency)) && (!takerPays.contains("issuer")))
|
||||
if ((!isXRP(payCurrency)) && (!takerPays.contains("issuer"))) {
|
||||
return std::unexpected{
|
||||
Status{RippledError::rpcSRC_ISR_MALFORMED, "Missing non-XRP issuer."}
|
||||
};
|
||||
}
|
||||
|
||||
ripple::AccountID getIssuer;
|
||||
|
||||
if (takerGets.contains("issuer")) {
|
||||
if (!takerGets["issuer"].is_string())
|
||||
if (!takerGets["issuer"].is_string()) {
|
||||
return std::unexpected{
|
||||
Status{RippledError::rpcINVALID_PARAMS, "taker_gets.issuer should be string"}
|
||||
};
|
||||
}
|
||||
|
||||
if (!ripple::to_issuer(
|
||||
getIssuer, boost::json::value_to<std::string>(takerGets.at("issuer"))
|
||||
|
||||
@@ -78,10 +78,11 @@ public:
|
||||
[[nodiscard]] static std::optional<Warning>
|
||||
check(boost::json::value const& value, std::string_view key)
|
||||
{
|
||||
if (value.is_object() and value.as_object().contains(key))
|
||||
if (value.is_object() and value.as_object().contains(key)) {
|
||||
return Warning{
|
||||
WarningCode::WarnRpcDeprecated, fmt::format("Field '{}' is deprecated.", key)
|
||||
};
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -51,10 +51,11 @@ namespace rpc::validation {
|
||||
[[nodiscard]] MaybeError
|
||||
Required::verify(boost::json::value const& value, std::string_view key)
|
||||
{
|
||||
if (not value.is_object() or not value.as_object().contains(key))
|
||||
if (not value.is_object() or not value.as_object().contains(key)) {
|
||||
return Error{Status{
|
||||
RippledError::rpcINVALID_PARAMS, "Required field '" + std::string{key} + "' missing"
|
||||
}};
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -127,17 +128,19 @@ CustomValidator CustomValidators::ledgerIndexValidator =
|
||||
|
||||
CustomValidator CustomValidators::ledgerTypeValidator =
|
||||
CustomValidator{[](boost::json::value const& value, std::string_view key) -> MaybeError {
|
||||
if (!value.is_string())
|
||||
if (!value.is_string()) {
|
||||
return Error{Status{
|
||||
RippledError::rpcINVALID_PARAMS, fmt::format("Invalid field '{}', not string.", key)
|
||||
}};
|
||||
}
|
||||
|
||||
auto const type =
|
||||
util::LedgerTypes::getLedgerEntryTypeFromStr(boost::json::value_to<std::string>(value));
|
||||
if (type == ripple::ltANY)
|
||||
if (type == ripple::ltANY) {
|
||||
return Error{
|
||||
Status{RippledError::rpcINVALID_PARAMS, fmt::format("Invalid field '{}'.", key)}
|
||||
};
|
||||
}
|
||||
|
||||
return MaybeError{};
|
||||
}};
|
||||
@@ -185,18 +188,20 @@ CustomValidator CustomValidators::accountMarkerValidator =
|
||||
|
||||
CustomValidator CustomValidators::accountTypeValidator =
|
||||
CustomValidator{[](boost::json::value const& value, std::string_view key) -> MaybeError {
|
||||
if (!value.is_string())
|
||||
if (!value.is_string()) {
|
||||
return Error{Status{
|
||||
RippledError::rpcINVALID_PARAMS, fmt::format("Invalid field '{}', not string.", key)
|
||||
}};
|
||||
}
|
||||
|
||||
auto const type = util::LedgerTypes::getAccountOwnedLedgerTypeFromStr(
|
||||
boost::json::value_to<std::string>(value)
|
||||
);
|
||||
if (type == ripple::ltANY)
|
||||
if (type == ripple::ltANY) {
|
||||
return Error{
|
||||
Status{RippledError::rpcINVALID_PARAMS, fmt::format("Invalid field '{}'.", key)}
|
||||
};
|
||||
}
|
||||
|
||||
return MaybeError{};
|
||||
}};
|
||||
@@ -225,10 +230,11 @@ CustomValidator CustomValidators::issuerValidator =
|
||||
ripple::AccountID issuer;
|
||||
|
||||
// TODO: need to align with the error
|
||||
if (!ripple::to_issuer(issuer, boost::json::value_to<std::string>(value)))
|
||||
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)
|
||||
}};
|
||||
}
|
||||
|
||||
if (issuer == ripple::noAccount()) {
|
||||
return Error{Status{
|
||||
@@ -308,21 +314,24 @@ CustomValidator CustomValidators::currencyIssueValidator =
|
||||
|
||||
CustomValidator CustomValidators::credentialTypeValidator =
|
||||
CustomValidator{[](boost::json::value const& value, std::string_view key) -> MaybeError {
|
||||
if (not value.is_string())
|
||||
if (not value.is_string()) {
|
||||
return Error{Status{
|
||||
ClioError::RpcMalformedAuthorizedCredentials, std::string(key) + " NotString"
|
||||
}};
|
||||
}
|
||||
|
||||
auto const& credTypeHex = ripple::strViewUnHex(value.as_string());
|
||||
if (!credTypeHex.has_value())
|
||||
if (!credTypeHex.has_value()) {
|
||||
return Error{Status{
|
||||
ClioError::RpcMalformedAuthorizedCredentials, std::string(key) + " NotHexString"
|
||||
}};
|
||||
}
|
||||
|
||||
if (credTypeHex->empty())
|
||||
if (credTypeHex->empty()) {
|
||||
return Error{
|
||||
Status{ClioError::RpcMalformedAuthorizedCredentials, std::string(key) + " is empty"}
|
||||
};
|
||||
}
|
||||
|
||||
if (credTypeHex->size() > ripple::maxCredentialTypeLength) {
|
||||
return Error{Status{
|
||||
@@ -374,10 +383,11 @@ CustomValidator CustomValidators::authorizeCredentialValidator =
|
||||
}
|
||||
|
||||
// don't want to change issuer error message to be about credentials
|
||||
if (!issuerValidator.verify(credObj, "issuer"))
|
||||
if (!issuerValidator.verify(credObj, "issuer")) {
|
||||
return Error{
|
||||
Status{ClioError::RpcMalformedAuthorizedCredentials, "issuer NotString"}
|
||||
};
|
||||
}
|
||||
|
||||
if (!obj.contains("credential_type")) {
|
||||
return Error{Status{
|
||||
|
||||
@@ -124,10 +124,11 @@ public:
|
||||
[[nodiscard]] static MaybeError
|
||||
verify(boost::json::value const& value, std::string_view key)
|
||||
{
|
||||
if (value.is_object() and value.as_object().contains(key))
|
||||
if (value.is_object() and value.as_object().contains(key)) {
|
||||
return Error{Status{
|
||||
RippledError::rpcNOT_SUPPORTED, "Not supported field '" + std::string{key} + '\''
|
||||
}};
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -419,10 +420,11 @@ public:
|
||||
return {}; // ignore. field does not exist, let 'required' fail instead
|
||||
|
||||
auto const res = value_to<Type>(value.as_object().at(key));
|
||||
if (std::find(std::begin(options_), std::end(options_), res) == std::end(options_))
|
||||
if (std::find(std::begin(options_), std::end(options_), res) == std::end(options_)) {
|
||||
return Error{
|
||||
Status{RippledError::rpcINVALID_PARAMS, fmt::format("Invalid field '{}'.", key)}
|
||||
};
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -65,15 +65,17 @@ ProductionAPIVersionParser::parse(boost::json::object const& request) const
|
||||
|
||||
auto const version = util::integralValueAs<uint32_t>(request.at("api_version"));
|
||||
|
||||
if (version > maxVersion_)
|
||||
if (version > maxVersion_) {
|
||||
return Error{fmt::format(
|
||||
"Requested API version is higher than maximum supported ({})", maxVersion_
|
||||
)};
|
||||
}
|
||||
|
||||
if (version < minVersion_)
|
||||
if (version < minVersion_) {
|
||||
return Error{fmt::format(
|
||||
"Requested API version is lower than minimum supported ({})", minVersion_
|
||||
)};
|
||||
}
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
@@ -247,10 +247,11 @@ AMMInfoHandler::spec([[maybe_unused]] uint32_t apiVersion)
|
||||
{
|
||||
static auto const kSTRING_ISSUE_VALIDATOR = validation::CustomValidator{
|
||||
[](boost::json::value const& value, std::string_view key) -> MaybeError {
|
||||
if (not value.is_string())
|
||||
if (not value.is_string()) {
|
||||
return Error{
|
||||
Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "NotString"}
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
ripple::issueFromJson(boost::json::value_to<std::string>(value));
|
||||
@@ -358,14 +359,16 @@ tag_invoke(boost::json::value_to_tag<AMMInfoHandler::Input>, boost::json::value
|
||||
if (jsonObject.contains(JS(asset2)))
|
||||
input.issue2 = parseIssue(jsonObject.at(JS(asset2)).as_object());
|
||||
|
||||
if (jsonObject.contains(JS(account)))
|
||||
if (jsonObject.contains(JS(account))) {
|
||||
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(
|
||||
boost::json::value_to<std::string>(jsonObject.at(JS(amm_account)))
|
||||
);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
@@ -166,9 +166,10 @@ tag_invoke(boost::json::value_to_tag<AccountChannelsHandler::Input>, boost::json
|
||||
if (jsonObject.contains(JS(ledger_hash)))
|
||||
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 =
|
||||
boost::json::value_to<std::string>(jv.at(JS(destination_account)));
|
||||
}
|
||||
|
||||
if (jsonObject.contains(JS(ledger_index))) {
|
||||
auto const expectedLedgerIndex = util::getLedgerIndex(jv.at(JS(ledger_index)));
|
||||
|
||||
@@ -57,10 +57,11 @@ AccountInfoHandler::process(AccountInfoHandler::Input const& input, Context cons
|
||||
{
|
||||
using namespace data;
|
||||
|
||||
if (!input.account && !input.ident)
|
||||
if (!input.account && !input.ident) {
|
||||
return Error{
|
||||
Status{RippledError::rpcINVALID_PARAMS, ripple::RPC::missing_field_message(JS(account))}
|
||||
};
|
||||
}
|
||||
|
||||
auto const range = sharedPtrBackend_->fetchLedgerRange();
|
||||
ASSERT(range.has_value(), "AccountInfo's ledger range must be available");
|
||||
|
||||
@@ -82,10 +82,11 @@ AccountNFTsHandler::process(AccountNFTsHandler::Input const& input, Context cons
|
||||
auto const blob = sharedPtrBackend_->fetchLedgerObject(pageKey, lgrInfo.seq, ctx.yield);
|
||||
|
||||
if (!blob) {
|
||||
if (input.marker.has_value())
|
||||
if (input.marker.has_value()) {
|
||||
return Error{Status{
|
||||
RippledError::rpcINVALID_PARAMS, "Marker field does not match any valid Page ID"
|
||||
}};
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -93,10 +94,11 @@ AccountNFTsHandler::process(AccountNFTsHandler::Input const& input, Context cons
|
||||
ripple::SLE{ripple::SerialIter{blob->data(), blob->size()}, pageKey}
|
||||
};
|
||||
|
||||
if (page->getType() != ripple::ltNFTOKEN_PAGE)
|
||||
if (page->getType() != ripple::ltNFTOKEN_PAGE) {
|
||||
return Error{
|
||||
Status{RippledError::rpcINVALID_PARAMS, "Marker matches Page ID from another Account"}
|
||||
};
|
||||
}
|
||||
|
||||
auto numPages = 0u;
|
||||
|
||||
|
||||
@@ -89,10 +89,11 @@ AccountTxHandler::process(AccountTxHandler::Input const& input, Context const& c
|
||||
}
|
||||
|
||||
if (input.ledgerHash || input.ledgerIndex || input.usingValidatedLedger) {
|
||||
if (ctx.apiVersion > 1u && (input.ledgerIndexMax || input.ledgerIndexMin))
|
||||
if (ctx.apiVersion > 1u && (input.ledgerIndexMax || input.ledgerIndexMin)) {
|
||||
return Error{
|
||||
Status{RippledError::rpcINVALID_PARAMS, "containsLedgerSpecifierAndRange"}
|
||||
};
|
||||
}
|
||||
|
||||
if (!input.ledgerIndexMax && !input.ledgerIndexMin) {
|
||||
// mimic rippled, when both range and index specified, respect the range.
|
||||
@@ -309,9 +310,10 @@ tag_invoke(boost::json::value_to_tag<AccountTxHandler::Input>, boost::json::valu
|
||||
};
|
||||
}
|
||||
|
||||
if (jsonObject.contains("tx_type"))
|
||||
if (jsonObject.contains("tx_type")) {
|
||||
input.transactionTypeInLowercase =
|
||||
boost::json::value_to<std::string>(jsonObject.at("tx_type"));
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
@@ -70,9 +70,10 @@ FeatureHandler::process(FeatureHandler::Input const& input, Context const& ctx)
|
||||
auto const& all = amendmentCenter_->getAll();
|
||||
|
||||
auto searchPredicate = [search = input.feature](auto const& feature) {
|
||||
if (search)
|
||||
if (search) {
|
||||
return ripple::to_string(feature.feature) == search.value() or
|
||||
feature.name == search.value();
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
@@ -230,10 +230,11 @@ tag_invoke(boost::json::value_to_tag<LedgerDataHandler::Input>, boost::json::val
|
||||
input.ledgerIndex = *expectedLedgerIndex;
|
||||
}
|
||||
|
||||
if (jsonObject.contains(JS(type)))
|
||||
if (jsonObject.contains(JS(type))) {
|
||||
input.type = util::LedgerTypes::getLedgerEntryTypeFromStr(
|
||||
boost::json::value_to<std::string>(jv.at(JS(type)))
|
||||
);
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
@@ -133,10 +133,11 @@ LedgerEntryHandler::process(LedgerEntryHandler::Input const& input, Context cons
|
||||
);
|
||||
|
||||
auto const authCreds = credentials::createAuthCredentials(authorizedCredentials);
|
||||
if (authCreds.size() != authorizedCredentials.size())
|
||||
if (authCreds.size() != authorizedCredentials.size()) {
|
||||
return Error{Status{
|
||||
ClioError::RpcMalformedAuthorizedCredentials, "duplicates in credentials."
|
||||
}};
|
||||
}
|
||||
|
||||
key = ripple::keylet::depositPreauth(owner.value(), authCreds).key;
|
||||
}
|
||||
@@ -295,10 +296,11 @@ std::expected<ripple::uint256, Status>
|
||||
LedgerEntryHandler::composeKeyFromDirectory(boost::json::object const& directory) noexcept
|
||||
{
|
||||
// can not specify both dir_root and owner.
|
||||
if (directory.contains(JS(dir_root)) && directory.contains(JS(owner)))
|
||||
if (directory.contains(JS(dir_root)) && directory.contains(JS(owner))) {
|
||||
return std::unexpected{
|
||||
Status{RippledError::rpcINVALID_PARAMS, "mayNotSpecifyBothDirRootAndOwner"}
|
||||
};
|
||||
}
|
||||
|
||||
// at least one should available
|
||||
if (!(directory.contains(JS(dir_root)) || directory.contains(JS(owner))))
|
||||
|
||||
@@ -85,10 +85,11 @@ LedgerIndexHandler::process(LedgerIndexHandler::Input const& input, Context cons
|
||||
return not earlierThan(ledgerIndex);
|
||||
});
|
||||
|
||||
if (greaterEqLedgerIter != view.end())
|
||||
if (greaterEqLedgerIter != view.end()) {
|
||||
return fillOutputByIndex(
|
||||
std::max(static_cast<std::uint32_t>(*greaterEqLedgerIter) - 1, minIndex)
|
||||
);
|
||||
}
|
||||
|
||||
return fillOutputByIndex(maxIndex);
|
||||
}
|
||||
|
||||
@@ -77,10 +77,11 @@ NFTHistoryHandler::process(NFTHistoryHandler::Input const& input, Context const&
|
||||
|
||||
if (input.ledgerHash || input.ledgerIndex) {
|
||||
// rippled does not have this check
|
||||
if (input.ledgerIndexMax || input.ledgerIndexMin)
|
||||
if (input.ledgerIndexMax || input.ledgerIndexMin) {
|
||||
return Error{
|
||||
Status{RippledError::rpcINVALID_PARAMS, "containsLedgerSpecifierAndRange"}
|
||||
};
|
||||
}
|
||||
|
||||
auto const expectedLgrInfo = getLedgerHeaderFromHashOrSeq(
|
||||
*sharedPtrBackend_, ctx.yield, input.ledgerHash, input.ledgerIndex, range->maxSequence
|
||||
|
||||
@@ -69,16 +69,18 @@ SubscribeHandler::spec([[maybe_unused]] uint32_t apiVersion)
|
||||
{
|
||||
static auto const kBOOKS_VALIDATOR = validation::CustomValidator{
|
||||
[](boost::json::value const& value, std::string_view key) -> MaybeError {
|
||||
if (!value.is_array())
|
||||
if (!value.is_array()) {
|
||||
return Error{
|
||||
Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "NotArray"}
|
||||
};
|
||||
}
|
||||
|
||||
for (auto const& book : value.as_array()) {
|
||||
if (!book.is_object())
|
||||
if (!book.is_object()) {
|
||||
return Error{
|
||||
Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "ItemNotObject"}
|
||||
};
|
||||
}
|
||||
|
||||
if (book.as_object().contains("both") && !book.as_object().at("both").is_bool())
|
||||
return Error{Status{RippledError::rpcINVALID_PARAMS, "bothNotBool"}};
|
||||
|
||||
@@ -70,10 +70,11 @@ TransactionEntryHandler::process(
|
||||
// the API for transaction_entry says the method only searches the specified
|
||||
// ledger; we simulate that here by returning not found if the transaction
|
||||
// is in a different ledger than the one specified.
|
||||
if (!dbRet || dbRet->ledgerSequence != output.ledgerHeader->seq)
|
||||
if (!dbRet || dbRet->ledgerSequence != output.ledgerHeader->seq) {
|
||||
return Error{
|
||||
Status{RippledError::rpcTXN_NOT_FOUND, "transactionNotFound", "Transaction not found."}
|
||||
};
|
||||
}
|
||||
|
||||
auto [txn, meta] = toExpandedJson(*dbRet, ctx.apiVersion);
|
||||
|
||||
|
||||
@@ -243,9 +243,10 @@ public:
|
||||
output.ledgerIndex = dbResponse->ledgerSequence;
|
||||
|
||||
// fetch ledger hash
|
||||
if (ctx.apiVersion > 1u)
|
||||
if (ctx.apiVersion > 1u) {
|
||||
output.ledgerHeader =
|
||||
sharedPtrBackend_->fetchLedgerBySequence(dbResponse->ledgerSequence, ctx.yield);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -56,16 +56,18 @@ UnsubscribeHandler::spec([[maybe_unused]] uint32_t apiVersion)
|
||||
{
|
||||
static auto const kBOOKS_VALIDATOR = validation::CustomValidator{
|
||||
[](boost::json::value const& value, std::string_view key) -> MaybeError {
|
||||
if (!value.is_array())
|
||||
if (!value.is_array()) {
|
||||
return Error{
|
||||
Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "NotArray"}
|
||||
};
|
||||
}
|
||||
|
||||
for (auto const& book : value.as_array()) {
|
||||
if (!book.is_object())
|
||||
if (!book.is_object()) {
|
||||
return Error{
|
||||
Status{RippledError::rpcINVALID_PARAMS, std::string(key) + "ItemNotObject"}
|
||||
};
|
||||
}
|
||||
|
||||
if (book.as_object().contains("both") && !book.as_object().at("both").is_bool())
|
||||
return Error{Status{RippledError::rpcINVALID_PARAMS, "bothNotBool"}};
|
||||
|
||||
Reference in New Issue
Block a user