feat: Updated disable-altpayments to altpayments#651
Conversation
|
Warning Review limit reached
More reviews will be available in 55 minutes and 44 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughReplaces the boolean Changesaltpayment prop refactor
Sequence Diagram(s)sequenceDiagram
participant Host as Host App
participant PayButton
participant parseAltpayment as parseAltpayment()
participant Widget
participant AltpaymentWidget
participant SideShift as SideShift Socket
Host->>PayButton: altpayment="BTC"
PayButton->>parseAltpayment: parseAltpayment("BTC")
parseAltpayment-->>PayButton: {autoStart:true, showAltpaymentLink:false, preselectedCoin:"BTC"}
PayButton->>Widget: altpayment="BTC"
Widget->>parseAltpayment: parseAltpayment("BTC")
parseAltpayment-->>Widget: altpaymentConfig
Widget->>AltpaymentWidget: preselectedCoin="BTC", autoStart=true
AltpaymentWidget->>SideShift: requestPairRate(BTC network)
SideShift-->>AltpaymentWidget: pairRate
AltpaymentWidget->>AltpaymentWidget: computeDepositAmountFromSettle()
AltpaymentWidget->>SideShift: createQuote(depositAmount)
SideShift-->>AltpaymentWidget: quote/shift
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
react/lib/components/Widget/Widget.tsx (1)
255-257: 🧹 Nitpick | 🔵 Trivial | 💤 Low valueConsider consolidating
parseAltpaymentcalls.
parseAltpayment(altpayment)is called twice: once in the state initializer (line 256) and once in the memoizedaltpaymentConfig(line 312). While the memoization handles re-renders correctly, the initial render parses the same value twice.This is a minor optimization opportunity - you could initialize
internalUseAltpaymentfromaltpaymentConfig.autoStartby reordering the declarations, though this would require the memo to be defined first.Also applies to: 312-313
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@react/lib/components/Widget/Widget.tsx` around lines 255 - 257, The function `parseAltpayment` is being called twice on initial render: once in the state initializer for `internalUseAltpayment` (line 256) and again in the memoized `altpaymentConfig` definition (line 312). To consolidate these calls and avoid redundant parsing, reorder the declarations by moving the `altpaymentConfig` useMemo hook before the `internalUseAltpayment` useState hook, then update the useState initializer to use `altpaymentConfig.autoStart` instead of calling `parseAltpayment(altpayment).autoStart` directly. This ensures `parseAltpayment` is only called once during the initial render while maintaining the same functionality.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@react/lib/tests/util/altpayment.test.ts`:
- Around line 39-42: In the test case for parseAltpayment that checks
unrecognized tickers, add an additional expect statement that calls
parseAltpayment with the parameter 'blahInvalidTicker' and verifies it returns
defaultConfig, following the same pattern as the existing assertions for 'ETH'
and 'DOGE'.
In `@react/lib/util/altpayment.ts`:
- Around line 13-19: The boolean parsing logic in the altpayment utility has
both the truthy and falsy cases returning DEFAULT_CONFIG, which prevents
representing inverted boolean behavior. To fix this, the second condition that
checks for value being true or 'true' should return a different configuration
value instead of DEFAULT_CONFIG. This will allow altpayment=true and
altpayment=false to have distinct behaviors as intended by the PR's objective to
invert the semantics from the old disable-altpayments naming.
---
Nitpick comments:
In `@react/lib/components/Widget/Widget.tsx`:
- Around line 255-257: The function `parseAltpayment` is being called twice on
initial render: once in the state initializer for `internalUseAltpayment` (line
256) and again in the memoized `altpaymentConfig` definition (line 312). To
consolidate these calls and avoid redundant parsing, reorder the declarations by
moving the `altpaymentConfig` useMemo hook before the `internalUseAltpayment`
useState hook, then update the useState initializer to use
`altpaymentConfig.autoStart` instead of calling
`parseAltpayment(altpayment).autoStart` directly. This ensures `parseAltpayment`
is only called once during the initial render while maintaining the same
functionality.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 764fb3a9-c9b1-4441-8c14-b4e862634089
📒 Files selected for processing (17)
docs/README.mddocs/_sidebar.mddocs/zh-cn/README.mddocs/zh-cn/_sidebar.mddocs/zh-tw/README.mddocs/zh-tw/_sidebar.mdpaybutton/dev/demo/index.htmlpaybutton/dev/demo/paybutton-generator.htmlpaybutton/src/index.tsxreact/lib/components/PayButton/PayButton.tsxreact/lib/components/PaymentDialog/PaymentDialog.tsxreact/lib/components/Widget/AltpaymentWidget.tsxreact/lib/components/Widget/Widget.tsxreact/lib/components/Widget/WidgetContainer.tsxreact/lib/tests/util/altpayment.test.tsreact/lib/util/altpayment.tsreact/lib/util/index.ts
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Description
Expanded the 'altpayments' config functionality (renaming it in the process and inverting the true/false behaviour)
Test plan
Test everything, but especially the "altpayment" (Sideshift) payment flow. Try setting
altpaymentstotrue,false,xec,btc, andblahInvalidTickerto make sure it behaves as you'd expect.Summary by CodeRabbit
Documentation
altpaymentinstead ofdisable-altpayment, including examples for each coin type.New Features