feat: display errors coming from the snaps when submitting confirm in send flow#25648
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. |
app/components/Views/confirmations/hooks/send/useSendActions.ts
Outdated
Show resolved
Hide resolved
app/components/Views/confirmations/components/send/recipient/recipient.tsx
Outdated
Show resolved
Hide resolved
app/components/Views/confirmations/hooks/send/useSendActions.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Extension is two step (asset => amount and recipient ) meanwhile mobile is (asset => amount => recipient). I understood that we blocked the button in the last page in extension but why would submission error is having effect in the amount page in mobile?
If the amount is an issue to submit this transaction - error should be raised upfront by authorized snap validateNonEvmAmount in app/components/Views/confirmations/hooks/send/useAmountValidation.ts.
There was a problem hiding this comment.
We can't raise upfront as we are missing params to be sent to the snap for it to run the tx simulation, we don't send the recipient param at this stage, hence why we can only raise it in the confirm screen.
Also this allows to be aligned with the extension behavior no ?
There was a problem hiding this comment.
I thought both extension and mobile PRs were intending just to handle exceptions when snap confirmation couldn't be created.
But this conversation already happened before and decided that those errors will be surfaced in the snap confirmation, discussion here: https://consensys.slack.com/archives/C099HFE1ZHA/p1769606213847949?thread_ts=1769519715.568409&cid=C099HFE1ZHA
As recipient page is final step before snap confirmation, this error should be surfaced there and only. Then user can go back and change the amount - I see no reason of bringing complexity into amount page only for Tron exception.
There was a problem hiding this comment.
So you'd display the error message in a popup in the recipient screen, is it something we do ? Because I haver never seen an error in this screen.
Also the reason I displayed it in the amount screen is because I saw that the button was commonly used for this reason.
There was a problem hiding this comment.
So you'd display the error message in a popup in the recipient screen, is it something we do ? Because I haver never seen an error in this screen.
We don't do that today. That would be awesome - but not fair to ask to implement in this PR. Because imagine - you don't really need to handle all the context additions, we could directly raise an Alert which would be more clear.
In fact - I was meaning to put that message in to this button as user final attempt was on the recipient screen, see recording:
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-02-06.at.10.10.50.mov
There was a problem hiding this comment.
Rather than pushing the error state into send-context, can't we capsulate it in the recipient page if transaction submission done by the button in that page?
There was a problem hiding this comment.
If we remove it from the send-context we would have to add it in the amount-keyboard.tsx as well would that be fine ?
| if (result?.valid === false) { | ||
| const errorMessage = result?.errors?.length | ||
| ? mapSnapErrorCodeIntoTranslation(result.errors[0].code) | ||
| : strings('send.transaction_error'); | ||
| updateSubmitError(errorMessage); | ||
| // Navigate back to the Amount screen where the error can be displayed | ||
| // (Recipient screen may not have a visible button when recipient is selected from list) | ||
| if (screensToPopOnError > 0) { | ||
| (navigation as StackNavigationProp<ParamListBase>).pop( | ||
| screensToPopOnError, | ||
| ); | ||
| } | ||
| return; | ||
| } |
There was a problem hiding this comment.
Apologies - I forgot to ask this question in extension PR but just noticed now.
What conditions we get result?.valid === false and what conditions that sendMultichainTransactionForReview will throw? One is userRejection but can't we simplify it to throw in the snap code always?
Trying to handle both cases looks a bit of duplication to me.
There was a problem hiding this comment.
Those are the conditions for result?.valid === false: (For tron at least, snaps are not aligned)
https://github.com/MetaMask/snap-tron-wallet/blob/5febcaf0c581ff8c76c92a3ec9c7557c10613fb9/packages/snap/src/handlers/clientRequest/clientRequest.ts#L419
We could always throw but that means aligning all the snaps and this PR is part of the tron snap issues that need to be resolved rather quickly for dapps connectivity release.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
These changes directly affect:
Per tag guidance: "When selecting SmokeNetworkExpansion for Solana transaction or signing flows, also select SmokeConfirmations" Performance Test Selection: |
|



Description
Adds proper error handling for non-EVM transaction submissions. When a multichain snap (Solana, Tron) returns validation errors during send, the error is displayed on the Continue button so users can correct the issue.
Related Extension PR: MetaMask/metamask-extension#39667
Changelog
CHANGELOG entry: Validation errors from non-EVM transaction snaps will now be displayed to users during send flow.
Related issues
Fixes: https://consensyssoftware.atlassian.net/jira/software/c/projects/NEB/boards/3738?assignee=62710850d7fd480068d7cff9&selectedIssue=NEB-385
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Adds new error-handling paths for non-EVM snap transaction submission, which can change user flow and messaging. Risk is moderate due to reliance on snap return shapes and new branching around navigation/alerts.
Overview
Non-EVM send submission now surfaces snap validation failures and internal errors to users instead of silently ignoring them.
useSendActionsinspects thesendMultichainTransactionForReviewresult forvalid: false, maps snap error codes to localized messages, and shows anAlert(falling back to a new genericsend.transaction_errorstring when no error details are provided). It also distinguishes user rejection viaerrorCodes.provider.userRejectedRequestto avoid showing an error UI.Adds unit tests covering non-EVM snap validation errors (with/without an
errorsarray), specific code translations, user rejection behavior, generic failures, and successful navigation; and exportsmapSnapErrorCodeIntoTranslationfor reuse.Written by Cursor Bugbot for commit 719916c. This will update automatically on new commits. Configure here.