View all files | ||||
A header-only, consteval RPC specification DSL for the XRP Ledger, shared by Clio and xrpld.
The DSL lets a handler declare its request parameters — types, requirements, defaults, modifiers — as a compile-time spec. The framework validates incoming request parameters against that spec before the handler runs, replacing hand-written per-handler validation logic.
Both backends resolve XRPL protocol types (AccountID, LedgerEntryType, error codes, …) from xrpl:: (libxrpl). The backend macro instead selects which server the spec is compiled for, controlling the server-conditional validators ifServerClio(...) / ifServerRippled(...) — each applies its wrapped validators only in the matching build. Exactly one macro must be defined by the consumer's build:
Defining both, or neither, is a compile error (see ServerConditional.hpp).
The library is distributed as a Conan header-library package exporting the CMake target rpcspec::rpcspec. Add it to your requirements and define the backend macro in your toolchain. Its only direct dependency is Boost::json; the XRPL protocol headers come from your project.
When hacking on the DSL while building a consumer (Clio or rippled) against it, register this repo as an editable Conan package. Consumers that require xrpl-rpc-spec/0.1.0 then resolve to your working tree instead of the Conan cache, so header edits are picked up on the consumer's next build — no conan export/conan create round-trip.
The recipe's layout() exposes include/ as the include dir in editable mode, so consumers find the headers directly in the source tree (no packaging step). After conan editable remove, consumers fall back to the cached package, so make sure one is available (conan create .) or re-export as needed.
The standalone tests run against the rippled (xrpl::) backend, but the small libxrpl protocol surface the DSL references is mocked in tests/stubs — so the only test dependencies are gtest and Boost::json (no libxrpl, no Conan remote beyond the defaults).
Conan provides both dependencies and generates the CMake presets. The tests option also wires up RPCSPEC_IS_RIPPLED=1 and rpcspec_tests=ON in the generated toolchain, so no extra -D flags are needed:
If gtest and Boost::json are already discoverable by find_package (e.g. installed system-wide), skip Conan and drive CMake directly. Here -Drpcspec_tests=ON is required, and the backend macro is set automatically for the test target: