Sponsored Content
Skip to content

refactor: move API functions from RPCHelpers.h to ApiVersion.h - #5889

Merged
bthomee merged 12 commits into
XRPLF:developfrom
mvadari:refactor-rpc-helpers1
Nov 3, 2025
Merged

refactor: move API functions from RPCHelpers.h to ApiVersion.h#5889
bthomee merged 12 commits into
XRPLF:developfrom
mvadari:refactor-rpc-helpers1

Conversation

@mvadari

@mvadari mvadari commented Oct 14, 2025

Copy link
Copy Markdown
Contributor

High Level Overview of Change

This PR moves two functions, setVersion and getAPIVersionNumber, from RPCHelpers.h to ApiVersion.h. There are no functionality or code changes.

Context of Change

Split out of #5684 to hopefully start making that PR a bit easier to review.

Type of Change

  • Refactor (non-breaking change that only restructures code)

API Impact

N/A

Test Plan

CI passes

Future Tasks

Add another PR that creates RPCLedgerHelpers and splits out that part of #5684, leaving only the actual functionality changes in #5684

@mvadari
mvadari requested a review from a team October 14, 2025 18:47
@mvadari
mvadari requested a review from godexsoft October 14, 2025 18:51
@codecov

codecov Bot commented Oct 14, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.2%. Comparing base (63a0856) to head (23ffa60).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #5889   +/-   ##
=======================================
  Coverage     78.2%   78.2%           
=======================================
  Files          817     816    -1     
  Lines        68940   68949    +9     
  Branches      8353    8353           
=======================================
+ Hits         53934   53943    +9     
  Misses       15006   15006           
Files with missing lines Coverage Δ
include/xrpl/protocol/ApiVersion.h 100.0% <100.0%> (ø)
src/xrpld/app/main/Application.cpp 68.6% <ø> (ø)
src/xrpld/app/main/GRPCServer.h 100.0% <ø> (ø)
src/xrpld/rpc/detail/Handler.cpp 86.2% <ø> (ø)
src/xrpld/rpc/detail/Handler.h 27.8% <ø> (ø)
src/xrpld/rpc/detail/RPCHelpers.cpp 81.9% <ø> (-0.4%) ⬇️
src/xrpld/rpc/detail/ServerHandler.cpp 86.5% <ø> (ø)
src/xrpld/rpc/handlers/LedgerHandler.cpp 20.4% <ø> (ø)
src/xrpld/rpc/handlers/LedgerHandler.h 70.6% <ø> (ø)
src/xrpld/rpc/handlers/Tx.cpp 93.2% <ø> (ø)
... and 1 more

... and 3 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@godexsoft godexsoft left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments

Comment thread include/xrpl/protocol/ApiVersion.h Outdated
if (apiVersion == apiVersionIfUnspecified)
{
/**
* API version numbers used in API version 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not a doxy comment that will actually work (reach documentation). You probably better use a simple comment instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread include/xrpl/protocol/ApiVersion.h Outdated
* 3) the version number is unspecified and
* APIVersionIfUnspecified is out of the supported range
*
* @param value a Json value that may or may not specifies

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter is currently called "jv" not "value"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread include/xrpl/protocol/ApiVersion.h Outdated

Json::Value const maxVersion(
betaEnabled ? RPC::apiBetaVersion : RPC::apiMaximumSupportedVersion);
Json::Value requestedVersion(RPC::apiVersionIfUnspecified);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this is just moving code around but consider cleaning this up (e.g. adding some whitespace where applicable)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored in a62c8e7

Comment thread include/xrpl/protocol/ApiVersion.h Outdated
{
requestedVersion = jv.get(jss::api_version, requestedVersion);
}
if (!(requestedVersion.isInt() || requestedVersion.isUInt()) ||

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This is a horrible condition. Any improvement here would be nice 🔢

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored in a62c8e7

Comment thread include/xrpl/protocol/ApiVersion.h Outdated
XRPL_ASSERT(
apiVersion != apiInvalidVersion,
"ripple::RPC::setVersion : input is valid");
auto&& object = addObject(parent, jss::version);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This auto&& is a bit confusing. According to addObject signature this would call the overload which returns by value if Object is not a Value. Is it some sort of shared pointer inside? I don't understand why setting fields on object below would make sense as object is technically a temporary here.

Also, Object is a terrible name for a template parameter - I did not even notice it at first and assumed that it's the Object type from the Json library. This definitely needs renaming at the very least but also try implementing some tests that use this function with Object (template type) be actual Object from Json library and see if it even does anything useful.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding tests etc for Object is out of scope of this PR but I'll look into a separate cleanup effort. Based on some preliminary digging I think there's a good chance we can get rid of that whole Object class and only use Json::Value everywhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did switch out the && for & in 7617f1b though

@mvadari
mvadari requested a review from godexsoft October 15, 2025 20:12

@pratikmankawde pratikmankawde left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@mvadari mvadari added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label Nov 3, 2025
@bthomee
bthomee merged commit b18dece into XRPLF:develop Nov 3, 2025
3 checks passed
@mvadari
mvadari deleted the refactor-rpc-helpers1 branch February 4, 2026 22:43
@mvadari mvadari added this to the 3.2.0 milestone May 20, 2026
beartec-jpg pushed a commit to beartec-jpg/FalconLedger that referenced this pull request Jun 1, 2026
…RPLF#5889)

This change moves two functions, `setVersion` and `getAPIVersionNumber`, from `RPCHelpers.h` to `ApiVersion.h`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants