feat: Add Formats and Fields to server_definitions#6321
feat: Add Formats and Fields to server_definitions#6321godexsoft wants to merge 57 commits intoXRPLF:developfrom
Conversation
| auto txCommonFields = std::set<std::string>(); | ||
| for (auto const& element : TxFormats::getCommonFields()) | ||
| { | ||
| Json::Value elementObj = Json::objectValue; | ||
| elementObj[jss::name] = element.sField().getName(); | ||
| elementObj[jss::optionality] = element.style(); | ||
| defs_[jss::TRANSACTION_FORMATS][jss::common].append(elementObj); | ||
| txCommonFields.insert(element.sField().getName()); | ||
| } | ||
|
|
||
| for (auto const& format : TxFormats::getInstance()) | ||
| { | ||
| auto const& soTemplate = format.getSOTemplate(); | ||
| Json::Value templateArray = Json::arrayValue; | ||
| for (auto const& element : soTemplate) | ||
| { | ||
| if (txCommonFields.count(element.sField().getName()) > 0) | ||
| continue; // skip common fields, already added | ||
| Json::Value elementObj = Json::objectValue; | ||
| elementObj[jss::name] = element.sField().getName(); | ||
| elementObj[jss::optionality] = element.style(); | ||
| templateArray.append(elementObj); | ||
| } | ||
| defs_[jss::TRANSACTION_FORMATS][format.getName()] = templateArray; | ||
| } | ||
|
|
There was a problem hiding this comment.
just out of curiosity, is there any benefit in inserting common fields first? Will they actually be ordered to be first in the printout in this case? I think we don't need to do any separation at all and just dump all the fields, regardless
There was a problem hiding this comment.
in case you decide to leave this behind, txCommonFields.count(element.sField().getName()) > 0 -> txCommonFields.contains(element.sField().getName())
There was a problem hiding this comment.
I checked and no it does not make it appear first (it's actually last in the list for both).
I don't think the intention was to have them first or ordered in any specific way, other than for the common fields to land under 'common' instead of injecting them into each format. Will apply your suggestion 👍
There was a problem hiding this comment.
The JSON library automatically sorts in alphabetical order
| defs_[jss::LEDGER_ENTRY_FORMATS] = Json::objectValue; | ||
| defs_[jss::LEDGER_ENTRY_FORMATS][jss::common] = Json::arrayValue; | ||
| auto ledgerCommonFields = std::set<std::string>(); | ||
| for (auto const& element : LedgerFormats::getCommonFields()) | ||
| { | ||
| Json::Value elementObj = Json::objectValue; | ||
| elementObj[jss::name] = element.sField().getName(); | ||
| elementObj[jss::optionality] = element.style(); | ||
| defs_[jss::LEDGER_ENTRY_FORMATS][jss::common].append(elementObj); | ||
| ledgerCommonFields.insert(element.sField().getName()); | ||
| } | ||
| for (auto const& format : LedgerFormats::getInstance()) | ||
| { | ||
| auto const& soTemplate = format.getSOTemplate(); | ||
| Json::Value templateArray = Json::arrayValue; | ||
| for (auto const& element : soTemplate) | ||
| { | ||
| if (ledgerCommonFields.count(element.sField().getName()) > 0) | ||
| continue; // skip common fields, already added | ||
| Json::Value elementObj = Json::objectValue; | ||
| elementObj[jss::name] = element.sField().getName(); | ||
| elementObj[jss::optionality] = element.style(); | ||
| templateArray.append(elementObj); | ||
| } | ||
| defs_[jss::LEDGER_ENTRY_FORMATS][format.getName()] = templateArray; | ||
| } | ||
|
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| various purposes, but attempting to use such values to identify | ||
| on-ledger objects will results in an invariant failure. | ||
| @note Values outside this range may be used internally by the code for various purposes, but | ||
| attempting to use such values to identify on-ledger objects will results in an invariant failure. |
There was a problem hiding this comment.
In this doc comment, the phrase "will results in an invariant failure" is grammatically incorrect (should be "will result"). Please fix to avoid propagating typos into generated docs and developer references.
| attempting to use such values to identify on-ledger objects will results in an invariant failure. | |
| attempting to use such values to identify on-ledger objects will result in an invariant failure. |
| { | ||
| BEAST_EXPECT(result[jss::result].isMember(jss::LEDGER_ENTRY_FORMATS)); | ||
|
|
||
| // Note: For the purposes of software maintainance, this test does not exhaustively |
There was a problem hiding this comment.
Typo in comment: "maintainance" should be "maintenance".
| // Note: For the purposes of software maintainance, this test does not exhaustively | |
| // Note: For the purposes of software maintenance, this test does not exhaustively |
| ## XRP Ledger server version 3.2.0 | ||
|
|
||
| [Version 3.2.0](https://github.com/XRPLF/rippled/releases/tag/3.2.0) | ||
|
|
||
| ### Additions in 3.2.0 | ||
|
|
||
| - `server_definitions`: Added the following new sections to the response ([#6321](https://github.com/XRPLF/rippled/pull/6321)): |
There was a problem hiding this comment.
This new changelog entry for "XRP Ledger server version 3.2.0" doesn’t include a release date, while the surrounding entries do. Please either add the release date (if known) or adjust the heading/link text to match the established format used in this file for unreleased/new versions.
ximinez
left a comment
There was a problem hiding this comment.
All of my concerns have been addressed, though Copilot identified a couple of things.
I haven't done a deep review, so I'm just going to dismiss this approval. There are plenty of other approvals to proceed with.
High Level Overview of Change
Closes #5151
Attempts to implement XRPLF/XRPL-Standards#418
This is a combination of #5702 (bulk of functionality) and #5616 (tests).
If merged:
server_definitions#5702tfBatchMasknot matching the previous constant is fixed and covered by an extra test inBatch_test.cpp.initializer_listwhere applicable.Context of Change
Type of Change
.gitignore, formatting, dropping support for older tooling)API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)