more simplification

This commit is contained in:
Mayukha Vadari
2026-07-02 16:31:23 -04:00
parent eac1ed9c2b
commit f37a7c49f6
6 changed files with 9 additions and 15 deletions

View File

@@ -225,7 +225,7 @@ SponsorshipSet::doApply()
sponsorBalanceAfterFee -= *feeAmount;
if (auto const ret = checkInsufficientReserve(
ctx_.getApplyViewContext(),
applyViewContext,
sponsorAccSle,
sponsorBalanceAfterFee.xrp(),
{.ownerCountDelta = 1},

View File

@@ -373,9 +373,8 @@ NFTokenAcceptOffer::transferNFToken(
std::uint32_t const buyerOwnerCountBefore = sleBuyer->getFieldU32(sfOwnerCount);
auto applyViewContext = ctx_.getApplyViewContext();
auto const insertRet =
nft::insertToken(applyViewContext, buyer, std::move(tokenAndPage->token));
nft::insertToken(ctx_.getApplyViewContext(), buyer, std::move(tokenAndPage->token));
// There was an issue where the buyer accepts a sell offer, the ledger
// didn't check if the buyer has enough reserve, meaning that buyer can get

View File

@@ -305,8 +305,8 @@ NFTokenMint::doApply()
object.setFieldVL(sfURI, *uri);
});
auto applyViewContext = ctx_.getApplyViewContext();
if (TER const ret = nft::insertToken(applyViewContext, accountID_, std::move(newToken));
if (TER const ret =
nft::insertToken(ctx_.getApplyViewContext(), accountID_, std::move(newToken));
!isTesSuccess(ret))
return ret;

View File

@@ -153,6 +153,7 @@ TER
DepositPreauth::doApply()
{
auto applyViewContext = ctx_.getApplyViewContext();
auto const sponsorSle = applyViewContext.txReserveContext.sponsorSle;
if (ctx_.tx.isFieldPresent(sfAuthorize))
{
auto const sleOwner = view().peek(keylet::account(accountID_));
@@ -162,8 +163,6 @@ DepositPreauth::doApply()
// A preauth counts against the reserve of the issuing account, but we
// check the starting balance because we want to allow dipping into the
// reserve to pay fees.
auto const applyViewContext = ctx_.getApplyViewContext();
auto const sponsorSle = applyViewContext.txReserveContext.sponsorSle;
if (auto const ret = checkInsufficientReserve(
applyViewContext, sleOwner, preFeeBalance_, {.ownerCountDelta = 1}, j_);
!isTesSuccess(ret))
@@ -210,8 +209,6 @@ DepositPreauth::doApply()
// A preauth counts against the reserve of the issuing account, but we
// check the starting balance because we want to allow dipping into the
// reserve to pay fees.
auto const applyViewContext = ctx_.getApplyViewContext();
auto const sponsorSle = applyViewContext.txReserveContext.sponsorSle;
if (auto const ret = checkInsufficientReserve(
applyViewContext, sleOwner, preFeeBalance_, {.ownerCountDelta = 1}, j_);
!isTesSuccess(ret))

View File

@@ -146,7 +146,7 @@ PaymentChannelCreate::doApply()
// unsponsored this hits the source branch and validates the
// source's pre-lock balance against base + (currentOC+1)*increment.
if (auto const ret = checkInsufficientReserve(
ctx_.getApplyViewContext(), sle, preFeeBalance_, {.ownerCountDelta = 1}, j_);
applyViewContext, sle, preFeeBalance_, {.ownerCountDelta = 1}, j_);
!isTesSuccess(ret))
return ret;
@@ -158,12 +158,11 @@ PaymentChannelCreate::doApply()
// - sponsored: adj=0 — sponsor covers the new owner increment,
// so the source only owes its base reserve.
// - unsponsored: adj=1 — source owes base + the new increment.
std::int32_t const ownerCountAdj = sponsorSle ? 0 : 1;
if (auto const ret = checkInsufficientReserve(
ctx_.getApplyViewContext(),
sle,
preFeeBalance_ - ctx_.tx[sfAmount].xrp(),
{.ownerCountDelta = ownerCountAdj},
{.ownerCountDelta = sponsorSle ? 0 : 1},
j_);
!isTesSuccess(ret))
return tecUNFUNDED;

View File

@@ -90,13 +90,12 @@ PaymentChannelFund::doApply()
// Check reserve and funds availability
auto const balance = (*sle)[sfBalance];
auto const applyViewContext = ctx_.getApplyViewContext();
if (auto const ret =
checkInsufficientReserve(ctx_.getApplyViewContext(), sle, balance, {}, j_);
if (auto const ret = checkInsufficientReserve(applyViewContext, sle, balance, {}, j_);
!isTesSuccess(ret))
return ret;
if (auto const ret = checkInsufficientReserve(
ctx_.getApplyViewContext(), sle, balance - ctx_.tx[sfAmount], {}, j_);
applyViewContext, sle, balance - ctx_.tx[sfAmount], {}, j_);
!isTesSuccess(ret))
return tecUNFUNDED;
}