Skip to content

feat: add structured balance errors for Stellar fee computation - #9659

Draft
Julink-eth wants to merge 3 commits into
mainfrom
feat/nonEvmBalanceError-new-struct
Draft

feat: add structured balance errors for Stellar fee computation#9659
Julink-eth wants to merge 3 commits into
mainfrom
feat/nonEvmBalanceError-new-struct

Conversation

@Julink-eth

@Julink-eth Julink-eth commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Explanation

Expose structured balance errors when Stellar fee computation fails due to insufficient funds.

  • Add and export the NonEvmBalanceError type.
  • Validate balance errors returned directly or through a nested Snap error.
  • Attach valid errors to quote metadata as nonEvmBalanceError.
  • Preserve existing behavior for non-balance and non-Stellar errors.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Additive, Stellar-only error handling on the non-EVM fee catch path; success paths and other chains are unchanged.

Overview
When Stellar non-EVM fee computation via the wallet snap fails for insufficient funds, clients can now show specific balance messaging instead of a generic missing-fee state.

The PR introduces and exports NonEvmBalanceError (codes InsufficientBalance / InsufficientBalanceToCoverFee, asset id, available/required amounts, optional reserveAmount for on-chain minimums). That payload is attached on quotes as nonEvmBalanceError on NonEvmFees and QuoteMetadata.

In appendNonEvmFees, only Stellar source quotes parse snap rejections: validators read structured data from error.data or nested error.data.cause.data, ignore malformed payloads, and otherwise keep the existing log-and-undefined-fee behavior for other chains and non-balance failures. Unit tests cover happy paths and validation edge cases.

Reviewed by Cursor Bugbot for commit f04571c. Bugbot is set up for automated code reviews on this repo. Configure here.

@Julink-eth
Julink-eth requested review from a team as code owners July 27, 2026 08:46
@Julink-eth
Julink-eth marked this pull request as draft July 27, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant