-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: add synthetic NFT fields to ledger RPC, refactor to have common helper function
#5706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
fix: add synthetic NFT fields to ledger RPC, refactor to have common helper function
#5706
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: mvadari <[email protected]>
122c476 to
ee3cba2
Compare
mvadari
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My approval doesn't count towards the 2 required, but I figured I should have some symbol of "the person working with Copilot thinks it's good to go"
|
@copilot |
…SyntheticInJson helper in simulate RPC Co-authored-by: mvadari <[email protected]>
I've replaced the individual synthetic field functions in the |
|
@tequdev just noting here the bug that Copilot found in your PR Would you mind doing a quick review of this PR? |
I saw that commit, but I couldn't see what bug was there. |
Hm, not sure either. Guess it's probably fine 🤷🏽 |
High Level Overview of Change
Refactor synthetic field injection by consolidating three commonly-called functions (
insertDeliveredAmount,insertNFTSyntheticInJson, andinsertMPTokenIssuanceID) into a single helper functioninsertAllSyntheticInJson. This improves code maintainability by reducing duplication and providing a single point of update for synthetic field processing.This results in also resolving #4835 and adding the synthetic
nftoken_idandnftoken_offer_idto theledgerRPC.Context of Change
Previously, the same three synthetic field injection functions were called together in multiple locations throughout the codebase:
src/xrpld/app/misc/NetworkOPs.cppsrc/xrpld/rpc/handlers/Tx.cppsrc/xrpld/rpc/handlers/AccountTx.cppsrc/xrpld/app/ledger/detail/LedgerToJson.cppsrc/xrpld/rpc/handlers/Simulate.cppThis pattern created maintenance overhead, as any changes to synthetic field processing would need to be replicated across all locations. Additionally,
LedgerToJson.cppcontained an outdated conditional check that only appliedinsertDeliveredAmountfor PAYMENT and CHECK_CASH transactions, which was no longer needed.The refactor consolidates this logic into a reusable helper function with two overloads to handle different parameter signatures (
ReadViewvsJsonContext).Type of Change
API Impact
Fixes issue #4835
Before / After
Before: Each location manually called three functions:
After: Single helper function call:
insertAllSyntheticInJson(response, ledger, transaction, transactionMeta);Test Plan
The change preserves existing functionality by calling the same underlying functions in the same order. All synthetic field injection behavior remains identical. The consolidation was tested across all five modified files to ensure consistent usage of the new helper function.
This also involved adding tests to ensure that the NFT synthetic fields were added to the
ledgerandaccount_txRPC.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.