From 097e25620b7a3e0e937063252f175fc4b7aabacf Mon Sep 17 00:00:00 2001 From: Shawn Xie Date: Wed, 23 Oct 2024 10:09:20 -0400 Subject: [PATCH] address comments --- src/xrpld/app/tx/detail/MPTokenAuthorize.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/xrpld/app/tx/detail/MPTokenAuthorize.cpp b/src/xrpld/app/tx/detail/MPTokenAuthorize.cpp index 0ad9252cb6d..b63d111a207 100644 --- a/src/xrpld/app/tx/detail/MPTokenAuthorize.cpp +++ b/src/xrpld/app/tx/detail/MPTokenAuthorize.cpp @@ -49,9 +49,6 @@ MPTokenAuthorize::preclaim(PreclaimContext const& ctx) auto const accountID = ctx.tx[sfAccount]; auto const holderID = ctx.tx[~sfMPTokenHolder]; - if (holderID && !(ctx.view.exists(keylet::account(*holderID)))) - return tecNO_DST; - // if non-issuer account submits this tx, then they are trying either: // 1. Unauthorize/delete MPToken // 2. Use/create MPToken @@ -106,6 +103,9 @@ MPTokenAuthorize::preclaim(PreclaimContext const& ctx) return tesSUCCESS; } + if (!ctx.view.exists(keylet::account(*holderID))) + return tecNO_DST; + auto const sleMptIssuance = ctx.view.read(keylet::mptIssuance(ctx.tx[sfMPTokenIssuanceID])); if (!sleMptIssuance) @@ -178,6 +178,12 @@ MPTokenAuthorize::authorize( // A potential holder wants to authorize/hold a mpt, the ledger must: // - add the new mptokenKey to the owner directory // - create the MPToken object for the holder + + // The reserve that is required to create the MPToken. Note + // that although the reserve increases with every item + // an account owns, in the case of MPTokens we only + // *enforce* a reserve if the user owns more than two + // items. This is similar to the reserve requirements of trust lines. std::uint32_t const uOwnerCount = sleAcct->getFieldU32(sfOwnerCount); XRPAmount const reserveCreate( (uOwnerCount < 2) ? XRPAmount(beast::zero)