feat: Accept MPT issuance IDs in book_offers (MPTokensV2) - #3127
feat: Accept MPT issuance IDs in book_offers (MPTokensV2)#3127kuznetsss wants to merge 8 commits into
Conversation
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
540818d to
db78c45
Compare
db78c45 to
93855ed
Compare
There was a problem hiding this comment.
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
BookOffersrequest parsing/validation to accept MPT issuance IDs and build books fromxrpl::Asset. - Add a shared
CustomValidators::bookTakerValidatorenforcingcurrencyvsmpt_issuance_idexclusivity with rippled-aligned errors. - Add MPT-aware funding in
postProcessOrderBookviaaccountHoldsMPTandSTAmount::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.
| xrpl::MPTID mptId; | ||
| [[maybe_unused]] auto const parsed = | ||
| mptId.parseHex("000004C463C52827307480341125DA0577DEFC38405DBADD"); | ||
| return xrpl::MPTIssue{mptId}; |
Adds MPTokensV2 support to
book_offers:taker_gets/taker_paysmay now specify an asset viampt_issuance_id(mutually exclusive withcurrency/issuer). Clio builds the MPT order book and returns correctly-funded offers, mirroring rippled'sdoBookOffersvalidation andgetBookPagefunding.(The MPT book keylet needs no change —
getBookBaseis already MPT-aware inlibxrpl3.2.0; Clio just builds theBookfromAssets.)Changes
BookOffershandler:Inputcarriesxrpl::Asset;spec()accepts/validatesmpt_issuance_id;tag_invokeparses it into anAsset.CustomValidators::bookTakerValidatorenforces the currency-vs-mpt_issuance_idexclusivity with rippled-matching errors.parseBook(Asset, Asset, domain)overload (the currency/issuer overload now delegates to it); error messages aligned with rippled.postProcessOrderBookfunds MPT offers from the holder'sMPTokenbalance (accountHoldsMPT) and usesSTAmount::asset().Known difference: an MPT issuer's own offers are treated as fully funded, matching the mirrored
getBookPage. rippled's separateissuerFundsToSelfIssuefix (bounding by remaining issuance) is noted in a comment to port later.Tests: validation + MPT funding cases in
BookOffersTests, full branch coverage forbookTakerValidatorinBaseTests, and directparseBooktests inRPCHelpersTests.