feat(stellar-wallet-snap): add error message display - #220
feat(stellar-wallet-snap): add error message display#220stanleyyconsensys wants to merge 4 commits into
Conversation
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
There was a problem hiding this comment.
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
errorMessagekey through confirmation views and render it in the validation banner. - Introduce a centralized mapping from
TransactionValidationExceptionsubclasses toconfirmation.txnError.*locale keys, and use it to show pre-submit failures in confirmation dialogs. - Update
onAmountInputpreflight to always validate as a self-transfer so destination-specific validation errors are deferred toconfirmSend.
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.
| 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). |
There was a problem hiding this comment.
i think resolve asset first instead of preflight validation run first is fine
|
@metamaskbot publish-preview |
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
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:
errorMessagekey through confirmation views and render it in the validation banner.TransactionValidationExceptionsubclasses toconfirmation.txnError.*locale keys, and use it to show pre-submit failures in confirmation dialogs.onAmountInputpreflight to always validate as a self-transfer so destination-specific validation errors are deferred toconfirmSend.References
Checklist