Fix build error: use bo->key() instead of getIndex() and resolve clang-format issues

Co-authored-by: mvadari <8029314+mvadari@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-08-21 01:05:57 +00:00
committed by Mayukha Vadari
parent 76a1831c6d
commit 0493180658

View File

@@ -74,13 +74,15 @@ NFTokenAcceptOffer::preclaim(PreclaimContext const& ctx)
if (hasExpired(ctx.view, (*offerSLE)[~sfExpiration]))
{
// Before fixExpiredNFTokenOfferRemoval amendment, expired offers
// caused tecEXPIRED in preclaim, leaving them on ledger forever.
// After the amendment, we allow expired offers to reach doApply()
// where they get deleted and tecEXPIRED is returned.
// Before fixExpiredNFTokenOfferRemoval amendment, expired
// offers caused tecEXPIRED in preclaim, leaving them on ledger
// forever. After the amendment, we allow expired offers to
// reach doApply() where they get deleted and tecEXPIRED is
// returned.
if (!ctx.view.rules().enabled(fixExpiredNFTokenOfferRemoval))
return {nullptr, tecEXPIRED};
// Amendment enabled: return the expired offer to be handled in doApply
// Amendment enabled: return the expired offer to be handled in
// doApply
}
// The initial implementation had a bug that allowed a negative
@@ -529,16 +531,16 @@ NFTokenAcceptOffer::doApply()
auto bo = loadToken(ctx_.tx[~sfNFTokenBuyOffer]);
auto so = loadToken(ctx_.tx[~sfNFTokenSellOffer]);
// With fixExpiredNFTokenOfferRemoval amendment, check for expired offers
// and delete them, returning tecEXPIRED. This ensures expired offers
// With fixExpiredNFTokenOfferRemoval amendment, check for expired offers
// and delete them, returning tecEXPIRED. This ensures expired offers
// are properly cleaned up from the ledger.
if (view().rules().enabled(fixExpiredNFTokenOfferRemoval))
{
bool foundExpired = false;
if (bo && hasExpired(view(), (*bo)[~sfExpiration]))
{
JLOG(j_.trace()) << "Buy offer is expired, deleting: " << bo->getIndex();
JLOG(j_.trace()) << "Buy offer is expired, deleting: " << bo->key();
if (!nft::deleteTokenOffer(view(), bo))
{
JLOG(j_.fatal()) << "Unable to delete expired buy offer '"
@@ -546,12 +548,13 @@ NFTokenAcceptOffer::doApply()
return tecINTERNAL;
}
foundExpired = true;
bo.reset(); // Clear the pointer since offer is deleted
bo.reset(); // Clear the pointer since offer is deleted
}
if (so && hasExpired(view(), (*so)[~sfExpiration]))
{
JLOG(j_.trace()) << "Sell offer is expired, deleting: " << so->getIndex();
JLOG(j_.trace())
<< "Sell offer is expired, deleting: " << so->key();
if (!nft::deleteTokenOffer(view(), so))
{
JLOG(j_.fatal()) << "Unable to delete expired sell offer '"
@@ -559,9 +562,9 @@ NFTokenAcceptOffer::doApply()
return tecINTERNAL;
}
foundExpired = true;
so.reset(); // Clear the pointer since offer is deleted
so.reset(); // Clear the pointer since offer is deleted
}
if (foundExpired)
return tecEXPIRED;
}