Skip to content

feat: Accept MPT issuance IDs in book_offers (MPTokensV2) - #3127

Open
kuznetsss wants to merge 8 commits into
XRPLF:developfrom
kuznetsss:Book_offers_accept_MPT_issuance_id
Open

feat: Accept MPT issuance IDs in book_offers (MPTokensV2)#3127
kuznetsss wants to merge 8 commits into
XRPLF:developfrom
kuznetsss:Book_offers_accept_MPT_issuance_id

Conversation

@kuznetsss

@kuznetsss kuznetsss commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Adds MPTokensV2 support to book_offers: taker_gets/taker_pays may now specify an asset via mpt_issuance_id (mutually exclusive with currency/issuer). Clio builds the MPT order book and returns correctly-funded offers, mirroring rippled's doBookOffers validation and getBookPage funding.

(The MPT book keylet needs no change — getBookBase is already MPT-aware in libxrpl 3.2.0; Clio just builds the Book from Assets.)

Changes

  • BookOffers handler: Input carries xrpl::Asset; spec() accepts/validates mpt_issuance_id; tag_invoke parses it into an Asset.
  • New shared CustomValidators::bookTakerValidator enforces the currency-vs-mpt_issuance_id exclusivity with rippled-matching errors.
  • New parseBook(Asset, Asset, domain) overload (the currency/issuer overload now delegates to it); error messages aligned with rippled.
  • postProcessOrderBook funds MPT offers from the holder's MPToken balance (accountHoldsMPT) and uses STAmount::asset().

Known difference: an MPT issuer's own offers are treated as fully funded, matching the mirrored getBookPage. rippled's separate issuerFundsToSelfIssue fix (bounding by remaining issuance) is noted in a comment to port later.

Tests: validation + MPT funding cases in BookOffersTests, full branch coverage for bookTakerValidator in BaseTests, and direct parseBook tests in RPCHelpersTests.

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.63866% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.70%. Comparing base (d7cd049) to head (93855ed).
⚠️ Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
src/rpc/RPCHelpers.cpp 97.22% 1 Missing and 1 partial ⚠️
src/rpc/handlers/BookOffers.hpp 75.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3127      +/-   ##
===========================================
+ Coverage    82.61%   82.70%   +0.09%     
===========================================
  Files          397      397              
  Lines        16034    16107      +73     
  Branches      8399     8438      +39     
===========================================
+ Hits         13247    13322      +75     
+ Misses        1667     1666       -1     
+ Partials      1120     1119       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kuznetsss
kuznetsss force-pushed the Book_offers_accept_MPT_issuance_id branch 2 times, most recently from 540818d to db78c45 Compare July 1, 2026 14:58
@kuznetsss
kuznetsss force-pushed the Book_offers_accept_MPT_issuance_id branch from db78c45 to 93855ed Compare July 1, 2026 15:06
@mathbunnyru
mathbunnyru requested a review from Copilot July 1, 2026 16:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds MPTokensV2 support to the book_offers RPC by allowing taker_gets / taker_pays to specify an xrpl::Asset via mpt_issuance_id (mutually exclusive with currency/issuer), and updates order-book funding logic to correctly fund MPT offers using MPToken balances.

Changes:

  • Extend BookOffers request parsing/validation to accept MPT issuance IDs and build books from xrpl::Asset.
  • Add a shared CustomValidators::bookTakerValidator enforcing currency vs mpt_issuance_id exclusivity with rippled-aligned errors.
  • Add MPT-aware funding in postProcessOrderBook via accountHoldsMPT and STAmount::asset(), plus new/updated unit tests.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/unit/rpc/RPCHelpersTests.cpp Adds parseBook(Asset, Asset, domain) tests and comprehensive accountHoldsMPT unit coverage.
tests/unit/rpc/handlers/BookOffersTests.cpp Updates parameter-validation expectations and adds standalone MPT book_offers + funding tests.
tests/unit/rpc/handlers/AllHandlerTests.cpp Updates BookOffersHandler::Input construction to use Asset/Issue.
tests/unit/rpc/BaseTests.cpp Adds focused branch coverage for bookTakerValidator.
src/rpc/RPCHelpers.hpp Declares accountHoldsMPT and the new parseBook(Asset, Asset, domain) overload.
src/rpc/RPCHelpers.cpp Implements accountHoldsMPT, updates order-book funding to support MPT, and refactors parseBook to asset-based parsing with rippled-aligned errors.
src/rpc/handlers/BookOffers.hpp Updates handler input/spec to accept mpt_issuance_id and validate via bookTakerValidator.
src/rpc/handlers/BookOffers.cpp Parses taker_gets/taker_pays into xrpl::Asset (Issue or MPTIssue) and uses the new parseBook overload.
src/rpc/common/Validators.hpp Declares CustomValidators::bookTakerValidator.
src/rpc/common/Validators.cpp Implements bookTakerValidator with rippled-matching error behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +840 to +843
xrpl::MPTID mptId;
[[maybe_unused]] auto const parsed =
mptId.parseHex("000004C463C52827307480341125DA0577DEFC38405DBADD");
return xrpl::MPTIssue{mptId};
Comment thread tests/unit/rpc/handlers/BookOffersTests.cpp
Comment thread tests/unit/rpc/handlers/BookOffersTests.cpp
Comment thread tests/unit/rpc/handlers/BookOffersTests.cpp

@godexsoft godexsoft left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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.

4 participants