diff --git a/src/App.js b/src/App.js index bfda0ac..8317156 100644 --- a/src/App.js +++ b/src/App.js @@ -19,6 +19,7 @@ function App() { projectId: process.env.REACT_APP_PROJECT_ID, }); setSignClient(signClient); + await subscribeToEvents(signClient); } catch (e) { console.log(e); } @@ -72,6 +73,19 @@ function App() { } } + async function subscribeToEvents(client) { + if (!client) + throw Error("Unable to subscribe to events. Client does not exist."); + try { + client.on("session_delete", () => { + console.log("The user has disconnected the session from their wallet."); + reset(); + }); + } catch (e) { + console.log(e); + } + } + const reset = () => { setAccount([]); setSession([]);