Skip to content

fix(sell,swap): surface the real wallet error instead of a generic message - #1448

Closed
Blume1977 wants to merge 1 commit into
DFXswiss:developfrom
Blume1977:fix/surface-wallet-error-on-sell
Closed

fix(sell,swap): surface the real wallet error instead of a generic message#1448
Blume1977 wants to merge 1 commit into
DFXswiss:developfrom
Blume1977:fix/surface-wallet-error-on-sell

Conversation

@Blume1977

Copy link
Copy Markdown
Contributor

Was

Wenn ein Verkauf oder Swap in der Wallet fehlschlägt, zeigten beide Screens bisher für jeden Fehler (ausser der 4001-Ablehnung) denselben Text «Irgendwas hat nicht funktioniert / Transaktion fehlgeschlagen» und warfen die eigentliche, umsetzbare Ursache weg.

Neu: ein gemeinsamer Helfer resolveWalletTxError klassifiziert den Fehler für beide Screens gleich. Eine Nutzer-Ablehnung (Code 4001 / AbortError) bleibt still, eine kuratierte TranslatedError wird dem Kunden angezeigt, alles andere behält den bisherigen generischen Hinweis auf die manuelle Einzahlungsadresse.

Warum

Häufigste Ursache eines hängenden Verkaufs ist eine noch offene Anfrage in der Wallet: Der Netzwerkwechsel wirft MetaMask -32002, was die Wallet-Hooks bereits in eine kuratierte, lokalisierte TranslatedError («Es ist bereits eine Anfrage offen. Bitte bestätige sie in deiner MetaMask und versuche es erneut.») umwandeln. Diese Meldung wurde verschluckt, der Kunde sah nur «Irgendwas hat nicht funktioniert» und versuchte es endlos erneut (realer Supportfall vom 02.09.2026: ETH als Gas vorhanden, Order gültig, trotzdem Abbruch ohne On-Chain-Transaktion).

Wie

  • src/util/wallet-tx-error.ts: reiner, testbarer Klassifizierer.
  • sell.screen.tsx / swap.screen.tsx: nutzen den Helfer im catch; kuratierte Meldung via translate('screens/home', key) (derselbe Namespace, den der Connect-Flow für Wallet-Fehler nutzt), sonst der bisherige Fallback.
  • DE/FR/IT-Übersetzungen für die sechs Wallet-Fehlermeldungen, die den Sende-Pfad erreichen können (bislang wurden diese überall nur auf Englisch angezeigt).

Tests

  • Neu: wallet-tx-error.test.ts (6 Fälle: 4001, AbortError, TranslatedError, unbekannter Fehler, leere Meldung, null/undefined).
  • sell-screen-cleared-amount + swap-screen-cleared-amount weiterhin grün (169 Tests gesamt).
  • eslint sauber (--max-warnings 0); i18n-Keys in DE/FR/IT konsistent.

Hinweis

Kein Konflikt mit dem offenen Viem-Port #1330 (fasst metamask.hook.ts an, nicht die Screens).

…ssage

When a sell or swap transaction fails in the wallet, both screens caught every
error (except a 4001 user rejection) and showed the same generic "Something went
wrong / Transaction failed" hint, throwing away the actual, actionable cause.

The most common case for a stuck sell is a request that is still pending in the
wallet: the chain switch throws MetaMask -32002, which the wallet hooks already
turn into a curated, localized TranslatedError ("There is already a request
pending. Please confirm it in your MetaMask and retry."). That message was
swallowed, so the customer only saw "Something went wrong" and kept retrying.

A shared helper (resolveWalletTxError) now classifies the error the same way for
both screens: a user cancellation (code 4001 or AbortError) stays silent, a
TranslatedError is surfaced to the user, and anything else keeps the generic
hint that points to the manual deposit address. The wallet error messages that
can reach the sell/swap send path get DE/FR/IT translations under screens/home,
the namespace the connect flow already uses for wallet errors.
@Blume1977 Blume1977 closed this Sep 2, 2026
@Blume1977
Blume1977 deleted the fix/surface-wallet-error-on-sell branch September 2, 2026 14:05
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.

1 participant