Skip to content

feat: Updated disable-altpayments to altpayments#651

Open
Klakurka wants to merge 3 commits into
masterfrom
feat/altpayment-prioritization
Open

feat: Updated disable-altpayments to altpayments#651
Klakurka wants to merge 3 commits into
masterfrom
feat/altpayment-prioritization

Conversation

@Klakurka

@Klakurka Klakurka commented Jun 22, 2026

Copy link
Copy Markdown
Member

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 altpayments to true, false, xec, btc, and blahInvalidTicker to make sure it behaves as you'd expect.

Summary by CodeRabbit

  • Documentation

    • Updated configuration parameters across all supported languages to use altpayment instead of disable-altpayment, including examples for each coin type.
  • New Features

    • Enhanced altpayment configuration with support for coin-specific behavior (XEC, BCH, BTC enable different payment flows).
    • Improved payment widget generator with intuitive dropdown-based altpayment selection instead of checkbox control.

@Klakurka Klakurka requested a review from chedieck June 22, 2026 05:56
@Klakurka Klakurka self-assigned this Jun 22, 2026
@Klakurka Klakurka added the enhancement (UI/UX/feature) New feature or request label Jun 22, 2026
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Klakurka, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bf1d2726-57a3-487f-802f-53345ab8123f

📥 Commits

Reviewing files that changed from the base of the PR and between 9339d75 and a9fe014.

📒 Files selected for processing (2)
  • react/lib/tests/util/altpayment.test.ts
  • react/lib/util/altpayment.ts
📝 Walkthrough

Walkthrough

Replaces the boolean disableAltpayment prop with a new altpayment?: string | boolean prop across the entire component tree. A new parseAltpayment utility maps ticker strings (XEC, BCH, BTC) and boolean values to a configuration object controlling auto-start, link visibility, and coin preselection. Docs and demos are updated accordingly.

Changes

altpayment prop refactor

Layer / File(s) Summary
parseAltpayment utility and tests
react/lib/util/altpayment.ts, react/lib/util/index.ts, react/lib/tests/util/altpayment.test.ts
Defines ParsedAltpayment type and parseAltpayment function mapping falsy/truthy/ticker inputs to config objects (showAltpaymentLink, autoStart, preselectedCoin), re-exports from util index, and tests all input cases.
Prop contract propagation
react/lib/components/Widget/WidgetContainer.tsx, react/lib/components/Widget/Widget.tsx, react/lib/components/PaymentDialog/PaymentDialog.tsx, react/lib/components/PayButton/PayButton.tsx, react/lib/components/Widget/AltpaymentWidget.tsx
Replaces disableAltpayment?: boolean with `altpayment?: string
Widget.tsx altpaymentConfig-driven rendering
react/lib/components/Widget/Widget.tsx
Imports parseAltpayment, memoizes altpaymentConfig, initializes internalUseAltpayment from autoStart, gates the SideShift link on showAltpaymentLink, wires preselectedCoin into AltpaymentWidget, and conditionally suppresses QR/standard UI and footer when thisUseAltpayment is active.
AltpaymentWidget preselectedCoin auto-flow
react/lib/components/Widget/AltpaymentWidget.tsx
Adds preselectedCoin prop; adds deposit computation helpers and auto-rate/quote refs; auto-selects coin, auto-requests pair rate, and centralizes quote creation in createQuote(); expands resetTrade; updates Send button disabled logic and coin selection visibility.
PayButton socket lifecycle refactor
react/lib/components/PayButton/PayButton.tsx
Initializes useAltpayment from parseAltpayment(altpayment).autoStart; adds altpaymentSocketRef, disconnectAltpaymentSocket, resetAltpaymentState, and a dialog-close effect; reworks socket setup effect with a cancelled guard.
Demo, generator, and allowedProps wiring
paybutton/src/index.tsx, paybutton/dev/demo/index.html, paybutton/dev/demo/paybutton-generator.html
Updates allowedProps whitelist to accept altpayment; replaces disable-altpayment HTML attributes; replaces generator checkbox with an altpayment select dropdown and updates Vue reactive default.
Documentation updates
docs/README.md, docs/_sidebar.md, docs/zh-cn/..., docs/zh-tw/...
Replaces disableAltpayment/disable-altpayment with altpayment in Advanced Usage examples, Parameters sections, and sidebar navigation across all three locales.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Suggested labels

enhancement (behind the scenes)

Suggested reviewers

  • chedieck
  • lissavxo

🐇 A rabbit hops with glee today,
disableAltpayment has gone away!
Now altpayment="BTC" starts the show,
With parseAltpayment running the flow —
Auto-start, preselect, shift with flair,
New tickers blooming everywhere! 🌸

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Updated disable-altpayments to altpayments' accurately describes the main change—renaming the configuration option and updating its behavior across the codebase.
Description check ✅ Passed The description includes a clear summary of the changes (renaming and inverting behavior) and a detailed test plan covering multiple scenarios including edge cases.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/altpayment-prioritization

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
react/lib/components/Widget/Widget.tsx (1)

255-257: 🧹 Nitpick | 🔵 Trivial | 💤 Low value

Consider consolidating parseAltpayment calls.

parseAltpayment(altpayment) is called twice: once in the state initializer (line 256) and once in the memoized altpaymentConfig (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 internalUseAltpayment from altpaymentConfig.autoStart by 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1924ada and 9339d75.

📒 Files selected for processing (17)
  • docs/README.md
  • docs/_sidebar.md
  • docs/zh-cn/README.md
  • docs/zh-cn/_sidebar.md
  • docs/zh-tw/README.md
  • docs/zh-tw/_sidebar.md
  • paybutton/dev/demo/index.html
  • paybutton/dev/demo/paybutton-generator.html
  • paybutton/src/index.tsx
  • react/lib/components/PayButton/PayButton.tsx
  • react/lib/components/PaymentDialog/PaymentDialog.tsx
  • react/lib/components/Widget/AltpaymentWidget.tsx
  • react/lib/components/Widget/Widget.tsx
  • react/lib/components/Widget/WidgetContainer.tsx
  • react/lib/tests/util/altpayment.test.ts
  • react/lib/util/altpayment.ts
  • react/lib/util/index.ts

Comment thread react/lib/tests/util/altpayment.test.ts
Comment thread react/lib/util/altpayment.ts Outdated
Klakurka and others added 2 commits June 21, 2026 23:58
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement (UI/UX/feature) New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant