Skip to content

feat(stellar-wallet-snap): add error message display - #220

Draft
stanleyyconsensys wants to merge 4 commits into
mainfrom
feat/stellar/display-txn-error
Draft

feat(stellar-wallet-snap): add error message display#220
stanleyyconsensys wants to merge 4 commits into
mainfrom
feat/stellar/display-txn-error

Conversation

@stanleyyconsensys

@stanleyyconsensys stanleyyconsensys commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Explanation

Adds localized, user-visible error messaging to Stellar wallet confirmation dialogs by surfacing pre-submit transaction validation failures (send + change-trust) directly in the UI, and aligning client-request behavior/docs/tests around that flow.

Changes:

  • Pass an optional localized errorMessage key through confirmation views and render it in the validation banner.
  • Introduce a centralized mapping from TransactionValidationException subclasses to confirmation.txnError.* locale keys, and use it to show pre-submit failures in confirmation dialogs.
  • Update onAmountInput preflight to always validate as a self-transfer so destination-specific validation errors are deferred to confirmSend.

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

@stanleyyconsensys

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/bitcoin-wallet-snap@2.0.1-preview-acf90d5
@metamask-previews/snap-networks-utils@1.0.0-preview-acf90d5
@metamask-previews/solana-wallet-snap@6.0.0-preview-acf90d5
@metamask-previews/stellar-wallet-snap@0.1.0-preview-acf90d5
@metamask-previews/tron-wallet-snap@3.1.0-preview-acf90d5

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds localized, user-visible error messaging to Stellar wallet confirmation dialogs by surfacing pre-submit transaction validation failures (send + change-trust) directly in the UI, and aligning client-request behavior/docs/tests around that flow.

Changes:

  • Pass an optional localized errorMessage key through confirmation views and render it in the validation banner.
  • Introduce a centralized mapping from TransactionValidationException subclasses to confirmation.txnError.* locale keys, and use it to show pre-submit failures in confirmation dialogs.
  • Update onAmountInput preflight to always validate as a self-transfer so destination-specific validation errors are deferred to confirmSend.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignChangeTrustOptOut/ConfirmSignChangeTrustOptOut.tsx Thread errorMessage into alerts and avoid rendering fee row when fee data is empty.
packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSignChangeTrustOptIn/ConfirmSignChangeTrustOptIn.tsx Same as opt-out: plumb errorMessage and guard fee row rendering.
packages/stellar-wallet-snap/src/ui/confirmation/views/ConfirmSendTransaction/ConfirmSendTransaction.tsx Plumb errorMessage and guard fee row rendering for error-only confirmations.
packages/stellar-wallet-snap/src/ui/confirmation/components/TransactionValidationAlert.tsx Render banner subtitle from a localized error key with a generic fallback.
packages/stellar-wallet-snap/src/ui/confirmation/components/ConfirmationAlerts.tsx Accept/forward errorMessage into the validation banner.
packages/stellar-wallet-snap/src/ui/confirmation/components/ConfirmationAlerts.test.tsx Update banner copy expectations and add coverage for custom validation copy.
packages/stellar-wallet-snap/src/ui/confirmation/api.ts Add errorMessage?: LocalizedMessage to shared confirmation props.
packages/stellar-wallet-snap/src/handlers/clientRequest/utils.ts Add getTxnErrorMessageKey mapping validation exceptions to locale keys.
packages/stellar-wallet-snap/src/handlers/clientRequest/utils.test.ts Unit test the exception → locale-key mapping logic.
packages/stellar-wallet-snap/src/handlers/clientRequest/onAmountInput.ts Ignore to for preflight; validate amount against sender self-transfer only.
packages/stellar-wallet-snap/src/handlers/clientRequest/onAmountInput.test.ts Update expectation that destination is always the sender account.
packages/stellar-wallet-snap/src/handlers/clientRequest/confirmSend.ts Show an error-only confirmation dialog on pre-submit validation failures before returning structured error codes.
packages/stellar-wallet-snap/src/handlers/clientRequest/confirmSend.test.ts Expand tests for pre-submit validation dialog + error-code outcomes; update activation behavior assertions.
packages/stellar-wallet-snap/src/handlers/clientRequest/changeTrustOpt.ts Show an error-only confirmation dialog for pre-submit validation failures and rethrow the error.
packages/stellar-wallet-snap/src/handlers/clientRequest/changeTrustOpt.test.ts Add coverage for error-dialog rendering on opt-in/opt-out validation failures.
packages/stellar-wallet-snap/snap.manifest.json Update bundle shasum to reflect the new build output.
packages/stellar-wallet-snap/messages.json Add new confirmation.txnError.* message keys (default catalog).
packages/stellar-wallet-snap/locales/es.json Add Spanish-locale entries for the new confirmation.txnError.* keys.
packages/stellar-wallet-snap/locales/en.json Add English-locale entries for the new confirmation.txnError.* keys.
packages/stellar-wallet-snap/docs/use-cases/client-request/onAmountInput.md Document that to is ignored and preflight always validates self-transfer.
packages/stellar-wallet-snap/docs/use-cases/client-request/confirmSend.md Document the new pre-submit validation dialog behavior and updated activation behavior.
packages/stellar-wallet-snap/docs/use-cases/client-request/changeTrustOpt.md Document the new pre-submit validation dialog behavior for change-trust.
packages/stellar-wallet-snap/CHANGELOG.md Add Unreleased “Changed” entries describing the new confirmation error display and onAmountInput behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/stellar-wallet-snap/CHANGELOG.md Outdated
Comment on lines 132 to +136
const assetMetadata = await this.#assetMetadataService.resolve(assetId);

const transaction = await this.#createTransaction({
request,
onChainAccount,
limit: limitForTx,
});
let transaction: Transaction;
try {
// Quit early if the opt-in is already redundant (throws for a missing opt-out trustline).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think resolve asset first instead of preflight validation run first is fine

@stanleyyconsensys

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/bitcoin-wallet-snap@2.0.1-preview-8ff90d2f
@metamask-previews/snap-networks-utils@1.0.0-preview-8ff90d2f
@metamask-previews/solana-wallet-snap@6.0.0-preview-8ff90d2f
@metamask-previews/stellar-wallet-snap@0.1.0-preview-8ff90d2f
@metamask-previews/tron-wallet-snap@3.1.0-preview-8ff90d2f

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.

2 participants