migrate createMPToken, reduce diff

This commit is contained in:
Mayukha Vadari
2026-07-02 16:06:49 -04:00
parent c83e556d1f
commit b42a9be370
22 changed files with 78 additions and 77 deletions

View File

@@ -125,8 +125,7 @@ ownerCount(SLE::const_ref sle, beast::Journal j, std::int32_t ownerCountAdj = 0)
* and the sponsor's sponsoring count.
*
* @param view The apply view for making changes
* @param accountSle The account's ledger entry
* @param sponsorSle The sponsor's ledger entry (if applicable)
* @param reserveCtx The account and sponsor information
* @param count Amount to add to the owner count
* @param j Journal for logging
*/
@@ -145,8 +144,7 @@ increaseOwnerCount(
* sfSponsor field.
*
* @param view The apply view for making changes
* @param accountSle The account's ledger entry
* @param sponsorSle The sponsor's ledger entry (if applicable)
* @param reserveCtx The account and sponsor information
* @param count Amount to remove from the owner count
* @param j Journal for logging
*/
@@ -157,19 +155,23 @@ decreaseOwnerCount(
std::uint32_t count,
beast::Journal j);
/** Decrease the owner counters of the account. If the object has a sponsor,
* adjust its counters too. Used primarily just before deleting the object.
/** Decrease owner-count fields for an existing ledger object.
*
* This helper derives the reserve sponsor from objectSle's sfSponsor field,
* then updates the same owner-count fields as decreaseOwnerCount. Use this
* when removing an existing object whose reserve sponsor is stored on that
* object.
*
* @param view The apply view for making changes
* @param ownerSle The account's ledger entry
* @param accountSle The account's ledger entry
* @param objectSle The object's ledger entry
* @param count Positive amount to remove from the owner count
* @param j Journal for logging (default: null sink)
* @param count Amount to remove from the owner count
* @param j Journal for logging
*/
void
decreaseOwnerCountForObject(
ApplyView& view,
SLE::pointer ownerSle,
SLE::ref accountSle,
SLE::ref objectSle,
std::uint32_t count,
beast::Journal j);

View File

@@ -196,24 +196,21 @@ escrowUnlockApplyHelper<MPTIssue>(
auto const mptKeylet = keylet::mptoken(issuanceKey.key, receiver);
if (!ctx.view.exists(mptKeylet) && createAsset && !receiverIssuer)
{
auto const sponsorSle = ctx.txReserveContext.sponsorSle;
if (auto const ret =
checkInsufficientReserve(ctx, sleDest, xrpBalance, {.ownerCountDelta = 1}, journal);
!isTesSuccess(ret))
return ret;
if (auto const ter = createMPToken(ctx.view, mptID, receiver, sponsorSle, 0);
!isTesSuccess(ter))
auto const reserveCtx =
ReserveContext::makeFromAccount(ctx.view, sleDest, ctx.txReserveContext.sponsorSle);
if (auto const ter = createMPToken(ctx.view, mptID, reserveCtx, 0); !isTesSuccess(ter))
{
return ter; // LCOV_EXCL_LINE
}
// update owner count.
increaseOwnerCount(
ctx.view, ReserveContext::makeFromAccount(ctx.view, sleDest, sponsorSle), 1, journal);
auto mptSle = ctx.view.peek(mptKeylet);
addSponsorToLedgerEntry(mptSle, sponsorSle);
increaseOwnerCount(ctx.view, reserveCtx, 1, journal);
}
if (!ctx.view.exists(mptKeylet) && !receiverIssuer)

View File

@@ -242,8 +242,7 @@ TER
createMPToken(
ApplyView& view,
MPTID const& mptIssuanceID,
AccountID const& account,
SLE::ref sponsorSle,
ReserveContext const& reserveCtx,
std::uint32_t const flags);
TER