From 2601f8d688490ce43d630557bfa3c0da701b75dd Mon Sep 17 00:00:00 2001 From: Alex Kremer Date: Tue, 11 Aug 2026 18:13:47 +0100 Subject: [PATCH] Introduce rpcspec 0.1.3 dependency --- CMakeLists.txt | 3 +++ conan.lock | 1 + conanfile.py | 1 + src/rpc/common/JsonBool.hpp | 51 +++---------------------------------- 4 files changed, 8 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b68eca363..f569c9217 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,9 @@ include(deps/cassandra) include(deps/libbacktrace) include(deps/spdlog) +include(deps/rpcspec) +target_link_libraries(clio_options INTERFACE rpcspec::rpcspec) + add_subdirectory(src) add_subdirectory(tests) diff --git a/conan.lock b/conan.lock index 3d063ec20..f74914b54 100644 --- a/conan.lock +++ b/conan.lock @@ -3,6 +3,7 @@ "requires": [ "zlib/1.3.2#1cb806da49011867778ffb6ac7190fcb%1782392402.122708", "xxhash/0.8.3#681d36a0a6111fc56e5e45ea182c19cc%1782392402.420688", + "xrpl-rpc-spec/0.1.3#e0552b7fdcb26d9249498fa4273474f1%1786463175.210094", "xrpl/3.3.0-rc1-custom#cdfb12fc2671eaea72d5920bea800fd2%1785426802.141277", "sqlite3/3.53.0#324ada52333108388a9a6108bfa96734%1782392403.185447", "spdlog/1.17.0#bcbaaf7147bda6ad24ffbd1ac3d7142c%1782736610.443882", diff --git a/conanfile.py b/conanfile.py index a4139086a..e03973343 100644 --- a/conanfile.py +++ b/conanfile.py @@ -17,6 +17,7 @@ class ClioConan(ConanFile): "fmt/12.1.0", "libbacktrace/cci.20210118", "spdlog/1.17.0", + "xrpl-rpc-spec/0.1.3", "xrpl/3.3.0-rc1-custom", ] diff --git a/src/rpc/common/JsonBool.hpp b/src/rpc/common/JsonBool.hpp index 2962abaa3..964238915 100644 --- a/src/rpc/common/JsonBool.hpp +++ b/src/rpc/common/JsonBool.hpp @@ -1,58 +1,13 @@ #pragma once -#include -#include -#include -#include - -#include +#include namespace rpc { /** - * @brief A wrapper around bool that allows to convert from any JSON value - */ -struct JsonBool { - bool value = false; - - /** @cond */ - operator bool() const - { - return value; - } - /** @endcond */ -}; - -/** - * @brief Convert a JSON value to a JsonBool + * @brief A wrapper around bool that allows conversion from any JSON value. * - * @param jsonValue The JSON value to convert - * @return The converted JsonBool */ -inline JsonBool -tag_invoke(boost::json::value_to_tag const&, boost::json::value const& jsonValue) -{ - switch (jsonValue.kind()) { - case boost::json::kind::null: - return JsonBool{false}; - case boost::json::kind::bool_: - return JsonBool{jsonValue.as_bool()}; - case boost::json::kind::uint64: - [[fallthrough]]; - case boost::json::kind::int64: - return JsonBool{jsonValue.as_int64() != 0}; - case boost::json::kind::double_: - return JsonBool{jsonValue.as_double() != 0.0}; - case boost::json::kind::string: - // Also should be `jsonValue.as_string() != "false"` but rippled doesn't do - // that. Anyway for v2 api we have bool validation - return JsonBool{!jsonValue.as_string().empty() && jsonValue.as_string()[0] != 0}; - case boost::json::kind::array: - return JsonBool{!jsonValue.as_array().empty()}; - case boost::json::kind::object: - return JsonBool{!jsonValue.as_object().empty()}; - } - throw std::runtime_error("Invalid json value"); -} +using JsonBool = spec::JsonBool; } // namespace rpc