From e6187c2eb805917cd64979c47456c5ad3eb5891b Mon Sep 17 00:00:00 2001 From: iAmKeralis1131f Date: Mon, 2 Feb 2026 18:02:01 +0530 Subject: [PATCH 1/3] fix #54 : handle multiple sync --- api1.js | 2 +- src/components/swap/Swap.js | 4 ++-- src/components/swap/SwapStateManager.js | 2 +- src/components/wallet/Wallet.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/api1.js b/api1.js index 2020790..c997549 100644 --- a/api1.js +++ b/api1.js @@ -528,7 +528,7 @@ function registerTakerHandlers() { } } }, - 5 * 60 * 1000 // 5 minutes + 15 * 60 * 1000 // 15 minutes ); } diff --git a/src/components/swap/Swap.js b/src/components/swap/Swap.js index 296c47c..e8284ea 100644 --- a/src/components/swap/Swap.js +++ b/src/components/swap/Swap.js @@ -2,7 +2,7 @@ import { SwapStateManager, formatRelativeTime } from './SwapStateManager.js'; // โœ… ADD CACHE CONSTANTS const SWAP_DATA_CACHE_KEY = 'swap_data_cache'; -const CACHE_DURATION = 300 * 1000; // 5 mins +const CACHE_DURATION = 15 * 60 * 1000; // 15 minutes // โœ… ADD CACHE FUNCTIONS function loadSwapDataFromCache() { @@ -67,7 +67,7 @@ export async function SwapComponent(container) { // If there's an active swap in progress, redirect to coinswap progress if (activeSwap && activeSwap.status === 'configured') { const age = Date.now() - activeSwap.createdAt; - if (age > 5 * 60 * 1000) { + if (age > 15 * 60 * 1000) { console.log('๐Ÿงน Clearing stale configured swap'); await SwapStateManager.clearSwapData(); } else { diff --git a/src/components/swap/SwapStateManager.js b/src/components/swap/SwapStateManager.js index 4f5b344..09b291a 100644 --- a/src/components/swap/SwapStateManager.js +++ b/src/components/swap/SwapStateManager.js @@ -45,7 +45,7 @@ export const SwapStateManager = { // Check if configured swap is stale (older than 5 minutes) if (activeSwap.status === 'configured') { const age = Date.now() - activeSwap.createdAt; - if (age > 5 * 60 * 1000) { + if (age > 15 * 60 * 1000) { console.log( '๐Ÿงน Clearing stale configured swap from hasActiveSwap check' ); diff --git a/src/components/wallet/Wallet.js b/src/components/wallet/Wallet.js index 7745748..d5c24de 100644 --- a/src/components/wallet/Wallet.js +++ b/src/components/wallet/Wallet.js @@ -1,5 +1,5 @@ const WALLET_CACHE_KEY = 'wallet_data_cache'; -const CACHE_DURATION = 90 * 1000; // 90 seconds +const CACHE_DURATION = 15 * 60 * 1000; // 15 minutes function loadWalletFromCache() { try { From 9c23f4718f59c8aa193bcf91175b4efd88c94a12 Mon Sep 17 00:00:00 2001 From: iAmKeralis1131f Date: Mon, 2 Feb 2026 19:40:40 +0530 Subject: [PATCH 2/3] fixes # 55 : stops offerbook from getting deleted fixes #56 : stops removing data while syncing --- api1.js | 25 ++++++++++++++++++------- src/components/market/Market.js | 30 +++++++++++++++++------------- 2 files changed, 35 insertions(+), 20 deletions(-) diff --git a/api1.js b/api1.js index c997549..486d3f4 100644 --- a/api1.js +++ b/api1.js @@ -375,13 +375,22 @@ function registerTakerHandlers() { ); if (fs.existsSync(offerbookPath)) { - console.log('๐Ÿ—‘๏ธ Deleting old offerbook.json...'); - fs.unlinkSync(offerbookPath); + try { + const content = fs.readFileSync(offerbookPath, 'utf8'); + JSON.parse(content); // Test if valid + console.log('โœ… Existing offerbook is valid'); + } catch (parseError) { + console.log('โš ๏ธ Corrupted offerbook detected, recreating...'); + fs.writeFileSync( + offerbookPath, + JSON.stringify({ makers: [] }), + 'utf8' + ); + } + } else { + console.log('๐Ÿ“ Creating initial offerbook.json...'); + fs.writeFileSync(offerbookPath, JSON.stringify({ makers: [] }), 'utf8'); } - - console.log('๐Ÿ“ Creating fresh empty offerbook.json...'); - fs.writeFileSync(offerbookPath, '[]', 'utf8'); - api1State.activeSyncs.set(syncId, { status: 'syncing', startedAt: Date.now(), @@ -831,7 +840,9 @@ function registerTakerHandlers() { if (!api1State.coinswapNapi) { await initNAPI(); if (!api1State.coinswapNapi) { - console.error('coinswap-napi not loaded for isWalletEncrypted check'); + console.error( + 'coinswap-napi not loaded for isWalletEncrypted check' + ); return false; } } diff --git a/src/components/market/Market.js b/src/components/market/Market.js index d6256e0..85f6272 100644 --- a/src/components/market/Market.js +++ b/src/components/market/Market.js @@ -277,8 +277,12 @@ export function Market(container) { refreshBtn.disabled = true; refreshBtn.innerHTML = 'Syncing...'; - // โœ… SHOW LOADER IMMEDIATELY - isLoading = true; + // โœ… Show sync progress bar ONLY + syncProgress = { + percent: 50, + status: 'syncing', + message: 'Syncing market data...', + }; updateUI(); try { @@ -292,10 +296,10 @@ export function Market(container) { console.log('๐Ÿ“ก Sync started:', syncId); localStorage.setItem('active_sync_id', syncId); - // โœ… SIMPLE: Just poll isOfferbookSyncing() until it's false + // Poll until sync completes let isSyncing = true; while (isSyncing) { - await new Promise((resolve) => setTimeout(resolve, 1000)); // Check every second + await new Promise((resolve) => setTimeout(resolve, 1000)); const statusResult = await window.api.taker.isOfferbookSyncing(); if (statusResult.success) { @@ -306,14 +310,17 @@ export function Market(container) { } } - // โœ… Sync is done - wait 2 more seconds for file write + // Sync is done - wait for file write console.log('โœ… Offerbook synced - waiting for file write...'); await new Promise((resolve) => setTimeout(resolve, 2000)); - // โœ… NOW fetch makers - console.log('โœ… Now fetching makers...'); + // Clear sync progress + syncProgress = null; + + // NOW fetch fresh makers + console.log('โœ… Now fetching fresh makers...'); localStorage.removeItem('active_sync_id'); - await fetchMakers(); // This sets isLoading = false + await fetchMakers(); // This sets isLoading = false and updates UI refreshBtn.innerHTML = 'โœ… Synced!'; setTimeout(() => { @@ -321,7 +328,7 @@ export function Market(container) { refreshBtn.innerHTML = originalText; }, 2000); } catch (error) { - isLoading = false; + syncProgress = null; updateUI(); refreshBtn.innerHTML = 'โŒ Failed'; showError(error.message); @@ -331,6 +338,7 @@ export function Market(container) { }, 3000); } } + async function initialize() { // Get protocol version const protocolResult = await window.api.taker.getProtocol(); @@ -609,7 +617,6 @@ export function Market(container) { document.body.appendChild(modal); }; - function updateUI() { const stats = calculateStats(); const tableBody = content.querySelector('#maker-table-body'); @@ -790,8 +797,6 @@ export function Market(container) { ` ) .join(''); - - } } } @@ -809,7 +814,6 @@ export function Market(container) { ).length; footer.innerHTML = `Showing ${displayedCount} ${currentMakerStatus} offers โ€ข ${timeStr}`; } - } content.innerHTML = ` From 2511fd31ddff2565d991632e8f6cd30ae6f42347 Mon Sep 17 00:00:00 2001 From: iAmKeralis1131f Date: Mon, 2 Feb 2026 19:47:22 +0530 Subject: [PATCH 3/3] update claude code workflow --- .github/workflows/claude-code-review.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml index d39cc8a..29150ba 100644 --- a/.github/workflows/claude-code-review.yml +++ b/.github/workflows/claude-code-review.yml @@ -30,7 +30,7 @@ jobs: id: claude-review uses: anthropics/claude-code-action@v1 with: - claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} github_token: ${{ secrets.GITHUB_TOKEN }} # Allow workflow to run for all users, including those without write access # โš ๏ธ Security Note: This bypasses the write permission requirement check.