Skip to content

Commit a45c558

Browse files
authored
[SDK] Fix: Improve PayEmbed error message parsing (#6732)
1 parent a3e7300 commit a45c558

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

.changeset/tired-windows-clean.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Improve pay error messages

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ export function SwapConfirmationScreen(props: {
6868

6969
const uiErrorMessage = useMemo(() => {
7070
if (step === "approval" && status === "error" && error) {
71-
if (error.toLowerCase().includes("user rejected")) {
71+
if (
72+
error.toLowerCase().includes("user rejected") ||
73+
error.toLowerCase().includes("user closed modal") ||
74+
error.toLowerCase().includes("user denied")
75+
) {
7276
return {
7377
title: "Failed to Approve",
7478
message: "Your wallet rejected the approval request.",
@@ -82,7 +86,11 @@ export function SwapConfirmationScreen(props: {
8286
}
8387

8488
if (step === "swap" && status === "error" && error) {
85-
if (error.toLowerCase().includes("user rejected")) {
89+
if (
90+
error.toLowerCase().includes("user rejected") ||
91+
error.toLowerCase().includes("user closed modal") ||
92+
error.toLowerCase().includes("user denied")
93+
) {
8694
return {
8795
title: "Failed to Confirm",
8896
message: "Your wallet rejected the confirmation request.",

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/TransferConfirmationScreen.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ export function TransferConfirmationScreen(
112112

113113
const uiErrorMessage = useMemo(() => {
114114
if (step === "approve" && status.id === "error" && status.error) {
115-
if (status.error.toLowerCase().includes("user rejected")) {
115+
if (
116+
status.error.toLowerCase().includes("user rejected") ||
117+
status.error.toLowerCase().includes("user closed modal") ||
118+
status.error.toLowerCase().includes("user denied")
119+
) {
116120
return {
117121
title: "Failed to Approve",
118122
message: "Your wallet rejected the approval request.",

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/SendFunds.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ export function SendFundsForm(props: {
145145
return locale.transactionFailed;
146146
}
147147

148-
if (message.includes("user rejected")) {
148+
if (
149+
message.includes("user rejected") ||
150+
message.includes("user closed modal") ||
151+
message.includes("user denied")
152+
) {
149153
return locale.transactionRejected;
150154
}
151155

0 commit comments

Comments
 (0)