Skip to content

refactor: Move maxMPTAmount onto MPTokenIssuanceEntry - #8375

Open
mvadari wants to merge 5 commits into
mvadari/rearch/mptokenissuance-isGlobalFrozenfrom
mvadari/rearch/mptokenissuance-maxMPTAmount
Open

mvadari wants to merge 5 commits into
mvadari/rearch/mptokenissuance-isGlobalFrozenfrom
mvadari/rearch/mptokenissuance-maxMPTAmount

Conversation

@mvadari

@mvadari mvadari commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

High Level Overview of Change

Adds the const member MPTokenIssuanceEntry::maxAmount() and uses it at every call site that already holds an issuance entry (MPTokenHelpers.cpp, TokenHelpers.cpp, MPTEndpointStep.cpp). The member body lives in the new src/libxrpl/ledger/entries/MPTokenIssuanceEntry.cpp, which explicitly instantiates MPTokenIssuanceEntry<ReadView> and MPTokenIssuanceEntry<ApplyView>.

Context of Change

Part of the Wrapped SLEs migration (design: step 2/3 of #7886). Issuance-specific logic now lives on the typed wrapper, so the compiler rejects calls with the wrong entry type. The free maxMPTAmount(SLE const&) stays and holds the implementation, because ValidMPTBalanceChanges::visitEntry (invariant) and the RPC AssetCache call it with a bare SLE and no view; the member calls it. Pure refactor: no amendment, no behavior change; any observable difference is a bug.

Stacked on #8374; review only the last commit. The commit before it is a cherry-pick of the MSVC C4661 fix from #8357 (needed because this PR adds out-of-line entry members); it drops out when #8357 merges.

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 (clang++ -fsyntax-only with project flags) the new MPTokenIssuanceEntry.cpp and all 48 .cpp files that include MPTokenIssuanceEntry.h or MPTokenHelpers.h; clang-tidy clean on the changed files; pre-commit clean. No new tests. CI runs the full unit test suite.

🤖 Generated with Claude Code

@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@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 consistent with its stated intent: it adds a const maxAmount() member to MPTokenIssuanceEntry that forwards to the existing free function maxMPTAmount(SLE const&), and swaps call sites that already hold a typed issuance entry to use the member instead. The new .cpp's **this correctly resolves to this->operator*() (returning the underlying SLE), matching the free function's signature, so there's no behavior change or recursion bug. The SLEBase.cpp macro change (definition → extern declaration) is explained in an inline comment and is a reasonable, deliberate accommodation for entries with out-of-line member bodies. No changed lines exhibit logic errors, resource issues, or security concerns; I found nothing worth flagging.

@mvadari
mvadari force-pushed the mvadari/rearch/mptokenissuance-maxMPTAmount branch from 2194e6d to dee799e Compare September 30, 2026 18:00
@mvadari
mvadari added this pull request to stack #8451 September 30, 2026 18:03
@mvadari
mvadari force-pushed the mvadari/rearch/mptokenissuance-maxMPTAmount branch 2 times, most recently from be53bb7 to 0a40c8e Compare October 5, 2026 14:49

@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 consistent with its stated goal: MPTokenIssuanceEntry::maxAmount() is added as a thin wrapper around the existing free maxMPTAmount(SLE const&), and all call sites that already hold an issuance entry are updated to use the member instead. The new .cpp correctly explicit-instantiates both ReadView/ApplyView specializations, and the **this dereference pattern matches the existing *sleIssuance/*sle usage at the old call sites, so there's no behavioral change. The SLEBase.cpp test macro rework (dropping per-entry explicit instantiation in favor of a static_assert-driven instantiation plus a new constructibility check) is well-explained by the added comment and is consistent with the stacked-PR migration context. No correctness, security, or consistency issues found in the changed (+) lines.

Add the const member MPTokenIssuanceEntry::maxAmount() and use it at
every call site that already holds an issuance entry. The member body
lives in the new src/libxrpl/ledger/entries/MPTokenIssuanceEntry.cpp,
which explicitly instantiates the read-only and writable entries.

The free maxMPTAmount(SLE const&) stays and holds the implementation:
ValidMPTBalanceChanges::visitEntry and the RPC AssetCache call it with
a bare SLE and no view, so they cannot build an entry.
@github-actions

github-actions Bot commented Nov 9, 2026

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/mptokenissuance-maxMPTAmount branch from 0a40c8e to 3340faa Compare November 10, 2026 00:03
@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.

No issues found.

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

1 participant