diff --git a/package.json b/package.json index 72afbd58f..32b4482cd 100644 --- a/package.json +++ b/package.json @@ -42,8 +42,8 @@ "test:e2e": "VITE_NOSTR_RELAY_URL=http://localhost:10547 playwright test", "test:e2e:ui": "VITE_NOSTR_RELAY_URL=http://localhost:10547 playwright test --ui", "test:codegen": "playwright codegen localhost:3002", - "lint": "eslint 'src/**/*.{ts,tsx,js,jsx}'", - "lint:fix": "eslint 'src/**/*.{ts,tsx,js,jsx}' --fix", + "lint": "eslint \"src/**/*.{ts,tsx,js,jsx}\"", + "lint:fix": "eslint \"src/**/*.{ts,tsx,js,jsx}\" --fix", "format": "prettier --write src", "format:check": "prettier --check src", "git-info": "node scripts/git-commit-info.js", diff --git a/src/screens/Apps/Boltz/Swap.tsx b/src/screens/Apps/Boltz/Swap.tsx index 4597fbd5c..d06f72ddb 100644 --- a/src/screens/Apps/Boltz/Swap.tsx +++ b/src/screens/Apps/Boltz/Swap.tsx @@ -51,6 +51,7 @@ export default function AppBoltzSwap() { const [processing, setProcessing] = useState(false) const [opDone, setOpDone] = useState(false) const [success, setSuccess] = useState(false) + const [swapManagerProcessing, setSwapManagerProcessing] = useState(false) // Subscribe to real-time updates for this swap useEffect(() => { @@ -58,9 +59,17 @@ export default function AppBoltzSwap() { let unsub: (() => void) | null = null let cancelled = false + + swapManager.isProcessing(swapInfo.id).then((p) => { + if (!cancelled) setSwapManagerProcessing(p) + }) + swapManager .subscribeToSwapUpdates(swapInfo.id, (updatedSwap) => { setSwapInfo(updatedSwap) + swapManager.isProcessing(updatedSwap.id).then((p) => { + if (!cancelled) setSwapManagerProcessing(p) + }) }) .then((unsubscribe) => { if (cancelled) { @@ -147,11 +156,15 @@ export default function AppBoltzSwap() { const isRefundable = isSubmarineSwapRefundable(swapInfo) || isChainSwapRefundable(swapInfo) const isClaimable = isReverseSwapClaimable(swapInfo) || isChainSwapClaimable(swapInfo) - const buttonLabel = isClaimable ? 'Complete swap' : 'Refund swap' + const buttonLabel = swapManagerProcessing ? 'Claiming...' : isClaimable ? 'Complete swap' : 'Refund swap' const refunded = swapInfo.status === 'transaction.refunded' const buttonHandler = async () => { try { + if (swapManager) { + const alreadyProcessing = await swapManager.isProcessing(swapInfo.id) + if (alreadyProcessing) return + } setProcessing(true) if (isReverseSwapClaimable(swapInfo)) { await claimVHTLC(swapInfo) @@ -217,9 +230,9 @@ export default function AppBoltzSwap() { )} - {!success && (isRefundable || isClaimable) ? ( + {!success && (isRefundable || isClaimable || swapManagerProcessing) ? ( -