-
Notifications
You must be signed in to change notification settings - Fork 619
SDK: Fix onSuccess prop not called properly on CheckoutWidget and BuyWidget #8054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDK: Fix onSuccess prop not called properly on CheckoutWidget and BuyWidget #8054
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 15f0839 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughMoves the non-transaction Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant BO as BridgeOrchestrator
participant Exec as Execution Flow
participant UI as SuccessScreen
rect rgb(240,248,255)
note over BO: Non-transaction mode (changed)
U->>BO: Start checkout/buy
BO->>Exec: Execute flow
Exec-->>BO: EXECUTION_COMPLETE
BO-->>U: onComplete() invoked
BO->>UI: Show SuccessScreen
U->>UI: Click Done
UI->>BO: handleDoneOrContinueClick
BO->>BO: Reset state (no onComplete here)
end
rect rgb(245,245,245)
note over BO: Transaction mode (unchanged)
U->>BO: Start checkout/buy
BO->>Exec: Execute flow
Exec-->>BO: EXECUTION_COMPLETE
BO->>BO: CONTINUE_TO_TRANSACTION
BO->>UI: Show SuccessScreen
U->>UI: Click Continue/Done
UI->>BO: handleDoneOrContinueClick
BO->>BO: Continue to transaction (as applicable)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
Comment |
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
size-limit report 📦
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8054 +/- ##
==========================================
- Coverage 56.54% 56.53% -0.01%
==========================================
Files 904 904
Lines 58871 58873 +2
Branches 4170 4165 -5
==========================================
- Hits 33287 33283 -4
- Misses 25478 25484 +6
Partials 106 106
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx (3)
229-237: onComplete moved to execution-complete (non-transaction): watch ordering divergence vs post‑buy pathHere you call send(...) before onComplete for non-transaction flows, but in handlePostBuyTransactionComplete you call onComplete then send. Divergent ordering can cause subtle differences (e.g., callbacks reading state/context before/after reset, or unmount timing). Pick one order and keep it consistent; I’d lean toward “send then onComplete” to avoid dispatching to an unmounted machine if onComplete closes the UI.
Option: standardize post‑buy to match this path (send first), leaving this block unchanged.
@@ -const handlePostBuyTransactionComplete = useCallback(() => { - onComplete?.(); - send({ type: "RESET" }); -}, [onComplete, send]); +const handlePostBuyTransactionComplete = useCallback(() => { + send({ type: "RESET" }); + onComplete?.(); +}, [onComplete, send]);Please sanity‑check both flows to ensure onComplete fires exactly once and the UI doesn’t flicker/close prematurely.
85-86: Optional chaining on required props is unnecessary; remove for type clarityonComplete, onError, and onCancel are non‑optional in BridgeOrchestratorProps but are invoked with optional chaining. Drop the ?. to surface contract violations at compile time.
- onComplete?.(); + onComplete(); - onError?.(error); + onError(error); - onCancel?.(); + onCancel();Also applies to: 90-91, 95-96, 192-196, 198-205, 260-269
141-158: Add explicit return type for BridgeOrchestratorPer guidelines for .ts/.tsx, add an explicit return type.
-export function BridgeOrchestrator({ +export function BridgeOrchestrator({ client, uiOptions, receiverAddress, onComplete, onError, onCancel, connectOptions, connectLocale, purchaseData, paymentLinkId, presetOptions, paymentMethods = ["crypto", "card"], showThirdwebBranding = true, supportedTokens, country = "US", -}: BridgeOrchestratorProps) { +}: BridgeOrchestratorProps): JSX.Element {.changeset/slimy-chefs-buy.md (1)
5-5: Tighten wording for the changeset entrySmoother phrasing and consistent naming.
-Fix `onSuccess` callback was not called correctly on `CheckoutWidget`, `BuyWidget` components +Fix onSuccess not being called correctly in CheckoutWidget and BuyWidget components.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
.changeset/slimy-chefs-buy.md(1 hunks)packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx(3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
.changeset/*.md
📄 CodeRabbit inference engine (AGENTS.md)
.changeset/*.md: Each change inpackages/*must include a changeset for the appropriate package
Version bump rules: patch for non‑API changes; minor for new/modified public API
Files:
.changeset/slimy-chefs-buy.md
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from@/typesor localtypes.tsbarrels
Prefer type aliases over interface except for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial,Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from@/typeswhere applicable
Prefertypealiases overinterfaceexcept for nominal shapes
Avoidanyandunknownunless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size
Files:
packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)
Files:
packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx
packages/thirdweb/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
packages/thirdweb/**/*.{ts,tsx}: Every public symbol must have comprehensive TSDoc with at least one compiling@exampleand a custom tag (@beta,@internal,@experimental, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose
Lazy‑load heavy dependencies inside async paths (e.g.,const { jsPDF } = await import("jspdf"))
Files:
packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
- GitHub Check: Build Packages
- GitHub Check: Size
- GitHub Check: E2E Tests (pnpm, esbuild)
- GitHub Check: Unit Tests
- GitHub Check: E2E Tests (pnpm, webpack)
- GitHub Check: E2E Tests (pnpm, vite)
- GitHub Check: Lint Packages
- GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
packages/thirdweb/src/react/web/ui/Bridge/BridgeOrchestrator.tsx (2)
395-395: SuccessScreen.onDone wired correctly to the new handlerThis connects the success action to the unified handler; good.
183-190: Rename + behavior shift confirmed — SuccessScreen.onDone now only resets/continuesVerified: SuccessScreen’s Done button calls onDone (packages/thirdweb/src/react/web/ui/Bridge/payment-success/SuccessScreen.tsx) which is wired to BridgeOrchestrator.handleDoneOrContinueClick — it sends RESET for non-transaction flows or CONTINUE_TO_TRANSACTION for transaction flows. onComplete is still invoked from BridgeOrchestrator.handleExecutionComplete (non-transaction) and handlePostBuyTransactionComplete (post-transaction). No stale references to the old handler name found.
Merge activity
|
…Widget (#8054) <!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR addresses an issue with the `onSuccess` callback not being triggered properly in the `CheckoutWidget` and `BuyWidget` components, improving the handling of buy completion and post-transaction actions. ### Detailed summary - Renamed `handleBuyComplete` to `handleDoneOrContinueClick`. - Adjusted the invocation of `onComplete` to only occur when `uiOptions.mode` is not "transaction". - Updated the dependency array for `handleExecutionComplete` to include `onComplete` and `uiOptions.mode`. - Changed the `onDone` prop in `SuccessScreen` to use `handleDoneOrContinueClick`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed an issue where the success callback in checkout and buy widgets did not fire reliably. * Improved non-transaction flows so completion triggers after execution finishes (instead of on Done), ensuring proper state reset and more consistent behavior. * **Chores** * Added a patch-level changeset entry documenting the fix. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
3a2a852 to
15f0839
Compare

PR-Codex overview
This PR addresses an issue where the
onSuccesscallback was not correctly triggered in theCheckoutWidgetandBuyWidgetcomponents, improving the handling of buy completion and post-buy transaction completion.Detailed summary
handleBuyCompletetohandleDoneOrContinueClick.handleExecutionCompleteto callonCompleteonly ifuiOptions.modeis not "transaction".onDoneprop inSuccessScreento usehandleDoneOrContinueClick.Summary by CodeRabbit
Bug Fixes
Chores