change Sponsor related fields to soeDEFAULT

This commit is contained in:
tequ
2026-01-07 12:31:01 +09:00
parent 2813fea294
commit cf03c4cb8f
5 changed files with 37 additions and 13 deletions

View File

@@ -150,9 +150,9 @@ LEDGER_ENTRY(ltACCOUNT_ROOT, 0x0061, AccountRoot, account, ({
{sfAMMID, soeOPTIONAL}, // pseudo-account designator
{sfVaultID, soeOPTIONAL}, // pseudo-account designator
{sfLoanBrokerID, soeOPTIONAL}, // pseudo-account designator
{sfSponsoredOwnerCount, soeOPTIONAL},
{sfSponsoringOwnerCount, soeOPTIONAL},
{sfSponsoringAccountCount,soeOPTIONAL},
{sfSponsoredOwnerCount, soeDEFAULT},
{sfSponsoringOwnerCount, soeDEFAULT},
{sfSponsoringAccountCount,soeDEFAULT},
}))
/** A ledger object which contains a list of object identifiers.
@@ -616,9 +616,9 @@ LEDGER_ENTRY(ltSPONSORSHIP, 0x0090, Sponsorship, sponsorship, ({
{sfPreviousTxnLgrSeq, soeREQUIRED},
{sfOwner, soeREQUIRED},
{sfSponsee, soeREQUIRED},
{sfFeeAmount, soeOPTIONAL},
{sfFeeAmount, soeDEFAULT},
{sfMaxFee, soeOPTIONAL},
{sfReserveCount, soeOPTIONAL},
{sfReserveCount, soeDEFAULT},
{sfOwnerNode, soeREQUIRED},
{sfSponseeNode, soeREQUIRED},
}))

View File

@@ -1387,7 +1387,10 @@ adjustOwnerCount(
currentReserveCount >= amount,
"xrpl::adjustOwnerCount : enough reserve count");
sle->setFieldU32(sfReserveCount, currentReserveCount - amount);
if (currentReserveCount - amount > 0)
sle->setFieldU32(sfReserveCount, currentReserveCount - amount);
else
sle->makeFieldAbsent(sfReserveCount);
view.update(sle);
}
}

View File

@@ -990,7 +990,7 @@ public:
auto sponsorFee = sponsorFeeBalance(sponsor, alice);
env(pay(alice, bob, XRP(100)),
fee(XRP(100) + drops(1)),
fee(XRP(90) + drops(1)),
sponsor::as(sponsor, tfSponsorFee),
ter(terINSUF_FEE_B));
env.close();
@@ -1001,6 +1001,25 @@ public:
BEAST_EXPECT(
sponsorFeeBalance(sponsor, alice) == sponsorFee);
}
// use all FeeAmount
{
// = FeeAmount
auto aliceBalance = env.balance(alice);
auto bobBalance = env.balance(bob);
auto sponsorBalance = env.balance(sponsor);
env(pay(alice, bob, XRP(100)),
fee(XRP(90)),
sponsor::as(sponsor, tfSponsorFee),
ter(tesSUCCESS));
env.close();
BEAST_EXPECT(env.balance(alice) == aliceBalance - XRP(100));
BEAST_EXPECT(env.balance(bob) == bobBalance + XRP(100));
BEAST_EXPECT(env.balance(sponsor) == sponsorBalance);
BEAST_EXPECT(!env.le(keylet::sponsor(sponsor, alice))
->isFieldPresent(sfFeeAmount));
}
// reset FeeAmount and MaxFee
env(sponsor::del(sponsor), sponsor::sponseeAcc(alice));

View File

@@ -271,13 +271,9 @@ SponsorshipSet::doApply()
(*newSle)[sfFeeAmount] = *feeAmount;
}
if (maxFee)
{
(*newSle)[sfMaxFee] = *maxFee;
}
if (reserveCount)
{
(*newSle)[sfReserveCount] = *reserveCount;
}
auto flags = 0;
if (ctx_.tx.isFlag(tfSponsorshipSetRequireSignForFee))

View File

@@ -501,8 +501,14 @@ Transactor::payFee()
if (!sle)
return tefINTERNAL; // LCOV_EXCL_LINE
sle->setFieldAmount(
result.field, sle->getFieldAmount(result.field) - feePaid);
auto const feeAmountAfter = sle->getFieldAmount(result.field) - feePaid;
if (feeAmountAfter == beast::zero &&
result.field.fieldMeta == SField::sMD_Default)
// for ltSponsorship.sfFeeAmount
sle->makeFieldAbsent(result.field);
else
sle->setFieldAmount(result.field, feeAmountAfter);
view().update(sle);