-
Notifications
You must be signed in to change notification settings - Fork 560
Feature: New UB Components #7354
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
Conversation
1a7e067
to
cfc7c79
Compare
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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/PayModal.tsx
(1 hunks)apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/components/client/PayModal.tsx
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: Size
- GitHub Check: Unit Tests
- GitHub Check: Lint Packages
- GitHub Check: Analyze (javascript)
@@ -63,7 +63,7 @@ export function PayPageEmbed({ | |||
onPurchaseSuccess: (result) => { | |||
if (!redirectUri) return; | |||
const url = new URL(redirectUri); | |||
switch (result.type) { | |||
switch (result?.type) { |
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.
🛠️ Refactor suggestion
Guard against undefined
before the switch to preserve discriminated-union narrowing
Using switch (result?.type)
widens the expression to 'crypto' | 'fiat' | 'transaction' | undefined
, preventing TypeScript from narrowing result
inside each case. This forces result.status
/ result.transactionHash
to be typed as any
, defeating the benefit of the discriminated union and risking silent type regressions.
Proposed fix: short-circuit when result
is falsy, then switch on the guaranteed, non-optional result.type
.
- switch (result?.type) {
+ if (!result) {
+ return window.open(url.toString());
+ }
+ switch (result.type) {
Optionally add a default
branch to future-proof against new result types.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
switch (result?.type) { | |
if (!result) { | |
return window.open(url.toString()); | |
} | |
switch (result.type) { |
🤖 Prompt for AI Agents
In apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx at line
66, the switch statement uses optional chaining on result.type, causing
TypeScript to widen the type and lose discriminated union narrowing. To fix
this, add a guard clause before the switch to return early or handle the case
when result is undefined, ensuring that inside the switch statement result is
always defined. Then switch on result.type without optional chaining.
Optionally, add a default case in the switch to handle any future result types
safely.
cfc7c79
to
1b600b3
Compare
1b600b3
to
74717d7
Compare
PR-Codex overview
This PR introduces new components for payment processing and enhances existing functionalities, including the transition from
PayEmbed
toCheckoutWidget
andBuyWidget
. It also improves error handling and adds utility functions for token management.Detailed summary
PayEmbed
component and replaced it withCheckoutWidget
andBuyWidget
.TransactionWidget
for executing transactions.ErrorBanner
andUnsupportedTokenScreen
.Summary by CodeRabbit
New Features
Enhancements
Documentation
Bug Fixes / Style
Tests