From d2f2b689f913532b1c8131232acbea686298239e Mon Sep 17 00:00:00 2001 From: Gigi Date: Thu, 16 Oct 2025 22:25:15 +0200 Subject: [PATCH] fix: create and setup pool BEFORE loading accounts from localStorage - NostrConnectAccount.fromJSON needs NostrConnectSigner.pool to be set - Move pool creation and setup before accounts.fromJSON() - This fixes 'Missing subscriptionMethod' error on page reload - Now bunker accounts can be properly restored from localStorage --- src/App.tsx | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 160cd058..defbb6d5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -188,6 +188,16 @@ function App() { // Register common account types (needed for deserialization) registerCommonAccountTypes(accounts) + // Create relay pool and set it up BEFORE loading accounts + // NostrConnectAccount.fromJSON needs this to restore the signer + const pool = new RelayPool() + NostrConnectSigner.pool = pool + console.log('[bunker] ✅ Pool assigned to NostrConnectSigner (before account load)') + + // Create a relay group for better event deduplication and management + pool.group(RELAYS) + console.log('[bunker] Created relay group with', RELAYS.length, 'relays (including local)') + // Load persisted accounts from localStorage try { const accountsJson = localStorage.getItem('accounts') @@ -235,17 +245,6 @@ function App() { } }) - const pool = new RelayPool() - - // Setup NostrConnectSigner to use the relay pool FIRST before any reconnections - NostrConnectSigner.pool = pool - console.log('[bunker] ✅ Pool assigned to NostrConnectSigner') - - // Create a relay group for better event deduplication and management - pool.group(RELAYS) - console.log('Created relay group with', RELAYS.length, 'relays (including local)') - console.log('Relay URLs:', RELAYS) - // Reconnect bunker signers when active account changes // Keep track of which accounts we've already reconnected to avoid double-connecting const reconnectedAccounts = new Set()