Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
},
"scripts": {
"prepare": "husky install",
"start": "pnpm git-info; pnpm build:worker; vite",
"build": "pnpm git-info; pnpm build:worker; vite build",
"start": "pnpm git-info && pnpm build:worker && vite",
"start:mainnet": "pnpm git-info && pnpm build:worker && cross-env VITE_ARK_SERVER=https://arkade.computer VITE_BOLTZ_URL=https://api.ark.boltz.exchange vite",
"build": "pnpm git-info && pnpm build:worker && vite build",
"build:worker": "vite build -c vite.worker.config.ts",
"test": "vitest run",
"test:ui": "vitest run --ui",
Expand Down Expand Up @@ -77,6 +78,7 @@
"@typescript-eslint/eslint-plugin": "^8.41.0",
"@typescript-eslint/parser": "^8.41.0",
"@vitejs/plugin-react": "^5.0.2",
"cross-env": "^10.1.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.32.0",
Expand Down
18 changes: 18 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 28 additions & 7 deletions src/components/SwapsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,42 @@ const SwapLine = ({ swap }: { swap: PendingReverseSwap | PendingSubmarineSwap })
}

export default function SwapsList() {
const { swapProvider } = useContext(LightningContext)
const { arkadeLightning, swapManager, getSwapHistory } = useContext(LightningContext)
const [swapHistory, setSwapHistory] = useState<(PendingReverseSwap | PendingSubmarineSwap)[]>([])

// Load initial swap history
useEffect(() => {
const choresOnInit = async () => {
if (!swapProvider) return
const loadHistory = async () => {
if (!arkadeLightning) return
try {
await swapProvider.refreshSwapsStatus()
setSwapHistory(await swapProvider.getSwapHistory())
const history = await getSwapHistory()
setSwapHistory(history)
} catch (err) {
consoleError(err, 'Error fetching swap history:')
}
}
choresOnInit()
}, [swapProvider])
loadHistory()
}, [arkadeLightning])

// Subscribe to swap updates from SwapManager for real-time updates
useEffect(() => {
if (!swapManager) return

const unsubscribe = swapManager.onSwapUpdate((swap) => {
setSwapHistory((prev) => {
const existingIndex = prev.findIndex((s) => s.id === swap.id)
if (existingIndex >= 0) {
const updated = [...prev]
updated[existingIndex] = swap
return updated
}
// New swap, add to beginning
return [swap, ...prev]
})
Comment on lines +140 to +150
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for PendingReverseSwap and PendingSubmarineSwap type definitions
fd -t f "\.ts$|\.tsx$" | head -20
rg -n "interface PendingReverseSwap|type PendingReverseSwap" -A 15
rg -n "interface PendingSubmarineSwap|type PendingSubmarineSwap" -A 15
rg -n "\.id\s*:|\.response\.id\s*:" -B 2 -A 2

Repository: arkade-os/wallet

Length of output: 599


🏁 Script executed:

#!/bin/bash
# Search for swap type definitions
rg -n "type Pending(Reverse|Submarine)Swap|interface Pending(Reverse|Submarine)Swap" -A 20

# Search for .response.id usage
rg -n "\.response\.id" -B 3 -A 1

# Search for swap.id usage  
rg -n "swap\.id" -B 2 -A 1

# Look for the SwapsList.tsx file and check key usage
fd "SwapsList\.tsx" -x cat -n

Repository: arkade-os/wallet

Length of output: 8774


Use consistent identifier for swap updates and React keys: swap.id should be used for both.

Line 142 matches swaps by s.id, but line 163 uses swap.response.id as the React key. If these IDs differ, React won't properly reconcile updated swaps—they'll appear as new elements instead of updates, causing UI glitches or stale renders. Use swap.id consistently for both the state update logic and the React key.

🤖 Prompt for AI Agents
In src/components/SwapsList.tsx around lines 140 to 150, the state update
matches swaps by swap.id but elsewhere the JSX uses swap.response.id as the
React key; make the identifiers consistent by changing the key to use swap.id
instead of swap.response.id so React can properly reconcile updated swaps;
update any JSX key or other places referencing swap.response.id to use swap.id
and ensure swap objects always include the canonical id field used here.

})

return unsubscribe
}, [swapManager])

if (swapHistory.length === 0) return <EmptySwapList />

Expand Down
184 changes: 0 additions & 184 deletions src/lib/lightning.ts

This file was deleted.

Loading