From 102ee331dbd9f3891bd65b254171ef8654d379cf Mon Sep 17 00:00:00 2001 From: NicolasCantu Date: Wed, 29 Oct 2025 16:04:59 +0100 Subject: [PATCH] fix: syntax error in wallet-setup and use simplified Device type in DeviceReaderService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **Motivations :** - Erreur de syntaxe dans wallet-setup.ts (try/catch mal formé) - Import de Device depuis SDK peut causer des erreurs de compilation - Utiliser un type simplifié pour éviter les dépendances lourdes **Modifications :** - Corriger l'indentation du try/catch dans wallet-setup.ts - Remplacer l'import Device par une interface simplifiée dans DeviceReaderService - Cette interface couvre les champs nécessaires sans dépendre du SDK complet **Pages affectées :** - src/pages/wallet-setup/wallet-setup.ts (correction syntaxe) - src/services/device-reader.service.ts (type simplifié) --- src/pages/wallet-setup/wallet-setup.ts | 43 +++++++++++++------------- src/services/device-reader.service.ts | 16 ++++++++-- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/src/pages/wallet-setup/wallet-setup.ts b/src/pages/wallet-setup/wallet-setup.ts index 7d396af..89d073f 100644 --- a/src/pages/wallet-setup/wallet-setup.ts +++ b/src/pages/wallet-setup/wallet-setup.ts @@ -78,31 +78,32 @@ document.addEventListener('DOMContentLoaded', async () => { services = await Services.getInstance(); console.log('✅ Services initialized successfully'); break; - } catch (error) { - const errorMessage = error instanceof Error ? error.message : String(error); - console.log(`⏳ Services not ready yet (attempt ${attempts + 1}/${maxAttempts}):`, errorMessage); + } catch (error) { + const errorMessage = error instanceof Error ? error.message : String(error); + console.log(`⏳ Services not ready yet (attempt ${attempts + 1}/${maxAttempts}):`, errorMessage); - // Si c'est une erreur de mémoire, arrêter immédiatement - if (errorMessage.includes('Out of memory') || errorMessage.includes('insufficient memory')) { - console.error('🚫 Memory error detected - stopping retry attempts'); - updateStatus('❌ Erreur: Mémoire insuffisante. Veuillez actualiser la page.', 'error'); - throw new Error('WebAssembly initialization failed due to insufficient memory. Please refresh the page.'); - } - - // Diagnostic plus détaillé - if (attempts === 5) { - console.log('🔍 Diagnostic: Checking memory usage...'); - if ((performance as any).memory) { - const memory = (performance as any).memory; - console.log(`📊 Memory usage: ${Math.round(memory.usedJSHeapSize / 1024 / 1024)}MB / ${Math.round(memory.totalJSHeapSize / 1024 / 1024)}MB`); + // Si c'est une erreur de mémoire, arrêter immédiatement + if (errorMessage.includes('Out of memory') || errorMessage.includes('insufficient memory')) { + console.error('🚫 Memory error detected - stopping retry attempts'); + updateStatus('❌ Erreur: Mémoire insuffisante. Veuillez actualiser la page.', 'error'); + throw new Error('WebAssembly initialization failed due to insufficient memory. Please refresh the page.'); } - } - attempts++; - if (attempts >= maxAttempts) { - throw new Error(`Services failed to initialize after ${maxAttempts} attempts. This may be due to high memory usage or WebAssembly initialization issues.`); + // Diagnostic plus détaillé + if (attempts === 5) { + console.log('🔍 Diagnostic: Checking memory usage...'); + if ((performance as any).memory) { + const memory = (performance as any).memory; + console.log(`📊 Memory usage: ${Math.round(memory.usedJSHeapSize / 1024 / 1024)}MB / ${Math.round(memory.totalJSHeapSize / 1024 / 1024)}MB`); + } + } + + attempts++; + if (attempts >= maxAttempts) { + throw new Error(`Services failed to initialize after ${maxAttempts} attempts. This may be due to high memory usage or WebAssembly initialization issues.`); + } + await new Promise(resolve => setTimeout(resolve, delayMs)); } - await new Promise(resolve => setTimeout(resolve, delayMs)); } } catch (error) { console.error('❌ Services not available:', error); diff --git a/src/services/device-reader.service.ts b/src/services/device-reader.service.ts index 0af8e7c..a1b4eac 100644 --- a/src/services/device-reader.service.ts +++ b/src/services/device-reader.service.ts @@ -4,7 +4,20 @@ */ import { DATABASE_CONFIG } from './database-config'; -import { Device } from '../../pkg/sdk_client'; + +// Type simplifié pour éviter les problèmes d'import du SDK +export interface Device { + sp_wallet?: { + address?: string; + birthday?: number; + last_scan?: number; + spend_key?: any; + scan_key?: any; + [key: string]: any; + }; + sp_client?: any; + [key: string]: any; +} export class DeviceReaderService { private static instance: DeviceReaderService | null = null; @@ -132,4 +145,3 @@ export class DeviceReaderService { } } } -