Skip to content

Conversation

@bordalix
Copy link
Collaborator

@bordalix bordalix commented Oct 22, 2025

@tiero please review

Summary by CodeRabbit

  • New Features

    • Added an action button on swap screens to claim or refund transactions.
    • Shows success confirmation with a visual checkmark and displays errors inline.
    • Action button disables while processing to prevent duplicate actions.
  • Improvement

    • Refreshes swap statuses before loading swap history for more accurate initial data.
  • Style

    • Minor formatting cleanup in swap index view.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 22, 2025

Warning

Rate limit exceeded

@bordalix has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 8 minutes and 16 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 8a0d28b and 2ff59b6.

📒 Files selected for processing (1)
  • src/screens/Apps/Boltz/Swap.tsx (3 hunks)

Walkthrough

Added UI state and action flow to the Boltz Swap screen to conditionally claim or refund HTLCs via the swap provider, refresh swap status after the action, surface success/error UI, updated swap history init to refresh statuses first, and applied a minor formatting edit.

Changes

Cohort / File(s) Summary
Swap component: UI state & action handler
src/screens/Apps/Boltz/Swap.tsx
Added local state (error, cooking, success); imported UI and utility helpers; read swapProvider from LightningContext; computed isRefundable/isClaimable; implemented buttonHandler to call claimVHTLC or refundVHTLC, refresh swap status, manage cooking state, and capture/log errors; render action button, error message, and success info.
Swaps list: init sequence change
src/components/SwapsList.tsx
Converted initialization to an async effect that awaits swapProvider.refreshSwapsStatus() before fetching swapProvider.getSwapHistory(); added consoleError logging on failure.
Formatting-only edit
src/screens/Apps/Boltz/Index.tsx
Inserted an empty line; no logic or API changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SwapUI as Boltz Swap Component
    participant Handler as buttonHandler
    participant Provider as swapProvider
    participant State as Local State

    User->>SwapUI: Click action button
    SwapUI->>Handler: invoke buttonHandler
    Handler->>State: set cooking = true

    alt reverse swap & claimable
        Handler->>Provider: claimVHTLC(swapId)
    else submarine swap & refundable
        Handler->>Provider: refundVHTLC(swapId)
    end

    Handler->>Provider: refreshSwapsStatus()
    Provider-->>Handler: updated status

    alt action succeeded
        Handler->>State: set success = true
        Handler->>State: set cooking = false
        SwapUI->>User: show success Info
    else action failed
        Provider-->>Handler: throws error
        Handler->>State: set error = extractedError
        Handler->>State: set cooking = false
        SwapUI->>User: show ErrorMessage
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review focus: correctness of conditional claim/refund branching, proper error extraction/logging, swapProvider null-safety, and UI state transitions in Swap.tsx. Verify async init ordering and error handling in SwapsList.tsx.

Possibly related PRs

Suggested reviewers

  • louisinger

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "add buttons to swap page" is directly related to the primary changes in the changeset. The main modifications involve adding interactive Button components to the Swap.tsx page, along with accompanying logic for error handling, state management (error, processing, success), and swap operation handlers (claiming and refunding). The title accurately captures the core change and is specific enough that a reviewer scanning the commit history would understand the primary modification being introduced. While the title could be more detailed (e.g., mentioning claim/refund functionality), it still clearly and concisely conveys the essential change without being misleading or overly vague.

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.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 22, 2025

Deploying wallet-signet with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2ff59b6
Status: ✅  Deploy successful!
Preview URL: https://2f0f32b2.wallet-23u.pages.dev
Branch Preview URL: https://buttons-on-swaps.wallet-23u.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 22, 2025

Deploying wallet-mutinynet with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2ff59b6
Status: ✅  Deploy successful!
Preview URL: https://370fe59b.arkade-wallet.pages.dev
Branch Preview URL: https://buttons-on-swaps.arkade-wallet.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Oct 22, 2025

Deploying wallet-bitcoin with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2ff59b6
Status: ✅  Deploy successful!
Preview URL: https://a99eb991.wallet-bitcoin.pages.dev
Branch Preview URL: https://buttons-on-swaps.wallet-bitcoin.pages.dev

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/screens/Apps/Boltz/Swap.tsx (1)

