diff --git a/src/pages/pairing/pairing.ts b/src/pages/pairing/pairing.ts index ab0e8c5..4985d71 100644 --- a/src/pages/pairing/pairing.ts +++ b/src/pages/pairing/pairing.ts @@ -7,7 +7,6 @@ import { getCorrectDOM } from '../../utils/html.utils'; import { IframePairingComponent } from '../../components/iframe-pairing/iframe-pairing'; import { checkPBKDF2Key, checkWalletWithRetries } from '../../utils/prerequisites.utils'; import loginHtml from '../home/home.html?raw'; -import loginCss from '../../4nk.css?raw'; // Extend WindowEventMap to include custom events declare global { @@ -93,12 +92,8 @@ document.addEventListener('DOMContentLoaded', async () => { updateStatus('🔄 Initialisation du pairing...', 'loading'); if (pairingContent) { - pairingContent.innerHTML = ` - - ${loginHtml} - `; + // Injecter seulement le HTML, le CSS est déjà chargé via le dans le + pairingContent.innerHTML = loginHtml; // Créer un conteneur simulant login-4nk-component pour getCorrectDOM const mockContainer = document.createElement('div'); diff --git a/src/services/service.ts b/src/services/service.ts index 719a0c8..2fea83e 100755 --- a/src/services/service.ts +++ b/src/services/service.ts @@ -2301,6 +2301,7 @@ export default class Services { /** * Ensures a complete initial scan is performed before requesting faucet tokens * This prevents the race condition between scan and faucet transactions + * Only performs scan if wallet is not already synchronized */ public async ensureCompleteInitialScan(): Promise { console.log('🔄 Ensuring complete initial scan...'); @@ -2311,9 +2312,18 @@ export default class Services { throw new Error('Device not found or wallet not initialized'); } - // Force a complete scan from birthday to current block height - const scanFromHeight = Math.max(0, this.currentBlockHeight - 100); - console.log(`🔄 Performing complete scan from block ${scanFromHeight} to ${this.currentBlockHeight}...`); + // Check if wallet is already synchronized + const lastScan = device.sp_wallet.last_scan || 0; + const isSynchronized = lastScan >= this.currentBlockHeight; + + if (isSynchronized) { + console.log(`✅ Wallet already synchronized (last_scan: ${lastScan}, current: ${this.currentBlockHeight})`); + return; + } + + // Only scan if wallet is not synchronized + console.log(`🔄 Wallet needs synchronization (last_scan: ${lastScan}, current: ${this.currentBlockHeight})`); + console.log(`🔄 Performing scan from block ${lastScan} to ${this.currentBlockHeight}...`); await this.sdkClient.scan_blocks(this.currentBlockHeight, BLINDBITURL); console.log('✅ Complete initial scan completed');