From e437e802dd38b4b624f56ce9fe55b549430fb65f Mon Sep 17 00:00:00 2001 From: Ben Kremer Date: Fri, 4 Mar 2022 12:01:39 +0000 Subject: [PATCH] fix: handle `session_updated` event in EthereumProvider examples --- .../src/contexts/ClientContext.tsx | 6 ++++++ .../src/contexts/ClientContext.tsx | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/dapps/react-dapp-v2-with-ethers/src/contexts/ClientContext.tsx b/dapps/react-dapp-v2-with-ethers/src/contexts/ClientContext.tsx index 415b3e1..bc3b4b4 100644 --- a/dapps/react-dapp-v2-with-ethers/src/contexts/ClientContext.tsx +++ b/dapps/react-dapp-v2-with-ethers/src/contexts/ClientContext.tsx @@ -115,6 +115,12 @@ export function ClientContextProvider({ children }: { children: ReactNode | Reac setPairings(_client.pairing.topics); }); + _client.on(CLIENT_EVENTS.session.updated, (updatedSession: SessionTypes.Settled) => { + console.log("EVENT", "session_updated"); + setAccounts(updatedSession.state.accounts); + setSession(updatedSession); + }); + _client.on(CLIENT_EVENTS.session.deleted, () => { console.log("EVENT", "session_deleted"); resetApp(); diff --git a/dapps/react-dapp-v2-with-web3js/src/contexts/ClientContext.tsx b/dapps/react-dapp-v2-with-web3js/src/contexts/ClientContext.tsx index 5052888..7f46e0c 100644 --- a/dapps/react-dapp-v2-with-web3js/src/contexts/ClientContext.tsx +++ b/dapps/react-dapp-v2-with-web3js/src/contexts/ClientContext.tsx @@ -117,6 +117,12 @@ export function ClientContextProvider({ children }: { children: ReactNode | Reac setPairings(_client.pairing.topics); }); + _client.on(CLIENT_EVENTS.session.updated, (updatedSession: SessionTypes.Settled) => { + console.log("EVENT", "session_updated"); + setAccounts(updatedSession.state.accounts); + setSession(updatedSession); + }); + _client.on(CLIENT_EVENTS.session.deleted, () => { console.log("EVENT", "session_deleted"); resetApp();