Repository navigation
fix: use toast to handle the failure message when a non-evm transaction return error after user confirm - #47528
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
✨ Files requiring CODEOWNER review ✨✅ @MetaMask/confirmations (2 files, +123 -4)
|
useSendActionsThere was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change restoring failure feedback for non-EVM sends after leaving the send screen.
No open issues 🎉
What changed in this PR
This PR restores failure feedback for non-EVM sends when the confirmation flow moves the user away from the send screen.
Changes:
- Shows a generic error toast when a send fails after leaving the send screen, while preserving inline errors on the send screen.
- Keeps user rejections silent and preserves existing back navigation.
- Adds tests for validation failures, thrown errors, and user rejections after leaving the send screen.
| File | Description |
|---|---|
ui/pages/confirmations/hooks/send/useSendActions.ts |
Selects inline errors or toast notifications based on the current route. |
ui/pages/confirmations/hooks/send/useSendActions.test.ts |
Adds toast mocks and tests for off-screen failures and silent rejection handling. |
Review effort: Balanced
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e79d15b. Configure here.
| // Show generic error message rather than error message from error code mapping | ||
| toast.error(genericErrorMessage); | ||
| } | ||
|
|
There was a problem hiding this comment.
Toast hidden after send return
Medium Severity
After a post-confirm non-EVM failure, the new path calls toast.error and then navigate(PREVIOUS_ROUTE). The loader only replaces /send/loader, so -1 typically returns to the send form. That form uses useHideToasts and this branch never sets updateNonEVMSubmitError, so the failure can still never appear.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit e79d15b. Configure here.
There was a problem hiding this comment.
no, -1 will redirect to home from this case
Builds ready [e79d15b]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 2 warn · 🔴 4 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [5aedeec] [reused from e79d15b]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 2 warn · 🔴 4 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [5768551] [reused from e79d15b]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 2 warn · 🔴 4 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
| } else { | ||
| // Show generic error message rather than error message from error code mapping | ||
| toast.error(genericErrorMessage); | ||
| } |
There was a problem hiding this comment.
Can confirmSend return { valid: false } after the user has approved in the Snap dialog? If it still able to return { valid: false }, then this means our validations doesn't work isn't it?
If not, this else branch can’t be reached (we’re still on /send/loader), and we can keep the original updateNonEVMSubmitError(errorMessage) here. The toast would then only be needed in the catch path.
There was a problem hiding this comment.
Today most of the snap will return valid false after user approve transaction
but 1 or 2 snap they throw exception for situration
the reason for return valid false after user confirm is that , the situration can be different after user confirm the txn
e.g
i have enough balance right before i click the confirm
at the same second that i confirm txn, my wallet out of fund, so the txn cant be send (some snap doing validation again after confirm the txn)
There was a problem hiding this comment.
Re-validating after approval makes sense, but returning { valid: false } after approval is the root issue. That shape means “fix your input” before the dialog, so the client has to guess which case it’s in. Tron, Solana and Bitcoin throw after approval, but Stellar returns valid: false, and it maps unexpected errors to Invalid too.
Can we align with the network snaps post-approval failures throw (or the Snap shows its own result screen)? I’m OK with this PR as a stopgap if there’s a follow-up issue. Also worth checking: in Stellar, if anything throws after sendTransaction (saving the pending transaction, scheduling the background event), it would report failure for a transaction that was actually broadcast.
Builds ready [97e8e78]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 3 warn · 🔴 4 fail)
Bundle Size Diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [4cc098e]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 4 warn · 🔴 3 fail)
Bundle Size Diffs
|
|
|
No release label on PR. Adding release label release-13.57.0 on PR, as PR was added to branch 13.57.0 when release was cut. |





Description
This PR fix the failure message is not show up
when a non-evm transaction return error after user confirm from the confirmation dialog
Previous
any error b4 dialog show, it return to amt input screen (bitcoin example)
any error after dialog show , it return home, no error
After fix
any error b4 dialog show, it return to amt input screen (bitcoin example)
any error after dialog show , it return home, toast with error (stellar example)
the root cause is
the loader component replace the navigation history
the current failure handle will redirect back to home
the solution is
display the error in toast when redirect back to home
as result
we can keep the same behavior when non-evm transaction return error before user confirm from the confirmation dialog
but only using toast when non-evm transaction return error after user confirm from the confirmation dialog
https://www.loom.com/share/c614df7241a54d08b36fdd4ef88a3832
Changelog
CHANGELOG entry: Fixed a bug that the failure message is omitted when having error in non-evm send fund
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Changes non-EVM send error UX and routing detection via
window.location.hash; logic is scoped to failure handling but affects a core user-facing send path.Overview
Fixes missing failure feedback when a non-EVM send fails after the user confirms in the Snap dialog. The send loader replaces navigation history, so navigating back no longer lands on the amount screen and
updateNonEVMSubmitErrorhad nothing visible to attach to.useSendActionsnow uses a newisRemainInSendScreen()helper (hash route still underSEND_ROUTE) to choose how errors surface: on the send flow, behavior is unchanged—validation and snap errors still set context viaupdateNonEVMSubmitError(including mapped snap codes). Once the user has left the send screen, the same failures show a generictoast.errorinstead, then still navigatePREVIOUS_ROUTE. User rejection (4001) stays silent—no toast, error cleared.Tests mock
toast.error, drivewindow.location.hashto simulate post-loader routes, and cover validation/RPC failures (toast shown) vs rejection (no toast).Reviewed by Cursor Bugbot for commit 4cc098e. Bugbot is set up for automated code reviews on this repo. Configure here.