fix stuff

This commit is contained in:
Mayukha Vadari
2026-07-06 17:25:22 -04:00
parent 5bce58357f
commit f415a20c98
2 changed files with 10 additions and 4 deletions

View File

@@ -115,13 +115,19 @@ CredentialAccept::doApply()
}
sleCred->setFieldU32(sfFlags, lsfAccepted);
view().update(sleCred);
auto txSponsorSle = getTxReserveSponsor(ctx_.getApplyViewContext());
if (!txSponsorSle)
return tefINTERNAL; // LCOV_EXCL_LINE
// Release the original creation sponsor from the credential (it covered
// the issuer's reserve), then assign the accept tx's sponsor (if any) so
// the credential reflects whoever is now covering the subject's reserve.
decreaseOwnerCountForObject(view(), sleIssuer, sleCred, 1, j_);
removeSponsorFromLedgerEntry(sleCred);
addSponsorToLedgerEntry(sleCred, *txSponsorSle);
increaseOwnerCount(view(), sleSubject, *txSponsorSle, 1, j_);
view().update(sleCred);
return tesSUCCESS;
}

View File

@@ -2882,15 +2882,15 @@ public:
BEAST_EXPECT(ownerCount(env, bob) == 0);
BEAST_EXPECT(sponsoredOwnerCount(env, bob) == 0);
// Bob accepts: ownership and sponsorship transfer to bob
// Bob accepts: issuer's sponsorship ends, bob becomes unsponsored owner
env(credentials::accept(bob, alice, credType));
env.close();
BEAST_EXPECT(ownerCount(env, alice) == 0);
BEAST_EXPECT(sponsoredOwnerCount(env, alice) == 0);
BEAST_EXPECT(sponsoringOwnerCount(env, sponsor) == 1); // still sponsoring, but now bob
BEAST_EXPECT(sponsoringOwnerCount(env, sponsor) == 0); // original sponsorship ended
BEAST_EXPECT(ownerCount(env, bob) == 1);
BEAST_EXPECT(sponsoredOwnerCount(env, bob) == 1);
BEAST_EXPECT(sponsoredOwnerCount(env, bob) == 0); // bob owns it without a sponsor
// CredentialDelete by subject
env(credentials::deleteCred(bob, bob, alice, credType));