Skip to content

feat: Updated disable-altpayments to altpayments#651

Merged
Klakurka merged 4 commits into
masterfrom
feat/altpayment-prioritization
Jul 22, 2026
Merged

feat: Updated disable-altpayments to altpayments#651
Klakurka merged 4 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 “Advanced Usage” and parameter docs (including sidebars) across supported languages to use altpayment instead of disable-altpayment, with updated XEC/BCH/BTC examples.
  • New Features
    • Updated the payment button demos and generator UI to configure altpayment via dropdown options.
    • Improved widget behavior to initialize and render the altpayment flow based on altpayment (including automatic BTC preselection).
  • Tests
    • Added coverage for altpayment configuration parsing.

@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

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2d35e4c6-515c-4a38-80c2-f7e60364de88

📥 Commits

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

📒 Files selected for processing (4)
  • paybutton/dev/demo/index.html
  • react/lib/components/Widget/Widget.tsx
  • react/lib/tests/util/altpayment.test.ts
  • react/lib/util/altpayment.ts

📝 Walkthrough

Walkthrough

Replaces the boolean disableAltpayment prop with altpayment?: string | boolean, adds ticker-based parsing and automatic SideShift behavior, updates socket cleanup, and revises component wiring, demos, tests, and documentation.

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
Maps boolean and ticker values to link visibility, auto-start, and coin preselection configurations, with tests for supported and fallback inputs.
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 with altpayment across public props and component boundaries.
Widget altpayment rendering
react/lib/components/Widget/Widget.tsx
Uses parsed configuration for automatic mode selection, link and footer visibility, layout changes, and AltpaymentWidget preselection.
AltpaymentWidget auto-flow
react/lib/components/Widget/AltpaymentWidget.tsx
Adds preselected-coin handling, automatic rate and quote requests, deposit computation, expanded reset state, loading rendering, and updated controls.
PayButton socket lifecycle
react/lib/components/PayButton/PayButton.tsx
Adds ref-backed socket cleanup, dialog-close state reset, cancellation guards, and parsed automatic startup.
Demo and generator wiring
paybutton/src/index.tsx, paybutton/dev/demo/index.html, paybutton/dev/demo/paybutton-generator.html
Accepts altpayment, updates demo attributes, and replaces the generator checkbox with a configuration selector.
Documentation updates
docs/README.md, docs/_sidebar.md, docs/zh-cn/..., docs/zh-tw/...
Replaces the old parameter examples, descriptions, and navigation links across all locales.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant HostApp
  participant PayButton
  participant Widget
  participant AltpaymentWidget
  participant SideShiftSocket

  HostApp->>PayButton: altpayment="BTC"
  PayButton->>Widget: pass altpayment
  Widget->>Widget: parseAltpayment("BTC")
  Widget->>AltpaymentWidget: preselectedCoin="BTC"
  AltpaymentWidget->>SideShiftSocket: requestPairRate(selectedCoinNetwork)
  SideShiftSocket-->>AltpaymentWidget: pair rate
  AltpaymentWidget->>SideShiftSocket: create-altpayment-quote
  SideShiftSocket-->>AltpaymentWidget: quote and shift state
Loading

Suggested labels: enhancement (behind the scenes)

Suggested reviewers: chedieck

🚥 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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 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.

@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 3 commits June 21, 2026 23:58
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@Klakurka
Klakurka merged commit b6e2ed5 into master Jul 22, 2026
2 of 3 checks passed
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