Skip to content

refactor: Use NFTokenOfferEntry everywhere - #8366

Open
mvadari wants to merge 3 commits into
developfrom
mvadari/rearch/nftokenoffer-entry
Open

mvadari wants to merge 3 commits into
developfrom
mvadari/rearch/nftokenoffer-entry

Conversation

@mvadari

@mvadari mvadari commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

High Level Overview of Change

Replace raw NFTokenOffer SLE pointers with NFTokenOfferEntryR/NFTokenOfferEntryW in NFTokenHelpers.cpp (removeTokenOffersWithLimit, deleteTokenOffer, tokenOfferCreateApply), NFTokenAcceptOffer, NFTokenCancelOffer, the expired-offer cleanup in Transactor.cpp, and the AccountDelete deleter removeNFTokenOfferFromLedger. nft::deleteTokenOffer() and NFTokenAcceptOffer::acceptOffer() now take the wrapper. No helper moves onto the wrapper in this PR.

NFTokenAcceptOffer::doApply() reads the offers after it deletes them. NFTokenOfferEntryW::erase() drops its SLE, so doApply() keeps read-only handles to the same SLEs for those reads.

Context of Change

Part of the Wrapped SLEs migration (design: step 2/3 of #7886). The wrapper types bind each pointer to the NFTokenOffer entry type and make the compiler enforce read-only vs. writable access. Pure refactor: no amendment, no behavior change; any observable difference is a bug.

This PR was fully written by AI (Claude Code) under human direction; the human author reviewed the diff.

API Impact

  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)

Test Plan

Syntax-checked every changed .cpp and every includer of NFTokenHelpers.h / NFTokenAcceptOffer.h (13 files, including applySteps.cpp and InvariantCheck.cpp); clang-tidy clean on the changed .cpp files. No new tests. CI runs the full unit test suite.

🤖 Generated with Claude Code

@ripple-ai-reviewer ripple-ai-reviewer Bot 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.

This is a careful, mechanical refactor migrating NFTokenOffer SLE pointer usage to the new NFTokenOfferEntryR/NFTokenOfferEntryW wrapper types across NFTokenHelpers, NFTokenAcceptOffer, NFTokenCancelOffer, Transactor's expired-offer cleanup, and AccountDelete's NFT offer deleter. The tricky part — NFTokenAcceptOffer::doApply() needing to read offer fields after deleteTokenOffer() erases the writable entries — is handled correctly by capturing NFTokenOfferEntryR read-only copies (buyOffer/sellOffer) before the erase calls, and the early-return-on-expired path avoids using those copies in a post-erase state. The main thing I'd want confirmed is whether the bridgeOffers() declaration change in NFTokenAcceptOffer.h corresponds to an actual (possibly out-of-scope) implementation update, since no matching .cpp change is visible in this diff.

@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.34884% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
.../libxrpl/tx/transactors/nft/NFTokenAcceptOffer.cpp 93.8% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

The deletion API can mutate two different views when its explicit view and wrapper-bound view differ.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Refactors NFT offer handling to use typed read/write ledger-entry wrappers.

Changes:

  • Migrates NFT offer creation, lookup, acceptance, cancellation, and cleanup.
  • Preserves read-only handles after writable entries are erased.
  • Updates helper and transactor interfaces.
File Description
src/​libxrpl/​tx/​transactors/​nft/​NFTokenCancelOffer.cpp Uses writable offer wrappers.
src/​libxrpl/​tx/​transactors/​nft/​NFTokenAcceptOffer.cpp Migrates offer validation and acceptance.
src/​libxrpl/​tx/​transactors/​account/​AccountDelete.cpp Wraps NFT offers during deletion.
src/​libxrpl/​tx/​Transactor.cpp Wraps expired offers during cleanup.
src/​libxrpl/​ledger/​helpers/​NFTokenHelpers.cpp Migrates offer creation and deletion helpers.
include/​xrpl/​tx/​transactors/​nft/​NFTokenAcceptOffer.h Updates private wrapper-based interfaces.
include/​xrpl/​ledger/​helpers/​NFTokenHelpers.h Updates the deletion helper API.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.


bool
deleteTokenOffer(ApplyView& view, SLE::ref offer)
deleteTokenOffer(ApplyView& view, NFTokenOfferEntryW& offer)
@github-actions

Copy link
Copy Markdown

This PR has conflicts, please resolve them in order for the PR to be reviewed.

@mvadari
mvadari force-pushed the mvadari/rearch/nftokenoffer-entry branch from 66c204d to f48da29 Compare September 30, 2026 17:46
@github-actions

Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

@ripple-ai-reviewer ripple-ai-reviewer Bot 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.

This is a careful, mechanical refactor swapping raw NFTokenOffer SLE pointers for the NFTokenOfferEntryR/W wrapper types across NFTokenHelpers, NFTokenAcceptOffer, NFTokenCancelOffer, Transactor's expired-offer cleanup, and AccountDelete's deleter. The sequencing in NFTokenAcceptOffer::doApply — capturing read-only NFTokenOfferEntryR copies before calling deleteTokenOffer() so the fields can still be read after the writable wrapper erases its SLE — is correct and matches the stated intent. I didn't find behavior-changing bugs in the visible diff; the two items below are lower-confidence observations rather than confirmed defects.

@mvadari
mvadari force-pushed the mvadari/rearch/nftokenoffer-entry branch from f48da29 to 007d178 Compare October 5, 2026 12:54

@ripple-ai-reviewer ripple-ai-reviewer Bot 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.

This is a clean, mechanical refactor replacing raw NFTokenOffer SLE pointers with the new NFTokenOfferEntryR/W wrapper types, consistent with the stated goal of enforcing read/write access at compile time with no behavior change. I traced the one genuinely risky spot in the diff — NFTokenAcceptOffer::doApply() reading buy/sell offer fields after nft::deleteTokenOffer() erases them — and the author correctly snapshots read-only NFTokenOfferEntryR copies (buyOffer/sellOffer) before calling deleteTokenOffer(), so the subsequent bridging/accept logic reads valid data instead of a post-erase wrapper. The early-return on foundExpired also correctly prevents use of an already-erased writable entry. The AccountDelete.cpp deleter and the other call sites (NFTokenHelpers.cpp, Transactor.cpp, NFTokenCancelOffer.cpp) all follow the same safe construct-check-erase pattern. I did not find any lines in the diff that introduce a correctness, security, or resource-leak issue with high confidence.

@github-actions

Copy link
Copy Markdown

This PR has conflicts, please resolve them in order for the PR to be reviewed.

Replace raw NFTokenOffer SLE pointers with NFTokenOfferEntryR and
NFTokenOfferEntryW in the NFToken helpers, the NFTokenOffer
transactors, the expired-offer cleanup in Transactor, and the
AccountDelete deleter.

deleteTokenOffer() and NFTokenAcceptOffer::acceptOffer() now take the
wrapper instead of an SLE. They stay free/private functions; moving
helpers onto the wrapper comes in a later PR.

NFTokenAcceptOffer::doApply() reads the offers after it deletes them.
Because NFTokenOfferEntryW::erase() drops its SLE, doApply() keeps
read-only handles to the same SLEs for those reads.

No behavior change.
@mvadari
mvadari force-pushed the mvadari/rearch/nftokenoffer-entry branch from 007d178 to cbf63b8 Compare November 9, 2026 22:59
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

All conflicts have been resolved. Assigned reviewers can now start or resume their review.

@ripple-ai-reviewer ripple-ai-reviewer Bot 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.

No issues found.

This branch has not been deployed

No deployments
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.

2 participants