Description
The SDK's sponsorship feature (via src/sponsorship.ts) builds BeginSponsoringFutureReserves / EndSponsoringFutureReserves operation pairs but does not verify in advance that the sponsoring account has sufficient XLM reserve to cover the new ledger entries it will sponsor. This causes submission failures that are cryptic to callers. A pre-submission reserve verifier should calculate the required reserve increase and check the sponsor's available balance.
Technical Context
Extend src/sponsorship.ts and src/preflightChecker.ts. Uses @stellar/stellar-sdk Server.loadAccount() to read subentry_count and num_sponsored, and the Stellar network's BASE_RESERVE constant. Reference SponsorshipConfig from src/types.ts. Add InsufficientSponsorReserveError to src/errors.ts. Expose the check as a method callable before the sponsorship transaction is built in src/txBuilder.ts.
Acceptance Criteria
Description
The SDK's sponsorship feature (via
src/sponsorship.ts) buildsBeginSponsoringFutureReserves/EndSponsoringFutureReservesoperation pairs but does not verify in advance that the sponsoring account has sufficient XLM reserve to cover the new ledger entries it will sponsor. This causes submission failures that are cryptic to callers. A pre-submission reserve verifier should calculate the required reserve increase and check the sponsor's available balance.Technical Context
Extend
src/sponsorship.tsandsrc/preflightChecker.ts. Uses@stellar/stellar-sdkServer.loadAccount()to readsubentry_countandnum_sponsored, and the Stellar network'sBASE_RESERVEconstant. ReferenceSponsorshipConfigfromsrc/types.ts. AddInsufficientSponsorReserveErrortosrc/errors.ts. Expose the check as a method callable before the sponsorship transaction is built insrc/txBuilder.ts.Acceptance Criteria
verifySponsorReserve(sponsorId: string, newEntries: number): Promise<ReserveCheckResult>calculates required XLM and compares with available balance{ sufficient: boolean, required: string, available: string, shortfall?: string }typed insrc/types.tsInsufficientSponsorReserveErrorwith the shortfall amount when the check fails andthrowOnInsufficient: truesrc/sponsorship.tscallsverifySponsorReserve()before building the sponsorship operation pairloadAccount()responses and assert correct reserve arithmetic for 0, 1, and 10 new entries