59-61: Consider making the button label logic more explicit.

The buttonLabel logic assumes a binary state (either claimable or refundable), but doesn't handle the case where neither is true. While the Buttons component protects against this by conditional rendering, this creates fragile coupling between the two.

Apply this diff for more explicit logic:

 const isRefundable = isSubmarineSwapRefundable(swapInfo)
 const isClaimable = isReverseClaimableStatus(swapInfo.status)
-const buttonLabel = isClaimable ? 'Complete swap' : 'Refund swap'
+const buttonLabel = isClaimable ? 'Complete swap' : isRefundable ? 'Refund swap' : ''
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c04f3cf and 9d51811.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • package.json (1 hunks)
  • src/screens/Apps/Boltz/Swap.tsx (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/screens/Apps/Boltz/Swap.tsx (11)
src/providers/flow.tsx (1)
  • FlowContext (82-95)
src/providers/lightning.tsx (1)
  • LightningContext (24-30)
src/lib/error.ts (1)
  • extractError (1-10)
src/lib/logs.ts (1)
  • consoleError (40-44)
src/components/ButtonsOnBottom.tsx (1)
  • ButtonsOnBottom (10-26)
src/components/Button.tsx (1)
  • Button (20-62)
src/components/Error.tsx (1)
  • ErrorMessage (10-21)
src/components/Info.tsx (1)
  • Info (14-30)
src/icons/CheckMark.tsx (1)
  • CheckMarkIcon (1-11)
src/components/Text.tsx (1)
  • TextSecondary (91-97)
src/components/Table.tsx (1)
  • Table (6-24)
🔇 Additional comments (5)
src/screens/Apps/Boltz/Swap.tsx (4)

1-21: LGTM!

The new imports are properly used throughout the component to add claim/refund functionality.


26-31: LGTM!

The swapProvider from context and the local state variables (error, cooking, success) are properly integrated for managing the claim/refund operations.


79-84: LGTM!

The conditional rendering logic correctly shows the button only when an action is available and not yet succeeded. The button is properly disabled during operations.


102-102: LGTM!

The button is properly positioned at the bottom of the layout.

package.json (1)

7-7: No issues found—package version is current and secure.

The latest version of @arkade-os/boltz-swap on npm is 0.2.5, matching the version specified in package.json, and no known security vulnerabilities were detected.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (1)
src/components/SwapsList.tsx (1)

121-126: Consider adding a loading state.

Users won't see any feedback while swap data is being fetched and refreshed. Adding a loading state would improve the user experience by providing visual feedback during the async operations.

You could add a loading state like this:

 export default function SwapsList() {
   const { swapProvider } = useContext(LightningContext)
   const [swapHistory, setSwapHistory] = useState<(PendingReverseSwap | PendingSubmarineSwap)[]>([])
+  const [loading, setLoading] = useState(true)

   useEffect(() => {
     const choresOnInit = async () => {
       if (!swapProvider) return
+      setLoading(true)
       try {
         await swapProvider.refreshSwapsStatus()
         setSwapHistory(await swapProvider.getSwapHistory())
       } catch (error) {
         console.error('Failed to fetch swap history:', error)
+      } finally {
+        setLoading(false)
       }
     }
     choresOnInit()
   }, [swapProvider])

+  if (loading) return <div>Loading...</div>
   if (swapHistory.length === 0) return <EmptySwapList />
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d64252b and 925633b.

📒 Files selected for processing (2)
  • src/components/SwapsList.tsx (1 hunks)
  • src/screens/Apps/Boltz/Index.tsx (1 hunks)
🔇 Additional comments (1)
src/screens/Apps/Boltz/Index.tsx (1)

27-27: LGTM!

Formatting improvement that adds visual separation between the component definition and the return statement.

@bordalix bordalix merged commit 7437fc2 into master Oct 28, 2025
5 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 12, 2025
@bordalix bordalix deleted the buttons_on_swaps branch November 26, 2025 14:30
@coderabbitai coderabbitai bot mentioned this pull request Dec 16, 2025
@coderabbitai coderabbitai bot mentioned this pull request Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants