Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/onramp-success-guard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"thirdweb": patch
---

Fixed Universal Bridge onramp checkout incorrectly reporting success when the onramp did not complete.
14 changes: 14 additions & 0 deletions packages/thirdweb/src/react/core/hooks/useStepExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ export function useStepExecutor(
return { completed: true };
} else if (status === "FAILED") {
setOnrampStatus("failed");
throw new Error("Payment failed");
}

return { completed: false };
Expand Down Expand Up @@ -517,12 +518,25 @@ export function useStepExecutor(
}

// Execute onramp first if configured and not already completed
let onrampCompleted =
preparedQuote.type !== "onramp" || onrampStatus === "completed";
if (preparedQuote.type === "onramp" && onrampStatus === "pending") {
await executeOnramp(
preparedQuote,
completedStatusResults,
abortController.signal,
);
onrampCompleted = true;
Comment thread
0xFirekeeper marked this conversation as resolved.
}

// An onramp must complete before any follow-up transactions run or
// success is reported.
if (!onrampCompleted) {
throw new ApiError({
code: "INTERNAL_SERVER_ERROR",
message: "Onramp did not complete",
statusCode: 500,
});
}

if (flatTxs.length > 0) {
Expand Down
Loading