From 157e17ae850a2426236fc670968c520da48c2dec Mon Sep 17 00:00:00 2001 From: Alex Kremer Date: Tue, 1 Sep 2026 13:44:14 +0100 Subject: [PATCH] Remove forwarders --- src/rpc/common/Validators.cpp | 10 ++++------ src/rpc/handlers/AccountObjects.cpp | 3 ++- src/rpc/handlers/LedgerData.cpp | 7 +++---- src/util/CMakeLists.txt | 1 - src/util/LedgerUtils.cpp | 22 ---------------------- src/util/LedgerUtils.hpp | 20 -------------------- tests/unit/util/LedgerUtilsTests.cpp | 19 ++++++++++--------- 7 files changed, 19 insertions(+), 63 deletions(-) delete mode 100644 src/util/LedgerUtils.cpp diff --git a/src/rpc/common/Validators.cpp b/src/rpc/common/Validators.cpp index 1a0f74374..5177989fe 100644 --- a/src/rpc/common/Validators.cpp +++ b/src/rpc/common/Validators.cpp @@ -4,7 +4,6 @@ #include "rpc/RPCHelpers.hpp" #include "rpc/common/Types.hpp" #include "util/AccountUtils.hpp" -#include "util/LedgerUtils.hpp" #include "util/TimeUtils.hpp" #include @@ -12,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -116,8 +116,7 @@ CustomValidator CustomValidators::ledgerTypeValidator = }}; } - auto const type = - util::LedgerTypes::getLedgerEntryTypeFromStr(boost::json::value_to(value)); + auto const type = spec::ledgerEntryTypeFromStr(boost::json::value_to(value)); if (type == xrpl::ltANY) { return Error{ Status{RippledError::RpcInvalidParams, fmt::format("Invalid field '{}'.", key)} @@ -176,9 +175,8 @@ CustomValidator CustomValidators::accountTypeValidator = }}; } - auto const type = util::LedgerTypes::getAccountOwnedLedgerTypeFromStr( - boost::json::value_to(value) - ); + auto const type = + spec::accountOwnedLedgerTypeFromStr(boost::json::value_to(value)); if (type == xrpl::ltANY) { return Error{ Status{RippledError::RpcInvalidParams, fmt::format("Invalid field '{}'.", key)} diff --git a/src/rpc/handlers/AccountObjects.cpp b/src/rpc/handlers/AccountObjects.cpp index cdde3372b..d23ade377 100644 --- a/src/rpc/handlers/AccountObjects.cpp +++ b/src/rpc/handlers/AccountObjects.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -160,7 +161,7 @@ tag_invoke(boost::json::value_to_tag, boost::json: } if (jsonObject.contains(JS(type))) { - input.type = util::LedgerTypes::getAccountOwnedLedgerTypeFromStr( + input.type = spec::accountOwnedLedgerTypeFromStr( boost::json::value_to(jv.at(JS(type))) ); } diff --git a/src/rpc/handlers/LedgerData.cpp b/src/rpc/handlers/LedgerData.cpp index 74724980c..cbe7ef3ed 100644 --- a/src/rpc/handlers/LedgerData.cpp +++ b/src/rpc/handlers/LedgerData.cpp @@ -6,7 +6,6 @@ #include "rpc/common/Types.hpp" #include "util/Assert.hpp" #include "util/JsonUtils.hpp" -#include "util/LedgerUtils.hpp" #include "util/log/Logger.hpp" #include @@ -14,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -215,9 +215,8 @@ tag_invoke(boost::json::value_to_tag, boost::json::val } if (jsonObject.contains(JS(type))) { - input.type = util::LedgerTypes::getLedgerEntryTypeFromStr( - boost::json::value_to(jv.at(JS(type))) - ); + input.type = + spec::ledgerEntryTypeFromStr(boost::json::value_to(jv.at(JS(type)))); } return input; diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index eba68cfa2..bd7704b12 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -33,7 +33,6 @@ target_sources( Taggable.cpp TerminationHandler.cpp TimeUtils.cpp - LedgerUtils.cpp MPTIssuanceUtils.cpp config/Array.cpp config/ArrayView.cpp diff --git a/src/util/LedgerUtils.cpp b/src/util/LedgerUtils.cpp deleted file mode 100644 index 8ac0e8846..000000000 --- a/src/util/LedgerUtils.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "util/LedgerUtils.hpp" - -#include -#include - -#include - -namespace util { - -xrpl::LedgerEntryType -LedgerTypes::getLedgerEntryTypeFromStr(std::string const& entryName) -{ - return rpc::spec::ledgerEntryTypeFromStr(entryName); -} - -xrpl::LedgerEntryType -LedgerTypes::getAccountOwnedLedgerTypeFromStr(std::string const& entryName) -{ - return rpc::spec::accountOwnedLedgerTypeFromStr(entryName); -} - -} // namespace util diff --git a/src/util/LedgerUtils.hpp b/src/util/LedgerUtils.hpp index 261804bb8..9bfd8d3f4 100644 --- a/src/util/LedgerUtils.hpp +++ b/src/util/LedgerUtils.hpp @@ -63,26 +63,6 @@ public: }); return res; } - - /** - * @brief Returns the xrpl::LedgerEntryType from the given string. - * - * @param entryName The name or canonical name (case-insensitive) of the ledger entry type for - * all categories - * @return The xrpl::LedgerEntryType of the given string, returns ltANY if not found. - */ - static xrpl::LedgerEntryType - getLedgerEntryTypeFromStr(std::string const& entryName); - - /** - * @brief Returns the xrpl::LedgerEntryType from the given string. - * - * @param entryName The name or canonical name (case-insensitive) of the ledger entry type for - * account owned category - * @return The xrpl::LedgerEntryType of the given string, returns ltANY if not found. - */ - static xrpl::LedgerEntryType - getAccountOwnedLedgerTypeFromStr(std::string const& entryName); }; /** diff --git a/tests/unit/util/LedgerUtilsTests.cpp b/tests/unit/util/LedgerUtilsTests.cpp index 7e6938890..b44dbb27e 100644 --- a/tests/unit/util/LedgerUtilsTests.cpp +++ b/tests/unit/util/LedgerUtilsTests.cpp @@ -2,6 +2,7 @@ #include "util/LedgerUtils.hpp" #include +#include #include #include @@ -55,16 +56,16 @@ TEST(LedgerUtilsTests, LedgerObjectTypeList) TEST(LedgerUtilsTests, StrToType) { - EXPECT_EQ(util::LedgerTypes::getLedgerEntryTypeFromStr("mess"), xrpl::ltANY); - EXPECT_EQ(util::LedgerTypes::getLedgerEntryTypeFromStr("tomato"), xrpl::ltANY); - EXPECT_EQ(util::LedgerTypes::getLedgerEntryTypeFromStr("account"), xrpl::ltACCOUNT_ROOT); - EXPECT_EQ(util::LedgerTypes::getLedgerEntryTypeFromStr("AccoUnt"), xrpl::ltANY); - EXPECT_EQ(util::LedgerTypes::getLedgerEntryTypeFromStr("AccountRoot"), xrpl::ltACCOUNT_ROOT); - EXPECT_EQ(util::LedgerTypes::getLedgerEntryTypeFromStr("ACCOUNTRoot"), xrpl::ltACCOUNT_ROOT); + EXPECT_EQ(rpc::spec::ledgerEntryTypeFromStr("mess"), xrpl::ltANY); + EXPECT_EQ(rpc::spec::ledgerEntryTypeFromStr("tomato"), xrpl::ltANY); + EXPECT_EQ(rpc::spec::ledgerEntryTypeFromStr("account"), xrpl::ltACCOUNT_ROOT); + EXPECT_EQ(rpc::spec::ledgerEntryTypeFromStr("AccoUnt"), xrpl::ltANY); + EXPECT_EQ(rpc::spec::ledgerEntryTypeFromStr("AccountRoot"), xrpl::ltACCOUNT_ROOT); + EXPECT_EQ(rpc::spec::ledgerEntryTypeFromStr("ACCOUNTRoot"), xrpl::ltACCOUNT_ROOT); constexpr auto kTypes = util::LedgerTypes::getLedgerEntryTypeStrList(); std::ranges::for_each(kTypes, [](auto const& typeStr) { - EXPECT_NE(util::LedgerTypes::getLedgerEntryTypeFromStr(typeStr), xrpl::ltANY); + EXPECT_NE(rpc::spec::ledgerEntryTypeFromStr(typeStr), xrpl::ltANY); }); } @@ -193,7 +194,7 @@ class LedgerEntryTypeFromStrTest : public ::testing::TestWithParam