Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sponsorship error type and user_pays fallback
Summary
Adds SDK error when sponsored (gasless) execution is unavailable and optional automatic fallback to user-paid fees. AVNU and Cartridge errors are normalized to a single contract so apps can show consistent UX.
New public API
SponsorshipNotAvailableError– Error withreason,provider("avnu"|"cartridge"|"unknown"),fallbackFeeRequired: true,rawErrorpolicy_rejected,policy_exceeded,unsupported_asset,invalid_paymaster_config,network_unavailable,account_not_ready,unknownSponsorshipNotAvailableError.isSponsorshipError(e),toFriendlyMessage(),getSponsorshipFriendlyMessage(reason),SPONSORSHIP_REASONS,SPONSORSHIP_REASON_MESSAGESstarkzap/sponsorshipfor a focused importExecuteOptions
fallbackTo?: "user_pays"– On sponsorship failure, retry with user-paid feesonFallback?: (error: SponsorshipNotAvailableError) => void– Called before retry (e.g. toast)Behavior
fallbackTo === "user_pays", ensure account is deployed, callonFallback, then retry withuser_pays. Non-sponsorship errors are rethrown unchangedSponsorshipNotAvailableErrorwithreason: "account_not_ready"Internal
src/wallet/sponsorship-errors.ts–normalizeAvnuSponsorshipError()andnormalizeCartridgeSponsorshipError()(config/auth →invalid_paymaster_config, quota →policy_exceeded, etc.)Files changed
src/types/sponsorship-error.ts(new)src/types/wallet.ts(ExecuteOptions + type import)src/types/index.ts(export)src/wallet/sponsorship-errors.ts(new)src/wallet/index.ts(fallback +runSponsoredExecution)src/wallet/cartridge.ts(fallback)src/sponsorship.ts(new)package.json(exports./sponsorship)Breaking changes
None. Additive only.