Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 20, 2025

High Level Overview of Change

Refactor synthetic field injection by consolidating three commonly-called functions (insertDeliveredAmount, insertNFTSyntheticInJson, and insertMPTokenIssuanceID) into a single helper function insertAllSyntheticInJson. 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_id and nftoken_offer_id to the ledger RPC.

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.cpp
  • src/xrpld/rpc/handlers/Tx.cpp
  • src/xrpld/rpc/handlers/AccountTx.cpp
  • src/xrpld/app/ledger/detail/LedgerToJson.cpp
  • src/xrpld/rpc/handlers/Simulate.cpp

This pattern created maintenance overhead, as any changes to synthetic field processing would need to be replicated across all locations. Additionally, LedgerToJson.cpp contained an outdated conditional check that only applied insertDeliveredAmount for 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 (ReadView vs JsonContext).

Type of Change

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

API Impact

Fixes issue #4835

Before / After

Before: Each location manually called three functions:

insertDeliveredAmount(response[jss::meta], ledger, transaction, transactionMeta);
insertNFTSyntheticInJson(response, transaction, transactionMeta);
insertMPTokenIssuanceID(response[jss::meta], transaction, transactionMeta);

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 ledger and account_tx RPC.


💡 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.

@mvadari

This comment was marked as resolved.

This comment was marked as resolved.

Copilot AI changed the title [WIP] Fix this issue. The linked pages should help with figuring out how to add the relevant field in the relevant place. Add missing nftoken_id synthetic field to ledger RPC response Aug 20, 2025
Copilot finished work on behalf of mvadari August 20, 2025 21:43
@mvadari mvadari added the DraftRunCI Normally CI does not run on draft PRs. This opts in. label Aug 20, 2025
@mvadari

This comment was marked as resolved.

This comment was marked as resolved.

Copilot AI changed the title Add missing nftoken_id synthetic field to ledger RPC response Add missing nftoken_id synthetic field to ledger RPC response and enhance NFT testing Aug 20, 2025
Copilot finished work on behalf of mvadari August 20, 2025 21:55
@mvadari

This comment was marked as resolved.

This comment was marked as resolved.

Copilot finished work on behalf of mvadari August 20, 2025 22:02
@mvadari

This comment was marked as resolved.

This comment was marked as resolved.

Copilot AI changed the title Add missing nftoken_id synthetic field to ledger RPC response and enhance NFT testing Fix missing nftoken_id synthetic field in ledger RPC response by properly handling API version differences Aug 20, 2025
Copilot finished work on behalf of mvadari August 20, 2025 22:40
@mvadari

This comment was marked as resolved.

This comment was marked as resolved.

Copilot finished work on behalf of mvadari August 21, 2025 14:25
@mvadari

This comment was marked as resolved.

@mvadari mvadari force-pushed the copilot/fix-5adea215-d850-4ab8-a595-b04e63e948a6 branch from 122c476 to ee3cba2 Compare September 10, 2025 15:48
Copy link
Collaborator

@mvadari mvadari left a 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"

@mvadari
Copy link
Collaborator

mvadari commented Sep 11, 2025

@copilot simulate now also has the same collection of metadata insert functions, please replace it with our new helper function. It is already well-tested, so additional tests shouldn't be needed.

…SyntheticInJson helper in simulate RPC

Co-authored-by: mvadari <[email protected]>
Copy link
Contributor Author

Copilot AI commented Sep 11, 2025

@copilot simulate now also has the same collection of metadata insert functions, please replace it with our new helper function. It is already well-tested, so additional tests shouldn't be needed.

I've replaced the individual synthetic field functions in the simulate RPC with the new insertAllSyntheticInJson helper function. The change also fixed an inconsistency where insertNFTSyntheticInJson was being called with the wrong parameter. Commit 4063cca.

Copilot finished work on behalf of mvadari September 11, 2025 14:29
Copilot AI requested a review from mvadari September 11, 2025 14:29
@mvadari
Copy link
Collaborator

mvadari commented Sep 11, 2025

@tequdev just noting here the bug that Copilot found in your PR

Would you mind doing a quick review of this PR?

@tequdev
Copy link
Member

tequdev commented Sep 21, 2025

@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.

@mvadari
Copy link
Collaborator

mvadari commented Sep 23, 2025

@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 🤷🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistant minted nftoken_id field in API response (Version: 1.12.0)

4 participants