Skip to content

feat(stellar-wallet-snap): Display error message in ChangeTrustOpt + ConfirmSend confirmation dialog + skip destination validation in onAmountInput - #220

Merged
stanleyyconsensys merged 9 commits into
mainfrom
feat/stellar/display-txn-error
Sep 4, 2026
Merged

feat(stellar-wallet-snap): Display error message in ChangeTrustOpt + ConfirmSend confirmation dialog + skip destination validation in onAmountInput#220
stanleyyconsensys merged 9 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.

https://www.loom.com/share/2fd42303066b4c6c8950b9865e9d7355

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

@stanleyyconsensys
stanleyyconsensys marked this pull request as ready for review September 3, 2026 04:04
@stanleyyconsensys
stanleyyconsensys requested a review from a team as a code owner September 3, 2026 04:04
@stanleyyconsensys stanleyyconsensys changed the title feat(stellar-wallet-snap): add error message display feat(stellar-wallet-snap): Display error message in ChangeTrustOpt + ConfirmSend confirmation dialog + skip destination account validation in onAmountInput Sep 3, 2026
@stanleyyconsensys stanleyyconsensys changed the title feat(stellar-wallet-snap): Display error message in ChangeTrustOpt + ConfirmSend confirmation dialog + skip destination account validation in onAmountInput feat(stellar-wallet-snap): Display error message in ChangeTrustOpt + ConfirmSend confirmation dialog + skip destination validation in onAmountInput Sep 3, 2026
return 'confirmation.txnError.trustlineNotAuthorized';
}
if (error instanceof TrustlineNotFoundException) {
return error.accountAddress === senderAddress

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.

trustline not found has different message if it is becoz of sender or recipient

@stanleyyconsensys

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Sep 3, 2026

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-44f19c3d
@metamask-previews/snap-networks-utils@1.0.0-preview-44f19c3d
@metamask-previews/solana-wallet-snap@6.0.0-preview-44f19c3d
@metamask-previews/stellar-wallet-snap@0.1.0-preview-44f19c3d
@metamask-previews/tron-wallet-snap@3.2.0-preview-44f19c3d

khanti42
khanti42 previously approved these changes Sep 3, 2026

@khanti42 khanti42 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.

Thanks for PR looks good.

I tested some of the validation workflows (including trustline). Surfacing the specific error in the snap confirmation UI is a clear UX win, and the happy path still feels fine.

One open question: alert placement (wondering if should be above vs below) is there convention for this ?

Nits / non-blocking:

  • Banner title always uses confirmation.simulationErrorTitle (“This transaction is expected to fail.”) for both pre-submit and mid-dialog failures. Wording feels a bit simulation-specific for those cases, a bit less good than what we had before. But maybe this is very rare as we handle many cases so should be ok.
  • Seems that when a confirmation is already open and mid-dialog revalidation fails (confirmation refresh cron), we lost the old “Transaction is no longer valid / may have expired or balance changed” copy in favor of the more generic subtitle. Pre-submit messaging is better; just flagging the shared banner path (refresher sets FetchStatus.Error without an errorMessage).

Otherwise LGTM from my side.

@stanleyyconsensys

Copy link
Copy Markdown
Contributor Author

hi @khanti42

Thx for the review

the second open point is good point
i was thinking try to make it generic, but seem the previous message is more fit to the case, i will see if we can re-use some message, instead of create too many condition to reduce the code reabability

i will take a look

@khanti42 khanti42 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.

LGTM

@stanleyyconsensys
stanleyyconsensys added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit 6f11c61 Sep 4, 2026
54 checks passed
@stanleyyconsensys
stanleyyconsensys deleted the feat/stellar/display-txn-error branch September 4, 2026 08:15
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.

4 participants